def _update_to_tip(self, button): self.repo.invalidate() wc = self.repo.workingctx() pl = wc.parents() p1, p2 = pl[0], self.repo.changectx('tip') pa = p1.ancestor(p2) warning = '' flags = [] if len(pl) > 1: warning = "Outstanding uncommitted merges" elif pa != p1 and pa != p2: warning = "Update spans branches" if warning: flags = ['--clean'] msg = 'Lose all changes in your working directory?' warning += ', requires clean checkout' if question_dialog(self, msg, warning) != gtk.RESPONSE_YES: return self.write("", False) # execute command and show output on text widget gobject.timeout_add(10, self.process_queue) cmdline = ['update', '-v', '-R', self.repo.root] + flags + ['tip'] self.hgthread = HgThread(cmdline) self.hgthread.start() self.stbar.begin() self.stbar.set_status_text('hg ' + ' '.join(cmdline))
def _rollback_clicked(self, toolbutton, data=None): response = question_dialog(self, "Rollback repository", "%s ?" % os.path.basename(self.root)) if not response == gtk.RESPONSE_YES: return cmd = ['rollback'] self._exec_cmd(cmd, postfunc=self._notify)
def do_push(br_from, location, overwrite): """ Update a mirror of a branch. :param br_from: the source branch :param location: the location of the branch that you'd like to update :param overwrite: overwrite target location if it diverged :return: number of revisions pushed """ from bzrlib.bzrdir import BzrDir from bzrlib.transport import get_transport transport = get_transport(location) location_url = transport.base old_rh = [] try: dir_to = BzrDir.open(location_url) br_to = dir_to.open_branch() except errors.NotBranchError: # create a branch. transport = transport.clone('..') try: relurl = transport.relpath(location_url) transport.mkdir(relurl) except errors.NoSuchFile: response = question_dialog(_i18n('Non existing parent directory'), _i18n("The parent directory (%s)\ndoesn't exist. Create?") % location) if response == gtk.RESPONSE_OK: transport.create_prefix() else: return dir_to = br_from.bzrdir.clone(location_url, revision_id=br_from.last_revision()) br_to = dir_to.open_branch() count = len(br_to.revision_history()) else: old_rh = br_to.revision_history() try: tree_to = dir_to.open_workingtree() except errors.NotLocalUrl: # FIXME - what to do here? how should we warn the user? count = br_to.pull(br_from, overwrite) except errors.NoWorkingTree: count = br_to.pull(br_from, overwrite) else: count = tree_to.pull(br_from, overwrite) return count
def _clean_clicked(self, toolbutton, data=None): response = question_dialog(self, "Clean repository", "%s ?" % os.path.basename(self.root)) if not response == gtk.RESPONSE_YES: return try: repo = hg.repository(ui.ui(), path=self.root) except RepoError: self.write("Unable to find repo at %s\n" % (self.root), False) return pl = repo.workingctx().parents() cmd = ['update', '--clean', '--rev', str(pl[0].rev())] self._exec_cmd(cmd, postfunc=self._notify)
def _server_stopped(self): ''' check if server is running, or to terminate if running ''' if gservice and not gservice.stopped: if question_dialog(self, "Really Exit?", "Server process is still running\n" + "Exiting will stop the server.") != gtk.RESPONSE_YES: return False else: self._stop_server() return True else: return True
def _on_push_clicked(self, widget): """ Push button clicked handler. """ location = self._combo.get_child().get_text() revs = 0 try: revs = do_push(self.branch, location=location, overwrite=False) except errors.DivergedBranches: response = question_dialog(_i18n('Branches have been diverged'), _i18n('You cannot push if branches have diverged.\nOverwrite?')) if response == gtk.RESPONSE_YES: revs = do_push(self.branch, location=location, overwrite=True) if self.branch is not None and self.branch.get_push_location() is None: self.branch.set_push_location(location) self._history.add_entry(location) info_dialog(_i18n('Push successful'), _i18n("%d revision(s) pushed.") % revs) self.response(gtk.RESPONSE_OK)
def _response(self, widget, response_id): if self.dirty: if question_dialog(self, 'Quit without saving?', 'Yes to abandon changes, No to continue') != gtk.RESPONSE_YES: widget.emit_stop_by_name('response')