# record.py # # Copyright 2007 Bryan O'Sullivan <*****@*****.**> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. """commands to interactively select changes for commit/qrefresh""" from mercurial.i18n import gettext, _ from mercurial import cmdutil, commands, extensions, hg, patch from mercurial import util import copy, cStringIO, errno, os, re, shutil, tempfile cmdtable = {} command = cmdutil.command(cmdtable) testedwith = "internal" lines_re = re.compile(r"@@ -(\d+),(\d+) \+(\d+),(\d+) @@\s*(.*)") diffopts = [ ("w", "ignore-all-space", False, _("ignore white space when comparing lines")), ("b", "ignore-space-change", None, _("ignore changes in the amount of white space")), ("B", "ignore-blank-lines", None, _("ignore changes whose lines are all blank")), ] def scanpatch(fp): """like patch.iterhunks, but yield different events - ('file', [header_lines + fromfile + tofile])
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
[diff-tools] kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child You can use -I/-X and list of file or directory names like normal :hg:`diff` command. The extdiff extension makes snapshots of only needed files, so running the external diff program will actually be pretty fast (at least faster than having to compare the entire tree). ''' from mercurial.i18n import _ from mercurial.node import short, nullid from mercurial import cmdutil, scmutil, util, commands, encoding, filemerge import os, shlex, shutil, tempfile, re cmdtable = {} command = cmdutil.command(cmdtable) testedwith = 'internal' def snapshot(ui, repo, files, node, tmproot): '''snapshot files as of some revision if not using snapshot, -I/-X does not work and recursive diff in tools like kdiff3 and meld displays too many files.''' dirname = os.path.basename(repo.root) if dirname == "": dirname = "root" if node is not None: dirname = '%s.%s' % (dirname, short(node)) base = os.path.join(tmproot, dirname) os.mkdir(base) if node is not None:
calltree.output(ostream) else: # format == 'text' stats = lsprof.Stats(p.getstats()) stats.sort() stats.pprint(top=10, file=ostream, climit=5) if output: ostream.close() else: return checkargs() qtrun = qtapp.QtRunner() table = {} command = cmdutil.command(table) # common command options globalopts = [ ('R', 'repository', '', _('repository root directory or symbolic path name')), ('v', 'verbose', None, _('enable additional output')), ('q', 'quiet', None, _('suppress output')), ('h', 'help', None, _('display help and exit')), ('', 'debugger', None, _('start debugger')), ('', 'profile', None, _('print command execution profile')), ('', 'nofork', None, _('do not fork GUI process')), ('', 'fork', None, _('always fork GUI process')), ('', 'listfile', '', _('read file list from file')), ('', 'listfileutf8', '', _('read file list from file encoding utf-8')),
else: # format == 'text' stats = lsprof.Stats(p.getstats()) stats.sort() stats.pprint(top=10, file=ostream, climit=5) if output: ostream.close() else: return checkargs() qtrun = qtapp.QtRunner() table = {} command = cmdutil.command(table) # common command options globalopts = [ ('R', 'repository', '', _('repository root directory or symbolic path name')), ('v', 'verbose', None, _('enable additional output')), ('q', 'quiet', None, _('suppress output')), ('h', 'help', None, _('display help and exit')), ('', 'debugger', None, _('start debugger')), ('', 'profile', None, _('print command execution profile')), ('', 'nofork', None, _('do not fork GUI process')), ('', 'fork', None, _('always fork GUI process')), ('', 'listfile', '', _('read file list from file')), ('', 'listfileutf8', '', _('read file list from file encoding utf-8')),
# # Copyright 2013, 2014 Yuya Nishihara <*****@*****.**> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. import os, socket from mercurial import cmdutil, commands, extensions, sslutil, util from tortoisehg.util import hgversion from tortoisehg.util.i18n import agettext as _ cmdtable = {} _mqcmdtable = {} command = cmdutil.command(cmdtable) mqcommand = cmdutil.command(_mqcmdtable) testedwith = hgversion.testedwith @command('debuggethostfingerprint', [], _('[SOURCE]'), optionalrepo=True) def debuggethostfingerprint(ui, repo, source='default'): """retrieve a fingerprint of the server certificate The server certificate is not verified. """ source = ui.expandpath(source) u = util.url(source) scheme = (u.scheme or '').split('+')[-1]
<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):
<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():