from __future__ import absolute_import import re from mercurial.i18n import _ from mercurial import ( commands, error, extensions, registrar, util, ) cmdtable = {} command = registrar.command(cmdtable) testedwith = b'ships-with-hg-core' usedinternally = { b'amend_source', b'branch', b'close', b'histedit_source', b'topic', b'rebase_source', b'intermediate-source', b'__touch-noise__', b'source', b'transplant_source', }
hg, merge, narrowspec, node, pycompat, registrar, repair, repository, repoview, sparse, util, wireprototypes, ) table = {} command = registrar.command(table) def setup(): """Wraps user-facing mercurial commands with narrow-aware versions.""" entry = extensions.wrapcommand(commands.table, 'clone', clonenarrowcmd) entry[1].append(('', 'narrow', None, _("create a narrow clone of select files"))) entry[1].append(('', 'depth', '', _("limit the history fetched by distance from heads"))) entry[1].append(('', 'narrowspec', '', _("read narrowspecs from file"))) # TODO(durin42): unify sparse/narrow --include/--exclude logic a bit if 'sparse' not in extensions.enabled(): entry[1].append(('', 'include', [], _("specifically fetch this file/directory")))
from mercurial import pycompat, scmutil from hgext import blackbox from hgext3rd import ( shareutil, smartlog, fbsparse as sparse, ) import os, socket, re, tempfile, time, traceback from remotefilelog import ( constants, shallowutil ) cmdtable = {} command = registrar.command(cmdtable) _failsafeerrors = [] def _failsafe(func): try: return func() except Exception as ex: index = len(_failsafeerrors) + 1 message = "[%d]: %s\n%s\n" % (index, str(ex), traceback.format_exc()) _failsafeerrors.append(message) return '(Failed. See footnote [%d])' % index def shcmd(cmd, input=None, check=True, keeperr=True): _, _, _, p = util.popen4(cmd) out, err = p.communicate(input)
def command(cmdtable): """ Compatibility layer for mercurial.cmdtutil.command. For Mercurials >= 3.1 it's just synonym for cmdutil.command. For Mercurials <= 3.0 it returns upward compatible function (adding norepo, optionalrepo and inferrepo args which are missing there). Usage: just call ``meu.command(cmdtable)`` instead of ``cmdutil.command(cmdtable)``. For example: >>> cmdtable = {} >>> cmd = command(cmdtable) >>> >>> @cmd("somecmd", [], "somecmd") ... def mycmd(ui, repo, sth, **opts): ... pass >>> >>> @cmd("othercmd", [ ... ('l', 'list', None, 'List widgets'), ... ('p', 'pagesize', 10, 'Page size'), ... ], "othercmd [-l] [-p 20]", norepo=True) ... def othercmd(ui, sth, **opts): ... pass >>> >>> sorted(cmdtable.keys()) ['othercmd', 'somecmd'] >>> cmdtable['othercmd'] # doctest: +ELLIPSIS (<function othercmd at ...>, [('l', 'list', None, 'List widgets'), ('p', 'pagesize', 10, 'Page size')], 'othercmd [-l] [-p 20]') Below is uninteresting test that it really works in various mecurials: >>> from mercurial import commands >>> # Syntax changed in hg3.8, trying to accomodate >>> commands.norepo if hasattr(commands, 'norepo') else ' othercmd' # doctest: +ELLIPSIS '... othercmd' >>> othercmd.__dict__['norepo'] if othercmd.__dict__ else True True >>> mycmd.__dict__['norepo'] if mycmd.__dict__ else False False """ from mercurial import cmdutil, commands import inspect try: from mercurial import registrar command = registrar.command(cmdtable) return command except (ImportError, AttributeError): command = cmdutil.command(cmdtable) spec = inspect.getargspec(command) if 'norepo' in spec[0]: # Looks like modern mercurial with correct api, keeping # it's implementation return command # Old mecurial with only name, options, synopsis in data, # patching to get full signature. This is more or less copy # of current implementation, sans docs. def parsealiases(cmd): return cmd.lstrip("^").split("|") def fixed_cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False, inferrepo=False): def decorator(func): if synopsis: cmdtable[name] = func, list(options), synopsis else: cmdtable[name] = func, list(options) if norepo: commands.norepo += ' %s' % ' '.join(parsealiases(name)) if optionalrepo: commands.optionalrepo += ' %s' % ' '.join(parsealiases(name)) if inferrepo: commands.inferrepo += ' %s' % ' '.join(parsealiases(name)) return func return decorator return fixed_cmd
<repository root="/foo/bar"> <manifest revision="1234" path="lib"> <file name="diff.rb" revision="123" node="34567abc..." time="12345" size="100"/> ... <dir name="redmine"/> ... </manifest> </repository> </rhmanifest> """ import re, time, cgi, urllib from mercurial import cmdutil, commands, node, error, hg, registrar cmdtable = {} command = registrar.command(cmdtable) if hasattr( registrar, 'command') else cmdutil.command(cmdtable) _x = cgi.escape _u = lambda s: cgi.escape(urllib.quote(s)) def _changectx(repo, rev): if isinstance(rev, str): rev = repo.lookup(rev) if hasattr(repo, 'changectx'): return repo.changectx(rev) else: return repo[rev]
<repository root="/foo/bar"> <manifest revision="1234" path="lib"> <file name="diff.rb" revision="123" node="34567abc..." time="12345" size="100"/> ... <dir name="redmine"/> ... </manifest> </repository> </rhmanifest> """ import re, time, cgi, urllib from mercurial import cmdutil, commands, node, error, hg, registrar cmdtable = {} command = registrar.command(cmdtable) if hasattr(registrar, 'command') else cmdutil.command(cmdtable) _x = cgi.escape _u = lambda s: cgi.escape(urllib.quote(s)) def _changectx(repo, rev): if isinstance(rev, str): rev = repo.lookup(rev) if hasattr(repo, 'changectx'): return repo.changectx(rev) else: return repo[rev] def _tip(ui, repo): # see mercurial/commands.py:tip def tiprev():
from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from itertools import izip state = {'new': ['new'], 'resolved': ['fixed', 'resolved']} default_state = 'new' default_issues_dir = ".issues" filter_prefix = ".filter" date_format = '%a, %d %b %Y %H:%M:%S %1%2' maildir_dirs = ['new', 'cur', 'tmp'] default_format = '%(id)s (%(len)3d) [%(state)s]: %(Subject)s' cmdtable = {} try: command = registrar.command(cmdtable) # was cmdtable.command except: command = cmdutil.command(cmdtable) @command('ilist', [ ('a', 'all', False, 'list all issues (by default only those with state new)'), ('p', 'property', [], 'list issues with specific field values (e.g., -p state=fixed); lists all possible values of a property if no = sign' ), ('o', 'order', 'new', 'order of the issues; choices: "new" (date submitted), "latest" (date of the last message)' ), ('d', 'date', '', 'restrict to issues matching the date (e.g., -d ">12/28/2007)"'),
from mercurial.scmutil import rcpath, userrcpath else: rcpath = util.rcpath userrcpath = util.userrcpath if util.version() >= b'4.7': from mercurial.registrar import command else: from mercurial.cmdutil import command VERSION = [1, 0, 2, 0, b''] cmdtable = {} command = command(cmdtable) def localrc(repo=None): """ Return the filesystem path to the repository's hgrc config file as a `str`, or `None` if the given `repo` is None. """ if repo is None: return None return os.path.join(repo.path, b'hgrc') def getconfigs(ui, repo): """ Get a sequence of possible configuration files, including local