def extsetup(ui): # Ensure required extensions are loaded. for ext in (b"purge", b"share"): try: extensions.find(ext) except KeyError: extensions.load(ui, ext, None)
def loadextension(ui, name): # Between Mercurial revisions 1.2 and 1.3, extensions.load() stopped # calling uisetup() after loading an extension. This could do # unexpected things if you use an hg version < 1.3 extensions.load(ui, name, None) mod = extensions.find(name) uisetup = getattr(mod, 'uisetup', None) if uisetup: uisetup(ui)
def extsetup(ui): # Ensure required extensions are loaded. for ext in ('purge', 'share'): try: extensions.find(ext) except KeyError: extensions.load(ui, ext, None) purgemod = extensions.find('purge') extensions.wrapcommand(purgemod.cmdtable, 'purge', purgewrapper)
def checkhghelps(): errorcnt = 0 for names, sec, doc in helptable: if util.safehasattr(doc, '__call__'): doc = doc() errorcnt += checkseclevel(doc, '%s help topic' % names[0], initlevel_topic) errorcnt += checkcmdtable(table, '%s command', initlevel_cmd) for name in sorted(extensions.enabled().keys() + extensions.disabled().keys()): mod = extensions.load(None, name, None) if not mod.__doc__: verbose('skip checking %s extension: no help document' % name) continue errorcnt += checkseclevel(mod.__doc__, '%s extension' % name, initlevel_ext) cmdtable = getattr(mod, 'cmdtable', None) if cmdtable: errorcnt += checkcmdtable(cmdtable, '%s command of ' + name + ' extension', initlevel_ext_cmd) return errorcnt
def showdoc(ui): # print options ui.write(minirst.section(_("Options"))) for optstr, desc in get_opts(globalopts): ui.write("%s\n %s\n\n" % (optstr, desc)) # print cmds ui.write(minirst.section(_("Commands"))) commandprinter(ui, table, minirst.subsection) # print help topics # The config help topic is included in the hgrc.5 man page. helpprinter(ui, helptable, minirst.section, exclude=['config']) ui.write(minirst.section(_("Extensions"))) ui.write( _("This section contains help for extensions that are " "distributed together with Mercurial. Help for other " "extensions is available in the help system.")) ui.write("\n\n" ".. contents::\n" " :class: htmlonly\n" " :local:\n" " :depth: 1\n\n") for extensionname in sorted(allextensionnames()): mod = extensions.load(None, extensionname, None) ui.write(minirst.subsection(extensionname)) ui.write("%s\n\n" % gettext(mod.__doc__)) cmdtable = getattr(mod, 'cmdtable', None) if cmdtable: ui.write(minirst.subsubsection(_('Commands'))) commandprinter(ui, cmdtable, minirst.subsubsubsection)
def showdoc(ui): # print options ui.write(minirst.section(_("Options"))) for optstr, desc in get_opts(globalopts): ui.write("%s\n %s\n\n" % (optstr, desc)) # print cmds ui.write(minirst.section(_("Commands"))) commandprinter(ui, table, minirst.subsection) # print help topics # The config help topic is included in the hgrc.5 man page. helpprinter(ui, helptable, minirst.section, exclude=['config']) ui.write(minirst.section(_("Extensions"))) ui.write(_("This section contains help for extensions that are " "distributed together with Mercurial. Help for other " "extensions is available in the help system.")) ui.write("\n\n" ".. contents::\n" " :class: htmlonly\n" " :local:\n" " :depth: 1\n\n") for extensionname in sorted(allextensionnames()): mod = extensions.load(None, extensionname, None) ui.write(minirst.subsection(extensionname)) ui.write("%s\n\n" % gettext(mod.__doc__)) cmdtable = getattr(mod, 'cmdtable', None) if cmdtable: ui.write(minirst.subsubsection(_('Commands'))) commandprinter(ui, cmdtable, minirst.subsubsubsection)
def checkhghelps(ui): errorcnt = 0 for names, sec, doc in helptable: if callable(doc): doc = doc(ui) errorcnt += checkseclevel(ui, doc, '%s help topic' % names[0], initlevel_topic) errorcnt += checkcmdtable(ui, table, '%s command', initlevel_cmd) for name in sorted( list(extensions.enabled()) + list(extensions.disabled())): mod = extensions.load(ui, name, None) if not mod.__doc__: ui.note(('skip checking %s extension: no help document\n') % name) continue errorcnt += checkseclevel(ui, mod.__doc__, '%s extension' % name, initlevel_ext) cmdtable = getattr(mod, 'cmdtable', None) if cmdtable: errorcnt += checkcmdtable(ui, cmdtable, '%%s command of %s extension' % name, initlevel_ext_cmd) return errorcnt
def checkhghelps(): errorcnt = 0 for names, sec, doc in helptable: if callable(doc): doc = doc() errorcnt += checkseclevel(doc, '%s help topic' % names[0], initlevel_topic) errorcnt += checkcmdtable(table, '%s command', initlevel_cmd) for name in sorted(extensions.enabled().keys() + extensions.disabled().keys()): mod = extensions.load(None, name, None) if not mod.__doc__: verbose('skip checking %s extension: no help document' % name) continue errorcnt += checkseclevel(mod.__doc__, '%s extension' % name, initlevel_ext) cmdtable = getattr(mod, 'cmdtable', None) if cmdtable: errorcnt += checkcmdtable(cmdtable, '%s command of ' + name + ' extension', initlevel_ext_cmd) return errorcnt
def tree_context_menu(self): _menu = gtk.Menu() _menu.append(create_menu('di_splay', self._show_status)) _menu.append(create_menu('_checkout', self._checkout)) self._cmenu_merge = create_menu('_merge with', self._merge) _menu.append(self._cmenu_merge) _menu.append(create_menu('_export patch', self._export_patch)) _menu.append(create_menu('e_mail patch', self._email_patch)) _menu.append(create_menu('add/remove _tag', self._add_tag)) _menu.append(create_menu('backout revision', self._backout_rev)) # need mq extension for strip command extensions.loadall(self.ui) extensions.load(self.ui, 'mq', None) _menu.append(create_menu('strip revision', self._strip_rev)) _menu.show_all() return _menu
def _refresh(self, initial): def fill_history(history, vlist, cpath): vlist.clear() if cpath not in history.get_keys(): return for v in history.get_value(cpath): vlist.append([v]) history = shlib.Settings('config_history') try: repo = hg.repository(ui.ui(), path=self.root) self.repo = repo except RepoError: self.repo = None return extensions.load(self.repo.ui, 'patchbomb', None) if initial: # Only zap these fields at startup self._tobox.child.set_text(repo.ui.config('email', 'to', '')) self._ccbox.child.set_text(repo.ui.config('email', 'cc', '')) self._frombox.child.set_text(repo.ui.config('email', 'from', '')) self._subjbox.child.set_text(repo.ui.config('email', 'subject', '')) fill_history(history, self._tolist, 'email.to') fill_history(history, self._cclist, 'email.cc') fill_history(history, self._fromlist, 'email.from') fill_history(history, self._subjlist, 'email.subject') # See if user has set flags in defaults.email self._git.set_sensitive(True) self._bundle.set_sensitive(True) self._plain.set_sensitive(True) defaults = repo.ui.config('defaults', 'email', '').split() for flag in defaults: if flag in ('-g', '--git'): self._git.set_active(True) self._git.set_sensitive(False) if flag in ('-b', '--bundle'): self._bundle.set_active(True) self._bundle.set_sensitive(False) if flag in ('--plain'): self._plain.set_active(True) self._plain.set_sensitive(False)
def hg_strip(repo, processed_nodes): class dummyui(object): def debug(self, msg): pass if StrictVersion(hg_version()) >= StrictVersion('2.8'): stripext = extensions.load(dummyui(), 'strip', '') return stripext.strip(dummyui(), repo, processed_nodes) else: return repo.mq.strip(repo, processed_nodes)
def extsetup(ui): extensions.wrapfunction(exchange, 'push', wrappedpush) # Mercurial 3.2 introduces a decorator for registering functions to # be called during discovery. Switch to this once we drop support for # 3.1. extensions.wrapfunction(exchange, '_pushdiscovery', wrappedpushdiscovery) # _pushbookmark gets called near the end of push. Sadly, there isn't # a better place to hook that has access to the pushop. extensions.wrapfunction(exchange, '_pushbookmark', wrappedpushbookmark) if os.name == 'posix': extensions.wrapfunction(sshpeer.sshpeer, 'readerr', wrappedreaderr) # Define some extra arguments on the push command. entry = extensions.wrapcommand(commands.table, 'push', pushcommand) entry[1].append(('', 'noreview', False, _('Do not perform a review on push.'))) entry[1].append(('', 'reviewid', '', _('Review identifier'))) entry[1].append(('c', 'changeset', '', _('Review this specific changeset only'))) # Value may be empty. So check config source to see if key is present. if (ui.configsource('extensions', 'rebase') != 'none' and ui.config('extensions', 'rebase') != '!'): # The extensions.afterloaded mechanism is busted. So we can't # reliably wrap the rebase command in case it hasn't loaded yet. So # just load the rebase extension and wrap the function directly # from its commands table. try: cmdutil.findcmd('rebase', commands.table, strict=True) except error.UnknownCommand: extensions.load(ui, 'rebase', '') # Extensions' cmdtable entries aren't merged with commands.table. # Instead, dispatch just looks at each module. So it is safe to wrap # the command on the extension module. rebase = extensions.find('rebase') extensions.wrapcommand(rebase.cmdtable, 'rebase', rebasecommand) templatekw.keywords['reviews'] = template_reviews
def extsetup(ui): extensions.wrapfunction(exchange, "push", wrappedpush) # Mercurial 3.2 introduces a decorator for registering functions to # be called during discovery. Switch to this once we drop support for # 3.1. extensions.wrapfunction(exchange, "_pushdiscovery", wrappedpushdiscovery) # _pushbookmark gets called near the end of push. Sadly, there isn't # a better place to hook that has access to the pushop. extensions.wrapfunction(exchange, "_pushbookmark", wrappedpushbookmark) if os.name == "posix": extensions.wrapfunction(sshpeer.sshpeer, "readerr", wrappedreaderr) # Define some extra arguments on the push command. entry = extensions.wrapcommand(commands.table, "push", pushcommand) entry[1].append(("", "noreview", False, _("Do not perform a review on push."))) entry[1].append(("", "reviewid", "", _("Review identifier"))) entry[1].append(("c", "changeset", "", _("Review this specific changeset only"))) # Value may be empty. So check config source to see if key is present. if ui.configsource("extensions", "rebase") != "none" and ui.config("extensions", "rebase") != "!": # The extensions.afterloaded mechanism is busted. So we can't # reliably wrap the rebase command in case it hasn't loaded yet. So # just load the rebase extension and wrap the function directly # from its commands table. try: cmdutil.findcmd("rebase", commands.table, strict=True) except error.UnknownCommand: extensions.load(ui, "rebase", "") # Extensions' cmdtable entries aren't merged with commands.table. # Instead, dispatch just looks at each module. So it is safe to wrap # the command on the extension module. rebase = extensions.find("rebase") extensions.wrapcommand(rebase.cmdtable, "rebase", rebasecommand) templatekw.keywords["reviews"] = template_reviews
def show_doc(ui): # print options section(ui, _("Options")) for optstr, desc in get_opts(globalopts): ui.write("%s\n %s\n\n" % (optstr, desc)) # print cmds section(ui, _("Commands")) commandprinter(ui, table, subsection) # print topics for names, sec, doc in helptable: if names[0] == "config": # The config help topic is included in the hgrc.5 man # page. continue for name in names: ui.write(".. _%s:\n" % name) ui.write("\n") section(ui, sec) if util.safehasattr(doc, '__call__'): doc = doc() ui.write(doc) ui.write("\n") section(ui, _("Extensions")) ui.write( _("This section contains help for extensions that are distributed " "together with Mercurial. Help for other extensions is available " "in the help system.")) ui.write("\n\n" ".. contents::\n" " :class: htmlonly\n" " :local:\n" " :depth: 1\n\n") for extensionname in sorted(allextensionnames()): mod = extensions.load(None, extensionname, None) subsection(ui, extensionname) ui.write("%s\n\n" % mod.__doc__) cmdtable = getattr(mod, 'cmdtable', None) if cmdtable: subsubsection(ui, _('Commands')) commandprinter(ui, cmdtable, subsubsubsection)
def runperfcommand(reponame, command, *args, **kwargs): os.environ["HGRCPATH"] = os.environ.get("ASVHGRCPATH", "") # for "historical portability" # ui.load() has been available since d83ca85 if util.safehasattr(uimod.ui, "load"): ui = uimod.ui.load() else: ui = uimod.ui() repo = hg.repository(ui, os.path.join(reposdir, reponame)) perfext = extensions.load(ui, 'perfext', os.path.join(basedir, 'contrib', 'perf.py')) cmd = getattr(perfext, command) ui.pushbuffer() cmd(ui, repo, *args, **kwargs) output = ui.popbuffer() match = outputre.search(output) if not match: raise ValueError("Invalid output {0}".format(output)) return float(match.group(1))
def show_doc(ui): # print options section(ui, _("Options")) for optstr, desc in get_opts(globalopts): ui.write("%s\n %s\n\n" % (optstr, desc)) # print cmds section(ui, _("Commands")) commandprinter(ui, table, subsection) # print topics for names, sec, doc in helptable: if names[0] == "config": # The config help topic is included in the hgrc.5 man # page. continue for name in names: ui.write(".. _%s:\n" % name) ui.write("\n") section(ui, sec) if util.safehasattr(doc, "__call__"): doc = doc() ui.write(doc) ui.write("\n") section(ui, _("Extensions")) ui.write( _( "This section contains help for extensions that are distributed " "together with Mercurial. Help for other extensions is available " "in the help system." ) ) ui.write("\n\n" ".. contents::\n" " :class: htmlonly\n" " :local:\n" " :depth: 1\n\n") for extensionname in sorted(allextensionnames()): mod = extensions.load(None, extensionname, None) subsection(ui, extensionname) ui.write("%s\n\n" % mod.__doc__) cmdtable = getattr(mod, "cmdtable", None) if cmdtable: subsubsection(ui, _("Commands")) commandprinter(ui, cmdtable, subsubsubsection)
def checkhghelps(ui): errorcnt = 0 for names, sec, doc in helptable: if callable(doc): doc = doc(ui) errorcnt += checkseclevel(ui, doc, "%s help topic" % names[0], initlevel_topic) errorcnt += checkcmdtable(ui, table, "%s command", initlevel_cmd) for name in sorted(extensions.enabled().keys() + extensions.disabled().keys()): mod = extensions.load(None, name, None) if not mod.__doc__: ui.note(("skip checking %s extension: no help document\n") % name) continue errorcnt += checkseclevel(ui, mod.__doc__, "%s extension" % name, initlevel_ext) cmdtable = getattr(mod, "cmdtable", None) if cmdtable: errorcnt += checkcmdtable(ui, cmdtable, "%s command of " + name + " extension", initlevel_ext_cmd) return errorcnt
import logging from pylons import request, response, session, tmpl_context as c from pylons.controllers.util import abort, redirect_to from dvdev.lib.base import BaseController, render # This is the mercurial WSGI web server from mercurial.hgweb.hgwebdir_mod import hgwebdir from mercurial import ui, extensions from pylons import config from os import path # We build a list of repositorie tuples consisting of the project name, and their directory repositories = [(path.basename(repo), repo) for repo in config.get('repo').split()] # Set some global config in a parent ui parentui = ui.ui() # Pylons already includes Pygments, so this comes for free! extensions.load(parentui, 'hgext.highlight', '') log = logging.getLogger(__name__) class MercurialgatewayController(BaseController): def __call__(self, environ, start_response): application = hgwebdir(repositories, parentui) output = application(environ, start_response) return ''.join([x for x in output])
from mercurial.scmutil import revsingle from mercurial.util import version as hg_version from distutils.version import StrictVersion from .util import (die, output, git_to_hg_spaces, hgmode, branch_tip, ref_to_name_reftype, BRANCH, BOOKMARK, TAG, user_config) class dummyui(object): def debug(self, msg): pass if StrictVersion(hg_version()) >= StrictVersion('2.8'): stripext = extensions.load(dummyui(), 'strip', '') def strip_revs(repo, processed_nodes): stripext.strip(dummyui(), repo, processed_nodes) else: def strip_revs(repo, processed_nodes): repo.mq.strip(repo, processed_nodes) class GitExporter(object): '''A processor when the remote receives a git-remote `export` command. Provides export information to push commits from git to the mercurial repository.''' NULL_PARENT = '\0' * 20
from mercurial.node import short as hgshort from mercurial.bookmarks import pushbookmark from mercurial.scmutil import revsingle from mercurial.util import version as hg_version from distutils.version import StrictVersion from .util import (die, output, git_to_hg_spaces, hgmode, branch_tip, ref_to_name_reftype, BRANCH, BOOKMARK, TAG, user_config) class dummyui(object): def debug(self, msg): pass if StrictVersion(hg_version()) >= StrictVersion('2.8'): stripext = extensions.load(dummyui(), 'strip', '') def strip_revs(repo, processed_nodes): stripext.strip(dummyui(), repo, processed_nodes) else: def strip_revs(repo, processed_nodes): repo.mq.strip(repo, processed_nodes) class GitExporter(object): '''A processor when the remote receives a git-remote `export` command. Provides export information to push commits from git to the mercurial repository.''' NULL_PARENT = '\0' * 20 def __init__(self, hgremote, parser):
def __init__(self, cwd='', root = '', repos=[]): """ Initialize the Dialog. """ gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL) shlib.set_tortoise_icon(self, 'menusynch.ico') self.root = root self.cwd = cwd self.selected_path = None self.hgthread = None # persistent app data self._settings = shlib.Settings('synch') self._recent_src = self._settings.mrul('src_paths') self.set_default_size(610, 400) self.paths = self._get_paths() self.origchangecount = self.repo.changelog.count() # load the fetch extension explicitly extensions.load(self.ui, 'fetch', None) name = self.repo.ui.config('web', 'name') or os.path.basename(root) self.set_title("TortoiseHg Synchronize - " + name) self.connect('delete-event', self._delete) # toolbar self.tbar = gtk.Toolbar() self.tips = gtk.Tooltips() self._stop_button = self._toolbutton(gtk.STOCK_STOP, 'Stop', self._stop_clicked, tip='Stop the hg operation') self._stop_button.set_sensitive(False) tbuttons = [ self._toolbutton(gtk.STOCK_GO_DOWN, 'Incoming', self._incoming_clicked, tip='Display changes that can be pulled' ' from selected repository'), self._toolbutton(gtk.STOCK_GOTO_BOTTOM, ' Pull ', self._pull_clicked, self._pull_menu(), tip='Pull changes from selected' ' repository'), gtk.SeparatorToolItem(), self._toolbutton(gtk.STOCK_GO_UP, 'Outgoing', self._outgoing_clicked, tip='Display local changes that will be pushed' ' to selected repository'), self._toolbutton(gtk.STOCK_GOTO_TOP, 'Push', self._push_clicked, tip='Push local changes to selected' ' repository'), self._toolbutton(gtk.STOCK_GOTO_LAST, 'Email', self._email_clicked, tip='Email local outgoing changes to' ' one or more recipients'), gtk.SeparatorToolItem(), self._stop_button, gtk.SeparatorToolItem(), self._toolbutton(gtk.STOCK_PREFERENCES, 'Configure', self._conf_clicked, tip='Configure peer repository paths'), gtk.SeparatorToolItem(), ] for btn in tbuttons: self.tbar.insert(btn, -1) sep = gtk.SeparatorToolItem() sep.set_expand(True) sep.set_draw(False) self.tbar.insert(sep, -1) button = self._toolbutton(gtk.STOCK_CLOSE, 'Quit', self._close_clicked, tip='Quit Application') self.tbar.insert(button, -1) vbox = gtk.VBox() self.add(vbox) vbox.pack_start(self.tbar, False, False, 2) # revision input revbox = gtk.HBox() lbl = gtk.Button("Remote Path:") lbl.unset_flags(gtk.CAN_FOCUS) lbl.connect('clicked', self._btn_remotepath_clicked) # revisions combo box self.pathlist = gtk.ListStore(str) self._pathbox = gtk.ComboBoxEntry(self.pathlist, 0) self._pathtext = self._pathbox.get_child() defrow = None defpushrow = None for row, (name, path) in enumerate(self.paths): if name == 'default': defrow = row if defpushrow is None: defpushrow = row elif name == 'default-push': defpushrow = row self.pathlist.append([path]) if repos: self._pathtext.set_text(repos[0]) elif defrow is not None: self._pathbox.set_active(defrow) elif defpushrow is not None: self._pathbox.set_active(defpushrow) sympaths = [x[1] for x in self.paths] for p in self._recent_src: if p not in sympaths: self.pathlist.append([p]) # create checkbox to disable proxy self._use_proxy = gtk.CheckButton("use proxy server") if ui.ui().config('http_proxy', 'host', ''): self._use_proxy.set_active(True) else: self._use_proxy.set_sensitive(False) revbox.pack_start(lbl, False, False) revbox.pack_start(self._pathbox, True, True) revbox.pack_end(self._use_proxy, False, False) vbox.pack_start(revbox, False, False, 2) expander = gtk.Expander('Advanced Options') expander.set_expanded(False) hbox = gtk.HBox() expander.add(hbox) revvbox = gtk.VBox() revhbox = gtk.HBox() self._reventry = gtk.Entry() self._force = gtk.CheckButton('Force pull or push') self.tips.set_tip(self._force, 'Run even when remote repository' ' is unrelated.') revhbox.pack_start(gtk.Label('Target Revision:'), False, False, 2) revhbox.pack_start(self._reventry, True, True, 2) eventbox = gtk.EventBox() eventbox.add(revhbox) self.tips.set_tip(eventbox, 'A specific revision up to which you' ' would like to push or pull.') revvbox.pack_start(eventbox, True, True, 8) revvbox.pack_start(self._force, False, False, 2) hbox.pack_start(revvbox, True, True, 4) frame = gtk.Frame('Incoming/Outgoing') hbox.pack_start(frame, False, False, 2) self._showpatch = gtk.CheckButton('Show Patches') self._newestfirst = gtk.CheckButton('Show Newest First') self._nomerge = gtk.CheckButton('Show No Merges') hbox = gtk.HBox() hbox.pack_start(self._showpatch, False, False, 2) hbox.pack_start(self._newestfirst, False, False, 2) hbox.pack_start(self._nomerge, False, False, 2) frame.add(hbox) vbox.pack_start(expander, False, False, 2) # hg output window scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_shadow_type(gtk.SHADOW_ETCHED_IN) scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.textview = gtk.TextView(buffer=None) self.textview.set_editable(False) self.textview.modify_font(pango.FontDescription("Monospace")) scrolledwindow.add(self.textview) self.textview.set_editable(False) self.textbuffer = self.textview.get_buffer() vbox.pack_start(scrolledwindow, True, True) self.buttonhbox = gtk.HBox() self.viewpulled = gtk.Button('View Pulled Revisions') self.viewpulled.connect('clicked', self._view_pulled_changes) self.updatetip = gtk.Button('Update to Tip') self.updatetip.connect('clicked', self._update_to_tip) self.buttonhbox.pack_start(self.viewpulled, False, False, 2) self.buttonhbox.pack_start(self.updatetip, False, False, 2) vbox.pack_start(self.buttonhbox, False, False, 2) self.stbar = gtklib.StatusBar() vbox.pack_start(self.stbar, False, False, 2) self.connect('map', self.update_buttons)