def extsetup(ui): try: from mercurial import wireproto except: from mercurial import wireprotov1server as wireproto from mercurial import extensions try: extensions.wrapfunction(wireproto, b'_capabilities', _capabilities) except AttributeError: extensions.wrapcommand(wireproto.commands, b'capabilities', capabilities) def wireprotocommand(name, args=b'', permission=b'push'): if hasattr(wireproto, 'wireprotocommand'): try: return wireproto.wireprotocommand(name, args, permission) except TypeError: if hasattr(wireproto, 'permissions'): wireproto.permissions[name] = permission return wireproto.wireprotocommand(name, args) def register(func): commands = wireproto.commands assert name not in commands commands[name] = (func, args) return register wireprotocommand(b'cinnabarclone', permission=b'pull')(cinnabar)
def uisetup(ui): """insert command wrappers for a bunch of commands""" docvals = {'extension': 'hgsubversion'} for cmd, (generic, target, fixdoc, ppopts, opts) in wrapcmds.iteritems(): if fixdoc and wrappers.generic.__doc__: docvals['command'] = cmd docvals['Command'] = cmd.capitalize() docvals['target'] = target doc = wrappers.generic.__doc__.strip() % docvals fn = getattr(commands, cmd) fn.__doc__ = fn.__doc__.rstrip() + '\n\n ' + doc wrapped = generic and wrappers.generic or getattr(wrappers, cmd) entry = extensions.wrapcommand(commands.table, cmd, wrapped) if ppopts: entry[1].extend(svnopts) if opts: entry[1].extend(opts) try: rebase = extensions.find('rebase') if not rebase: return entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase) entry[1].append(('', 'svn', None, 'automatic svn rebase')) except: pass
def setup(): """Wraps user-facing mercurial commands with narrow-aware versions.""" entry = extensions.wrapcommand(commands.table, b'clone', clonenarrowcmd) entry[1].append( (b'', b'narrow', None, _(b"create a narrow clone of select files"))) entry[1].append(( b'', b'depth', b'', _(b"limit the history fetched by distance from heads"), )) entry[1].append( (b'', b'narrowspec', b'', _(b"read narrowspecs from file"))) # TODO(durin42): unify sparse/narrow --include/--exclude logic a bit if b'sparse' not in extensions.enabled(): entry[1].append((b'', b'include', [], _(b"specifically fetch this file/directory"))) entry[1].append(( b'', b'exclude', [], _(b"do not fetch this file/directory, even if included"), )) entry = extensions.wrapcommand(commands.table, b'pull', pullnarrowcmd) entry[1].append(( b'', b'depth', b'', _(b"limit the history fetched by distance from heads"), )) extensions.wrapcommand(commands.table, b'archive', archivenarrowcmd)
def extsetup(ui): # Wrap the localrepo.dirstate() function. # # The original dirstate attribute is a filecache object, and needs slightly # special handling to wrap properly. # # (The fsmonitor and sqldirstate extensions both already wrap it, and each # has slightly different mechanisms for doing so. Here we wrap it more # like sqldirstate does. Ideally code for wrapping filecache objects # should just get put into core mercurial.) orig = localrepo.localrepository.dirstate # For some reason, localrepository.invalidatedirstate() does not call # dirstate.invalidate() by default, so we must wrap it. extensions.wrapfunction(localrepo.localrepository, 'invalidatedirstate', invalidatedirstate) extensions.wrapfunction(context.committablectx, 'markcommitted', mark_committed) extensions.wrapfunction(mergemod, 'update', merge_update) extensions.wrapfunction(hg, '_showstats', update_showstats) extensions.wrapfunction(orig, 'func', wrapdirstate) extensions.wrapcommand(commands.table, 'add', overrides.add) extensions.wrapcommand(commands.table, 'remove', overrides.remove) orig.paths = () if _thrift_client_type != 'native': ui.warn( _('unable to import native thrift client for eden; ' 'falling back to pyremote invocation\n'))
def extsetup(ui): extensions.wrapfunction(exchange, b'pull', pull) extensions.wrapfunction(webutil, b'changesetentry', changesetentry) extensions.wrapfunction(webutil, b'changelistentry', changelistentry) extensions.wrapfunction(bookmarks, b'updatefromremote', bmupdatefromremote) extensions.wrapfunction(webcommands, b'filelog', filelog) # Install IP filtering for bundle URLs. # Build-in command from core Mercurial. extensions.wrapcommand(wireprotov1server.commands, b'clonebundles', processbundlesmanifest) entry = extensions.wrapcommand(commands.table, b'serve', servehgmo) entry[1].append( (b'', b'hgmo', False, b'Run a server configured like hg.mozilla.org')) setattr(webcommands, 'info', infowebcommand) webcommands.__all__.append(b'info') setattr(webcommands, 'headdivergence', headdivergencewebcommand) webcommands.__all__.append(b'headdivergence') setattr(webcommands, 'automationrelevance', automationrelevancewebcommand) webcommands.__all__.append(b'automationrelevance') setattr(webcommands, 'isancestor', isancestorwebcommand) webcommands.__all__.append(b'isancestor') setattr(webcommands, 'repoinfo', repoinfowebcommand) webcommands.__all__.append(b'repoinfo')
def wrapstrip(loaded): try: stripmod = extensions.find('strip') except KeyError: pass else: extensions.wrapcommand(stripmod.cmdtable, 'strip', safestrip)
def extsetup(ui): try: from mercurial import wireproto except: from mercurial import wireprotov1server as wireproto from mercurial import extensions try: extensions.wrapfunction(wireproto, '_capabilities', _capabilities) except AttributeError: extensions.wrapcommand( wireproto.commands, 'capabilities', capabilities) def wireprotocommand(name, args='', permission='push'): if hasattr(wireproto, 'wireprotocommand'): try: return wireproto.wireprotocommand(name, args, permission) except TypeError: if hasattr(wireproto, 'permissions'): wireproto.permissions[name] = permission return wireproto.wireprotocommand(name, args) def register(func): commands = wireproto.commands assert name not in commands commands[name] = (func, args) return register wireprotocommand('cinnabarclone', permission='pull')(cinnabar)
def extsetup(ui): extensions.wrapcommand(commands.table, 'init', initcommand) # Configure null handler for kafka.* loggers to prevent "No handlers could # be found" messages from creeping into output. kafkalogger = logging.getLogger('kafka') if not kafkalogger.handlers: kafkalogger.addHandler(logging.NullHandler())
def extsetup(ui): extensions.wrapfunction(wireproto, 'dispatch', wireprotodispatch) extensions.wrapcommand(commands.table, 'init', initcommand) # Configure null handler for kafka.* loggers to prevent "No handlers could # be found" messages from creeping into output. kafkalogger = logging.getLogger('kafka') if not kafkalogger.handlers: kafkalogger.addHandler(logging.NullHandler())
def wrapshelve(loaded=False): try: shelvemod = extensions.find('shelve') extensions.wrapcommand(shelvemod.cmdtable, 'shelve', _bypassdirsync) extensions.wrapcommand(shelvemod.cmdtable, 'unshelve', _bypassdirsync) except KeyError: pass
def _setupclone(ui): entry = commands.table['^clone'] entry[1].append(('', 'enable-profile', [], 'enable a sparse profile')) entry[1].append(('', 'include', [], 'include sparse pattern')) entry[1].append(('', 'exclude', [], 'exclude sparse pattern')) extensions.wrapcommand(commands.table, 'clone', _clonesparsecmd)
def _setupclone(ui): entry = commands.table['clone'] entry[1].append(('', 'enable-profile', [], 'enable a sparse profile')) entry[1].append(('', 'include', [], 'include sparse pattern')) entry[1].append(('', 'exclude', [], 'exclude sparse pattern')) extensions.wrapcommand(commands.table, 'clone', _clonesparsecmd)
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 uisetup(ui): extensions.wrapfunction(repair, 'strip', strip) extensions.wrapcommand(commands.table, 'update', tasksupdate) extensions.wrapcommand(commands.table, 'log', taskslog) extensions.wrapcommand(commands.table, 'export', tasksexport) entry = extensions.wrapcommand(commands.table, 'push', taskspush) entry[1].append(('', 'completed-tasks', None, _('push all heads that have completed tasks only'))) entry[1].append(('', 'all-tasks', None, _('push all heads including those with incomplete tasks'))) try: transplant = extensions.find('transplant') if transplant: entry = extensions.wrapcommand(transplant.cmdtable, 'transplant', taskstransplant) entry[1].append(('t', 'task', '', _('transplant all changesets in task TASK'))) except: pass try: patchbomb = extensions.find('patchbomb') if patchbomb: entry = extensions.wrapcommand(patchbomb.cmdtable, 'email', tasksemail) entry[1].append(('t', 'task', '', _('email all changesets in task TASK'))) except: pass
def extsetup(ui): """insert command wrappers for a bunch of commands""" docvals = {'extension': 'hgsubversion'} for cmd, (generic, target, fixdoc, ppopts, opts) in wrapcmds.iteritems(): if fixdoc and wrappers.generic.__doc__: docvals['command'] = cmd docvals['Command'] = cmd.capitalize() docvals['target'] = target doc = wrappers.generic.__doc__.strip() % docvals fn = getattr(commands, cmd) fn.__doc__ = fn.__doc__.rstrip() + '\n\n ' + doc wrapped = generic and wrappers.generic or getattr(wrappers, cmd) entry = extensions.wrapcommand(commands.table, cmd, wrapped) if ppopts: entry[1].extend(svnopts) if opts: entry[1].extend(opts) try: rebase = extensions.find('rebase') if not rebase: return entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase) entry[1].append(('', 'svn', None, 'automatic svn rebase')) except: pass if not hgutil.safehasattr(localrepo.localrepository, 'push'): # Mercurial >= 3.2 extensions.wrapfunction(exchange, 'push', wrappers.exchangepush) if not hgutil.safehasattr(localrepo.localrepository, 'pull'): # Mercurial >= 3.2 extensions.wrapfunction(exchange, 'pull', wrappers.exchangepull) helpdir = os.path.join(os.path.dirname(__file__), 'help') entries = ( ( ['subversion'], "Working with Subversion Repositories", # Mercurial >= 3.6: doc(ui) lambda *args: open(os.path.join(helpdir, 'subversion.rst')).read() ), ) help.helptable.extend(entries) templatekw.keywords.update(util.templatekeywords) revset.symbols.update(util.revsets) subrepo.types['hgsubversion'] = svnexternals.svnsubrepo
def uisetup(ui): extensions.wrapfunction(repair, 'strip', strip) extensions.wrapcommand(commands.table, 'update', tasksupdate) extensions.wrapcommand(commands.table, 'log', taskslog) extensions.wrapcommand(commands.table, 'export', tasksexport) entry = extensions.wrapcommand(commands.table, 'push', taskspush) entry[1].append(('', 'completed-tasks', None, _('push all heads that have completed tasks only'))) entry[1].append( ('', 'all-tasks', None, _('push all heads including those with incomplete tasks'))) try: transplant = extensions.find('transplant') if transplant: entry = extensions.wrapcommand(transplant.cmdtable, 'transplant', taskstransplant) entry[1].append( ('t', 'task', '', _('transplant all changesets in task TASK'))) except: pass try: patchbomb = extensions.find('patchbomb') if patchbomb: entry = extensions.wrapcommand(patchbomb.cmdtable, 'email', tasksemail) entry[1].append( ('t', 'task', '', _('email all changesets in task TASK'))) except: pass
def extsetup(ui): """insert command wrappers for a bunch of commands""" docvals = {"extension": "hgsubversion"} for cmd, (generic, target, fixdoc, ppopts, opts) in wrapcmds.iteritems(): if fixdoc and wrappers.generic.__doc__: docvals["command"] = cmd docvals["Command"] = cmd.capitalize() docvals["target"] = target doc = wrappers.generic.__doc__.strip() % docvals fn = getattr(commands, cmd) fn.__doc__ = fn.__doc__.rstrip() + "\n\n " + doc wrapped = generic and wrappers.generic or getattr(wrappers, cmd) entry = extensions.wrapcommand(commands.table, cmd, wrapped) if ppopts: entry[1].extend(svnopts) if opts: entry[1].extend(opts) try: rebase = extensions.find("rebase") if not rebase: return entry = extensions.wrapcommand(rebase.cmdtable, "rebase", wrappers.rebase) entry[1].append(("", "svn", None, "automatic svn rebase")) except: pass if not hgutil.safehasattr(localrepo.localrepository, "push"): # Mercurial >= 3.2 extensions.wrapfunction(exchange, "push", wrappers.exchangepush) if not hgutil.safehasattr(localrepo.localrepository, "pull"): # Mercurial >= 3.2 extensions.wrapfunction(exchange, "pull", wrappers.exchangepull) helpdir = os.path.join(os.path.dirname(__file__), "help") entries = ( ( ["subversion"], "Working with Subversion Repositories", lambda: open(os.path.join(helpdir, "subversion.rst")).read(), ), ) help.helptable.extend(entries) templatekw.keywords.update(util.templatekeywords) revset.symbols.update(util.revsets) subrepo.types["hgsubversion"] = svnexternals.svnsubrepo
def extsetup(): """insert command wrappers for a bunch of commands""" # add the ui argument to this function once we drop support for 1.3 docvals = {'extension': 'hgsubversion'} for cmd, (generic, target, fixdoc, ppopts, opts) in wrapcmds.iteritems(): if fixdoc and wrappers.generic.__doc__: docvals['command'] = cmd docvals['Command'] = cmd.capitalize() docvals['target'] = target doc = wrappers.generic.__doc__.strip() % docvals fn = getattr(commands, cmd) fn.__doc__ = fn.__doc__.rstrip() + '\n\n ' + doc wrapped = generic and wrappers.generic or getattr(wrappers, cmd) entry = extensions.wrapcommand(commands.table, cmd, wrapped) if ppopts: entry[1].extend(svnopts) if opts: entry[1].extend(opts) try: rebase = extensions.find('rebase') if not rebase: return entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase) entry[1].append(('', 'svn', None, 'automatic svn rebase')) except: pass helpdir = os.path.join(os.path.dirname(__file__), 'help') entries = ( (['subversion'], "Working with Subversion Repositories", lambda: open(os.path.join(helpdir, 'subversion.rst')).read()), ) # in 1.6 and earler the help table is a tuple if getattr(help.helptable, 'extend', None): help.helptable.extend(entries) else: help.helptable = help.helptable + entries if templatekw: templatekw.keywords.update(util.templatekeywords) if revset: revset.symbols.update(util.revsets) if subrepo: subrepo.types['hgsubversion'] = svnexternals.svnsubrepo
def extsetup(ui): """insert command wrappers for a bunch of commands""" docvals = {'extension': 'hgsubversion'} for cmd, (generic, target, fixdoc, ppopts, opts) in wrapcmds.iteritems(): if fixdoc and wrappers.generic.__doc__: docvals['command'] = cmd docvals['Command'] = cmd.capitalize() docvals['target'] = target doc = wrappers.generic.__doc__.strip() % docvals fn = getattr(commands, cmd) fn.__doc__ = fn.__doc__.rstrip() + '\n\n ' + doc wrapped = generic and wrappers.generic or getattr(wrappers, cmd) entry = extensions.wrapcommand(commands.table, cmd, wrapped) if ppopts: entry[1].extend(svnopts) if opts: entry[1].extend(opts) try: rebase = extensions.find('rebase') if not rebase: return entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', wrappers.rebase) entry[1].append(('', 'svn', None, 'automatic svn rebase')) except: pass if not hgutil.safehasattr(localrepo.localrepository, 'push'): # Mercurial >= 3.2 extensions.wrapfunction(exchange, 'push', wrappers.exchangepush) if not hgutil.safehasattr(localrepo.localrepository, 'pull'): # Mercurial >= 3.2 extensions.wrapfunction(exchange, 'pull', wrappers.exchangepull) helpdir = os.path.join(os.path.dirname(__file__), 'help') entries = ( (['subversion'], "Working with Subversion Repositories", # Mercurial >= 3.6: doc(ui) lambda *args: open(os.path.join(helpdir, 'subversion.rst')).read()), ) help.helptable.extend(entries) templatekw.keywords.update(util.templatekeywords) revset.symbols.update(util.revsets) subrepo.types['hgsubversion'] = svnexternals.svnsubrepo
def extsetup(ui): extensions.wrapfunction(wireproto, 'dispatch', wireprotodispatch) extensions.wrapcommand(commands.table, 'init', initcommand) if _ORIG_PHASE_HEADS_HANDLER: bundle2.parthandlermapping['phase-heads'] = phase_heads_handler phase_heads_handler.params = _ORIG_PHASE_HEADS_HANDLER.params # Configure null handler for kafka.* loggers to prevent "No handlers could # be found" messages from creeping into output. kafkalogger = logging.getLogger('kafka') if not kafkalogger.handlers: kafkalogger.addHandler(logging.NullHandler())
def _setupadd(ui): entry = commands.table['^add'] entry[1].append(('s', 'sparse', None, 'also include directories of added files in sparse config')) def _add(orig, ui, repo, *pats, **opts): if opts.get('sparse'): dirs = set() for pat in pats: dirname, basename = util.split(pat) dirs.add(dirname) _config(ui, repo, list(dirs), opts, include=True) return orig(ui, repo, *pats, **opts) extensions.wrapcommand(commands.table, 'add', _add)
def _setupadd(ui): entry = commands.table['add'] entry[1].append(('s', 'sparse', None, 'also include directories of added files in sparse config')) def _add(orig, ui, repo, *pats, **opts): if opts.get(r'sparse'): dirs = set() for pat in pats: dirname, basename = util.split(pat) dirs.add(dirname) sparse.updateconfig(repo, list(dirs), opts, include=True) return orig(ui, repo, *pats, **opts) extensions.wrapcommand(commands.table, 'add', _add)
def extsetup(ui): global bz_available try: extensions.find('bzexport') bz_available = True except KeyError: pass extensions.wrapcommand(commands.table, 'pull', pullexpand) extensions.wrapfunction(exchange, 'pull', pull) extensions.wrapfunction(exchange, 'push', push) revset.symbols['bug'] = revset_bug revset.symbols['dontbuild'] = revset_dontbuild revset.symbols['me'] = revset_me revset.symbols['nobug'] = revset_nobug revset.symbols['reviewer'] = revset_reviewer revset.symbols['reviewed'] = revset_reviewed if not ui.configbool('mozext', 'disable_local_database'): revset.symbols['pushhead'] = revset_pushhead revset.symbols['tree'] = revset_tree revset.symbols['firstpushdate'] = revset_firstpushdate revset.symbols['firstpushtree'] = revset_firstpushtree revset.symbols['pushdate'] = revset_pushdate templatekw.keywords['bug'] = template_bug templatekw.keywords['bugs'] = template_bugs templatekw.keywords['reviewer'] = template_reviewer templatekw.keywords['reviewers'] = template_reviewers if not ui.configbool('mozext', 'disable_local_database'): templatekw.keywords['firstrelease'] = template_firstrelease templatekw.keywords['firstbeta'] = template_firstbeta templatekw.keywords['firstaurora'] = template_firstaurora templatekw.keywords['firstnightly'] = template_firstnightly templatekw.keywords['auroradate'] = template_auroradate templatekw.keywords['nightlydate'] = template_nightlydate templatekw.keywords['firstpushuser'] = template_firstpushuser templatekw.keywords['firstpushtree'] = template_firstpushtree templatekw.keywords['firstpushtreeherder'] = template_firstpushtreeherder templatekw.keywords['firstpushdate'] = template_firstpushdate templatekw.keywords['pushdates'] = template_pushdates templatekw.keywords['pushheaddates'] = template_pushheaddates templatekw.keywords['trees'] = template_trees templatekw.keywords['reltrees'] = template_reltrees templater.funcs['dates'] = template_dates
def extsetup_post_crecord(): crecord_ext = find_extension('crecord') mq_ext = find_extension('mq') if crecord_ext and mq_ext: entry = extensions.wrapcommand(crecord_ext.cmdtable, 'qcrecord', qcrecord_wrapper) entry[1].extend([('Q', 'mqcommit', None, 'commit change to patch queue'), ('M', 'mqmessage', '%a: %p%Q', 'commit message for patch creation')])
def extsetup(ui): extensions.wrapfunction(webutil, 'changesetentry', changesetentry) extensions.wrapfunction(webutil, 'changelistentry', changelistentry) extensions.wrapfunction(bookmarks, 'updatefromremote', bmupdatefromremote) revset.symbols['reviewer'] = revset_reviewer revset.safesymbols.add('reviewer') entry = extensions.wrapcommand(commands.table, 'serve', servehgmo) entry[1].append(('', 'hgmo', False, 'Run a server configured like hg.mozilla.org')) wrapper = ui.config('hgmo', 'mozbuildinfowrapper') if wrapper: if '"' in wrapper or "'" in wrapper: raise util.Abort('quotes may not appear in hgmo.mozbuildinfowrapper') setattr(webcommands, 'mozbuildinfo', mozbuildinfowebcommand) webcommands.__all__.append('mozbuildinfo') setattr(webcommands, 'info', infowebcommand) webcommands.__all__.append('info') setattr(webcommands, 'headdivergence', headdivergencewebcommand) webcommands.__all__.append('headdivergence')
def clientextsetup(ui): entry = extensions.wrapcommand(commands.table, 'push', _push) entry[1].append(('', 'bundle-store', None, _('force push to go to bundle store (EXPERIMENTAL)'))) extensions.wrapcommand(commands.table, 'pull', _pull) extensions.wrapfunction(discovery, 'checkheads', _checkheads) wireprotov1peer.wirepeer.listkeyspatterns = listkeyspatterns partorder = exchange.b2partsgenorder index = partorder.index('changeset') partorder.insert(index, partorder.pop(partorder.index(scratchbranchparttype)))
def uisetup(ui): extensions.wrapfunction(context.workingfilectx, 'data', wfctx_data) extensions.wrapfunction(context.workingfilectx, 'flags', wfctx_flags) extensions.wrapfunction(context.workingfilectx, 'renamed', wfctx_renamed) entry = extensions.wrapcommand(commands.table, 'commit', partialcommit) entry[1].append(('', 'partials', '', 'selected patch chunks (internal use only)'))
def setupdirectaccess(): """ Add two new filtername that behave like visible to provide direct access and direct access with warning. Wraps the commands to setup direct access """ repoview.filtertable.update({'visible-directaccess-nowarn': _computehidden}) repoview.filtertable.update({'visible-directaccess-warn': _computehidden}) branchmap.subsettable['visible-directaccess-nowarn'] = 'visible' branchmap.subsettable['visible-directaccess-warn'] = 'visible' for warn, ext, cmd in directaccesslevel: try: cmdtable = extensions.find(ext).cmdtable if ext else commands.table wrapper = wrapwitherror if warn == 'error' else wrapwithoutwarning extensions.wrapcommand(cmdtable, cmd, wrapper) except (error.UnknownCommand, KeyError): pass
def uisetup(ui): 'Replace pull with a decorator to provide --rebase option' entry = extensions.wrapcommand(commands.table, 'pull', pullrebase) entry[1].append(('', 'rebase', None, _("rebase working directory to branch head"))) entry[1].append(('t', 'tool', '', _("specify merge tool for rebase")))
def extsetup(ui): entry = wrapcommand(commands.table, 'push', _push) try: # Don't add the 'to' arg if it already exists extensions.find('remotenames') except KeyError: entry[1].append(('', 'to', '', _('server revision to rebase onto'))) partorder = exchange.b2partsgenorder partorder.insert(partorder.index('changeset'), partorder.pop(partorder.index(rebaseparttype))) partorder.insert(0, partorder.pop(partorder.index(commonheadsparttype))) wrapfunction(discovery, 'checkheads', _checkheads) # we want to disable the heads check because in pushrebase repos, we # expect the heads to change during the push and we should not abort. # The check heads functions are used to verify that the heads haven't # changed since the client did the initial discovery. Pushrebase is meant # to allow concurrent pushes, so the heads may have very well changed. # So let's not do this check. wrapfunction(exchange, 'check_heads', _exchangecheckheads) wrapfunction(exchange, '_pushb2ctxcheckheads', _skipcheckheads) origpushkeyhandler = bundle2.parthandlermapping['pushkey'] newpushkeyhandler = lambda *args, **kwargs: \ bundle2pushkey(origpushkeyhandler, *args, **kwargs) newpushkeyhandler.params = origpushkeyhandler.params bundle2.parthandlermapping['pushkey'] = newpushkeyhandler bundle2.parthandlermapping['b2x:pushkey'] = newpushkeyhandler wrapfunction(exchange, 'unbundle', unbundle) wrapfunction(hg, '_peerorrepo', _peerorrepo)
def uisetup(ui): '''Replaces pull with a decorator to provide --rebaseif option''' entry = extensions.wrapcommand(commands.table, 'pull', pullrebaseif) entry[1].append(('', 'rebaseif', None, _('rebase or merge working directory to branch head')) )
def extsetup(ui): # TRACKING hg49 4.8 would emit bytearray instances against PEP-3333. extensions.wrapfunction(requestmod.wsgiresponse, 'sendresponse', wsgisendresponse) extensions.wrapfunction(exchange, 'pull', pull) extensions.wrapfunction(webutil, 'changesetentry', changesetentry) extensions.wrapfunction(webutil, 'changelistentry', changelistentry) extensions.wrapfunction(bookmarks, 'updatefromremote', bmupdatefromremote) extensions.wrapfunction(webcommands, 'filelog', filelog) revset.symbols['reviewer'] = revset_reviewer revset.safesymbols.add('reviewer') revset.symbols['automationrelevant'] = revset_automationrelevant revset.safesymbols.add('automationrelevant') # Install IP filtering for bundle URLs. # Build-in command from core Mercurial. extensions.wrapcommand(wireprotov1server.commands, 'clonebundles', processbundlesmanifest) entry = extensions.wrapcommand(commands.table, 'serve', servehgmo) entry[1].append(('', 'hgmo', False, 'Run a server configured like hg.mozilla.org')) setattr(webcommands, 'info', infowebcommand) webcommands.__all__.append('info') setattr(webcommands, 'headdivergence', headdivergencewebcommand) webcommands.__all__.append('headdivergence') setattr(webcommands, 'automationrelevance', automationrelevancewebcommand) webcommands.__all__.append('automationrelevance') setattr(webcommands, 'isancestor', isancestorwebcommand) webcommands.__all__.append('isancestor') setattr(webcommands, 'repoinfo', repoinfowebcommand) webcommands.__all__.append('repoinfo') # TRACKING hg49 install custom filesdata command handler to work around bugs. wireprotov2server.COMMANDS[b'filesdata'].func = filesdata # Teach rawstorefiledata command to cache. wireprotov2server.COMMANDS[b'rawstorefiledata'].cachekeyfn = rawstorefiledata_cache_fn
def setupdirectaccess(): """ Add two new filtername that behave like visible to provide direct access and direct access with warning. Wraps the commands to setup direct access """ repoview.filtertable.update( {'visible-directaccess-nowarn': _computehidden}) repoview.filtertable.update({'visible-directaccess-warn': _computehidden}) branchmap.subsettable['visible-directaccess-nowarn'] = 'visible' branchmap.subsettable['visible-directaccess-warn'] = 'visible' for warn, ext, cmd in directaccesslevel: try: cmdtable = extensions.find(ext).cmdtable if ext else commands.table wrapper = wrapwitherror if warn == 'error' else wrapwithoutwarning extensions.wrapcommand(cmdtable, cmd, wrapper) except (error.UnknownCommand, KeyError): pass
def extsetup(ui): extensions.wrapfunction(exchange, 'pull', pull) extensions.wrapfunction(webutil, 'changesetentry', changesetentry) extensions.wrapfunction(webutil, 'changelistentry', changelistentry) extensions.wrapfunction(bookmarks, 'updatefromremote', bmupdatefromremote) extensions.wrapfunction(webcommands, 'filelog', filelog) revset.symbols['reviewer'] = revset_reviewer revset.safesymbols.add('reviewer') revset.symbols['automationrelevant'] = revset_automationrelevant revset.safesymbols.add('automationrelevant') # Install IP filtering for bundle URLs. # Build-in command from core Mercurial. extensions.wrapcommand(wireprotov1server.commands, 'clonebundles', processbundlesmanifest) entry = extensions.wrapcommand(commands.table, 'serve', servehgmo) entry[1].append( ('', 'hgmo', False, 'Run a server configured like hg.mozilla.org')) wrapper = ui.config('hgmo', 'mozbuildinfowrapper') if wrapper: if '"' in wrapper or "'" in wrapper: raise error.Abort('quotes may not appear in ' 'hgmo.mozbuildinfowrapper') setattr(webcommands, 'mozbuildinfo', mozbuildinfowebcommand) webcommands.__all__.append('mozbuildinfo') setattr(webcommands, 'info', infowebcommand) webcommands.__all__.append('info') setattr(webcommands, 'headdivergence', headdivergencewebcommand) webcommands.__all__.append('headdivergence') setattr(webcommands, 'automationrelevance', automationrelevancewebcommand) webcommands.__all__.append('automationrelevance') setattr(webcommands, 'isancestor', isancestorwebcommand) webcommands.__all__.append('isancestor') setattr(webcommands, 'repoinfo', repoinfowebcommand) webcommands.__all__.append('repoinfo')
def _wrapcmd(cmd, table, wrapfn, msg): '''wrap the command''' def wrapper(orig, *args, **kwargs): if kwargs['interactive']: return wrapfn(*args, **kwargs) return orig(*args, **kwargs) entry = extensions.wrapcommand(table, cmd, wrapper) entry[1].append(('i', 'interactive', None, msg))
def extsetup(ui): extensions.wrapfunction(localrepo, b'makestore', _makestore) extensions.wrapfunction(localrepo, b'makefilestorage', _makefilestorage) # Inject --git flag for `hg init` entry = extensions.wrapcommand(commands.table, b'init', init) entry[1].extend([(b'', b'git', None, b'setup up a git repository instead of hg')]) localrepo.featuresetupfuncs.add(_featuresetup)
def extsetup(ui): extensions.wrapfunction(wireproto, '_capabilities', capabilities) # To short circuit operations with discovery repos. extensions.wrapcommand(wireproto.commands, 'heads', wrappedwireprotoheads) setattr(webcommands, 'mozreviewcapabilities', capabilitieswebcommand) webcommands.__all__.append('mozreviewcapabilities') setattr(webcommands, 'mozreviewsubmitseries', submitserieswebcommand) webcommands.__all__.append('mozreviewsubmitseries') setattr(webcommands, 'mozreviewpublish', publishwebcommand) webcommands.__all__.append('mozreviewpublish') setattr(webcommands, 'mozreviewreviewrepos', reviewreposwebcommand) webcommands.__all__.append('mozreviewreviewrepos')
def has_automv(loaded): if not loaded: return automv = extensions.find('automv') entry = extensions.wrapcommand(cmdtable, 'amend', automv.mvcheck) entry[1].append( ('', 'no-move-detection', None, _('disable automatic file move detection')))
def uisetup(ui): 'Replace pull with a decorator to provide --rebase option' entry = extensions.wrapcommand(commands.table, 'pull', pullrebase) entry[1].append(('', 'rebase', None, _("rebase working directory to branch head"))) entry[1].append(('t', 'tool', '', _("specify merge tool for rebase"))) cmdutil.summaryhooks.add('rebase', summaryhook)
def _wrapcmd(ui, cmd, table, wrapfn): '''wrap the command''' def graph(orig, *args, **kwargs): if kwargs['graph']: return wrapfn(*args, **kwargs) return orig(*args, **kwargs) entry = extensions.wrapcommand(table, cmd, graph) entry[1].append(('G', 'graph', None, _("show the revision DAG")))
def uisetup_post_mq(ui, mq): entry = extensions.wrapcommand(mq.cmdtable, 'qrefresh', qrefresh_wrapper) entry[1].extend([('Q', 'mqcommit', None, 'commit change to patch queue'), ('M', 'mqmessage', '', 'commit message for patch update')]) entry = extensions.wrapcommand(mq.cmdtable, 'qnew', qnew_wrapper) entry[1].extend([('Q', 'mqcommit', None, 'commit change to patch queue'), ('M', 'mqmessage', '%a: %p%Q', 'commit message for patch creation')]) entry = extensions.wrapcommand(mq.cmdtable, 'qimport', qimport_wrapper) entry[1].extend([('Q', 'mqcommit', None, 'commit change to patch queue'), ('M', 'mqmessage', 'IMPORT: %p%Q', 'commit message for patch import')]) entry = extensions.wrapcommand(mq.cmdtable, 'qdelete', qdelete_wrapper) entry[1].extend([('Q', 'mqcommit', None, 'commit change to patch queue'), ('M', 'mqmessage', '', 'commit message for patch deletion')]) entry = extensions.wrapcommand(mq.cmdtable, 'qrename', qrename_wrapper) entry[1].extend([('Q', 'mqcommit', None, 'commit change to patch queue'), ('M', 'mqmessage', '%a: %p -> %n%Q', 'commit message for patch rename')]) entry = extensions.wrapcommand(mq.cmdtable, 'qfinish', qfinish_wrapper) entry[1].extend([('Q', 'mqcommit', None, 'commit change to patch queue'), ('M', 'mqmessage', 'FINISHED%Q', 'commit message for patch finishing')]) entry = extensions.wrapcommand(mq.cmdtable, 'qfold', qfold_wrapper) entry[1].extend([('Q', 'mqcommit', None, 'commit change to patch queue'), ('M', 'mqmessage', '%a: %p <- %n%Q', 'commit message for patch folding')])
def extsetup(ui): extensions.wrapfunction(webutil, 'changesetentry', changesetentry) extensions.wrapfunction(webutil, 'changelistentry', changelistentry) extensions.wrapfunction(bookmarks, 'updatefromremote', bmupdatefromremote) extensions.wrapfunction(webcommands, 'filelog', filelog) revset.symbols['reviewer'] = revset_reviewer revset.safesymbols.add('reviewer') revset.symbols['automationrelevant'] = revset_automationrelevant revset.safesymbols.add('automationrelevant') # Install IP filtering for bundle URLs. # Build-in command from core Mercurial. extensions.wrapcommand(wireproto.commands, 'clonebundles', clonebundleswireproto) # Legacy bundleclone command. Need to support until all clients run # 3.6+. if 'bundles' in wireproto.commands: extensions.wrapcommand(wireproto.commands, 'bundles', bundleclonewireproto) entry = extensions.wrapcommand(commands.table, 'serve', servehgmo) entry[1].append( ('', 'hgmo', False, 'Run a server configured like hg.mozilla.org')) wrapper = ui.config('hgmo', 'mozbuildinfowrapper') if wrapper: if '"' in wrapper or "'" in wrapper: raise util.Abort( 'quotes may not appear in hgmo.mozbuildinfowrapper') setattr(webcommands, 'mozbuildinfo', mozbuildinfowebcommand) webcommands.__all__.append('mozbuildinfo') setattr(webcommands, 'info', infowebcommand) webcommands.__all__.append('info') setattr(webcommands, 'headdivergence', headdivergencewebcommand) webcommands.__all__.append('headdivergence') setattr(webcommands, 'automationrelevance', automationrelevancewebcommand) webcommands.__all__.append('automationrelevance')
def uisetup(ui): extensions.wrapcommand(commands.table, 'outgoing', guess_kilnpath) extensions.wrapcommand(commands.table, 'pull', guess_kilnpath) extensions.wrapcommand(commands.table, 'incoming', guess_kilnpath) push_cmd = extensions.wrapcommand(commands.table, 'push', wrap_push) # Add --review as a valid flag to push's command table push_cmd[1].extend([('', 'review', None, 'associate changesets with Kiln review')])
def extsetup(ui): extensions.wrapfunction(wireproto, '_capabilities', capabilities) pushkey.register('strip', pushstrip, liststrip) # To short circuit operations with discovery repos. extensions.wrapcommand(wireproto.commands, 'heads', wrappedwireprotoheads) setattr(webcommands, 'mozreviewcapabilities', capabilitieswebcommand) webcommands.__all__.append('mozreviewcapabilities') setattr(webcommands, 'mozreviewsubmitseries', submitserieswebcommand) webcommands.__all__.append('mozreviewsubmitseries') setattr(webcommands, 'mozreviewpublish', publishwebcommand) webcommands.__all__.append('mozreviewpublish') setattr(webcommands, 'mozreviewreviewrepos', reviewreposwebcommand) webcommands.__all__.append('mozreviewreviewrepos')
def uisetup(ui): 'Add --patience option to diff command and wrap a few functions.' entry = extensions.wrapcommand(commands.table, 'diff', diffcmdwrapper) entry[1].append(('', 'patience', None, _('use patience diff algorithm'))) extensions.wrapfunction(bdiff, 'blocks', blockswrapper) extensions.wrapfunction(patch, 'diff', diffwrapper) extensions.wrapfunction(mdiff, 'unidiff', unidiffwrapper)
def uisetup(ui): hiddenoverride.uisetup(ui) prune.uisetup(ui) entry = extensions.wrapcommand(commands.table, 'commit', commit) for opt in amendopts: opt = (opt[0], opt[1], opt[2], "(with --amend) " + opt[3]) entry[1].append(opt) # manual call of the decorator command('^amend', [ ('A', 'addremove', None, _('mark new/missing files as added/removed before committing')), ('e', 'edit', None, _('prompt to edit the commit message')), ('i', 'interactive', None, _('use interactive mode')), ] + amendopts + commands.walkopts + commands.commitopts + commands.commitopts2, _('hg amend [OPTION]...'))(amend) def has_automv(loaded): if not loaded: return automv = extensions.find('automv') entry = extensions.wrapcommand(cmdtable, 'amend', automv.mvcheck) entry[1].append( ('', 'no-move-detection', None, _('disable automatic file move detection'))) extensions.afterloaded('automv', has_automv) def evolveloaded(loaded): if not loaded: return evolvemod = extensions.find('evolve') # Remove conflicted commands from evolve. table = evolvemod.cmdtable for name in ['prev', 'next', 'split', 'fold', 'metaedit', 'prune']: todelete = [k for k in table if name in k] for k in todelete: oldentry = table[k] table['debugevolve%s' % name] = oldentry del table[k] extensions.afterloaded('evolve', evolveloaded) def rebaseloaded(loaded): if not loaded: return entry = extensions.wrapcommand(rebasemod.cmdtable, 'rebase', wraprebase) entry[1].append(( '', 'restack', False, _('rebase all changesets in the current ' 'stack onto the latest version of their ' 'respective parents') )) extensions.afterloaded('rebase', rebaseloaded)
def extsetup(ui): entry = extensions.wrapcommand(commands.table, b'commit', _commit) options = entry[1] options.append(( b'', b'extra', [], _(b'set a changeset\'s extra values'), _(b"KEY=VALUE"), ))
def rebaseloaded(loaded): if not loaded: return entry = extensions.wrapcommand(rebasemod.cmdtable, 'rebase', wraprebase) entry[1].append(( '', 'restack', False, _('rebase all changesets in the current ' 'stack onto the latest version of their ' 'respective parents') ))
def _wrapcmd(cmd, table, wrapfn): """wrap the command""" def graph(orig, *args, **kwargs): if kwargs["graph"]: return wrapfn(*args, **kwargs) return orig(*args, **kwargs) entry = extensions.wrapcommand(table, cmd, graph) entry[1].append(("G", "graph", None, _("show the revision DAG")))
def extsetup(ui): extensions.wrapfunction(webutil, 'changesetentry', changesetentry) extensions.wrapfunction(webutil, 'changelistentry', changelistentry) extensions.wrapfunction(bookmarks, 'updatefromremote', bmupdatefromremote) extensions.wrapfunction(webcommands, 'filelog', filelog) revset.symbols['reviewer'] = revset_reviewer revset.safesymbols.add('reviewer') revset.symbols['automationrelevant'] = revset_automationrelevant revset.safesymbols.add('automationrelevant') # Install IP filtering for bundle URLs. # Build-in command from core Mercurial. extensions.wrapcommand(wireproto.commands, 'clonebundles', clonebundleswireproto) # Legacy bundleclone command. Need to support until all clients run # 3.6+. if 'bundles' in wireproto.commands: extensions.wrapcommand(wireproto.commands, 'bundles', bundleclonewireproto) entry = extensions.wrapcommand(commands.table, 'serve', servehgmo) entry[1].append(('', 'hgmo', False, 'Run a server configured like hg.mozilla.org')) wrapper = ui.config('hgmo', 'mozbuildinfowrapper') if wrapper: if '"' in wrapper or "'" in wrapper: raise util.Abort('quotes may not appear in hgmo.mozbuildinfowrapper') setattr(webcommands, 'mozbuildinfo', mozbuildinfowebcommand) webcommands.__all__.append('mozbuildinfo') setattr(webcommands, 'info', infowebcommand) webcommands.__all__.append('info') setattr(webcommands, 'headdivergence', headdivergencewebcommand) webcommands.__all__.append('headdivergence') setattr(webcommands, 'automationrelevance', automationrelevancewebcommand) webcommands.__all__.append('automationrelevance')
def uisetup(ui): 'Replace pull with a decorator to provide --rebase option' entry = extensions.wrapcommand(commands.table, 'pull', pullrebase) entry[1].append(('', 'rebase', None, _("rebase working directory to branch head"))) entry[1].append(('t', 'tool', '', _("specify merge tool for rebase"))) cmdutil.summaryhooks.add('rebase', summaryhook) cmdutil.unfinishedstates.append( ['rebasestate', False, False, _('rebase in progress'), _("use 'hg rebase --continue' or 'hg rebase --abort'")])
def uisetup(ui): extensions.wrapcommand(commands.table, 'pull', _pull_with_cache) extensions.wrapcommand(commands.table, 'push', _push_with_cache) try: extensions.wrapcommand(extensions.find("fetch").cmdtable, 'fetch', _pull_with_cache) except KeyError: pass