def remove_tag(self): # gather input data is_local = self.localchk.get_active() name = self.tagentry.get_text() eng_msg = self.engchk.get_active() use_msg = self.customchk.get_active() # verify input if name == "": dialog.error_dialog(self, _("Tag name is empty"), _("Please select tag name to remove")) self.tagentry.grab_focus() return False if use_msg: message = self.msgentry.get_text() else: message = "" try: self.remove_hg_tag(name, message, is_local, english=eng_msg) dialog.info_dialog(self, _("Tagging completed"), _('Tag "%s" has been removed') % name) self.update_tagcombo() except util.Abort, inst: dialog.error_dialog(self, _("Error in tagging"), str(inst)) return False
def exec_cmd(self, cmd): if self.cmd_running(): dialog.error_dialog(self, _('Cannot run now'), _('Please try again after the previous command has completed')) return self.stop_button.set_sensitive(True) proxy_host = ui.ui().config('http_proxy', 'host', '') use_proxy = self.use_proxy.get_active() text_entry = self.pathbox.get_child() remote_path = hglib.fromutf(text_entry.get_text()).strip() remote_path = hglib.validate_synch_path(remote_path, self.repo) cmdline = cmd[:] cmdline += ['--verbose'] if proxy_host and not use_proxy: cmdline += ["--config", "http_proxy.host="] cmdline += ['--', remote_path] self.lastcmd = cmdline # show command to be executed self.write("", False) # execute command and show output on text widget gobject.timeout_add(10, self.process_queue) self.hgthread = hgthread.HgThread(cmdline, parent=self) self.hgthread.start() self.stbar.begin() self.stbar.set_text('hg ' + ' '.join(cmd)) self.add_src_to_recent(remote_path)
def should_live(self): if self.cmd_running(): dialog.error_dialog(self, _('Cannot close now'), _('command is running')) return True else: self.update_settings() self._settings.write() if os.name == 'nt': os.dup2(self.oldstdout, sys.__stdout__.fileno()) os.close(self.oldstdout) return False
def write_ignore_lines(self): if self.doseoln: out = [line + '\r\n' for line in self.ignorelines] else: out = [line + '\n' for line in self.ignorelines] try: f = util.atomictempfile(self.ignorefile, 'wb', createmode=None) f.writelines(out) f.rename() except EnvironmentError, e: dialog.error_dialog(self, _('Unable to write .hgignore file'), hglib.tounicode(str(e)))
def rename_resp(dlg, response): if response != gtk.RESPONSE_OK: dlg.destroy() return try: root = paths.find_root() repo = hg.repository(ui.ui(), root) except (ImportError, error.RepoError): dlg.destroy() return new_name = hglib.fromutf(dlg.entry.get_text()) opts = {} opts['force'] = False # Checkbox? Nah. opts['after'] = True opts['dry_run'] = False saved = sys.stderr errors = cStringIO.StringIO() toquit = False try: sys.stderr = errors repo.ui.pushbuffer() repo.ui.quiet = True try: new_name = util.canonpath(root, root, new_name) targetdir = os.path.dirname(new_name) or '.' if dlg.orig.lower() == new_name.lower() and os.path.isdir(dlg.orig): os.rename(dlg.orig, new_name) else: if not os.path.isdir(targetdir): os.makedirs(targetdir) shutil.move(dlg.orig, new_name) commands.rename(repo.ui, repo, dlg.orig, new_name, **opts) toquit = True except (OSError, IOError, util.Abort, error.RepoError), inst: dialog.error_dialog(None, _('rename error'), str(inst)) toquit = False finally: sys.stderr = saved textout = errors.getvalue() + repo.ui.popbuffer() errors.close() if len(textout) > 1: dialog.error_dialog(None, _('rename error'), textout) elif toquit: dlg.destroy()
def add_tag(self): # gather input data is_local = self.localchk.get_active() name = self.tagentry.get_text() rev = self.reventry.get_text() force = self.replacechk.get_active() eng_msg = self.engchk.get_active() use_msg = self.customchk.get_active() message = self.msgentry.get_text() # verify input if name == "": dialog.error_dialog(self, _("Tag input is empty"), _("Please enter tag name")) self.tagentry.grab_focus() return False if use_msg and not message: dialog.error_dialog(self, _("Custom commit message is empty"), _("Please enter commit message")) self.msgentry.grab_focus() return False # add tag to repo try: self.add_hg_tag(name, rev, message, is_local, force=force, english=eng_msg) dialog.info_dialog(self, _("Tagging completed"), _('Tag "%s" has been added') % name) self.update_tagcombo() except util.Abort, inst: dialog.error_dialog(self, _("Error in tagging"), str(inst)) return False
def _exec_cmd(self, cmd, postfunc=None): if self._cmd_running(): dialog.error_dialog(self, _('Cannot run now'), _('Please try again after the previous command has completed')) return self._stop_button.set_sensitive(True) cmdline = cmd cmdline.append('--verbose') cmdline.append('--repository') cmdline.append(self.repo.root) # show command to be executed self.write("", False) # execute command and show output on text widget gobject.timeout_add(10, self.process_queue) self.hgthread = hgthread.HgThread(cmdline, postfunc) self.hgthread.start() self.pbar.set_text('hg ' + ' '.join(cmdline)) self.inprogress = True self.pbar.show()
return False if use_msg and not message: dialog.error_dialog(self, _("Custom commit message is empty"), _("Please enter commit message")) self.msgentry.grab_focus() return False # add tag to repo try: self.add_hg_tag(name, rev, message, is_local, force=force, english=eng_msg) dialog.info_dialog(self, _("Tagging completed"), _('Tag "%s" has been added') % name) self.update_tagcombo() except util.Abort, inst: dialog.error_dialog(self, _("Error in tagging"), str(inst)) return False except: dialog.error_dialog(self, _("Error in tagging"), traceback.format_exc()) return False def remove_tag(self): # gather input data is_local = self.localchk.get_active() name = self.tagentry.get_text() eng_msg = self.engchk.get_active() use_msg = self.customchk.get_active() # verify input if name == "": dialog.error_dialog(self, _("Tag name is empty"), _("Please select tag name to remove")) self.tagentry.grab_focus() return False
def pfinish(self, patch_name): """ [pbranch] Execute 'pfinish' command. The workdir must be clean. The patch branch dependencies must be merged. :param patch_name: A patch branch (not an internal branch) """ # Check preconditions for pfinish assert self.is_patch(patch_name) pmerge_status = self.pstatus(patch_name) if pmerge_status != []: dialog.error_dialog(self.parent_window, _('Pending Pmerge'), _('You cannot finish this patch branch unless you pmerge it first.\n' 'pmerge will solve the following issues with %(patch)s:\n' '* %(issuelist)s') % {'patch': patch_name, 'issuelist': '* '.join(pmerge_status)} ) return if not self.workdir_is_clean(): dialog.error_dialog(self.parent_window, _('Uncommitted Local Changes'), _('pfinish uses your working directory for temporary work.\n' 'Please commit your local changes before issuing pfinish.') ) return if hasattr(self.repo, 'mq') and len(self.repo.mq.applied) > 0: dialog.error_dialog(self.parent_window, _('Applied MQ patch'), _('pfinish must be able to commit, but this is not allowed\n' 'as long as you have MQ patches applied.') ) return # Set up environment for mercurial commands class CmdWidgetUi(mercurial.ui.ui): def __init__(self, cmdLogWidget): src = None super(CmdWidgetUi, self).__init__(src) self.cmdLogWidget = cmdLogWidget def write(self, *args, **opts): for a in args: self.cmdLogWidget.append(str(a)) def write_err(self, *args, **opts): for a in args: self.cmdLogWidget.append(str(a), error=True) def flush(self): pass def prompt(self, msg, choices=None, default="y"): raise util.Abort("Internal Error: prompt not available") def promptchoice(self, msg, choices, default=0): raise util.Abort("Internal Error: promptchoice not available") def getpass(self, prompt=None, default=None): raise util.Abort("Internal Error: getpass not available") repo = self.repo ui = CmdWidgetUi(self.cmd.log) old_ui = repo.ui repo.ui = ui # Commit patch to dependency fd, patch_file_name = tempfile.mkstemp(prefix='thg-patch-') patch_file = os.fdopen(fd, 'w') patch_file.writelines(self.pdiff(patch_name)) patch_file.close() upstream_branch = self.pgraph().deps(patch_name)[0] hg.update(ui, repo, rev=upstream_branch) hg.import_(ui, repo, patch_file_name, base='', strip=1) os.unlink(patch_file_name) # Close patch branch hg.update(ui, repo, rev=patch_name) hg.merge(ui, repo, upstream_branch) msg = _('Patch branch finished') hg.commit(ui, repo, close_branch=True, message=msg) # Update GUI repo.ui = old_ui self.emit('repo-invalidated')
def should_live(self): if self._cmd_running(): dialog.error_dialog(self, _('Cannot close now'), _('command is running')) return True return False