##// END OF EJS Templates
revert: triage "deleted" files into more appropriate categories...
revert: triage "deleted" files into more appropriate categories Status can return file as "deleted". This is only a special case related to working directory state: file is recorded as tracked but no file exists on disk. This will never be a state obtainable from manifest comparisons. "Deleted" files have another working directory status shadowed by the lack of file. They will -alway- be touched by revert. The "lack of file" can be seen as a modification. The file will never match the same "content" as in the revert target. From there we have two options: 1. The file exists in the target and can be seen as "modified". 2. The file does not exist in the target and can be seen as "added". So now we just dispatch elements from delete into appropriate categories.

File last commit:

r22176:328efb5c stable
r22185:afead12e default
Show More
commands.py
6060 lines | 218.4 KiB | text/x-python | PythonLexer
mpm@selenic.com
import and startup cleanups...
r249 # commands.py - command processing for mercurial
#
Thomas Arendsen Hein
Updated copyright notices and add "and others" to "hg version"
r4635 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
mpm@selenic.com
import and startup cleanups...
r249 #
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
mpm@selenic.com
import and startup cleanups...
r249
Peter Arrenbrecht
wireproto: add known([id]) function...
r13723 from node import hex, bin, nullid, nullrev, short
Ronny Pfannschmidt
switch lock releasing in the core from gc to explicit
r8109 from lock import release
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 from i18n import _
Alexandre Garnier
debuginstall: handle quoted path for editor (issue4316)...
r21957 import os, re, difflib, time, tempfile, errno, shlex
Chris Jerdonek
debuginstall: add Python information to debuginstall output (issue4128)...
r20740 import sys
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 import hg, scmutil, util, revlog, copies, error, bookmarks
Siddharth Agarwal
url: use open and not url.open for local files (issue3624)
r17887 import patch, help, encoding, templatekw, discovery
Idan Kamara
serve: add --cmdserver option to communicate with hg over a pipe
r14647 import archival, changegroup, cmdutil, hbisect
Augie Fackler
commands: import hgweb.server in a way that 2to3 can rewrite
r19757 import sshserver, hgweb, commandserver
anatoly techtonik
version: show enabled extensions (issue4209)...
r21848 import extensions
Augie Fackler
commands: import hgweb.server in a way that 2to3 can rewrite
r19757 from hgweb import server as hgweb_server
Martin Geisler
commands: partial backout of fbb68b382040
r15856 import merge as mergemod
Matt Mackall
filesets: introduce basic fileset expression parser
r14511 import minirst, revset, fileset
Patrick Mezard
incoming/outgoing: handle --graph in core
r17182 import dagparser, context, simplemerge, graphmod
Augie Fackler
cleanup: move stdlib imports to their own import statement...
r20034 import random
import setdiscovery, treediscovery, dagutil, pvec, localrepo
Pierre-Yves David
bundle2: move `readbundle` into the `exchange` module...
r21063 import phases, obsolete, exchange
Matt Mackall
Kill ui.setconfig_remoteopts...
r2731
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 table = {}
command = cmdutil.command(table)
Gregory Szorc
commands: define norepo in command decorator
r21768 # Space delimited list of commands that don't require local repositories.
# This should be populated by passing norepo=True into the @command decorator.
norepo = ''
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 # Space delimited list of commands that optionally require local repositories.
# This should be populated by passing optionalrepo=True into the @command
# decorator.
optionalrepo = ''
Gregory Szorc
commands: define inferrepo in command decorator
r21778 # Space delimited list of commands that will examine arguments looking for
# a repository. This should be populated by passing inferrepo=True into the
# @command decorator.
inferrepo = ''
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 # common command options
globalopts = [
('R', 'repository', '',
_('repository root directory or name of overlay bundle file'),
_('REPO')),
('', 'cwd', '',
_('change working directory'), _('DIR')),
('y', 'noninteractive', None,
Martin Geisler
commands: improve help for -y/--noninteractive...
r14849 _('do not prompt, automatically pick the first choice for all prompts')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('q', 'quiet', None, _('suppress output')),
('v', 'verbose', None, _('enable additional output')),
('', 'config', [],
_('set/override config option (use \'section.name=value\')'),
_('CONFIG')),
('', 'debug', None, _('enable debugging output')),
('', 'debugger', None, _('start debugger')),
('', 'encoding', encoding.encoding, _('set the charset encoding'),
_('ENCODE')),
('', 'encodingmode', encoding.encodingmode,
_('set the charset encoding mode'), _('MODE')),
('', 'traceback', None, _('always print a traceback on exception')),
('', 'time', None, _('time how long the command takes')),
('', 'profile', None, _('print command execution profile')),
('', 'version', None, _('output version information and exit')),
('h', 'help', None, _('display help and exit')),
Pierre-Yves David
clfilter: enforce hidden changeset globally...
r18267 ('', 'hidden', False, _('consider hidden changesets')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ]
dryrunopts = [('n', 'dry-run', None,
_('do not perform actions, just print output'))]
remoteopts = [
('e', 'ssh', '',
_('specify ssh command to use'), _('CMD')),
('', 'remotecmd', '',
_('specify hg command to run on the remote side'), _('CMD')),
('', 'insecure', None,
_('do not verify server certificate (ignoring web.cacerts config)')),
]
walkopts = [
('I', 'include', [],
_('include names matching the given patterns'), _('PATTERN')),
('X', 'exclude', [],
_('exclude names matching the given patterns'), _('PATTERN')),
]
commitopts = [
('m', 'message', '',
_('use text as commit message'), _('TEXT')),
('l', 'logfile', '',
_('read commit message from file'), _('FILE')),
]
commitopts2 = [
('d', 'date', '',
_('record the specified date as commit date'), _('DATE')),
('u', 'user', '',
_('record the specified user as committer'), _('USER')),
]
templateopts = [
('', 'style', '',
Matt Mackall
templater: deprecate --style now that -T exists
r20669 _('display using template map file (DEPRECATED)'), _('STYLE')),
Matt Mackall
commands: add -T alternative to --template
r20665 ('T', 'template', '',
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 _('display with template'), _('TEMPLATE')),
]
logopts = [
('p', 'patch', None, _('show patch')),
('g', 'git', None, _('use git extended diff format')),
('l', 'limit', '',
_('limit number of changes displayed'), _('NUM')),
('M', 'no-merges', None, _('do not show merges')),
('', 'stat', None, _('output diffstat-style summary of changes')),
Patrick Mezard
incoming/outgoing: handle --graph in core
r17182 ('G', 'graph', None, _("show the revision DAG")),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ] + templateopts
diffopts = [
('a', 'text', None, _('treat all files as text')),
('g', 'git', None, _('use git extended diff format')),
('', 'nodates', None, _('omit dates from diff headers'))
]
Patrick Mezard
annotate: support diff whitespace filtering flags (issue3030)...
r15528 diffwsopts = [
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('w', 'ignore-all-space', None,
_('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')),
Patrick Mezard
annotate: support diff whitespace filtering flags (issue3030)...
r15528 ]
diffopts2 = [
('p', 'show-function', None, _('show which function each change is in')),
('', 'reverse', None, _('produce a diff that undoes the changes')),
] + diffwsopts + [
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('U', 'unified', '',
_('number of lines of context to show'), _('NUM')),
('', 'stat', None, _('output diffstat-style summary of changes')),
]
Martin Geisler
commands: use mergetoolopts when a command supports --tool
r14852 mergetoolopts = [
('t', 'tool', '', _('specify merge tool')),
]
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 similarityopts = [
('s', 'similarity', '',
_('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
]
subrepoopts = [
('S', 'subrepos', None,
_('recurse into subrepositories'))
]
Matt Mackall
Kill ui.setconfig_remoteopts...
r2731
mpm@selenic.com
hg help: use docstrings only...
r255 # Commands start here, listed alphabetically
mpm@selenic.com
Beginning of new command parsing interface...
r209
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^add',
walkopts + subrepoopts + dryrunopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... [FILE]...'),
inferrepo=True)
Bryan O'Sullivan
Get add and locate to use new repo and dirstate walk code....
r724 def add(ui, repo, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """add the specified files on the next commit
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 Schedule files to be version controlled and added to the
repository.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Matt Mackall
Add doc notes about revert and hg status vs diff
r3829 The files will be added to the repository at the next commit. To
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 undo an add before that, see :hg:`forget`.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
timeless
help: miscellaneous language fixes
r7807 If no names are given, add all files to the repository.
Martin Geisler
commands: add verbose example to help text for add
r10446
.. container:: verbose
An example showing how new (unknown) files are added
Martin Geisler
Use hg role in help strings
r10973 automatically by :hg:`add`::
Martin Geisler
commands: add verbose example to help text for add
r10446
$ ls
foo.c
$ hg status
? foo.c
$ hg add
adding foo.c
$ hg status
Martin Geisler
commands: correct example in add help text
r10448 A foo.c
Nicolas Dumazet
commands: document return values of add and paths commands
r11507
Returns 0 if all files are successfully added.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(repo[None], pats, opts)
Martin Geisler
add: recurse into subrepositories with --subrepos/-S flag
r12270 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
David M. Carr
add: fix subrepo recursion for explicit path handling...
r15911 opts.get('subrepos'), prefix="", explicitonly=False)
Martin Geisler
add: move main part to cmdutil to make it easier to reuse
r12269 return rejected and 1 or 0
mpm@selenic.com
commands: migrate status and branch...
r213
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('addremove',
similarityopts + walkopts + dryrunopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... [FILE]...'),
inferrepo=True)
Bryan O'Sullivan
Get addremove to use new walk code....
r766 def addremove(ui, repo, *pats, **opts):
Thomas Arendsen Hein
Documentation fixes for addremove....
r3181 """add all new files, delete all missing files
Vadim Gelfer
deprecate addremove command.
r2181
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 Add all new files and remove all missing files from the
repository.
New files are ignored if they match any of the patterns in
Javi Merino
doc: Add back quotes around filenames...
r13344 ``.hgignore``. As with add, these changes take effect at the next
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 commit.
Vadim Gelfer
addremove: add -s/--similarity option...
r2958
Patrick Mezard
addremove: mention --similarity defaults to 100 (issue3430)
r17266 Use the -s/--similarity option to detect renamed files. This
Martin Geisler
commands: wrap docstrings at 70 characters...
r9249 option takes a percentage between 0 (disabled) and 100 (files must
Patrick Mezard
addremove: mention --similarity defaults to 100 (issue3430)
r17266 be identical) as its parameter. With a parameter greater than 0,
this compares every removed file with every added file and records
those similar enough as renames. Detecting renamed files this way
Arnab Bose
commands: mention "hg status -C" in addremove help
r11518 can be expensive. After using this option, :hg:`status -C` can be
Patrick Mezard
addremove: mention --similarity defaults to 100 (issue3430)
r17266 used to check which files were identified as moved or renamed. If
not specified, -s/--similarity defaults to 100 and only renames of
identical files are detected.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 if all files are successfully added.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Bryan O'Sullivan
addremove: print meaningful error message if --similar not numeric
r4966 try:
Dirkjan Ochtman
commands: addremove does similarity 100 by default
r11551 sim = float(opts.get('similarity') or 100)
Bryan O'Sullivan
addremove: print meaningful error message if --similar not numeric
r4966 except ValueError:
raise util.Abort(_('similarity must be a number'))
Vadim Gelfer
addremove: add -s/--similarity option...
r2958 if sim < 0 or sim > 100:
raise util.Abort(_('similarity must be between 0 and 100'))
Matt Mackall
scmutil: drop some aliases in cmdutil
r14321 return scmutil.addremove(repo, pats, opts, similarity=sim / 100.0)
mpm@selenic.com
hg checkout: refuse to checkout if there are outstanding changes...
r219
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^annotate|blame',
[('r', 'rev', '', _('annotate the specified revision'), _('REV')),
('', 'follow', None,
_('follow copies/renames and list the filename (DEPRECATED)')),
('', 'no-follow', None, _("don't follow copies and renames")),
('a', 'text', None, _('treat all files as text')),
('u', 'user', None, _('list the author (long with -v)')),
('f', 'file', None, _('list the filename')),
('d', 'date', None, _('list the date (short with -q)')),
('n', 'number', None, _('list the revision number (default)')),
('c', 'changeset', None, _('list the changeset')),
('l', 'line-number', None, _('show line number at the first appearance'))
Patrick Mezard
annotate: support diff whitespace filtering flags (issue3030)...
r15528 ] + diffwsopts + walkopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
inferrepo=True)
Bryan O'Sullivan
Convert annotate over to walk interface....
r733 def annotate(ui, repo, *pats, **opts):
timeless
Improve English for help text of many core hg commands....
r8779 """show changeset information by line for each file
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 List changes in files, showing the revision id responsible for
each line
timeless
Improve English for help text of many core hg commands....
r8779 This command is useful for discovering when a change was made and
by whom.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 Without the -a/--text option, annotate will avoid processing files
timeless
Improve English for help text of many core hg commands....
r8779 it detects as binary. With -a, annotate will annotate the file
anyway, although the results will probably be neither useful
nor desirable.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Thomas Arendsen Hein
Make annotate --follow an alias for -f/--file to behave like in older versions...
r10579 if opts.get('follow'):
# --follow is deprecated and now just an alias for -f/--file
# to mimic the behavior of Mercurial before version 1.5
Martin Geisler
annotate: use real Booleans instead of 0/1
r14216 opts['file'] = True
Thomas Arendsen Hein
Make annotate --follow an alias for -f/--file to behave like in older versions...
r10579
Thomas Arendsen Hein
Make annotae/grep print short dates with -q/--quiet....
r6134 datefunc = ui.quiet and util.shortdate or util.datestr
getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
lupus@debian.org
Added --date option to annotate.
r1522
mpm@selenic.com
Handle empty file list for annotate
r744 if not pats:
timeless
Generally replace "file name" with "filename" in help and comments.
r8761 raise util.Abort(_('at least one filename or pattern is required'))
mpm@selenic.com
Handle empty file list for annotate
r744
Ion Savin
annotate: show full changeset hash when invoked with --debug and -c
r15631 hexfn = ui.debugflag and hex or short
Thomas Arendsen Hein
annotate: fix alignment of columns in front of line numbers (issue2807)
r14358 opmap = [('user', ' ', lambda x: ui.shortuser(x[0].user())),
('number', ' ', lambda x: str(x[0].rev())),
Ion Savin
annotate: show full changeset hash when invoked with --debug and -c
r15631 ('changeset', ' ', lambda x: hexfn(x[0].node())),
Thomas Arendsen Hein
annotate: fix alignment of columns in front of line numbers (issue2807)
r14358 ('date', ' ', getdate),
('file', ' ', lambda x: x[0].path()),
('line_number', ':', lambda x: str(x[1])),
Thomas Arendsen Hein
Add --line-number option to hg annotate (issue506)...
r4857 ]
Matt Mackall
many, many trivial check-code fixups
r10282 if (not opts.get('user') and not opts.get('changeset')
Dirkjan Ochtman
commands: annotate follows by default, separate -f/--file option
r10369 and not opts.get('date') and not opts.get('file')):
Martin Geisler
annotate: use real Booleans instead of 0/1
r14216 opts['number'] = True
mpm@selenic.com
Beginning of new command parsing interface...
r209
Thomas Arendsen Hein
Add --line-number option to hg annotate (issue506)...
r4857 linenumber = opts.get('line_number') is not None
Benoit Boissinot
fix coding style (reported by pylint)
r10394 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
Thomas Arendsen Hein
Add --line-number option to hg annotate (issue506)...
r4857 raise util.Abort(_('at least one of -n/-c is required for -l'))
Thomas Arendsen Hein
annotate: fix alignment of columns in front of line numbers (issue2807)
r14358 funcmap = [(func, sep) for op, sep, func in opmap if opts.get(op)]
funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
Thomas Arendsen Hein
Add --line-number option to hg annotate (issue506)...
r4857
Matt Mackall
annotate: catch nonexistent files using match.bad callback (issue1590)
r13697 def bad(x, y):
raise util.Abort("%s: %s" % (x, y))
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 ctx = scmutil.revsingle(repo, opts.get('rev'))
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(ctx, pats, opts)
Matt Mackall
annotate: catch nonexistent files using match.bad callback (issue1590)
r13697 m.bad = bad
Dirkjan Ochtman
commands: annotate follows by default, separate -f/--file option
r10369 follow = not opts.get('no_follow')
Patrick Mezard
annotate: support diff whitespace filtering flags (issue3030)...
r15528 diffopts = patch.diffopts(ui, opts, section='annotate')
Matt Mackall
context: add walk method
r6764 for abs in ctx.walk(m):
fctx = ctx[abs]
Alexander Solovyov
commands: optional options where possible...
r7131 if not opts.get('text') and util.binary(fctx.data()):
Matt Mackall
walk: remove rel and exact returns
r6584 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
mpm@selenic.com
Teach annotate about binary files
r1016 continue
Patrick Mezard
annotate: support diff whitespace filtering flags (issue3030)...
r15528 lines = fctx.annotate(follow=follow, linenumber=linenumber,
diffopts=diffopts)
mpm@selenic.com
Beginning of new command parsing interface...
r209 pieces = []
Thomas Arendsen Hein
annotate: fix alignment of columns in front of line numbers (issue2807)
r14358 for f, sep in funcmap:
Thomas Arendsen Hein
Add --line-number option to hg annotate (issue506)...
r4857 l = [f(n) for n, dummy in lines]
if l:
FUJIWARA Katsunori
i18n: use encoding.colwidth() for correct column width...
r11611 sized = [(x, encoding.colwidth(x)) for x in l]
ml = max([w for x, w in sized])
Thomas Arendsen Hein
annotate: fix alignment of columns in front of line numbers (issue2807)
r14358 pieces.append(["%s%s%s" % (sep, ' ' * (ml - w), x)
for x, w in sized])
mpm@selenic.com
Beginning of new command parsing interface...
r209
mpm@selenic.com
Fixes for annotate...
r771 if pieces:
for p, l in zip(zip(*pieces), lines):
Thomas Arendsen Hein
annotate: fix alignment of columns in front of line numbers (issue2807)
r14358 ui.write("%s: %s" % ("".join(p), l[1]))
mpm@selenic.com
Beginning of new command parsing interface...
r209
Ion Savin
annotate: append newline after non newline-terminated file listings...
r15829 if lines and not lines[-1][1].endswith('\n'):
ui.write('\n')
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('archive',
[('', 'no-decode', None, _('do not pass files through decoders')),
('p', 'prefix', '', _('directory prefix for files in archive'),
_('PREFIX')),
('r', 'rev', '', _('revision to distribute'), _('REV')),
('t', 'type', '', _('type of distribution to create'), _('TYPE')),
] + subrepoopts + walkopts,
_('[OPTION]... DEST'))
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112 def archive(ui, repo, dest, **opts):
timeless
Improve English for help text of many core hg commands....
r8779 '''create an unversioned archive of a repository revision
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112
By default, the revision used is the parent of the working
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 directory; use -r/--rev to specify a different revision.
David Wolever
archive: autodetect archive type by extension (issue2058)
r10650 The archive type is automatically detected based on file
extension (or override using -t/--type).
Matt Mackall
archive: add help examples
r15109 .. container:: verbose
Examples:
- create a zip file containing the 1.0 release::
hg archive -r 1.0 project-1.0.zip
- create a tarball excluding .hg files::
hg archive project.tar.gz -X ".hg*"
David Wolever
archive: autodetect archive type by extension (issue2058)
r10650 Valid types are:
Martin Geisler
commands: use field lists instead of literal blocks in docstrings...
r9892
:``files``: a directory full of files (default)
:``tar``: tar archive, uncompressed
:``tbz2``: tar archive, compressed using bzip2
:``tgz``: tar archive, compressed using gzip
:``uzip``: zip archive, uncompressed
:``zip``: zip archive, compressed using deflate
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112
The exact name of the destination archive or directory is given
Martin Geisler
Use hg role in help strings
r10973 using a format string; see :hg:`help export` for details.
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112
Each member added to an archive file has a directory prefix
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 prepended. Use -p/--prefix to specify a format string for the
prefix. The default is the basename of the archive, with suffixes
removed.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112 '''
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 ctx = scmutil.revsingle(repo, opts.get('rev'))
Brendan Cully
archive: abort on empty repository. Fixes #624.
r5061 if not ctx:
Matt Mackall
archive: fix bogus error message with no working directory
r7528 raise util.Abort(_('no working directory: please specify a revision'))
Brendan Cully
archive: abort on empty repository. Fixes #624.
r5061 node = ctx.node()
Matt Mackall
cmdutil: make_filename -> makefilename
r14290 dest = cmdutil.makefilename(repo, dest, node)
Matt Mackall
backout dbdb777502dc (issue3077) (issue3071)...
r15381 if os.path.realpath(dest) == repo.root:
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112 raise util.Abort(_('repository root cannot be destination'))
David Wolever
archive: autodetect archive type by extension (issue2058)
r10650
Martin Geisler
archival: move commands.archive.guess_type to archival.guesskind...
r11557 kind = opts.get('type') or archival.guesskind(dest) or 'files'
Alexander Solovyov
commands: optional options where possible...
r7131 prefix = opts.get('prefix')
David Wolever
archive: autodetect archive type by extension (issue2058)
r10650
Vadim Gelfer
archive: make "hg archive -t XXX -" to write to stdout
r2476 if dest == '-':
if kind == 'files':
raise util.Abort(_('cannot archive plain files to stdout'))
Idan Kamara
archive: wrap the ui descriptor so it doesn't get closed...
r14742 dest = cmdutil.makefileobj(repo, dest)
Matt Mackall
many, many trivial check-code fixups
r10282 if not prefix:
prefix = os.path.basename(repo.root) + '-%h'
David Wolever
archive: autodetect archive type by extension (issue2058)
r10650
Matt Mackall
cmdutil: make_filename -> makefilename
r14290 prefix = cmdutil.makefilename(repo, prefix, node)
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 matchfn = scmutil.match(ctx, [], opts)
Alexander Solovyov
commands: optional options where possible...
r7131 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
Martin Geisler
subrepo: add support for 'hg archive'
r12323 matchfn, prefix, subrepos=opts.get('subrepos'))
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('backout',
[('', 'merge', None, _('merge with old dirstate parent after backout')),
Matt Mackall
backout: deprecate/hide support for backing out merges...
r15211 ('', 'parent', '',
_('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('r', 'rev', '', _('revision to backout'), _('REV')),
FUJIWARA Katsunori
backout: accept '--edit' like other commands creating new changeset...
r21712 ('e', 'edit', False, _('invoke editor on commit messages')),
Martin Geisler
commands: use mergetoolopts when a command supports --tool
r14852 ] + mergetoolopts + walkopts + commitopts + commitopts2,
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 _('[OPTION]... [-r] REV'))
Daniel Holth
accept -r REV in more places...
r4450 def backout(ui, repo, node=None, rev=None, **opts):
Vadim Gelfer
add backout command....
r2158 '''reverse effect of earlier changeset
Jonathan Nieder
backout: make help more explicit about what backout does...
r13340 Prepare a new changeset with the effect of REV undone in the
current working directory.
Jonathan Nieder
backout: clarify which changesets are new in help text...
r13473 If REV is the parent of the working directory, then this new changeset
Jonathan Nieder
backout: make help more explicit about what backout does...
r13340 is committed automatically. Otherwise, hg needs to merge the
changes and the merged result is left uncommitted.
Matt Mackall
backout: add a note about not working on merges
r15210 .. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Matt Mackall
backout: add a note about not working on merges
r15210 backout cannot be used to fix either an unwanted or
incorrect merge.
Matt Mackall
backout: mark some help verbose
r15209 .. container:: verbose
By default, the pending changeset will have one parent,
maintaining a linear history. With --merge, the pending
changeset will instead have two parents: the old parent of the
working directory and a new child of REV that simply undoes REV.
Before version 1.7, the behavior without --merge was equivalent
to specifying --merge followed by :hg:`update --clean .` to
cancel the merge and leave the child of REV as a head to be
merged separately.
Thomas Arendsen Hein
Document log date ranges and mention 'hg help dates' for all commands (issue998)
r6163
Martin Geisler
Use hg role in help strings
r10973 See :hg:`help dates` for a list of formats valid for -d/--date.
Matt Mackall
commands: initial audit of exit codes...
r11177
Yuya Nishihara
backout: correct commit status of no changes made (BC) (issue4190)...
r20872 Returns 0 on success, 1 if nothing to backout or there are unresolved
files.
Thomas Arendsen Hein
Document log date ranges and mention 'hg help dates' for all commands (issue998)
r6163 '''
Daniel Holth
accept -r REV in more places...
r4450 if rev and node:
raise util.Abort(_("please specify just one revision"))
if not rev:
rev = node
Vadim Gelfer
add backout command....
r2158
Thomas Arendsen Hein
Fix and test 'hg backout' without or with too many revisions.
r4726 if not rev:
raise util.Abort(_("please specify a revision to backout"))
Thomas Arendsen Hein
Fix bad behaviour when specifying an invalid date (issue700)...
r6139 date = opts.get('date')
if date:
opts['date'] = util.parsedate(date)
Matt Mackall
commands: add checks for unfinished operations (issue3955)...
r19476 cmdutil.checkunfinished(repo)
Matt Mackall
cmdutil: bail_if_changed to bailifchanged
r14289 cmdutil.bailifchanged(repo)
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 node = scmutil.revsingle(repo, rev).node()
Matt Mackall
cmdutil: make bail_if_changed bail on uncommitted merge
r5716
Vadim Gelfer
add backout command....
r2158 op1, op2 = repo.dirstate.parents()
Mads Kiilerich
backout: use commonancestorsheads for checking linear heritage...
r21105 if node not in repo.changelog.commonancestorsheads(op1, node):
Mads Kiilerich
backout: improve confusing 'cannot backout change on a different branch' abort...
r20791 raise util.Abort(_('cannot backout change that is not an ancestor'))
Matt Mackall
backout: disallow across branches (issue655)
r5568
Vadim Gelfer
backout: allow backout of merge changeset with --parent option....
r2614 p1, p2 = repo.changelog.parents(node)
if p1 == nullid:
timeless
Improve English for help text of many core hg commands....
r8779 raise util.Abort(_('cannot backout a change with no parents'))
Vadim Gelfer
add backout command....
r2158 if p2 != nullid:
Alexander Solovyov
commands: optional options where possible...
r7131 if not opts.get('parent'):
Matt Mackall
backout: deprecate/hide support for backing out merges...
r15211 raise util.Abort(_('cannot backout a merge changeset'))
Vadim Gelfer
backout: allow backout of merge changeset with --parent option....
r2614 p = repo.lookup(opts['parent'])
if p not in (p1, p2):
Marcos Chaves
fix warnings generated by pygettext.py.
r3679 raise util.Abort(_('%s is not a parent of %s') %
Thomas Arendsen Hein
Indentation cleanups for 2956948b81f3.
r3680 (short(p), short(node)))
Vadim Gelfer
backout: allow backout of merge changeset with --parent option....
r2614 parent = p
else:
Alexander Solovyov
commands: optional options where possible...
r7131 if opts.get('parent'):
Vadim Gelfer
backout: allow backout of merge changeset with --parent option....
r2614 raise util.Abort(_('cannot use --parent on non-merge changeset'))
parent = p1
Matt Mackall
backout: disallow across branches (issue655)
r5568
Matt Mackall
backout: reverse changeset belongs on current branch...
r6423 # the backout should appear on the same branch
Idan Kamara
commands: add missing wlock to backout
r16470 wlock = repo.wlock()
try:
branch = repo.dirstate.branch()
Kevin Bullock
backout: call cmdutil.commit directly instead of commands.commit...
r18689 bheads = repo.branchheads(branch)
Kevin Bullock
backout: use cmdutil.revert directly instead of commands.revert...
r18685 rctx = scmutil.revsingle(repo, hex(parent))
Idan Kamara
commands: add missing wlock to backout
r16470 if not opts.get('merge') and op1 != node:
try:
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
'backout')
Pierre-Yves David
backout: add a message after backout that need manual commit...
r20276 stats = mergemod.update(repo, parent, True, True, False,
node, False)
Pierre-Yves David
backout: avoid update on simple case....
r20275 repo.setparents(op1, op2)
hg._showstats(repo, stats)
if stats[3]:
Pierre-Yves David
backout: add a message after backout that need manual commit...
r20276 repo.ui.status(_("use 'hg resolve' to retry unresolved "
"file merges\n"))
else:
msg = _("changeset %s backed out, "
"don't forget to commit.\n")
ui.status(msg % short(node))
Pierre-Yves David
backout: avoid update on simple case....
r20275 return stats[3] > 0
Idan Kamara
commands: add missing wlock to backout
r16470 finally:
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 ui.setconfig('ui', 'forcemerge', '', '')
Pierre-Yves David
backout: avoid update on simple case....
r20275 else:
hg.clean(repo, node, show_stats=False)
repo.dirstate.setbranch(branch)
cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
Idan Kamara
commands: add missing wlock to backout
r16470
Kevin Bullock
backout: call cmdutil.commit directly instead of commands.commit...
r18689 def commitfunc(ui, repo, message, match, opts):
FUJIWARA Katsunori
backout: pass 'editform' argument to 'cmdutil.getcommiteditor'...
r22007 editform = 'backout'
e = cmdutil.getcommiteditor(editform=editform, **opts)
FUJIWARA Katsunori
backout: avoid redundant message examination...
r21412 if not message:
# we don't translate commit messages
message = "Backed out changeset %s" % short(node)
FUJIWARA Katsunori
backout: pass 'editform' argument to 'cmdutil.getcommiteditor'...
r22007 e = cmdutil.getcommiteditor(edit=True, editform=editform)
Kevin Bullock
backout: call cmdutil.commit directly instead of commands.commit...
r18689 return repo.commit(message, opts.get('user'), opts.get('date'),
match, editor=e)
newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
Yuya Nishihara
backout: correct commit status of no changes made (BC) (issue4190)...
r20872 if not newnode:
ui.status(_("nothing changed\n"))
return 1
Kevin Bullock
backout: call cmdutil.commit directly instead of commands.commit...
r18689 cmdutil.commitstatus(repo, newnode, branch, bheads)
Kevin Bullock
backout: remove unnecessary dict copy...
r18687
Idan Kamara
commands: add missing wlock to backout
r16470 def nice(node):
return '%d:%s' % (repo.changelog.rev(node), short(node))
ui.status(_('changeset %s backs out changeset %s\n') %
(nice(repo.changelog.tip()), nice(node)))
if opts.get('merge') and op1 != node:
hg.clean(repo, op1, show_stats=False)
ui.status(_('merging with changeset %s\n')
% nice(repo.changelog.tip()))
try:
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
'backout')
Idan Kamara
commands: add missing wlock to backout
r16470 return hg.merge(repo, hex(repo.changelog.tip()))
finally:
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 ui.setconfig('ui', 'forcemerge', '', '')
Idan Kamara
commands: add missing wlock to backout
r16470 finally:
wlock.release()
Gilles Moris
backout: provide linear backout as a default (without --merge option)...
r12727 return 0
Vadim Gelfer
add backout command....
r2158
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('bisect',
[('r', 'reset', False, _('reset bisect state')),
('g', 'good', False, _('mark changeset good')),
('b', 'bad', False, _('mark changeset bad')),
('s', 'skip', False, _('skip testing changeset')),
('e', 'extend', False, _('extend the bisect range')),
('c', 'command', '', _('use command to check changeset state'), _('CMD')),
('U', 'noupdate', False, _('do not update to target'))],
_("[-gbsr] [-U] [-c CMD] [REV]"))
Alexander Solovyov
bisect: ability to check revision with command
r7227 def bisect(ui, repo, rev=None, extra=None, command=None,
Benoit Boissinot
bisect: new command to extend the bisect range (issue2690)...
r13601 reset=None, good=None, bad=None, skip=None, extend=None,
noupdate=None):
Matt Mackall
bisect: make bisect a built-in command
r5775 """subdivision search of changesets
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 This command helps to find changesets which introduce problems. To
use, mark the earliest changeset you know exhibits the problem as
bad, then mark the latest changeset which is free from the problem
as good. Bisect will update your working directory to a revision
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 for testing (unless the -U/--noupdate option is specified). Once
timeless
Improve English for help text of many core hg commands....
r8779 you have performed tests, mark the working directory as good or
bad, and bisect will either update to another candidate changeset
Dirkjan Ochtman
bisect: expand help text to explain REV argument and --noupdate
r6928 or announce that it has found the bad revision.
Dirkjan Ochtman
clean up trailing spaces
r7184
Dirkjan Ochtman
bisect: expand help text to explain REV argument and --noupdate
r6928 As a shortcut, you can also use the revision argument to mark a
revision as good or bad without checking it out first.
Alexander Solovyov
bisect: ability to check revision with command
r7227
timeless
Improve English for help text of many core hg commands....
r8779 If you supply a command, it will be used for automatic bisection.
Bryan O'Sullivan
bisect: set HG_NODE when runing a command...
r16648 The environment variable HG_NODE will contain the ID of the
changeset being tested. The exit status of the command will be
used to mark revisions as good or bad: status 0 means good, 125
means to skip the revision, 127 (command not found) will abort the
bisection, and any other non-zero exit status means the revision
is bad.
Matt Mackall
commands: initial audit of exit codes...
r11177
"Yann E. MORIN"
bisect: add some bisection examples, and some log revset.bisect() examples...
r15139 .. container:: verbose
Some examples:
Santiago Pay=C3=A0 i Miralta
help: fix backwards bisect help example
r20151 - start a bisection with known bad revision 34, and good revision 12::
"Yann E. MORIN"
bisect: add some bisection examples, and some log revset.bisect() examples...
r15139
hg bisect --bad 34
hg bisect --good 12
- advance the current bisection by marking current revision as good or
bad::
hg bisect --good
hg bisect --bad
Mads Kiilerich
fix trivial spelling errors
r17424 - mark the current revision, or a known revision, to be skipped (e.g. if
"Yann E. MORIN"
bisect: add some bisection examples, and some log revset.bisect() examples...
r15139 that revision is not usable because of another issue)::
hg bisect --skip
hg bisect --skip 23
FUJIWARA Katsunori
doc: end line preceding command line example with double colon
r19958 - skip all revisions that do not touch directories ``foo`` or ``bar``::
Jordi Gutiérrez Hermoso
bisect: add example for limiting bisection to specified directories...
r17969
FUJIWARA Katsunori
doc: use double quotation mark to quote arguments in examples for Windows users...
r19959 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
Jordi Gutiérrez Hermoso
bisect: add example for limiting bisection to specified directories...
r17969
"Yann E. MORIN"
bisect: add some bisection examples, and some log revset.bisect() examples...
r15139 - forget the current bisection::
hg bisect --reset
- use 'make && make tests' to automatically find the first broken
revision::
hg bisect --reset
hg bisect --bad 34
hg bisect --good 12
FUJIWARA Katsunori
doc: use double quotation mark to quote arguments in examples for Windows users...
r19959 hg bisect --command "make && make tests"
"Yann E. MORIN"
bisect: add some bisection examples, and some log revset.bisect() examples...
r15139
- see all changesets whose states are already known in the current
bisection::
hg log -r "bisect(pruned)"
Bryan O'Sullivan
bisect: track the current changeset (issue3382)...
r16647 - see the changeset currently being bisected (especially useful
if running with -U/--noupdate)::
hg log -r "bisect(current)"
"Yann E. MORIN"
bisect: add some bisection examples, and some log revset.bisect() examples...
r15139 - see all changesets that took part in the current bisection::
hg log -r "bisect(range)"
Martin Geisler
bisect: don't mention obsolete graphlog extension in help
r20146 - you can even get a nice graph::
"Yann E. MORIN"
bisect: add some bisection examples, and some log revset.bisect() examples...
r15139
hg log --graph -r "bisect(range)"
"Yann E. MORIN"
revset.bisect: add 'ignored' set to the bisect keyword...
r15147 See :hg:`help revsets` for more about the `bisect()` keyword.
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Matt Mackall
bisect: make bisect a built-in command
r5775 """
Benoit Boissinot
bisect: new command to extend the bisect range (issue2690)...
r13601 def extendbisectrange(nodes, good):
# bisect is incomplete when it ends on a merge node and
# one of the parent was not checked.
parents = repo[nodes[0]].parents()
if len(parents) > 1:
side = good and state['bad'] or state['good']
num = len(set(i.node() for i in parents) & set(side))
if num == 1:
Yuya Nishihara
bisect: fix indent level
r14157 return parents[0].ancestor(parents[1])
Benoit Boissinot
bisect: new command to extend the bisect range (issue2690)...
r13601 return None
Alexander Solovyov
bisect: ability to check revision with command
r7227 def print_result(nodes, good):
Matt Mackall
bisect: make bisect a built-in command
r5775 displayer = cmdutil.show_changeset(ui, repo, {})
Bernhard Leiner
Add support for multiple possible bisect results (issue1228, issue1182)...
r6858 if len(nodes) == 1:
# narrowed it down to a single revision
Wagner Bruna
commands, i18n: avoid untranslated strings as message parameters
r8088 if good:
ui.write(_("The first good revision is:\n"))
else:
ui.write(_("The first bad revision is:\n"))
Dirkjan Ochtman
cmdutil: use change contexts for cset-printer and cset-templater
r7369 displayer.show(repo[nodes[0]])
Benoit Boissinot
bisect: new command to extend the bisect range (issue2690)...
r13601 extendnode = extendbisectrange(nodes, good)
if extendnode is not None:
ui.write(_('Not all ancestors of this changeset have been'
' checked.\nUse bisect --extend to continue the '
'bisection from\nthe common ancestor, %s.\n')
Alexander Solovyov
drop {short,hex}(ctx.node()) calls in favor of ctx methods
r14055 % extendnode)
Bernhard Leiner
Add support for multiple possible bisect results (issue1228, issue1182)...
r6858 else:
# multiple possible revisions
Wagner Bruna
commands, i18n: avoid untranslated strings as message parameters
r8088 if good:
ui.write(_("Due to skipped revisions, the first "
"good revision could be any of:\n"))
else:
ui.write(_("Due to skipped revisions, the first "
"bad revision could be any of:\n"))
Bernhard Leiner
Add support for multiple possible bisect results (issue1228, issue1182)...
r6858 for n in nodes:
Dirkjan Ochtman
cmdutil: use change contexts for cset-printer and cset-templater
r7369 displayer.show(repo[n])
Robert Bachmann
Added support for templatevar "footer" to cmdutil.py
r10152 displayer.close()
Alexander Solovyov
bisect: ability to check revision with command
r7227
def check_state(state, interactive=True):
if not state['good'] or not state['bad']:
if (good or bad or skip or reset) and interactive:
return
if not state['good']:
raise util.Abort(_('cannot bisect (no known good revisions)'))
else:
raise util.Abort(_('cannot bisect (no known bad revisions)'))
return True
# backward compatibility
if rev in "good bad reset init".split():
ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
cmd, rev, extra = rev, extra, None
if cmd == "good":
good = True
elif cmd == "bad":
bad = True
else:
reset = True
Benoit Boissinot
bisect: new command to extend the bisect range (issue2690)...
r13601 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
Alexander Solovyov
bisect: ability to check revision with command
r7227 raise util.Abort(_('incompatible arguments'))
Matt Mackall
commands: add checks for unfinished operations (issue3955)...
r19476 cmdutil.checkunfinished(repo)
Alexander Solovyov
bisect: ability to check revision with command
r7227 if reset:
p = repo.join("bisect.state")
if os.path.exists(p):
os.unlink(p)
return
state = hbisect.load_state(repo)
if command:
changesets = 1
Mads Kiilerich
bisect: --command without --noupdate should flag the parent rev it tested...
r20237 if noupdate:
try:
node = state['current'][0]
except LookupError:
Bryan O'Sullivan
bisect: track the current changeset (issue3382)...
r16647 raise util.Abort(_('current bisect revision is unknown - '
'start a new bisect to fix'))
Mads Kiilerich
bisect: --command without --noupdate should flag the parent rev it tested...
r20237 else:
Bryan O'Sullivan
bisect: track the current changeset (issue3382)...
r16647 node, p2 = repo.dirstate.parents()
if p2 != nullid:
raise util.Abort(_('current bisect revision is a merge'))
try:
Benoit Boissinot
bisect: improve hg bisect -c (relative paths, error handling)...
r7590 while changesets:
# update state
Bryan O'Sullivan
bisect: track the current changeset (issue3382)...
r16647 state['current'] = [node]
Bryan O'Sullivan
bisect: save current state before running a command...
r16593 hbisect.save_state(repo, state)
Bryan O'Sullivan
bisect: set HG_NODE when runing a command...
r16648 status = util.system(command,
environ={'HG_NODE': hex(node)},
out=ui.fout)
Benoit Boissinot
bisect: improve hg bisect -c (relative paths, error handling)...
r7590 if status == 125:
transition = "skip"
elif status == 0:
transition = "good"
# status < 0 means process was killed
elif status == 127:
raise util.Abort(_("failed to execute %s") % command)
elif status < 0:
raise util.Abort(_("%s killed") % command)
else:
transition = "bad"
Bryan O'Sullivan
bisect: track the current changeset (issue3382)...
r16647 ctx = scmutil.revsingle(repo, rev, node)
Matt Mackall
commands: add revset support to most commands
r12925 rev = None # clear for future iterations
Patrick Mezard
bisect: improve --command output...
r8805 state[transition].append(ctx.node())
Martin Geisler
bisect: lowercase status message
r16936 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
Benoit Boissinot
bisect: improve hg bisect -c (relative paths, error handling)...
r7590 check_state(state, interactive=False)
# bisect
Mads Kiilerich
bisect: avoid confusing use of variables with same names in nested local scopes
r20052 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
Benoit Boissinot
bisect: improve hg bisect -c (relative paths, error handling)...
r7590 # update to next check
Bryan O'Sullivan
bisect: track the current changeset (issue3382)...
r16647 node = nodes[0]
if not noupdate:
cmdutil.bailifchanged(repo)
hg.clean(repo, node, show_stats=False)
Benoit Boissinot
bisect: improve hg bisect -c (relative paths, error handling)...
r7590 finally:
Bryan O'Sullivan
bisect: track the current changeset (issue3382)...
r16647 state['current'] = [node]
Benoit Boissinot
bisect: improve hg bisect -c (relative paths, error handling)...
r7590 hbisect.save_state(repo, state)
Mads Kiilerich
bisect: avoid confusing use of variables with same names in nested local scopes
r20052 print_result(nodes, bgood)
Matt Mackall
commands: initial audit of exit codes...
r11177 return
Alexander Solovyov
bisect: ability to check revision with command
r7227
# update state
Dirkjan Ochtman
bisect: allow revsets in addition to single revs (issue2360)
r12177
if rev:
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
Dirkjan Ochtman
bisect: allow revsets in addition to single revs (issue2360)
r12177 else:
nodes = [repo.lookup('.')]
Benoit Boissinot
bisect: no need to save the state if it wasn't changed
r9689 if good or bad or skip:
if good:
Dirkjan Ochtman
bisect: allow revsets in addition to single revs (issue2360)
r12177 state['good'] += nodes
Benoit Boissinot
bisect: no need to save the state if it wasn't changed
r9689 elif bad:
Dirkjan Ochtman
bisect: allow revsets in addition to single revs (issue2360)
r12177 state['bad'] += nodes
Benoit Boissinot
bisect: no need to save the state if it wasn't changed
r9689 elif skip:
Dirkjan Ochtman
bisect: allow revsets in addition to single revs (issue2360)
r12177 state['skip'] += nodes
Benoit Boissinot
bisect: no need to save the state if it wasn't changed
r9689 hbisect.save_state(repo, state)
Alexander Solovyov
bisect: ability to check revision with command
r7227
if not check_state(state):
return
# actually bisect
nodes, changesets, good = hbisect.bisect(repo.changelog, state)
Benoit Boissinot
bisect: new command to extend the bisect range (issue2690)...
r13601 if extend:
if not changesets:
extendnode = extendbisectrange(nodes, good)
if extendnode is not None:
FUJIWARA Katsunori
i18n: fix "% inside _()" problems...
r20868 ui.write(_("Extending search to changeset %d:%s\n")
% (extendnode.rev(), extendnode))
Bryan O'Sullivan
bisect: track the current changeset (issue3382)...
r16647 state['current'] = [extendnode.node()]
hbisect.save_state(repo, state)
Benoit Boissinot
bisect: new command to extend the bisect range (issue2690)...
r13601 if noupdate:
return
Matt Mackall
cmdutil: bail_if_changed to bailifchanged
r14289 cmdutil.bailifchanged(repo)
Benoit Boissinot
bisect: new command to extend the bisect range (issue2690)...
r13601 return hg.clean(repo, extendnode.node())
raise util.Abort(_("nothing to extend"))
Alexander Solovyov
bisect: ability to check revision with command
r7227 if changesets == 0:
print_result(nodes, good)
Bernhard Leiner
Add support for multiple possible bisect results (issue1228, issue1182)...
r6858 else:
assert len(nodes) == 1 # only a single node can be tested next
node = nodes[0]
Matt Mackall
bisect: make bisect a built-in command
r5775 # compute the approximate number of remaining tests
tests, size = 0, 2
while size <= changesets:
tests, size = tests + 1, size * 2
rev = repo.changelog.rev(node)
Cédric Duval
bisect: fix format specifiers for integers
r9012 ui.write(_("Testing changeset %d:%s "
"(%d changesets remaining, ~%d tests)\n")
Joel Rosdahl
Avoid importing mercurial.node/mercurial.repo stuff from mercurial.hg
r6217 % (rev, short(node), changesets, tests))
Bryan O'Sullivan
bisect: track the current changeset (issue3382)...
r16647 state['current'] = [node]
hbisect.save_state(repo, state)
Matt Mackall
bisect: make bisect a built-in command
r5775 if not noupdate:
Matt Mackall
cmdutil: bail_if_changed to bailifchanged
r14289 cmdutil.bailifchanged(repo)
Matt Mackall
bisect: make bisect a built-in command
r5775 return hg.clean(repo, node)
Kevin Bullock
commands: 'hg bookmark NAME' should work even with ui.strict=True...
r18075 @command('bookmarks|bookmark',
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 [('f', 'force', False, _('force')),
('r', 'rev', '', _('revision'), _('REV')),
('d', 'delete', False, _('delete a given bookmark')),
('m', 'rename', '', _('rename a given bookmark'), _('NAME')),
Matt Mackall
bookmarks: correct correction of -i
r15959 ('i', 'inactive', False, _('mark a bookmark inactive'))],
Kevin Bullock
bookmarks: allow bookmark command to take multiple arguments...
r19147 _('hg bookmarks [OPTIONS]... [NAME]...'))
def bookmark(ui, repo, *names, **opts):
Matt Mackall
bookmarks: improve the bookmark help (issue4244)
r21762 '''create a new bookmark or list existing bookmarks
Bookmarks are labels on changesets to help track lines of development.
Bookmarks are unversioned and can be moved, renamed and deleted.
Deleting or moving a bookmark has no effect on the associated changesets.
Creating or updating to a bookmark causes it to be marked as 'active'.
Active bookmarks are indicated with a '*'.
When a commit is made, an active bookmark will advance to the new commit.
A plain :hg:`update` will also advance an active bookmark, if possible.
Updating away from a bookmark will cause it to be deactivated.
Bookmarks can be pushed and pulled between repositories (see
:hg:`help push` and :hg:`help pull`). If a shared bookmark has
diverged, a new 'divergent bookmark' of the form 'name@path' will
be created. Using :hg:'merge' will resolve the divergence.
A bookmark named '@' has the special property that :hg:`clone` will
check it out by default if it exists.
.. container:: verbose
Examples:
- create an active bookmark for a new line of development::
hg book new-feature
- create an inactive bookmark as a place marker::
hg book -i reviewed
- create an inactive bookmark on another changeset::
hg book -r .^ tested
- move the '@' bookmark from another branch::
hg book -f @
Matt Mackall
bookmarks: move push/pull command features to core
r13368 '''
Kevin Bullock
bookmarks: allow bookmark command to take multiple arguments...
r19147 force = opts.get('force')
rev = opts.get('rev')
delete = opts.get('delete')
rename = opts.get('rename')
inactive = opts.get('inactive')
David Soria Parra
bookmarks: check bookmark format during rename (issue3662)
r17789 def checkformat(mark):
mark = mark.strip()
if not mark:
raise util.Abort(_("bookmark names cannot consist entirely of "
"whitespace"))
Kevin Bullock
scmutil: add bad character checking to checknewlabel...
r17821 scmutil.checknewlabel(repo, mark, 'bookmark')
David Soria Parra
bookmarks: check bookmark format during rename (issue3662)
r17789 return mark
Siddharth Agarwal
commands.bookmarks: pass cur in explicitly to checkconflict...
r20233 def checkconflict(repo, mark, cur, force=False, target=None):
David Soria Parra
bookmarks: check bookmark format during rename (issue3662)
r17789 if mark in marks and not force:
Kevin Bullock
bookmarks: allow moving a bookmark forward to a descendant...
r18773 if target:
Kevin Bullock
bookmarks: allow (re-)activating a bookmark on the current changeset...
r18781 if marks[mark] == target and target == cur:
# re-activating a bookmark
return
Kevin Bullock
bookmarks: allow moving a bookmark forward to a descendant...
r18773 anc = repo.changelog.ancestors([repo[target].rev()])
bmctx = repo[marks[mark]]
Sean Farley
bookmarks: resolve divergent bookmarks when fowarding bookmark to descendant...
r19109 divs = [repo[b].node() for b in marks
if b.split('@', 1)[0] == mark.split('@', 1)[0]]
Sean Farley
bookmarks: resolve divergent bookmark when moving across a branch...
r19111
# allow resolving a single divergent bookmark even if moving
# the bookmark across branches when a revision is specified
# that contains a divergent bookmark
if bmctx.rev() not in anc and target in divs:
bookmarks.deletedivergent(repo, [target], mark)
return
Sean Farley
bookmarks: resolve divergent bookmarks when fowarding bookmark to descendant...
r19109 deletefrom = [b for b in divs
if repo[b].rev() in anc or b == target]
bookmarks.deletedivergent(repo, deletefrom, mark)
Sean Farley
commands: use bookmarks.validdest instead of duplicating logic...
r20282 if bookmarks.validdest(repo, bmctx, repo[target]):
Kevin Bullock
bookmarks: allow moving a bookmark forward to a descendant...
r18773 ui.status(_("moving bookmark '%s' forward from %s\n") %
(mark, short(bmctx.node())))
return
David Soria Parra
bookmarks: check bookmark format during rename (issue3662)
r17789 raise util.Abort(_("bookmark '%s' already exists "
"(use -f to force)") % mark)
if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
and not force):
raise util.Abort(
_("a bookmark cannot have the name of an existing branch"))
David Soria Parra
bookmarks: abort when incompatible options are used (issue3663)...
r17790 if delete and rename:
raise util.Abort(_("--delete and --rename are incompatible"))
if delete and rev:
raise util.Abort(_("--rev is incompatible with --delete"))
if rename and rev:
raise util.Abort(_("--rev is incompatible with --rename"))
Kevin Bullock
bookmarks: allow bookmark command to take multiple arguments...
r19147 if not names and (delete or rev):
Kevin Bullock
bookmarks: simplify code...
r17791 raise util.Abort(_("bookmark name required"))
David Soria Parra
bookmarks: abort when incompatible options are used (issue3663)...
r17790
Siddharth Agarwal
commands.bookmarks: hold wlock for write operations...
r20232 if delete or rename or names or inactive:
wlock = repo.wlock()
try:
Siddharth Agarwal
commands.bookmarks: move cur initialization to inside wlock...
r20234 cur = repo.changectx('.').node()
Siddharth Agarwal
commands.bookmarks: hold wlock for write operations...
r20232 marks = repo._bookmarks
if delete:
for mark in names:
if mark not in marks:
raise util.Abort(_("bookmark '%s' does not exist") %
mark)
if mark == repo._bookmarkcurrent:
bookmarks.unsetcurrent(repo)
del marks[mark]
marks.write()
elif rename:
if not names:
raise util.Abort(_("new bookmark name required"))
elif len(names) > 1:
raise util.Abort(_("only one new bookmark name allowed"))
mark = checkformat(names[0])
if rename not in marks:
raise util.Abort(_("bookmark '%s' does not exist") % rename)
Siddharth Agarwal
commands.bookmarks: pass cur in explicitly to checkconflict...
r20233 checkconflict(repo, mark, cur, force)
Siddharth Agarwal
commands.bookmarks: hold wlock for write operations...
r20232 marks[mark] = marks[rename]
if repo._bookmarkcurrent == rename and not inactive:
bookmarks.setcurrent(repo, mark)
del marks[rename]
marks.write()
elif names:
newact = None
for mark in names:
mark = checkformat(mark)
if newact is None:
newact = mark
if inactive and mark == repo._bookmarkcurrent:
bookmarks.unsetcurrent(repo)
return
tgt = cur
if rev:
tgt = scmutil.revsingle(repo, rev).node()
Siddharth Agarwal
commands.bookmarks: pass cur in explicitly to checkconflict...
r20233 checkconflict(repo, mark, cur, force, tgt)
Siddharth Agarwal
commands.bookmarks: hold wlock for write operations...
r20232 marks[mark] = tgt
if not inactive and cur == marks[newact] and not rev:
bookmarks.setcurrent(repo, newact)
elif cur != tgt and newact == repo._bookmarkcurrent:
bookmarks.unsetcurrent(repo)
marks.write()
elif inactive:
if len(marks) == 0:
ui.status(_("no bookmarks set\n"))
elif not repo._bookmarkcurrent:
ui.status(_("no active bookmark\n"))
else:
bookmarks.unsetcurrent(repo)
finally:
wlock.release()
Kevin Bullock
bookmarks: further flatten code...
r17822 else: # show bookmarks
Siddharth Agarwal
commands.bookmarks: move hexfn to inside list block...
r20235 hexfn = ui.debugflag and hex or short
Siddharth Agarwal
commands.bookmarks: hold wlock for write operations...
r20232 marks = repo._bookmarks
Siddharth Agarwal
commands.bookmarks: separate out 'no bookmarks set' status messages...
r20231 if len(marks) == 0:
ui.status(_("no bookmarks set\n"))
else:
for bmark, n in sorted(marks.iteritems()):
current = repo._bookmarkcurrent
if bmark == current:
prefix, label = '*', 'bookmarks.current'
else:
prefix, label = ' ', ''
if ui.quiet:
ui.write("%s\n" % bmark, label=label)
else:
Matt Mackall
bookmarks: properly align multi-byte characters
r21571 pad = " " * (25 - encoding.colwidth(bmark))
ui.write(" %s %s%s %d:%s\n" % (
prefix, bmark, pad, repo.changelog.rev(n), hexfn(n)),
Siddharth Agarwal
commands.bookmarks: separate out 'no bookmarks set' status messages...
r20231 label=label)
Matt Mackall
bookmarks: move push/pull command features to core
r13368
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('branch',
[('f', 'force', None,
_('set branch name even if it shadows an existing branch')),
('C', 'clean', None, _('reset branch name to parent branch name'))],
_('[-fC] [NAME]'))
Brendan Cully
branch: require --force to shadow existing branches
r4202 def branch(ui, repo, label=None, **opts):
Matt Mackall
add branch and branches commands
r3502 """set or show the current branch name
Matt Mackall
branch: move note about permanence to the top, add 'global'
r15610 .. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Matt Mackall
branch: move note about permanence to the top, add 'global'
r15610 Branch names are permanent and global. Use :hg:`bookmark` to create a
light-weight bookmark instead. See :hg:`help glossary` for more
information about named branches and bookmarks.
Brendan Cully
Notify the user that hg branch does not create a branch until commit
r4601 With no argument, show the current branch name. With one argument,
timeless
Improve English for help text of many core hg commands....
r8779 set the working directory branch name (the branch will not exist
in the repository until the next commit). Standard practice
recommends that primary development take place on the 'default'
branch.
Brendan Cully
branch: require --force to shadow existing branches
r4202
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 Unless -f/--force is specified, branch will not let you set a
timeless
Improve English for help text of many core hg commands....
r8779 branch name that already exists, even if it's inactive.
Thomas Arendsen Hein
Mention 'hg update' to switch branches in help for branch and branches.
r5999
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 Use -C/--clean to reset the working directory branch to that of
the parent of the working directory, negating a previous branch
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 change.
Sune Foldager
branch: added more support for named branches...
r7006
Martin Geisler
Use hg role in help strings
r10973 Use the command :hg:`update` to switch to an existing branch. Use
:hg:`commit --close-branch` to mark this branch as closed.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Matt Mackall
add branch and branches commands
r3502 """
Yuya Nishihara
branch: strip whitespace before testing known branch name...
r19180 if label:
label = label.strip()
Idan Kamara
commands: add missing wlock to branch
r16471 if not opts.get('clean') and not label:
Matt Mackall
branch: operate on branch names in local string space where possible...
r13047 ui.write("%s\n" % repo.dirstate.branch())
Idan Kamara
commands: add missing wlock to branch
r16471 return
wlock = repo.wlock()
try:
if opts.get('clean'):
label = repo[None].p1().branch()
repo.dirstate.setbranch(label)
ui.status(_('reset working directory to branch %s\n') % label)
elif label:
Brodie Rao
localrepo: add branchtip() method for faster single-branch lookups...
r16719 if not opts.get('force') and label in repo.branchmap():
Idan Kamara
commands: add missing wlock to branch
r16471 if label not in [p.branch() for p in repo.parents()]:
raise util.Abort(_('a branch of the same name already'
' exists'),
# i18n: "it" refers to an existing branch
hint=_("use 'hg update' to switch to it"))
Tim Henigan
branch: add missing repo argument to checknewlabel...
r17990 scmutil.checknewlabel(repo, label, 'branch')
Idan Kamara
commands: add missing wlock to branch
r16471 repo.dirstate.setbranch(label)
ui.status(_('marked working directory as branch %s\n') % label)
ui.status(_('(branches are permanent and global, '
'did you want a bookmark?)\n'))
finally:
wlock.release()
Matt Mackall
add branch and branches commands
r3502
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('branches',
[('a', 'active', False, _('show only branches that have unmerged heads')),
('c', 'closed', False, _('show normal and closed branches'))],
_('[-ac]'))
Matt Mackall
branches: add --closed flag for consistency with heads
r8991 def branches(ui, repo, active=False, closed=False):
Matt Mackall
add branch and branches commands
r3502 """list repository named branches
Eric Hopper
Change branches to sort 'active' branches first, and add an option to show only active branches.
r4675 List the repository's named branches, indicating which ones are
Matt Mackall
branches: add --closed flag for consistency with heads
r8991 inactive. If -c/--closed is specified, also list branches which have
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 been marked closed (see :hg:`commit --close-branch`).
Matt Mackall
branches: add --closed flag for consistency with heads
r8991
If -a/--active is specified, only show active branches. A branch
is considered active if it contains repository heads.
Thomas Arendsen Hein
Mention 'hg update' to switch branches in help for branch and branches.
r5999
Martin Geisler
Use hg role in help strings
r10973 Use the command :hg:`update` to switch to an existing branch.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0.
Matt Mackall
add branch and branches commands
r3502 """
Matt Mackall
branches: add --closed flag for consistency with heads
r8991
Stefano Tortarolo
Active branches fix (issue1104)
r6631 hexfunc = ui.debugflag and hex or short
Brodie Rao
branches: improve performance by removing redundant operations...
r16721
Brodie Rao
branches: avoid unnecessary changectx.branch() calls...
r20182 allheads = set(repo.heads())
Brodie Rao
branches: improve performance by removing redundant operations...
r16721 branches = []
Brodie Rao
branches: simplify with repo.branchmap().iterbranches()...
r20192 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
isactive = not isclosed and bool(set(heads) & allheads)
branches.append((tag, repo[tip], isactive, not isclosed))
Brodie Rao
branches: avoid unnecessary changectx.branch() calls...
r20182 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
Brodie Rao
branches: improve performance by removing redundant operations...
r16721 reverse=True)
Brodie Rao
branches: avoid unnecessary changectx.branch() calls...
r20182 for tag, ctx, isactive, isopen in branches:
Stefano Tortarolo
Active branches fix (issue1104)
r6631 if (not active) or isactive:
Travis Herrick
branches: quiet option observes other parameters
r16612 if isactive:
label = 'branches.active'
notice = ''
Brodie Rao
branches: improve performance by removing redundant operations...
r16721 elif not isopen:
Travis Herrick
branches: quiet option observes other parameters
r16612 if not closed:
continue
label = 'branches.closed'
notice = _(' (closed)')
else:
label = 'branches.inactive'
notice = _(' (inactive)')
Brodie Rao
branches: avoid unnecessary changectx.branch() calls...
r20182 if tag == repo.dirstate.branch():
Travis Herrick
branches: quiet option observes other parameters
r16612 label = 'branches.current'
Brodie Rao
branches: avoid unnecessary changectx.branch() calls...
r20182 rev = str(ctx.rev()).rjust(31 - encoding.colwidth(tag))
Brodie Rao
branches: improve performance by removing redundant operations...
r16721 rev = ui.label('%s:%s' % (rev, hexfunc(ctx.node())),
Sean Farley
color: add additional changeset.phase label to log.changeset and log.parent...
r17788 'log.changeset changeset.%s' % ctx.phasestr())
Brodie Rao
branches: avoid unnecessary changectx.branch() calls...
r20182 labeledtag = ui.label(tag, label)
Eric Hopper
Change branches to sort 'active' branches first, and add an option to show only active branches.
r4675 if ui.quiet:
Brodie Rao
branches: avoid unnecessary changectx.branch() calls...
r20182 ui.write("%s\n" % labeledtag)
Eric Hopper
Change branches to sort 'active' branches first, and add an option to show only active branches.
r4675 else:
Brodie Rao
branches: avoid unnecessary changectx.branch() calls...
r20182 ui.write("%s %s%s\n" % (labeledtag, rev, notice))
Matt Mackall
add branch and branches commands
r3502
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('bundle',
[('f', 'force', None, _('run even when the destination is unrelated')),
('r', 'rev', [], _('a changeset intended to be added to the destination'),
_('REV')),
('b', 'branch', [], _('a specific branch you would like to bundle'),
_('BRANCH')),
('', 'base', [],
_('a base changeset assumed to be available at the destination'),
_('REV')),
('a', 'all', None, _('bundle all changesets in the repository')),
('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
] + remoteopts,
_('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
Vadim Gelfer
push, outgoing, bundle: fall back to "default" if "default-push" not defined
r2494 def bundle(ui, repo, fname, dest=None, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """create a changegroup file
Thomas Arendsen Hein
Corrected help text for bundle.
r3511 Generate a compressed changegroup file collecting changesets not
timeless
help: miscellaneous language fixes
r7807 known to be in another repository.
Thomas Arendsen Hein
Corrected help text for bundle.
r3511
timeless
help: Improved body text
r10376 If you omit the destination repository, then hg assumes the
destination will have all the nodes you specify with --base
Christian Ebert
Consistently 1 space after full stops in command doc strings...
r6448 parameters. To create a bundle containing all changesets, use
Henrik Stuart
help: describe bundle compression methods (issue1523)
r8903 -a/--all (or --base null).
Stefano Mioli
commands: improve bundle compression methods description
r8958 You can change compression method with the -t/--type option.
The available compression methods are: none, bzip2, and
Henrik Stuart
help: describe bundle compression methods (issue1523)
r8903 gzip (by default, bundles are compressed using bzip2).
Thomas Arendsen Hein
Corrected help text for bundle.
r3511
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 The bundle file can then be transferred using conventional means
and applied to another repository with the unbundle or pull
command. This is useful when direct push and pull are not
available or when exporting an entire repository is undesirable.
Thomas Arendsen Hein
Corrected help text for bundle.
r3511
Applying bundles preserves all changeset contents including
permissions, copy/rename information, and revision history.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success, 1 if no changes found.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
commands: add revset support to most commands
r12925 revs = None
if 'rev' in opts:
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 revs = scmutil.revrange(repo, opts['rev'])
Matt Mackall
commands: add revset support to most commands
r12925
Bryan O'Sullivan
commands: move bundle type validation earlier...
r16427 bundletype = opts.get('type', 'bzip2').lower()
btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
bundletype = btypes.get(bundletype)
if bundletype not in changegroup.bundletypes:
raise util.Abort(_('unknown bundle type specified with --type'))
John Mulligan
Add --all option to bundle command
r6171 if opts.get('all'):
base = ['null']
else:
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 base = scmutil.revrange(repo, opts.get('base'))
Benoit Boissinot
bundle-ng: add bundlecaps argument to getbundle() command
r19201 # TODO: get desired bundlecaps from command line.
bundlecaps = None
Benoit Boissinot
add -r/--rev and --base option to bundle...
r3284 if base:
if dest:
Martin Geisler
commands: typo in bundle abort message...
r8669 raise util.Abort(_("--base is incompatible with specifying "
Benoit Boissinot
add -r/--rev and --base option to bundle...
r3284 "a destination"))
Peter Arrenbrecht
discovery: drop findoutgoing and simplify findcommonincoming's api...
r14073 common = [repo.lookup(rev) for rev in base]
Pierre-Yves David
discovery: introduce outgoing object for result of findcommonoutgoing...
r15837 heads = revs and map(repo.lookup, revs) or revs
Pierre-Yves David
localrepo: move the getbundle method in changegroup module...
r20930 cg = changegroup.getbundle(repo, 'bundle', heads=heads, common=common,
bundlecaps=bundlecaps)
Matt Mackall
scmutil: unify some 'no changes found' messages...
r15993 outgoing = None
Benoit Boissinot
add -r/--rev and --base option to bundle...
r3284 else:
Sune Foldager
interpret repo#name url syntax as branch instead of revision...
r10365 dest = ui.expandpath(dest or 'default-push', dest or 'default')
Sune Foldager
add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
r10379 dest, branches = hg.parseurl(dest, opts.get('branch'))
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 other = hg.peer(repo, opts, dest)
FUJIWARA Katsunori
bundle: treat branches created newly on the local correctly (issue3828)...
r18701 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
Peter Arrenbrecht
discovery: resurrect findoutgoing as findcommonoutgoing for extension hooks...
r14213 heads = revs and map(repo.lookup, revs) or revs
Pierre-Yves David
discovery: introduce outgoing object for result of findcommonoutgoing...
r15837 outgoing = discovery.findcommonoutgoing(repo, other,
onlyheads=heads,
Sune Foldager
bundle: make bundles more portable (isue3441)...
r16736 force=opts.get('force'),
portable=True)
Pierre-Yves David
localrepo: move the getlocalbundle method in changegroup module...
r20928 cg = changegroup.getlocalbundle(repo, 'bundle', outgoing, bundlecaps)
Peter Arrenbrecht
discovery: drop findoutgoing and simplify findcommonincoming's api...
r14073 if not cg:
Patrick Mezard
discovery: add extinct changesets to outgoing.excluded...
r17248 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
Matt Mackall
commands: initial audit of exit codes...
r11177 return 1
Benoit Boissinot
bundle: fix bundle generation for empty changegroup
r10616
Benoit Allard
add compression type type parameter to bundle command
r6570 changegroup.writebundle(cg, fname, bundletype)
mpm@selenic.com
Add preliminary support for the bundle and unbundle commands
r1218
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('cat',
[('o', 'output', '',
_('print output to file with formatted name'), _('FORMAT')),
('r', 'rev', '', _('print the given revision'), _('REV')),
('', 'decode', None, _('apply any matching decode filter')),
] + walkopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... FILE...'),
inferrepo=True)
Bryan O'Sullivan
Switch cat command to use walk code....
r1254 def cat(ui, repo, file1, *pats, **opts):
Thomas Arendsen Hein
doc string fix: hg cat and manifest default to current parent revision.
r3914 """output the current or given revision of files
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 Print the specified files as they were at the given revision. If
Matt Mackall
cat: remove incorrect reference to tip
r19400 no revision is given, the parent of the working directory is used.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Output may be to a file, in which case the name of the file is
Matt Harbison
cat: explicitly document the supported formatter rules...
r21078 given using a format string. The formatting rules as follows:
:``%%``: literal "%" character
Martin Geisler
commands: use field lists instead of literal blocks in docstrings...
r9892 :``%s``: basename of file being printed
:``%d``: dirname of file being printed, or '.' if in repository root
:``%p``: root-relative path name of file being printed
Matt Harbison
cat: explicitly document the supported formatter rules...
r21078 :``%H``: changeset hash (40 hexadecimal digits)
:``%R``: changeset revision number
:``%h``: short-form changeset hash (12 hexadecimal digits)
:``%r``: zero-padded changeset revision number
:``%b``: basename of the exporting repository
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 ctx = scmutil.revsingle(repo, opts.get('rev'))
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(ctx, (file1,) + pats, opts)
Durham Goode
cat: increase perf when catting single files...
r20293
Matt Harbison
cat: support cat with explicit paths in subrepos...
r21041 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
mpm@selenic.com
migrate remaining commands...
r248
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^clone',
[('U', 'noupdate', None,
_('the clone will include an empty working copy (only a repository)')),
('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
('r', 'rev', [], _('include the specified changeset'), _('REV')),
('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
('', 'pull', None, _('use pull protocol to copy metadata')),
('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
] + remoteopts,
Gregory Szorc
commands: define norepo in command decorator
r21768 _('[OPTION]... SOURCE [DEST]'),
norepo=True)
Thomas Arendsen Hein
Use python function instead of external 'cp' command when cloning repos....
r698 def clone(ui, source, dest=None, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """make a copy of an existing repository
Create a copy of an existing repository in a new directory.
If no destination directory name is specified, it defaults to the
basename of the source.
The location of the source is added to the new repository's
Javi Merino
doc: Add back quotes around filenames...
r13344 ``.hg/hgrc`` file, as the default to be used for future pulls.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Matt Mackall
clone: move portions of help into the verbose section
r15177 Only local paths and ``ssh://`` URLs are supported as
destinations. For ``ssh://`` destinations, no working directory or
``.hg/hgrc`` will be created on the remote side.
Matt Mackall
mention default branch in branch and clone help
r7942
Matt Mackall
clone: improve help on -r/-b and tags
r15174 To pull only a subset of changesets, specify one or more revisions
identifiers with -r/--rev or branches with -b/--branch. The
resulting clone will contain only the specified changesets and
their ancestors. These options (or 'clone src#rev dest') imply
--pull, even for local source repositories. Note that specifying a
tag will include the tagged changeset but not the changeset
containing the tag.
Adrian Buehlmann
clone: add option -u/--updaterev
r9714
Kevin Bullock
help: document '@' bookmark in 'help bookmarks' and 'help clone'
r18474 If the source repository has a bookmark called '@' set, that
revision will be checked out in the new repository by default.
Matt Mackall
clone: add a note about -u/-U
r15178 To check out a particular version, use -u/--update, or
-U/--noupdate to create a clone with no working directory.
Matt Mackall
clone: move portions of help into the verbose section
r15177 .. container:: verbose
For efficiency, hardlinks are used for cloning whenever the
source and destination are on the same filesystem (note this
applies only to the repository data, not to the working
directory). Some filesystems, such as AFS, implement hardlinking
incorrectly, but do not report errors. In these cases, use the
--pull option to avoid hardlinking.
In some cases, you can clone repositories and the working
directory using full hardlinks with ::
$ cp -al REPO REPOCLONE
This is the fastest way to clone, but it is not always safe. The
operation is not atomic (making sure REPO is not modified during
the operation is up to you) and you have to make sure your
editor breaks hardlinks (Emacs and most Linux Kernel tools do
so). Also, this is not compatible with certain extensions that
place their metadata under the .hg directory, such as mq.
Mercurial will update the working directory to the first applicable
revision from this list:
a) null if -U or the source repository has no changesets
b) if -u . and the source repository is local, the first parent of
the source repository's working directory
c) the changeset specified with -u (if a branch name, this means the
latest head of that branch)
d) the changeset specified with -r
e) the tipmost head specified with -b
f) the tipmost head specified with the url#branch source syntax
Kevin Bullock
help: update verbose 'clone' help to include '@' bookmark
r18476 g) the revision marked with the '@' bookmark, if present
h) the tipmost head of the default branch
i) tip
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
clone: add help examples
r15179 Examples:
- clone a remote repository to a new directory named hg/::
hg clone http://selenic.com/hg
- create a lightweight local clone::
hg clone project/ project-feature/
- clone from an absolute path on an ssh server (note double-slash)::
hg clone ssh://user@server//home/projects/alpha/
- do a high-speed clone over a LAN while checking out a
specified version::
hg clone --uncompressed http://server/repo -u 1.5
- create a repository without changesets after a particular revision::
hg clone -r 04e544 experimental/ good/
- clone (and track) a particular named branch::
hg clone http://selenic.com/hg#stable
Matt Mackall
clone: move url crossref to bottom
r15175 See :hg:`help urls` for details on specifying URLs.
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Adrian Buehlmann
clone: add option -u/--updaterev
r9714 if opts.get('noupdate') and opts.get('updaterev'):
raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
Peter Arrenbrecht
hg: add opts argument to clone for internal remoteui
r14553 r = hg.clone(ui, opts, source, dest,
Matt Mackall
commands: initial audit of exit codes...
r11177 pull=opts.get('pull'),
stream=opts.get('uncompressed'),
rev=opts.get('rev'),
update=opts.get('updaterev') or not opts.get('noupdate'),
branch=opts.get('branch'))
return r is None
mpm@selenic.com
Whitespace cleanups...
r515
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^commit|ci',
[('A', 'addremove', None,
_('mark new/missing files as added/removed before committing')),
('', 'close-branch', None,
_('mark a branch as closed, hiding it from the branch list')),
Idan Kamara
commit: add option to amend the working dir parent...
r16458 ('', 'amend', None, _('amend the parent of the working dir')),
Jordi Gutiérrez Hermoso
commit: enable --secret option...
r19440 ('s', 'secret', None, _('use the secret phase for committing')),
FUJIWARA Katsunori
doc: unify help text for "--edit" option...
r21952 ('e', 'edit', None, _('invoke editor on commit messages')),
Martin Geisler
subrepos: abort commit by default if a subrepo is dirty (BC)...
r15321 ] + walkopts + commitopts + commitopts2 + subrepoopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... [FILE]...'),
inferrepo=True)
Bryan O'Sullivan
Adapt commit to use file matching code....
r813 def commit(ui, repo, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """commit the specified files or all outstanding changes
Martin Geisler
Change double spaces to single spaces in help texts.
r7983 Commit changes to the given files into the repository. Unlike a
Adrian Buehlmann
commit: use the term SCM instead of RCS...
r13303 centralized SCM, this operation is a local operation. See
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 :hg:`push` for a way to actively distribute your changes.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
Use hg role in help strings
r10973 If a list of files is omitted, all changes reported by :hg:`status`
mcmillen@cs.cmu.edu
Spelling fix: "commited" -> "committed"
r1995 will be committed.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Bryan O'Sullivan
commit: when committing the results of a merge, it's all or nothing...
r6385 If you are committing the result of a merge, do not provide any
timeless
Generally replace "file name" with "filename" in help and comments.
r8761 filenames or -I/-X filters.
Bryan O'Sullivan
commit: when committing the results of a merge, it's all or nothing...
r6385
Greg Ward
commit: explicitly document the existence of "last-message.txt"
r11877 If no commit message is specified, Mercurial starts your
configured editor where you can enter a message. In case your
commit fails, you will find a backup of your message in
``.hg/last-message.txt``.
Thomas Arendsen Hein
Document log date ranges and mention 'hg help dates' for all commands (issue998)
r6163
Idan Kamara
commit: add option to amend the working dir parent...
r16458 The --amend flag can be used to amend the parent of the
working directory with a new commit that contains the changes
in the parent in addition to those currently reported by :hg:`status`,
if there are any. The old commit is stored in a backup bundle in
``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
on how to restore it).
Message, user and date are taken from the amended commit unless
specified. When a message isn't specified on the command line,
the editor will open with the message of the amended commit.
It is not possible to amend public changesets (see :hg:`help phases`)
or changesets that have children.
Martin Geisler
Use hg role in help strings
r10973 See :hg:`help dates` for a list of formats valid for -d/--date.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success, 1 if nothing changed.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Martin Geisler
subrepos: abort commit by default if a subrepo is dirty (BC)...
r15321 if opts.get('subrepos'):
Matt Mackall
amend: complain more comprehensibly about subrepos
r19232 if opts.get('amend'):
raise util.Abort(_('cannot amend with --subrepos'))
timeless@mozdev.org
spelling: override
r17504 # Let --subrepos on the command line override config setting.
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
Martin Geisler
subrepos: abort commit by default if a subrepo is dirty (BC)...
r15321
Matt Mackall
checkunfinished: accommodate histedit quirk...
r19496 cmdutil.checkunfinished(repo, commit=True)
Simon King
graft: refuse to commit an interrupted graft (issue3667)
r19253
Iulian Stana
commit: amending with --close-branch (issue3445)...
r19305 branch = repo[None].branch()
bheads = repo.branchheads(branch)
John Mulligan
branch closing: mark closed branches with a 'close' extra...
r7655 extra = {}
if opts.get('close_branch'):
extra['close'] = 1
Dirkjan Ochtman
warn about new heads on commit (issue842)
r6336
Iulian Stana
commit: amending with --close-branch (issue3445)...
r19305 if not bheads:
raise util.Abort(_('can only close branch heads'))
elif opts.get('amend'):
if repo.parents()[0].p1().branch() != branch and \
repo.parents()[0].p2().branch() != branch:
raise util.Abort(_('can only close branch heads'))
Matt Mackall
commit: note new branch heads rather than topological heads...
r11173
Idan Kamara
commit: add option to amend the working dir parent...
r16458 if opts.get('amend'):
Adrian Buehlmann
commit: use ui.configbool when checking 'commitsubrepos' setting on --amend...
r16505 if ui.configbool('ui', 'commitsubrepos'):
Matt Mackall
amend: complain more comprehensibly about subrepos
r19232 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
Idan Kamara
commit: add option to amend the working dir parent...
r16458
old = repo['.']
if old.phase() == phases.public:
raise util.Abort(_('cannot amend public changesets'))
if len(repo[None].parents()) > 1:
raise util.Abort(_('cannot amend while merging'))
Pierre-Yves David
amend: allow amend of non-head when obsolete is enabled...
r18163 if (not obsolete._enabled) and old.children():
Idan Kamara
commit: add option to amend the working dir parent...
r16458 raise util.Abort(_('cannot amend changeset with children'))
FUJIWARA Katsunori
commit: create new amend changeset as secret correctly for "--secret" option...
r20700 # commitfunc is used only for temporary amend commit by cmdutil.amend
Idan Kamara
commit: add option to amend the working dir parent...
r16458 def commitfunc(ui, repo, message, match, opts):
FUJIWARA Katsunori
commit: create new amend changeset as secret correctly for "--secret" option...
r20700 return repo.commit(message,
opts.get('user') or old.user(),
opts.get('date') or old.date(),
match,
extra=extra)
Idan Kamara
commit: add option to amend the working dir parent...
r16458
Augie Fackler
strip: move bookmarks to nearest ancestor rather than '.'...
r17264 current = repo._bookmarkcurrent
marks = old.bookmarks()
Idan Kamara
commit: add option to amend the working dir parent...
r16458 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
if node == old.node():
Martin Geisler
commit: note when files are missing...
r13899 ui.status(_("nothing changed\n"))
Idan Kamara
commit: add option to amend the working dir parent...
r16458 return 1
Augie Fackler
strip: move bookmarks to nearest ancestor rather than '.'...
r17264 elif marks:
ui.debug('moving bookmarks %r from %s to %s\n' %
(marks, old.hex(), hex(node)))
Augie Fackler
bookmarks: introduce a bmstore to manage bookmark persistence...
r17922 newmarks = repo._bookmarks
Augie Fackler
strip: move bookmarks to nearest ancestor rather than '.'...
r17264 for bm in marks:
Augie Fackler
bookmarks: introduce a bmstore to manage bookmark persistence...
r17922 newmarks[bm] = node
Augie Fackler
strip: move bookmarks to nearest ancestor rather than '.'...
r17264 if bm == current:
bookmarks.setcurrent(repo, bm)
Augie Fackler
bookmarks: introduce a bmstore to manage bookmark persistence...
r17922 newmarks.write()
Idan Kamara
commit: add option to amend the working dir parent...
r16458 else:
def commitfunc(ui, repo, message, match, opts):
Pierre-Yves David
commit: update the --secret code to use backupconfig and restoreconfig...
r22039 backup = ui.backupconfig('phases', 'new-commit')
baseui = repo.baseui
basebackup = baseui.backupconfig('phases', 'new-commit')
Jordi Gutiérrez Hermoso
commit: enable --secret option...
r19440 try:
if opts.get('secret'):
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
Jordi Gutiérrez Hermoso
commit: propagate --secret option to subrepos (issue4182)...
r20772 # Propagate to subrepos
Pierre-Yves David
commit: update the --secret code to use backupconfig and restoreconfig...
r22039 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
Jordi Gutiérrez Hermoso
commit: enable --secret option...
r19440
FUJIWARA Katsunori
commit: pass 'editform' argument to 'cmdutil.getcommiteditor'...
r22010 editform = 'commit.normal'
editor = cmdutil.getcommiteditor(editform=editform, **opts)
Jordi Gutiérrez Hermoso
commit: enable --secret option...
r19440 return repo.commit(message, opts.get('user'), opts.get('date'),
FUJIWARA Katsunori
commit: use "getcommiteditor()" instead of explicit editor choice...
r21414 match,
FUJIWARA Katsunori
commit: pass 'editform' argument to 'cmdutil.getcommiteditor'...
r22010 editor=editor,
FUJIWARA Katsunori
commit: use "getcommiteditor()" instead of explicit editor choice...
r21414 extra=extra)
Jordi Gutiérrez Hermoso
commit: enable --secret option...
r19440 finally:
Pierre-Yves David
commit: update the --secret code to use backupconfig and restoreconfig...
r22039 ui.restoreconfig(backup)
repo.baseui.restoreconfig(basebackup)
Jordi Gutiérrez Hermoso
commit: enable --secret option...
r19440
Idan Kamara
commit: add option to amend the working dir parent...
r16458
node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
if not node:
stat = repo.status(match=scmutil.match(repo[None], pats, opts))
if stat[3]:
ui.status(_("nothing changed (%d missing files, see "
"'hg status')\n") % len(stat[3]))
else:
ui.status(_("nothing changed\n"))
return 1
Matt Mackall
commit: note new branch heads rather than topological heads...
r11173
Kevin Bullock
commit: factor out status printing into a helper function...
r18688 cmdutil.commitstatus(repo, node, branch, bheads, opts)
Gilles Moris
Have verbose and debug flag print the changeset rev and hash when committing....
r6935
Matt Mackall
config: move showconfig code and add config as primary alias...
r20570 @command('config|showconfig|debugconfig',
Matt Mackall
config: add initial implementation of --edit...
r20572 [('u', 'untrusted', None, _('show untrusted configuration options')),
Matt Mackall
config: add --global and --local flags...
r20782 ('e', 'edit', None, _('edit user config')),
('l', 'local', None, _('edit repository config')),
('g', 'global', None, _('edit global config'))],
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 _('[-u] [NAME]...'),
optionalrepo=True)
Matt Mackall
config: move showconfig code and add config as primary alias...
r20570 def config(ui, repo, *values, **opts):
"""show combined config settings from all hgrc files
With no arguments, print names and values of all config items.
With one argument of the form section.name, print just the value
of that config item.
With multiple arguments, print names and values of all config
items with matching section names.
Matt Mackall
config: mention edit options and config topic in help
r20783 With --edit, start an editor on the user-level config file. With
--global, edit the system-wide config file. With --local, edit the
repository-level config file.
Matt Mackall
config: move showconfig code and add config as primary alias...
r20570 With --debug, the source (filename and line number) is printed
for each config item.
Matt Mackall
config: mention edit options and config topic in help
r20783 See :hg:`help config` for more information about config files.
Matt Mackall
config: move showconfig code and add config as primary alias...
r20570 Returns 0 on success.
Matt Mackall
config: mention edit options and config topic in help
r20783
Matt Mackall
config: move showconfig code and add config as primary alias...
r20570 """
Matt Mackall
config: add --global and --local flags...
r20782 if opts.get('edit') or opts.get('local') or opts.get('global'):
if opts.get('local') and opts.get('global'):
raise util.Abort(_("can't use --local and --global together"))
if opts.get('local'):
if not repo:
raise util.Abort(_("can't use --local outside a repository"))
paths = [repo.join('hgrc')]
elif opts.get('global'):
paths = scmutil.systemrcpath()
else:
paths = scmutil.userrcpath()
Matt Mackall
config: add initial implementation of --edit...
r20572 for f in paths:
if os.path.exists(f):
break
else:
f = paths[0]
Matt Mackall
config: add example config file when -e called with no config
r20573 fp = open(f, "w")
fp.write(
'# example config (see "hg help config" for more info)\n'
'\n'
'[ui]\n'
Jordi Gutiérrez Hermoso
config: clarify and exemplify the user name in the sample config file
r20664 '# name and email, e.g.\n'
'# username = Jane Doe <jdoe@example.com>\n'
Matt Mackall
config: add example config file when -e called with no config
r20573 'username =\n'
'\n'
'[extensions]\n'
'# uncomment these lines to enable some popular extensions\n'
'# (see "hg help extensions" for more info)\n'
'# pager =\n'
'# progress =\n'
'# color =\n')
fp.close()
Matt Mackall
config: add initial implementation of --edit...
r20572 editor = ui.geteditor()
util.system("%s \"%s\"" % (editor, f),
onerr=util.Abort, errprefix=_("edit failed"),
out=ui.fout)
return
Matt Mackall
config: move showconfig code and add config as primary alias...
r20570 for f in scmutil.rcpath():
ui.debug('read config from: %s\n' % f)
untrusted = bool(opts.get('untrusted'))
if values:
sections = [v for v in values if '.' not in v]
items = [v for v in values if '.' in v]
if len(items) > 1 or items and sections:
raise util.Abort(_('only one config item permitted'))
for section, name, value in ui.walkconfig(untrusted=untrusted):
value = str(value).replace('\n', '\\n')
sectname = section + '.' + name
if values:
for v in values:
if v == section:
ui.debug('%s: ' %
ui.configsource(section, name, untrusted))
ui.write('%s=%s\n' % (sectname, value))
elif v == sectname:
ui.debug('%s: ' %
ui.configsource(section, name, untrusted))
ui.write(value, '\n')
else:
ui.debug('%s: ' %
ui.configsource(section, name, untrusted))
ui.write('%s=%s\n' % (sectname, value))
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('copy|cp',
[('A', 'after', None, _('record a copy that has already occurred')),
('f', 'force', None, _('forcibly copy over an existing managed file')),
] + walkopts + dryrunopts,
_('[OPTION]... [SOURCE]... DEST'))
Bryan O'Sullivan
Add rename/mv command....
r1253 def copy(ui, repo, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """mark files as copied for the next commit
Christian Ebert
Consistently 1 space after full stops in command doc strings...
r6448 Mark dest as having copies of source files. If dest is a
directory, copies are put in that directory. If dest is a file,
timeless
help: miscellaneous language fixes
r7807 the source must be a single file.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
By default, this command copies the contents of files as they
timeless
Improve English for help text of many core hg commands....
r8779 exist in the working directory. If invoked with -A/--after, the
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 operation is recorded, but no copying is performed.
timeless
help: miscellaneous language fixes
r7807 This command takes effect with the next commit. To undo a copy
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 before that, see :hg:`revert`.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success, 1 if errors are encountered.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
repo locks: use True/False
r4914 wlock = repo.wlock(False)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 try:
Matt Mackall
copy: handle rename internally...
r5610 return cmdutil.copy(ui, repo, pats, opts)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 finally:
Ronny Pfannschmidt
switch lock releasing in the core from gc to explicit
r8109 wlock.release()
mpm@selenic.com
Add hg copy...
r363
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
Thomas Arendsen Hein
Make hg debugancestor accept -R by making it an optionalrepo command.
r6189 def debugancestor(ui, repo, *args):
mpm@selenic.com
Add debugancestor command
r1262 """find the ancestor revision of two revisions in a given index"""
Thomas Arendsen Hein
debugancestor: use *args instead of *opts, to not confuse with option dicts.
r6188 if len(args) == 3:
index, rev1, rev2 = args
Adrian Buehlmann
move opener from util to scmutil
r13970 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
Alexis S. L. Carvalho
debugancestor: use repo.lookup when no revlog was specified
r6253 lookup = r.lookup
Thomas Arendsen Hein
debugancestor: use *args instead of *opts, to not confuse with option dicts.
r6188 elif len(args) == 2:
Thomas Arendsen Hein
Make hg debugancestor accept -R by making it an optionalrepo command.
r6189 if not repo:
Martin Geisler
Lowercase error messages
r12067 raise util.Abort(_("there is no Mercurial repository here "
Thomas Arendsen Hein
Make hg debugancestor accept -R by making it an optionalrepo command.
r6189 "(.hg not found)"))
Thomas Arendsen Hein
debugancestor: use *args instead of *opts, to not confuse with option dicts.
r6188 rev1, rev2 = args
Bryan O'Sullivan
debugancestor: make the index argument optional, defaulting to 00changelog.i
r6178 r = repo.changelog
Alexis S. L. Carvalho
debugancestor: use repo.lookup when no revlog was specified
r6253 lookup = repo.lookup
Bryan O'Sullivan
debugancestor: make the index argument optional, defaulting to 00changelog.i
r6178 else:
raise util.Abort(_('either two or three arguments required'))
Alexis S. L. Carvalho
debugancestor: use repo.lookup when no revlog was specified
r6253 a = r.ancestor(lookup(rev1), lookup(rev2))
mpm@selenic.com
Add debugancestor command
r1262 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('debugbuilddag',
[('m', 'mergeable-file', None, _('add single file mergeable changes')),
('o', 'overwritten-file', None, _('add single file all revs overwrite')),
('n', 'new-file', None, _('add new file at each rev'))],
_('[OPTION]... [TEXT]'))
Martin Geisler
debugbuilddag: read DAG from stdin if not given on cmdline
r14283 def debugbuilddag(ui, repo, text=None,
Peter Arrenbrecht
debugbuilddag: build a changelog dag from a concise description...
r11337 mergeable_file=False,
overwritten_file=False,
new_file=False):
Martin Geisler
debugbuilddag: read DAG from stdin if not given on cmdline
r14283 """builds a repo with a given DAG from scratch in the current empty repo
The description of the DAG is read from stdin if not given on the
command line.
Peter Arrenbrecht
debugbuilddag: build a changelog dag from a concise description...
r11337
Elements:
- "+n" is a linear run of n nodes based on the current default parent
- "." is a single node based on the current default parent
- "$" resets the default parent to null (implied at the start);
otherwise the default parent is always the last node created
- "<p" sets the default parent to the backref p
- "*p" is a fork at parent p, which is a backref
- "*p1/p2" is a merge of parents p1 and p2, which are backrefs
- "/p2" is a merge of the preceding node and p2
- ":tag" defines a local tag for the preceding node
- "@branch" sets the named branch for subsequent nodes
- "#...\\n" is a comment up to the end of the line
Whitespace between the above elements is ignored.
A backref is either
- a number n, which references the node curr-n, where curr is the current
node, or
- the name of a local tag you placed earlier using ":tag", or
- empty to denote the default parent.
All string valued-elements are either strictly alphanumeric, or must
Martin Geisler
debugbuilddag: escape backslash properly in help string
r11881 be enclosed in double quotes ("..."), with "\\" as escape character.
Peter Arrenbrecht
debugbuilddag: build a changelog dag from a concise description...
r11337 """
Martin Geisler
debugbuilddag: read DAG from stdin if not given on cmdline
r14283 if text is None:
ui.status(_("reading DAG from stdin\n"))
Idan Kamara
commands: use ui descriptors when reading/writing from stdin/out
r14639 text = ui.fin.read()
Martin Geisler
debugbuilddag: read DAG from stdin if not given on cmdline
r14283
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 cl = repo.changelog
if len(cl) > 0:
Martin Geisler
commands: get rid of generic exception in debugbuilddag
r11342 raise util.Abort(_('repository is not empty'))
Peter Arrenbrecht
debugbuilddag: build a changelog dag from a concise description...
r11337
Martin Geisler
debugbuilddag: output progress information
r14279 # determine number of revs in DAG
total = 0
for type, data in dagparser.parsedag(text):
if type == 'n':
total += 1
Peter Arrenbrecht
debugbuilddag: build a changelog dag from a concise description...
r11337
if mergeable_file:
linesperrev = 2
# make a file with k lines per rev
Martin Geisler
debugbuilddag: output progress information
r14279 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 initialmergedlines.append("")
tags = []
Mads Kiilerich
debugbuilddag: lock repo before starting transaction
r15875 lock = tr = None
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 try:
Mads Kiilerich
debugbuilddag: lock repo before starting transaction
r15875 lock = repo.lock()
tr = repo.transaction("builddag")
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163
at = -1
atbranch = 'default'
nodeids = []
Wagner Bruna
debugbuilddag: fix starting a dag on a non-default branch
r16219 id = 0
ui.progress(_('building'), id, unit=_('revisions'), total=total)
Peter Arrenbrecht
debugbuilddag: build a changelog dag from a concise description...
r11337 for type, data in dagparser.parsedag(text):
if type == 'n':
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.note(('node %s\n' % str(data)))
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 id, ps = data
files = []
fctxs = {}
p2 = None
if mergeable_file:
fn = "mf"
p1 = repo[ps[0]]
if len(ps) > 1:
p2 = repo[ps[1]]
pa = p1.ancestor(p2)
Augie Fackler
commands: fix implicit tuple that is invalid syntax in Python3
r18181 base, local, other = [x[fn].data() for x in (pa, p1,
p2)]
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 m3 = simplemerge.Merge3Text(base, local, other)
ml = [l.strip() for l in m3.merge_lines()]
ml.append("")
elif at > 0:
ml = p1[fn].data().split("\n")
else:
ml = initialmergedlines
ml[id * linesperrev] += " r%i" % id
mergedtext = "\n".join(ml)
files.append(fn)
Sean Farley
memfilectx: call super.__init__ instead of duplicating code...
r21689 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163
if overwritten_file:
fn = "of"
files.append(fn)
Sean Farley
memfilectx: call super.__init__ instead of duplicating code...
r21689 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163
if new_file:
fn = "nf%i" % id
files.append(fn)
Sean Farley
memfilectx: call super.__init__ instead of duplicating code...
r21689 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 if len(ps) > 1:
if not p2:
p2 = repo[ps[1]]
for fn in p2:
if fn.startswith("nf"):
files.append(fn)
fctxs[fn] = p2[fn]
def fctxfn(repo, cx, path):
return fctxs.get(path)
if len(ps) == 0 or ps[0] < 0:
pars = [None, None]
elif len(ps) == 1:
pars = [nodeids[ps[0]], None]
else:
pars = [nodeids[p] for p in ps]
cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
date=(id, 0),
user="debugbuilddag",
extra={'branch': atbranch})
nodeid = repo.commitctx(cx)
nodeids.append(nodeid)
at = id
elif type == 'l':
id, name = data
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.note(('tag %s\n' % name))
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
elif type == 'a':
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.note(('branch %s\n' % data))
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 atbranch = data
Martin Geisler
debugbuilddag: output progress information
r14279 ui.progress(_('building'), id, unit=_('revisions'), total=total)
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 tr.close()
Mads Kiilerich
debugbuilddag: lock repo before starting transaction
r15875
if tags:
repo.opener.write("localtags", "".join(tags))
Peter Arrenbrecht
debugbuilddag: use memctx for speed...
r14163 finally:
Martin Geisler
debugbuilddag: output progress information
r14279 ui.progress(_('building'), None)
Mads Kiilerich
debugbuilddag: lock repo before starting transaction
r15875 release(tr, lock)
Peter Arrenbrecht
debugbuilddag: build a changelog dag from a concise description...
r11337
Gregory Szorc
commands: define norepo in command decorator
r21768 @command('debugbundle',
[('a', 'all', None, _('show all details'))],
_('FILE'),
norepo=True)
Peter Arrenbrecht
commands: add debugbundle command...
r13724 def debugbundle(ui, bundlepath, all=None, **opts):
"""lists the contents of a bundle"""
Siddharth Agarwal
url: use open and not url.open for local files (issue3624)
r17887 f = hg.openpath(ui, bundlepath)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 try:
Pierre-Yves David
bundle2: add a ui argument to readbundle...
r21064 gen = exchange.readbundle(ui, f, bundlepath)
Patrick Mezard
code indentation fixes
r13747 if all:
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
Patrick Mezard
code indentation fixes
r13747
def showchunks(named):
ui.write("\n%s\n" % named)
Benoit Boissinot
bundler: make parsechunk return the base revision of the delta
r14141 chain = None
Martin Geisler
check-code: flag 0/1 used as constant Boolean expression
r14494 while True:
Benoit Boissinot
unbundler: separate delta and header parsing...
r14144 chunkdata = gen.deltachunk(chain)
Peter Arrenbrecht
commands: add debugbundle command...
r13724 if not chunkdata:
break
node = chunkdata['node']
Patrick Mezard
code indentation fixes
r13747 p1 = chunkdata['p1']
p2 = chunkdata['p2']
cs = chunkdata['cs']
Benoit Boissinot
bundler: make parsechunk return the base revision of the delta
r14141 deltabase = chunkdata['deltabase']
delta = chunkdata['delta']
ui.write("%s %s %s %s %s %s\n" %
Patrick Mezard
code indentation fixes
r13747 (hex(node), hex(p1), hex(p2),
Benoit Boissinot
bundler: make parsechunk return the base revision of the delta
r14141 hex(cs), hex(deltabase), len(delta)))
chain = node
Patrick Mezard
code indentation fixes
r13747
Benoit Boissinot
unbundler: separate delta and header parsing...
r14144 chunkdata = gen.changelogheader()
Patrick Mezard
code indentation fixes
r13747 showchunks("changelog")
Benoit Boissinot
unbundler: separate delta and header parsing...
r14144 chunkdata = gen.manifestheader()
Patrick Mezard
code indentation fixes
r13747 showchunks("manifest")
Martin Geisler
check-code: flag 0/1 used as constant Boolean expression
r14494 while True:
Benoit Boissinot
unbundler: separate delta and header parsing...
r14144 chunkdata = gen.filelogheader()
if not chunkdata:
Patrick Mezard
code indentation fixes
r13747 break
Benoit Boissinot
unbundler: separate delta and header parsing...
r14144 fname = chunkdata['filename']
Patrick Mezard
code indentation fixes
r13747 showchunks(fname)
else:
Benoit Boissinot
unbundler: separate delta and header parsing...
r14144 chunkdata = gen.changelogheader()
Benoit Boissinot
bundler: make parsechunk return the base revision of the delta
r14141 chain = None
Martin Geisler
check-code: flag 0/1 used as constant Boolean expression
r14494 while True:
Benoit Boissinot
unbundler: separate delta and header parsing...
r14144 chunkdata = gen.deltachunk(chain)
Patrick Mezard
code indentation fixes
r13747 if not chunkdata:
break
node = chunkdata['node']
ui.write("%s\n" % hex(node))
Benoit Boissinot
bundler: make parsechunk return the base revision of the delta
r14141 chain = node
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 finally:
Peter Arrenbrecht
commands: add debugbundle command...
r13724 f.close()
Sune Foldager
order commands alphabetically
r14302 @command('debugcheckstate', [], '')
mpm@selenic.com
A bunch of parsing/help updates...
r596 def debugcheckstate(ui, repo):
"""validate the correctness of the current dirstate"""
mpm@selenic.com
add dirstate debugging commands...
r460 parent1, parent2 = repo.dirstate.parents()
Matt Mackall
use repo[changeid] to get a changectx
r6747 m1 = repo[parent1].manifest()
m2 = repo[parent2].manifest()
mpm@selenic.com
add dirstate debugging commands...
r460 errors = 0
Matt Mackall
dirstate: add __contains__ and make __getitem__ more useful...
r4906 for f in repo.dirstate:
state = repo.dirstate[f]
mpm@selenic.com
add dirstate debugging commands...
r460 if state in "nr" and f not in m1:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
mpm@selenic.com
add dirstate debugging commands...
r460 errors += 1
if state in "a" and f in m1:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
mpm@selenic.com
add dirstate debugging commands...
r460 errors += 1
if state in "m" and f not in m1 and f not in m2:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.warn(_("%s in state %s, but not in either manifest\n") %
mpm@selenic.com
Remove all remaining print statements...
r582 (f, state))
mpm@selenic.com
add dirstate debugging commands...
r460 errors += 1
for f in m1:
Matt Mackall
dirstate: add __contains__ and make __getitem__ more useful...
r4906 state = repo.dirstate[f]
mpm@selenic.com
add dirstate debugging commands...
r460 if state not in "nrm":
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
mpm@selenic.com
add dirstate debugging commands...
r460 errors += 1
if errors:
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 error = _(".hg/dirstate inconsistent with current parent's manifest")
raise util.Abort(error)
mpm@selenic.com
add dirstate debugging commands...
r460
Gregory Szorc
commands: define norepo in command decorator
r21768 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
Sune Foldager
order commands alphabetically
r14302 def debugcommands(ui, cmd='', *args):
"""list all available commands and options"""
for cmd, vals in sorted(table.iteritems()):
cmd = cmd.split('|')[0].strip('^')
opts = ', '.join([i[1] for i in vals[1]])
ui.write('%s: %s\n' % (cmd, opts))
@command('debugcomplete',
[('o', 'options', None, _('show the command options'))],
Gregory Szorc
commands: define norepo in command decorator
r21768 _('[-o] CMD'),
norepo=True)
Sune Foldager
order commands alphabetically
r14302 def debugcomplete(ui, cmd='', **opts):
"""returns the completion list associated with the given command"""
if opts.get('options'):
options = []
otables = [globalopts]
if cmd:
aliases, entry = cmdutil.findcmd(cmd, table, False)
otables.append(entry[1])
for t in otables:
for o in t:
if "(DEPRECATED)" in o[3]:
continue
if o[0]:
options.append('-%s' % o[0])
options.append('--%s' % o[1])
ui.write("%s\n" % "\n".join(options))
return
cmdlist = cmdutil.findpossible(cmd, table)
Matt Mackall
revset: add a debugrevspec command
r11276 if ui.verbose:
Sune Foldager
order commands alphabetically
r14302 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
ui.write("%s\n" % "\n".join(sorted(cmdlist)))
Matt Mackall
subrepo: introduce basic state parsing
r8812
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('debugdag',
[('t', 'tags', None, _('use tags as labels')),
('b', 'branches', None, _('annotate with branch names')),
('', 'dots', None, _('use dots for runs')),
('s', 'spaces', None, _('separate elements by spaces'))],
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 _('[OPTION]... [FILE [REV]...]'),
optionalrepo=True)
Peter Arrenbrecht
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text...
r11336 def debugdag(ui, repo, file_=None, *revs, **opts):
"""format the changelog or an index DAG as a concise textual description
If you pass a revlog index, the revlog's DAG is emitted. If you list
timeless@mozdev.org
en-us: labeled
r17500 revision numbers, they get labeled in the output as rN.
Peter Arrenbrecht
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text...
r11336
Otherwise, the changelog DAG of the current repo is emitted.
"""
spaces = opts.get('spaces')
dots = opts.get('dots')
if file_:
Adrian Buehlmann
move opener from util to scmutil
r13970 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
Peter Arrenbrecht
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text...
r11336 revs = set((int(r) for r in revs))
def events():
for r in rlog:
Brodie Rao
cleanup: eradicate long lines
r16683 yield 'n', (r, list(set(p for p in rlog.parentrevs(r)
if p != -1)))
Peter Arrenbrecht
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text...
r11336 if r in revs:
yield 'l', (r, "r%i" % r)
elif repo:
cl = repo.changelog
tags = opts.get('tags')
branches = opts.get('branches')
if tags:
labels = {}
for l, n in repo.tags().items():
labels.setdefault(cl.rev(n), []).append(l)
def events():
b = "default"
for r in cl:
if branches:
newb = cl.read(cl.node(r))[5]['branch']
if newb != b:
yield 'a', newb
b = newb
Brodie Rao
cleanup: eradicate long lines
r16683 yield 'n', (r, list(set(p for p in cl.parentrevs(r)
if p != -1)))
Peter Arrenbrecht
debugdag and debugindexdag: emit changelog/revlog DAGs as concise text...
r11336 if tags:
ls = labels.get(r)
if ls:
for l in ls:
yield 'l', (r, l)
else:
raise util.Abort(_('need repo for changelog dag'))
for line in dagparser.dagtextlines(events(),
addspaces=spaces,
wraplabels=True,
wrapannotations=True,
wrapnonlinear=dots,
usedots=dots,
maxlinewidth=70):
ui.write(line)
ui.write("\n")
Sune Foldager
debugindex etc.: add --changelog and --manifest options...
r14323 @command('debugdata',
[('c', 'changelog', False, _('open changelog')),
('m', 'manifest', False, _('open manifest'))],
_('-c|-m|FILE REV'))
Mads Kiilerich
check-code: check for spaces around = for named parameters
r19872 def debugdata(ui, repo, file_, rev=None, **opts):
Matt Mackall
revlog: simplify revlog version handling...
r4258 """dump the contents of a data file revision"""
Sune Foldager
debugindex etc.: add --changelog and --manifest options...
r14323 if opts.get('changelog') or opts.get('manifest'):
file_, rev = None, file_
elif rev is None:
raise error.CommandError('debugdata', _('invalid arguments'))
r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
Anupam Kapoor
Fix traceback during invalid rev identifier for debugdata
r1313 try:
ui.write(r.revision(r.lookup(rev)))
except KeyError:
Thomas Arendsen Hein
Never apply string formatting to generated errors with util.Abort....
r3072 raise util.Abort(_('invalid revision identifier %s') % rev)
mpm@selenic.com
Add debugdata for dumping revlog revision data
r1039
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('debugdate',
[('e', 'extended', None, _('try extended date formats'))],
Gregory Szorc
commands: define norepo in command decorator
r21768 _('[-e] DATE [RANGE]'),
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 norepo=True, optionalrepo=True)
Matt Mackall
Add date matching support...
r3812 def debugdate(ui, date, range=None, **opts):
Matt Mackall
add debugdate command
r3805 """parse and display a date"""
Matt Mackall
Add date matching support...
r3812 if opts["extended"]:
d = util.parsedate(date, util.extendeddateformats)
else:
d = util.parsedate(date)
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(("internal: %s %s\n") % d)
ui.write(("standard: %s\n") % util.datestr(d))
Matt Mackall
Add date matching support...
r3812 if range:
m = util.matchdate(range)
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(("match: %s\n") % m(d[0]))
Matt Mackall
add debugdate command
r3805
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('debugdiscovery',
[('', 'old', None, _('use old-style discovery')),
('', 'nonheads', None,
_('use old-style discovery with non-heads included')),
] + remoteopts,
_('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 def debugdiscovery(ui, repo, remoteurl="default", **opts):
"""runs the changeset discovery protocol in isolation"""
Brodie Rao
cleanup: eradicate long lines
r16683 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
opts.get('branch'))
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 remote = hg.peer(repo, opts, remoteurl)
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
# make sure tests are repeatable
random.seed(12323)
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 def doit(localheads, remoteheads, remote=remote):
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 if opts.get('old'):
if localheads:
Brodie Rao
cleanup: eradicate long lines
r16683 raise util.Abort('cannot use localheads with old style '
'discovery')
Peter Arrenbrecht
peer: introduce real peer classes...
r17192 if not util.safehasattr(remote, 'branches'):
# enable in-client legacy support
remote = localrepo.locallegacypeer(remote.local())
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
force=True)
common = set(common)
if not opts.get('nonheads'):
Mads Kiilerich <mads at kiilerich.com>
debugdiscovery: report heads in sorted order
r18254 ui.write(("unpruned common: %s\n") %
" ".join(sorted(short(n) for n in common)))
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 dag = dagutil.revlogdag(repo.changelog)
all = dag.ancestorset(dag.internalizeall(common))
common = dag.externalizeall(dag.headsetofconnecteds(all))
else:
common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
common = set(common)
rheads = set(hds)
lheads = set(repo.heads())
Mads Kiilerich <mads at kiilerich.com>
debugdiscovery: report heads in sorted order
r18254 ui.write(("common heads: %s\n") %
" ".join(sorted(short(n) for n in common)))
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 if lheads <= common:
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(("local is subset\n"))
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164 elif rheads <= common:
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(("remote is subset\n"))
Peter Arrenbrecht
discovery: add new set-based discovery...
r14164
serverlogs = opts.get('serverlog')
if serverlogs:
for filename in serverlogs:
logfile = open(filename, 'r')
try:
line = logfile.readline()
while line:
parts = line.strip().split(';')
op = parts[1]
if op == 'cg':
pass
elif op == 'cgss':
doit(parts[2].split(' '), parts[3].split(' '))
elif op == 'unb':
doit(parts[3].split(' '), parts[2].split(' '))
line = logfile.readline()
finally:
logfile.close()
else:
remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
opts.get('remote_head'))
localrevs = opts.get('local_head')
doit(localrevs, remoterevs)
Patrick Mezard
debugfileset: implement --rev, more tests
r17370 @command('debugfileset',
[('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
_('[-r REV] FILESPEC'))
def debugfileset(ui, repo, expr, **opts):
Matt Mackall
filesets: introduce basic fileset expression parser
r14511 '''parse and apply a fileset specification'''
Patrick Mezard
debugfileset: implement --rev, more tests
r17370 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
Matt Mackall
filesets: introduce basic fileset expression parser
r14511 if ui.verbose:
tree = fileset.parse(expr)[0]
ui.note(tree, "\n")
Matt Mackall
fileset: drop matchfn...
r14673
Augie Fackler
commands: use ctx.getfileset instead of fileset.getfileset
r20404 for f in ctx.getfileset(expr):
Matt Mackall
fileset: basic pattern and boolean support...
r14551 ui.write("%s\n" % f)
Matt Mackall
filesets: introduce basic fileset expression parser
r14511
Gregory Szorc
commands: define norepo in command decorator
r21768 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
Mads Kiilerich
check-code: check for spaces around = for named parameters
r19872 def debugfsinfo(ui, path="."):
Sune Foldager
order commands alphabetically
r14302 """show information detected about current filesystem"""
util.writefile('.debugfsinfo', '')
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
Matt Mackall
debugfs: add hardlink support reporting
r19616 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
Sune Foldager
order commands alphabetically
r14302 and 'yes' or 'no'))
os.unlink('.debugfsinfo')
@command('debuggetbundle',
[('H', 'head', [], _('id of head node'), _('ID')),
('C', 'common', [], _('id of common node'), _('ID')),
('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
Gregory Szorc
commands: define norepo in command decorator
r21768 _('REPO FILE [-H|-C ID]...'),
norepo=True)
Sune Foldager
order commands alphabetically
r14302 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
"""retrieves a bundle from a repo
Every ID must be a full-length hex node id string. Saves the bundle to the
given file.
"""
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 repo = hg.peer(ui, opts, repopath)
Sune Foldager
order commands alphabetically
r14302 if not repo.capable('getbundle'):
raise util.Abort("getbundle() not supported by target repository")
args = {}
if common:
args['common'] = [bin(s) for s in common]
if head:
args['heads'] = [bin(s) for s in head]
Benoit Boissinot
bundle-ng: add bundlecaps argument to getbundle() command
r19201 # TODO: get desired bundlecaps from command line.
args['bundlecaps'] = None
Sune Foldager
order commands alphabetically
r14302 bundle = repo.getbundle('debug', **args)
bundletype = opts.get('type', 'bzip2').lower()
btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
bundletype = btypes.get(bundletype)
if bundletype not in changegroup.bundletypes:
raise util.Abort(_('unknown bundle type specified with --type'))
changegroup.writebundle(bundle, bundlepath, bundletype)
@command('debugignore', [], '')
jfh
add debugignore which yields the combined ignore patten of the .hgignore files...
r13396 def debugignore(ui, repo, *values, **opts):
"""display the combined ignore pattern"""
ignore = repo.dirstate._ignore
Augie Fackler
debugignore: use getattr instead of hasattr
r14949 includepat = getattr(ignore, 'includepat', None)
if includepat is not None:
ui.write("%s\n" % includepat)
jfh
debugignore: catch the case when ignore.includepat doesn't exist...
r13406 else:
raise util.Abort(_("no ignore patterns found"))
jfh
add debugignore which yields the combined ignore patten of the .hgignore files...
r13396
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('debugindex',
Sune Foldager
debugindex etc.: add --changelog and --manifest options...
r14323 [('c', 'changelog', False, _('open changelog')),
('m', 'manifest', False, _('open manifest')),
('f', 'format', 0, _('revlog format'), _('FORMAT'))],
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 _('[-f FORMAT] -c|-m|FILE'),
optionalrepo=True)
Mads Kiilerich
check-code: check for spaces around = for named parameters
r19872 def debugindex(ui, repo, file_=None, **opts):
mpm@selenic.com
A bunch of parsing/help updates...
r596 """dump the contents of an index file"""
Sune Foldager
debugindex etc.: add --changelog and --manifest options...
r14323 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
Matt Mackall
debugindex: add --format flag to allow debugging parentdelta...
r12893 format = opts.get('format', 0)
if format not in (0, 1):
Martin Geisler
commands: mark strings for translation
r13470 raise util.Abort(_("unknown format %d") % format)
Matt Mackall
debugindex: add --format flag to allow debugging parentdelta...
r12893
Sune Foldager
debugindex: change output for generaldelta revlogs...
r14254 generaldelta = r.version & revlog.REVLOGGENERALDELTA
if generaldelta:
basehdr = ' delta'
else:
basehdr = ' base'
Matt Mackall
debugindex: add --format flag to allow debugging parentdelta...
r12893
if format == 0:
Sune Foldager
debugindex: change output for generaldelta revlogs...
r14254 ui.write(" rev offset length " + basehdr + " linkrev"
Matt Mackall
debugindex: add --format flag to allow debugging parentdelta...
r12893 " nodeid p1 p2\n")
elif format == 1:
ui.write(" rev flag offset length"
Brodie Rao
cleanup: eradicate long lines
r16683 " size " + basehdr + " link p1 p2"
" nodeid\n")
Matt Mackall
debugindex: add --format flag to allow debugging parentdelta...
r12893
Matt Mackall
add __len__ and __iter__ methods to repo and revlog
r6750 for i in r:
mason@suse.com
Implement revlogng....
r2072 node = r.node(i)
Sune Foldager
debugindex: change output for generaldelta revlogs...
r14254 if generaldelta:
base = r.deltaparent(i)
else:
base = r.chainbase(i)
Matt Mackall
debugindex: add --format flag to allow debugging parentdelta...
r12893 if format == 0:
try:
pp = r.parents(node)
Brodie Rao
cleanup: replace naked excepts with except Exception: ...
r16689 except Exception:
Matt Mackall
debugindex: add --format flag to allow debugging parentdelta...
r12893 pp = [nullid, nullid]
ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
Sune Foldager
debugindex: change output for generaldelta revlogs...
r14254 i, r.start(i), r.length(i), base, r.linkrev(i),
Matt Mackall
debugindex: add --format flag to allow debugging parentdelta...
r12893 short(node), short(pp[0]), short(pp[1])))
elif format == 1:
pr = r.parentrevs(i)
ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
Sune Foldager
debugindex: change output for generaldelta revlogs...
r14254 base, r.linkrev(i), pr[0], pr[1], short(node)))
mpm@selenic.com
migrate remaining commands...
r248
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
Sune Foldager
debugindex(dot): try to access filelogs through repo, if possible...
r12132 def debugindexdot(ui, repo, file_):
timeless
Improve English for help text of many core hg commands....
r8779 """dump an index DAG as a graphviz dot file"""
Sune Foldager
debugindex(dot): try to access filelogs through repo, if possible...
r12132 r = None
if repo:
filelog = repo.file(file_)
if len(filelog):
r = filelog
if not r:
Adrian Buehlmann
move opener from util to scmutil
r13970 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(("digraph G {\n"))
Matt Mackall
add __len__ and __iter__ methods to repo and revlog
r6750 for i in r:
Samuel Masham
Update debugindexdot to work with RevlogNG.
r2287 node = r.node(i)
pp = r.parents(node)
ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
if pp[1] != nullid:
ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
mpm@selenic.com
Remove all remaining print statements...
r582 ui.write("}\n")
mpm@selenic.com
migrate remaining commands...
r248
Gregory Szorc
commands: define norepo in command decorator
r21768 @command('debuginstall', [], '', norepo=True)
Matt Mackall
Add debuginstall command to do basic install tests
r3844 def debuginstall(ui):
Matt Mackall
commands: initial audit of exit codes...
r11177 '''test Mercurial installation
Returns 0 on success.
'''
Matt Mackall
Add debuginstall command to do basic install tests
r3844
Matt Mackall
Make debuginstall actually attempt to use external patch and merge...
r3846 def writetemp(contents):
Thomas Arendsen Hein
Use a prefix for debuginstall tempfiles....
r4849 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
Matt Mackall
Make debuginstall actually attempt to use external patch and merge...
r3846 f = os.fdopen(fd, "wb")
f.write(contents)
f.close()
return name
Matt Mackall
Add debuginstall command to do basic install tests
r3844 problems = 0
# encoding
Martin Geisler
debuginstall: lowercase status messages
r16934 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
Matt Mackall
Add debuginstall command to do basic install tests
r3844 try:
Matt Mackall
move encoding bits from util to encoding...
r7948 encoding.fromlocal("test")
Matt Mackall
Add debuginstall command to do basic install tests
r3844 except util.Abort, inst:
ui.write(" %s\n" % inst)
Matt Mackall
Add some remedies and a username check to debuginstall
r3848 ui.write(_(" (check that your locale is properly set)\n"))
Matt Mackall
Add debuginstall command to do basic install tests
r3844 problems += 1
Chris Jerdonek
debuginstall: add Python information to debuginstall output (issue4128)...
r20740 # Python
Matt Mackall
debuginstall: change showing to checking for consistency and future checking
r20741 ui.status(_("checking Python executable (%s)\n") % sys.executable)
ui.status(_("checking Python version (%s)\n")
Chris Jerdonek
debuginstall: add Python information to debuginstall output (issue4128)...
r20740 % ("%s.%s.%s" % sys.version_info[:3]))
Adrian Buehlmann
debuginstall: show directory for Python lib...
r17392 ui.status(_("checking Python lib (%s)...\n")
% os.path.dirname(os.__file__))
Matt Mackall
Add debuginstall command to do basic install tests
r3844 # compiled modules
Martin Geisler
debuginstall: lowercase status messages
r16934 ui.status(_("checking installed modules (%s)...\n")
Matt Mackall
debuginstall: report installpath
r12004 % os.path.dirname(__file__))
Matt Mackall
Add debuginstall command to do basic install tests
r3844 try:
Matt Mackall
debuginstall: report installpath
r12004 import bdiff, mpatch, base85, osutil
Matt Mackall
pyflakes: clean up some import noise
r15223 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
Matt Mackall
Add debuginstall command to do basic install tests
r3844 except Exception, inst:
ui.write(" %s\n" % inst)
Matt Mackall
Add some remedies and a username check to debuginstall
r3848 ui.write(_(" One or more extensions could not be found"))
ui.write(_(" (check that you compiled the extensions)\n"))
Matt Mackall
Add debuginstall command to do basic install tests
r3844 problems += 1
# templates
Matt Mackall
debuginstall: report the template path
r15200 import templater
p = templater.templatepath()
Martin Geisler
debuginstall: lowercase status messages
r16934 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
Simon Heimberg
commands: hg debuginstall checks missing templates (issue4151)...
r20389 if p:
m = templater.templatepath("map-cmdline.default")
if m:
# template found, check if it is working
try:
templater.templater(m)
except Exception, inst:
ui.write(" %s\n" % inst)
p = None
else:
ui.write(_(" template 'default' not found\n"))
p = None
else:
ui.write(_(" no template directories found\n"))
if not p:
Matt Mackall
Add some remedies and a username check to debuginstall
r3848 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
Matt Mackall
Add debuginstall command to do basic install tests
r3844 problems += 1
# editor
Martin Geisler
debuginstall: lowercase status messages
r16934 ui.status(_("checking commit editor...\n"))
Osku Salerma
Use VISUAL in addition to EDITOR when choosing the editor to use.
r5660 editor = ui.geteditor()
Alexandre Garnier
debuginstall: handle quoted path for editor (issue4316)...
r21957 cmdpath = util.findexe(shlex.split(editor)[0])
Matt Mackall
Add debuginstall command to do basic install tests
r3844 if not cmdpath:
Benoit Boissinot
debuginstall: fix a copy/paste error
r3855 if editor == 'vi':
Matt Mackall
Add debuginstall command to do basic install tests
r3844 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
Brodie Rao
help: refer to user configuration file more consistently...
r12083 ui.write(_(" (specify a commit editor in your configuration"
" file)\n"))
Matt Mackall
Add debuginstall command to do basic install tests
r3844 else:
ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
Brodie Rao
help: refer to user configuration file more consistently...
r12083 ui.write(_(" (specify a commit editor in your configuration"
" file)\n"))
Matt Mackall
Add debuginstall command to do basic install tests
r3844 problems += 1
Matt Mackall
Add some remedies and a username check to debuginstall
r3848 # check username
Martin Geisler
debuginstall: lowercase status messages
r16934 ui.status(_("checking username...\n"))
Martin Geisler
commands: call ui.username carefully in debuginstall...
r9734 try:
Brodie Rao
cleanup: remove unused variables
r12063 ui.username()
Martin Geisler
commands: call ui.username carefully in debuginstall...
r9734 except util.Abort, e:
ui.write(" %s\n" % e)
Brodie Rao
help: refer to user configuration file more consistently...
r12083 ui.write(_(" (specify a username in your configuration file)\n"))
Martin Geisler
commands: call ui.username carefully in debuginstall...
r9734 problems += 1
Matt Mackall
Add some remedies and a username check to debuginstall
r3848
Matt Mackall
Add debuginstall command to do basic install tests
r3844 if not problems:
Martin Geisler
debuginstall: lowercase status messages
r16934 ui.status(_("no problems detected\n"))
Matt Mackall
Add debuginstall command to do basic install tests
r3844 else:
ui.write(_("%s problems detected,"
" please check your install!\n") % problems)
return problems
Gregory Szorc
commands: define norepo in command decorator
r21768 @command('debugknown', [], _('REPO ID...'), norepo=True)
Sune Foldager
order commands alphabetically
r14302 def debugknown(ui, repopath, *ids, **opts):
"""test whether node ids are known to a repo
Brodie Rao
cleanup: eradicate long lines
r16683 Every ID must be a full-length hex node id string. Returns a list of 0s
and 1s indicating unknown/known.
Sune Foldager
order commands alphabetically
r14302 """
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 repo = hg.peer(ui, opts, repopath)
Sune Foldager
order commands alphabetically
r14302 if not repo.capable('known'):
raise util.Abort("known() not supported by target repository")
flags = repo.known([bin(s) for s in ids])
ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
Bryan O'Sullivan
completion: add a debuglabelcomplete command...
r18790 @command('debuglabelcomplete', [], _('LABEL...'))
def debuglabelcomplete(ui, repo, *args):
'''complete "labels" - tags, open branch names, bookmark names'''
labels = set()
labels.update(t[0] for t in repo.tagslist())
labels.update(repo._bookmarks.keys())
Brodie Rao
debuglabelcomplete: simplify with repo.branchmap().iterbranches()
r20191 labels.update(tag for (tag, heads, tip, closed)
in repo.branchmap().iterbranches() if not closed)
Bryan O'Sullivan
completion: add a debuglabelcomplete command...
r18790 completions = set()
if not args:
args = ['']
for a in args:
completions.update(l for l in labels if l.startswith(a))
ui.write('\n'.join(sorted(completions)))
ui.write('\n')
Pierre-Yves David
debugobsolete: add --flags option...
r17830 @command('debugobsolete',
[('', 'flags', 0, _('markers flag')),
] + commitopts2,
Pierre-Yves.David@ens-lyon.org
debugobsolete: list all obsolete marker if no argument are specified
r17074 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
def debugobsolete(ui, repo, precursor=None, *successors, **opts):
Pierre-Yves David
debugobsolete: improve command help...
r18657 """create arbitrary obsolete marker
Wagner Bruna
commands: fix typo in debugobsolete docstring
r18854 With no arguments, displays the list of obsolescence markers."""
Matt Mackall
branchmap: don't use ui.warn for debug message
r21789
Patrick Mezard
debugobsolete: do not traceback on invalid node identifiers
r17292 def parsenodeid(s):
try:
# We do not use revsingle/revrange functions here to accept
# arbitrary node identifiers, possibly not present in the
# local repository.
n = bin(s)
if len(n) != len(nullid):
raise TypeError()
return n
except TypeError:
raise util.Abort('changeset references must be full hexadecimal '
'node identifiers')
Pierre-Yves.David@ens-lyon.org
debugobsolete: list all obsolete marker if no argument are specified
r17074 if precursor is not None:
metadata = {}
if 'date' in opts:
metadata['date'] = opts['date']
metadata['user'] = opts['user'] or ui.username()
Patrick Mezard
debugobsolete: do not traceback on invalid node identifiers
r17292 succs = tuple(parsenodeid(succ) for succ in successors)
Pierre-Yves.David@ens-lyon.org
debugobsolete: list all obsolete marker if no argument are specified
r17074 l = repo.lock()
try:
Pierre-Yves David
obsolete: write obsolete marker inside a transaction...
r17126 tr = repo.transaction('debugobsolete')
try:
Pierre-Yves David
debugobsolete: add --flags option...
r17830 repo.obsstore.create(tr, parsenodeid(precursor), succs,
opts['flags'], metadata)
Pierre-Yves David
obsolete: write obsolete marker inside a transaction...
r17126 tr.close()
finally:
tr.release()
Pierre-Yves.David@ens-lyon.org
debugobsolete: list all obsolete marker if no argument are specified
r17074 finally:
l.release()
else:
Matt Mackall
debugobsolete: remove spurious ctx from variable name...
r17123 for m in obsolete.allmarkers(repo):
Pierre-Yves David
debugobsolete: extract marker display in a dedicated function...
r20470 cmdutil.showmarker(ui, m)
Pierre-Yves.David@ens-lyon.org
command: creation of obsolete marker...
r17071
Bryan O'Sullivan
completion: add a debugpathcomplete command...
r18792 @command('debugpathcomplete',
[('f', 'full', None, _('complete an entire path')),
('n', 'normal', None, _('show only normal files')),
('a', 'added', None, _('show only added files')),
('r', 'removed', None, _('show only removed files'))],
_('FILESPEC...'))
def debugpathcomplete(ui, repo, *specs, **opts):
'''complete part or all of a tracked path
This command supports shells that offer path name completion. It
currently completes only files already known to the dirstate.
Completion extends only to the next path segment unless
--full is specified, in which case entire paths are used.'''
def complete(path, acceptable):
dirstate = repo.dirstate
spec = os.path.normpath(os.path.join(os.getcwd(), path))
rootdir = repo.root + os.sep
if spec != repo.root and not spec.startswith(rootdir):
return [], []
if os.path.isdir(spec):
spec += '/'
spec = spec[len(rootdir):]
fixpaths = os.sep != '/'
if fixpaths:
spec = spec.replace(os.sep, '/')
speclen = len(spec)
fullpaths = opts['full']
files, dirs = set(), set()
adddir, addfile = dirs.add, files.add
for f, st in dirstate.iteritems():
if f.startswith(spec) and st[0] in acceptable:
if fixpaths:
f = f.replace('/', os.sep)
if fullpaths:
addfile(f)
continue
s = f.find(os.sep, speclen)
if s >= 0:
Sean Farley
pathcomplete: remove ambiguous entries for sole completion on a directory...
r20136 adddir(f[:s])
Bryan O'Sullivan
completion: add a debugpathcomplete command...
r18792 else:
addfile(f)
return files, dirs
acceptable = ''
if opts['normal']:
acceptable += 'nm'
if opts['added']:
acceptable += 'a'
if opts['removed']:
acceptable += 'r'
cwd = repo.getcwd()
if not specs:
specs = ['.']
files, dirs = set(), set()
for spec in specs:
f, d = complete(spec, acceptable or 'nmar')
files.update(f)
dirs.update(d)
Bryan O'Sullivan
pathcomplete: complete directories more conservatively...
r18796 files.update(dirs)
Bryan O'Sullivan
completion: add a debugpathcomplete command...
r18792 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
ui.write('\n')
Gregory Szorc
commands: define norepo in command decorator
r21768 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
Sune Foldager
order commands alphabetically
r14302 '''access the pushkey key/value protocol
With two args, list the keys in the given namespace.
With five args, set a key to new if it currently is set to old.
Reports success or failure.
'''
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 target = hg.peer(ui, {}, repopath)
Sune Foldager
order commands alphabetically
r14302 if keyinfo:
key, old, new = keyinfo
r = target.pushkey(namespace, key, old, new)
ui.status(str(r) + '\n')
return not r
else:
Mads Kiilerich <mads at kiilerich.com>
debugpushkey: list keys sorted
r18255 for k, v in sorted(target.listkeys(namespace).iteritems()):
Sune Foldager
order commands alphabetically
r14302 ui.write("%s\t%s\n" % (k.encode('string-escape'),
v.encode('string-escape')))
Matt Mackall
pvec: introduce pvecs
r16249 @command('debugpvec', [], _('A B'))
def debugpvec(ui, repo, a, b=None):
ca = scmutil.revsingle(repo, a)
cb = scmutil.revsingle(repo, b)
pa = pvec.ctxpvec(ca)
pb = pvec.ctxpvec(cb)
if pa == pb:
rel = "="
elif pa > pb:
rel = ">"
elif pa < pb:
rel = "<"
elif pa | pb:
rel = "|"
ui.write(_("a: %s\n") % pa)
ui.write(_("b: %s\n") % pb)
ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
(abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
pa.distance(pb), rel))
Mads Kiilerich
debugrebuildstate: rename to debugrebuilddirstate...
r18963 @command('debugrebuilddirstate|debugrebuildstate',
Sune Foldager
order commands alphabetically
r14302 [('r', 'rev', '', _('revision to rebuild to'), _('REV'))],
Mads Kiilerich
debugrebuildstate: clarify that rev can't be specified without -r...
r18961 _('[-r REV]'))
Mads Kiilerich
debugrebuildstate: rename to debugrebuilddirstate...
r18963 def debugrebuilddirstate(ui, repo, rev):
Mads Kiilerich
debugrebuildstate: clarify that rev can't be specified without -r...
r18961 """rebuild the dirstate as it would look like for the given revision
If no revision is specified the first current parent will be used.
The dirstate will be set to the files of the given revision.
The actual working directory content or existing dirstate
information such as adds or removes is not considered.
One use of this command is to make the next :hg:`status` invocation
check the actual file content.
"""
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 ctx = scmutil.revsingle(repo, rev)
Sune Foldager
order commands alphabetically
r14302 wlock = repo.wlock()
try:
repo.dirstate.rebuild(ctx.node(), ctx.manifest())
finally:
wlock.release()
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('debugrename',
[('r', 'rev', '', _('revision to debug'), _('REV'))],
_('[-r REV] FILE'))
Matt Mackall
refactor debugrenamed
r3652 def debugrename(ui, repo, file1, *pats, **opts):
bos@serpentine.internal.keyresearch.com
Add doc string for debugrename.
r1194 """dump rename information"""
Matt Mackall
refactor debugrenamed
r3652
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 ctx = scmutil.revsingle(repo, opts.get('rev'))
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(ctx, (file1,) + pats, opts)
Matt Mackall
context: add walk method
r6764 for abs in ctx.walk(m):
fctx = ctx[abs]
Matt Mackall
walk: pass match object to cmdutil.walk...
r6579 o = fctx.filelog().renamed(fctx.filenode())
Matt Mackall
walk: remove rel and exact returns
r6584 rel = m.rel(abs)
Matt Mackall
walk: pass match object to cmdutil.walk...
r6579 if o:
ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
Matt Mackall
refactor debugrenamed
r3652 else:
ui.write(_("%s not renamed\n") % rel)
mpm@selenic.com
Add some rename debugging support
r1116
Sune Foldager
debugindex etc.: add --changelog and --manifest options...
r14323 @command('debugrevlog',
[('c', 'changelog', False, _('open changelog')),
Matt Mackall
debugrevlog: add --dump flag to dump graphable per-revision statistics
r14326 ('m', 'manifest', False, _('open manifest')),
('d', 'dump', False, _('dump index data'))],
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 _('-c|-m|FILE'),
optionalrepo=True)
Mads Kiilerich
check-code: check for spaces around = for named parameters
r19872 def debugrevlog(ui, repo, file_=None, **opts):
Sune Foldager
add debugrevlog command...
r14304 """show data and statistics about a revlog"""
Sune Foldager
debugindex etc.: add --changelog and --manifest options...
r14323 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
Matt Mackall
debugrevlog: add --dump flag to dump graphable per-revision statistics
r14326
if opts.get("dump"):
numrevs = len(r)
Mads Kiilerich
debugrevlog: format columns (more) nicely when dumping index data
r21032 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
Matt Mackall
debugrevlog: add --dump flag to dump graphable per-revision statistics
r14326 " rawsize totalsize compression heads\n")
ts = 0
heads = set()
for rev in xrange(numrevs):
Matt Mackall
revlog: drop base() again...
r14371 dbase = r.deltaparent(rev)
if dbase == -1:
dbase = rev
Matt Mackall
debugrevlog: add --dump flag to dump graphable per-revision statistics
r14326 cbase = r.chainbase(rev)
p1, p2 = r.parentrevs(rev)
rs = r.rawsize(rev)
ts = ts + rs
heads -= set(r.parentrevs(rev))
heads.add(rev)
Mads Kiilerich
debugrevlog: format columns (more) nicely when dumping index data
r21032 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d %11d %5d\n" %
Matt Mackall
debugrevlog: add --dump flag to dump graphable per-revision statistics
r14326 (rev, p1, p2, r.start(rev), r.end(rev),
r.start(dbase), r.start(cbase),
r.start(p1), r.start(p2),
rs, ts, ts / r.end(rev), len(heads)))
return 0
Sune Foldager
add debugrevlog command...
r14304 v = r.version
format = v & 0xFFFF
flags = []
gdelta = False
if v & revlog.REVLOGNGINLINEDATA:
flags.append('inline')
if v & revlog.REVLOGGENERALDELTA:
gdelta = True
flags.append('generaldelta')
Sune Foldager
debugrevlog: many improvements
r14305 if not flags:
flags = ['(none)']
Sune Foldager
add debugrevlog command...
r14304
nummerges = 0
Sune Foldager
debugrevlog: many improvements
r14305 numfull = 0
Sune Foldager
add debugrevlog command...
r14304 numprev = 0
nump1 = 0
nump2 = 0
numother = 0
nump1prev = 0
nump2prev = 0
Sune Foldager
debugrevlog: many improvements
r14305 chainlengths = []
Sune Foldager
add debugrevlog command...
r14304
datasize = [None, 0, 0L]
Sune Foldager
debugrevlog: many improvements
r14305 fullsize = [None, 0, 0L]
Sune Foldager
add debugrevlog command...
r14304 deltasize = [None, 0, 0L]
def addsize(size, l):
if l[0] is None or size < l[0]:
l[0] = size
if size > l[1]:
l[1] = size
l[2] += size
numrevs = len(r)
for rev in xrange(numrevs):
p1, p2 = r.parentrevs(rev)
delta = r.deltaparent(rev)
if format > 0:
addsize(r.rawsize(rev), datasize)
if p2 != nullrev:
nummerges += 1
size = r.length(rev)
if delta == nullrev:
Sune Foldager
debugrevlog: many improvements
r14305 chainlengths.append(0)
numfull += 1
addsize(size, fullsize)
Sune Foldager
add debugrevlog command...
r14304 else:
Sune Foldager
debugrevlog: many improvements
r14305 chainlengths.append(chainlengths[delta] + 1)
Sune Foldager
add debugrevlog command...
r14304 addsize(size, deltasize)
Sune Foldager
debugrevlog: many improvements
r14305 if delta == rev - 1:
numprev += 1
if delta == p1:
nump1prev += 1
Sune Foldager
add debugrevlog command...
r14304 elif delta == p2:
Sune Foldager
debugrevlog: many improvements
r14305 nump2prev += 1
elif delta == p1:
nump1 += 1
elif delta == p2:
nump2 += 1
elif delta != nullrev:
numother += 1
Patrick Mezard
debugrevlog: handle numrevs == numfull case (issue3537)...
r17188 # Adjust size min value for empty cases
for size in (datasize, fullsize, deltasize):
if size[0] is None:
size[0] = 0
Sune Foldager
debugrevlog: many improvements
r14305 numdeltas = numrevs - numfull
numoprev = numprev - nump1prev - nump2prev
totalrawsize = datasize[2]
Sune Foldager
add debugrevlog command...
r14304 datasize[2] /= numrevs
Sune Foldager
debugrevlog: many improvements
r14305 fulltotal = fullsize[2]
fullsize[2] /= numfull
deltatotal = deltasize[2]
Patrick Mezard
debugrevlog: handle numrevs == numfull case (issue3537)...
r17188 if numrevs - numfull > 0:
deltasize[2] /= numrevs - numfull
Sune Foldager
debugrevlog: many improvements
r14305 totalsize = fulltotal + deltatotal
avgchainlen = sum(chainlengths) / numrevs
compratio = totalrawsize / totalsize
basedfmtstr = '%%%dd\n'
basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
def dfmtstr(max):
return basedfmtstr % len(str(max))
def pcfmtstr(max, padding=0):
return basepcfmtstr % (len(str(max)), ' ' * padding)
def pcfmt(value, total):
return (value, 100 * float(value) / total)
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('format : %d\n') % format)
ui.write(('flags : %s\n') % ', '.join(flags))
Sune Foldager
debugrevlog: many improvements
r14305
ui.write('\n')
fmt = pcfmtstr(totalsize)
fmt2 = dfmtstr(totalsize)
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('revisions : ') + fmt2 % numrevs)
ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
ui.write(('revisions : ') + fmt2 % numrevs)
ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
ui.write(('revision size : ') + fmt2 % totalsize)
ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
Sune Foldager
debugrevlog: many improvements
r14305
ui.write('\n')
fmt = dfmtstr(max(avgchainlen, compratio))
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('avg chain length : ') + fmt % avgchainlen)
ui.write(('compression ratio : ') + fmt % compratio)
Sune Foldager
add debugrevlog command...
r14304
if format > 0:
Sune Foldager
debugrevlog: many improvements
r14305 ui.write('\n')
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
Sune Foldager
add debugrevlog command...
r14304 % tuple(datasize))
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
Sune Foldager
debugrevlog: many improvements
r14305 % tuple(fullsize))
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
Sune Foldager
add debugrevlog command...
r14304 % tuple(deltasize))
Sune Foldager
debugrevlog: many improvements
r14305 if numdeltas > 0:
ui.write('\n')
fmt = pcfmtstr(numdeltas)
fmt2 = pcfmtstr(numdeltas, 4)
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
Sune Foldager
debugrevlog: many improvements
r14305 if numprev > 0:
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
Brodie Rao
cleanup: eradicate long lines
r16683 numprev))
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
Brodie Rao
cleanup: eradicate long lines
r16683 numprev))
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
Brodie Rao
cleanup: eradicate long lines
r16683 numprev))
Sune Foldager
debugrevlog: many improvements
r14305 if gdelta:
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('deltas against p1 : ')
+ fmt % pcfmt(nump1, numdeltas))
ui.write(('deltas against p2 : ')
+ fmt % pcfmt(nump2, numdeltas))
ui.write(('deltas against other : ') + fmt % pcfmt(numother,
Brodie Rao
cleanup: eradicate long lines
r16683 numdeltas))
Sune Foldager
add debugrevlog command...
r14304
Siddharth Agarwal
commands.debugrevspec: add an option to print the optimized expression tree...
r20497 @command('debugrevspec',
[('', 'optimize', None, _('print parsed tree after optimizing'))],
('REVSPEC'))
def debugrevspec(ui, repo, expr, **opts):
Patrick Mezard
debugrevspec: mention --verbose to print the parsed tree
r16104 """parse and apply a revision specification
Use --verbose to print the parsed tree before and after aliases
expansion.
"""
Sune Foldager
order commands alphabetically
r14302 if ui.verbose:
tree = revset.parse(expr)[0]
Patrick Mezard
debugrevspec: pretty print output...
r16218 ui.note(revset.prettyformat(tree), "\n")
Sune Foldager
order commands alphabetically
r14302 newtree = revset.findaliases(ui, tree)
if newtree != tree:
Patrick Mezard
debugrevspec: pretty print output...
r16218 ui.note(revset.prettyformat(newtree), "\n")
Siddharth Agarwal
commands.debugrevspec: add an option to print the optimized expression tree...
r20497 if opts["optimize"]:
weight, optimizedtree = revset.optimize(newtree, True)
ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
Sune Foldager
order commands alphabetically
r14302 func = revset.match(ui, expr)
Lucas Moscovicz
revset: changed revsets to use spanset...
r20526 for c in func(repo, revset.spanset(repo)):
Sune Foldager
order commands alphabetically
r14302 ui.write("%s\n" % c)
@command('debugsetparents', [], _('REV1 [REV2]'))
def debugsetparents(ui, repo, rev1, rev2=None):
"""manually set the parents of the current working directory
This is useful for writing repository conversion tools, but should
be used with care.
Returns 0 on success.
"""
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 r1 = scmutil.revsingle(repo, rev1).node()
r2 = scmutil.revsingle(repo, rev2, 'null').node()
Sune Foldager
order commands alphabetically
r14302
wlock = repo.wlock()
try:
Patrick Mezard
localrepo: add setparents() to adjust dirstate copies (issue3407)...
r16551 repo.setparents(r1, r2)
Sune Foldager
order commands alphabetically
r14302 finally:
wlock.release()
Mads Kiilerich
debugstate: rename to debugdirstate...
r18962 @command('debugdirstate|debugstate',
Sune Foldager
order commands alphabetically
r14302 [('', 'nodates', None, _('do not display the saved mtime')),
('', 'datesort', None, _('sort by saved mtime'))],
_('[OPTION]...'))
def debugstate(ui, repo, nodates=None, datesort=None):
"""show the contents of the current dirstate"""
timestr = ""
showdate = not nodates
if datesort:
keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
else:
keyfunc = None # sort by filename
for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
if showdate:
if ent[3] == -1:
# Pad or slice to locale representation
locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
time.localtime(0)))
timestr = 'unset'
timestr = (timestr[:locale_len] +
' ' * (locale_len - len(timestr)))
else:
timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
time.localtime(ent[3]))
if ent[1] & 020000:
mode = 'lnk'
else:
Mads Kiilerich
windows: use umask 022 in debugstate output...
r15440 mode = '%3o' % (ent[1] & 0777 & ~util.umask)
Sune Foldager
order commands alphabetically
r14302 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
for f in repo.dirstate.copies():
ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
@command('debugsub',
[('r', 'rev', '',
_('revision to check'), _('REV'))],
_('[-r REV] [REV]'))
def debugsub(ui, repo, rev=None):
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 ctx = scmutil.revsingle(repo, rev, None)
Sune Foldager
order commands alphabetically
r14302 for k, v in sorted(ctx.substate.items()):
Matt Mackall
i18n: wrap false positives for translation detection
r17956 ui.write(('path %s\n') % k)
ui.write((' source %s\n') % v[0])
ui.write((' revision %s\n') % v[1])
Sune Foldager
order commands alphabetically
r14302
Pierre-Yves David
obsolete: compute successors set...
r18068 @command('debugsuccessorssets',
[],
_('[REV]'))
def debugsuccessorssets(ui, repo, *revs):
"""show set of successors for revision
A successors set of changeset A is a consistent group of revisions that
succeed A. It contains non-obsolete changesets only.
In most cases a changeset A has a single successors set containing a single
Wagner Bruna
debugsuccessorssets: fix typos in docstring
r18458 successor (changeset A replaced by A').
Pierre-Yves David
obsolete: compute successors set...
r18068
A changeset that is made obsolete with no successors are called "pruned".
Such changesets have no successors sets at all.
A changeset that has been "split" will have a successors set containing
Wagner Bruna
debugsuccessorssets: fix typos in docstring
r18458 more than one successor.
Pierre-Yves David
obsolete: compute successors set...
r18068
A changeset that has been rewritten in multiple different ways is called
"divergent". Such changesets have multiple successor sets (each of which
may also be split, i.e. have multiple successors).
Results are displayed as follows::
<rev1>
<successors-1A>
<rev2>
<successors-2A>
<successors-2B1> <successors-2B2> <successors-2B3>
Here rev2 has two possible (i.e. divergent) successors sets. The first
holds one element, whereas the second holds three (i.e. the changeset has
been split).
"""
# passed to successorssets caching computation from one call to another
cache = {}
ctx2str = str
node2str = short
if ui.debug():
def ctx2str(ctx):
return ctx.hex()
node2str = hex
for rev in scmutil.revrange(repo, revs):
ctx = repo[rev]
ui.write('%s\n'% ctx2str(ctx))
for succsset in obsolete.successorssets(repo, ctx.node(), cache):
if succsset:
ui.write(' ')
ui.write(node2str(succsset[0]))
for node in succsset[1:]:
ui.write(' ')
ui.write(node2str(node))
ui.write('\n')
Sune Foldager
order commands alphabetically
r14302
Gregory Szorc
commands: define inferrepo in command decorator
r21778 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
Bryan O'Sullivan
Clean up walk and changes code to use normalised names properly....
r820 def debugwalk(ui, repo, *pats, **opts):
Thomas Arendsen Hein
Added missing doc strings for two new debug commmands.
r1053 """show how files match on given patterns"""
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(repo[None], pats, opts)
Matt Mackall
walk: remove cmdutil.walk
r6585 items = list(repo.walk(m))
Thomas Arendsen Hein
Cleanups to commands.py
r1065 if not items:
return
Adrian Buehlmann
debugwalk: observe ui.slash config option
r16953 f = lambda fn: fn
if ui.configbool('ui', 'slash') and os.sep != '/':
f = lambda fn: util.normpath(fn)
Matt Mackall
walk: return a single value
r6586 fmt = 'f %%-%ds %%-%ds %%s' % (
max([len(abs) for abs in items]),
max([len(m.rel(abs)) for abs in items]))
for abs in items:
Adrian Buehlmann
debugwalk: observe ui.slash config option
r16953 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
Thomas Arendsen Hein
Make debugwalk strip trailing spaces and remove these from test-walk.out
r1309 ui.write("%s\n" % line.rstrip())
Bryan O'Sullivan
Clean up walk and changes code to use normalised names properly....
r820
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('debugwireargs',
[('', 'three', '', 'three'),
('', 'four', '', 'four'),
('', 'five', '', 'five'),
] + remoteopts,
Gregory Szorc
commands: define norepo in command decorator
r21768 _('REPO [OPTIONS]... [ONE [TWO]]'),
norepo=True)
Peter Arrenbrecht
debug: add debugwireargs to test argument passing over the wire...
r13720 def debugwireargs(ui, repopath, *vals, **opts):
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 repo = hg.peer(ui, opts, repopath)
Peter Arrenbrecht
debug: add debugwireargs to test argument passing over the wire...
r13720 for opt in remoteopts:
del opts[opt[1]]
args = {}
for k, v in opts.iteritems():
if v:
args[k] = v
# run twice to check that we don't mess up the stream for the next command
res1 = repo.debugwireargs(*vals, **args)
res2 = repo.debugwireargs(*vals, **args)
ui.write("%s\n" % res1)
if res1 != res2:
ui.warn("%s\n" % res2)
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^diff',
[('r', 'rev', [], _('revision'), _('REV')),
('c', 'change', '', _('change made by revision'), _('REV'))
] + diffopts + diffopts2 + walkopts + subrepoopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
inferrepo=True)
Bryan O'Sullivan
Convert diff command over to using walk code.
r732 def diff(ui, repo, *pats, **opts):
Benoit Boissinot
make all commands be repo-wide by default...
r1568 """diff repository (or selected files)
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Show differences between revisions for the specified files.
Differences between files are shown using the unified diff format.
Erik Zielke
Use note admonition
r12389 .. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Erik Zielke
Use note admonition
r12389 diff may generate unexpected results for merges, as it will
default to comparing against the working directory's first
parent changeset if no revisions are specified.
Matt Mackall
Add notes about diff/merge asymmetry to export, diff, and log
r3822
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 When two revision arguments are given, then changes are shown
between those revisions. If only one revision is specified then
that revision is compared to the working directory, and, when no
revisions are specified, the working directory files are compared
to its parent.
timeless
commands: correct diff -c explanation
r10527 Alternatively you can specify -c/--change with a revision to see
the changes in that changeset relative to its first parent.
timeless
commands: mention diff -c
r10520
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 Without the -a/--text option, diff will avoid generating diffs of
files it detects as binary. With -a, diff will generate a diff
anyway, probably with undesirable results.
Use the -g/--git option to generate diffs in the git extended diff
Martin Geisler
Use hg role in help strings
r10973 format. For more information, read :hg:`help diffs`.
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
diff: add help examples
r15110 .. container:: verbose
Examples:
- compare a file in the current working directory to its parent::
hg diff foo.c
- compare two historical versions of a directory, with rename info::
hg diff --git -r 1.0:1.2 lib/
- get change stats relative to the last change on some date::
hg diff --stat -r "date('may 2')"
- diff all newly-added files that contain a keyword::
hg diff "set:added() and grep(GNU)"
- compare a revision and its parents::
hg diff -c 9353 # compare against first parent
hg diff -r 9353^:9353 # same using revset syntax
hg diff -r 9353^2:9353 # compare against the second parent
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Stepan Koltsov
diff: add --change option to display single changeset diff (issue1420)
r7628
revs = opts.get('rev')
change = opts.get('change')
Brodie Rao
diff: add --stat for diffstat output...
r9640 stat = opts.get('stat')
Martin Geisler
diff: change --inverse to --reverse...
r9857 reverse = opts.get('reverse')
Stepan Koltsov
diff: add --change option to display single changeset diff (issue1420)
r7628
if revs and change:
msg = _('cannot specify --rev and --change at the same time')
raise util.Abort(msg)
elif change:
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 node2 = scmutil.revsingle(repo, change, None).node()
Matt Mackall
misc: replace .parents()[0] with p1()
r13878 node1 = repo[node2].p1().node()
Stepan Koltsov
diff: add --change option to display single changeset diff (issue1420)
r7628 else:
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 node1, node2 = scmutil.revpair(repo, revs)
mpm@selenic.com
big heap of command clean-up work...
r245
Martin Geisler
diff: change --inverse to --reverse...
r9857 if reverse:
Yannick Gingras
diff: add --inverse option...
r9725 node1, node2 = node2, node1
Brodie Rao
diffstat: with --git, mark binary files with Bin...
r9642 diffopts = patch.diffopts(ui, opts)
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(repo[node2], pats, opts)
Martin Geisler
diff: recurse into subrepositories with --subrepos/-S flag
r12167 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
listsubrepos=opts.get('subrepos'))
Thomas Arendsen Hein
Show revisions in diffs like CVS, based on a patch from Goffredo Baroncelli....
r396
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^export',
[('o', 'output', '',
_('print output to file with formatted name'), _('FORMAT')),
('', 'switch-parent', None, _('diff against the second parent')),
('r', 'rev', [], _('revisions to export'), _('REV')),
] + diffopts,
Mads Kiilerich
export: export working directory parent by default...
r18956 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
mpm@selenic.com
[PATCH] New export patch...
r580 def export(ui, repo, *changesets, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """dump the header and diffs for one or more changesets
Print the changeset header and diffs for one or more revisions.
Mads Kiilerich
export: export working directory parent by default...
r18956 If no revision is given, the parent of the working directory is used.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Steve Losh
commands: fix the list of changeset header information in 'hg help export'
r10334 The information shown in the changeset header is: author, date,
Steve Losh
commands: fix more changeset header information in 'hg help export'
r10335 branch name (if non-default), changeset hash, parent(s) and commit
comment.
Matt Mackall
Add notes about diff/merge asymmetry to export, diff, and log
r3822
Christian Ebert
Use more note admonitions in help texts
r12390 .. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Christian Ebert
Use more note admonitions in help texts
r12390 export may generate unexpected diff output for merge
changesets, as it will compare the merge changeset against its
first parent only.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Output may be to a file, in which case the name of the file is
Martin Geisler
commands: use field lists instead of literal blocks in docstrings...
r9892 given using a format string. The formatting rules are as follows:
:``%%``: literal "%" character
Matt Mackall
help: fix bytes/digit confusion for hashes...
r11718 :``%H``: changeset hash (40 hexadecimal digits)
Martin Geisler
commands: use field lists instead of literal blocks in docstrings...
r9892 :``%N``: number of patches being generated
:``%R``: changeset revision number
:``%b``: basename of the exporting repository
Matt Mackall
help: fix bytes/digit confusion for hashes...
r11718 :``%h``: short-form changeset hash (12 hexadecimal digits)
Andrzej Bieniek
export: add %m to file format string (first line of the commit message)...
r14986 :``%m``: first line of the commit message (only alphanumeric characters)
Martin Geisler
commands: use field lists instead of literal blocks in docstrings...
r9892 :``%n``: zero-padded sequence number, starting at 1
:``%r``: zero-padded changeset revision number
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 Without the -a/--text option, export will avoid generating diffs
of files it detects as binary. With -a, export will generate a
diff anyway, probably with undesirable results.
Use the -g/--git option to generate diffs in the git extended diff
Martin Geisler
Use hg role in help strings
r10973 format. See :hg:`help diffs` for more information.
Dirkjan Ochtman
help: commands supporting --git point to the gitdiffs topic (issue1352)
r7307
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 With the --switch-parent option, the diff will be against the
second parent. It can be useful to review a merge.
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
export: add help examples
r15111 .. container:: verbose
Examples:
- use export and import to transplant a bugfix to the current
branch::
hg export -r 9353 | hg import -
- export all the changesets between two revisions to a file with
rename information::
hg export --git -r 123:150 > changes.txt
- split outgoing changes into a series of patches with
descriptive names::
hg export -r "outgoing()" -o "%n-%m.patch"
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Alexander Solovyov
commands.export: accept -r option as revision specification...
r10015 changesets += tuple(opts.get('rev', []))
Mads Kiilerich
export: export working directory parent by default...
r18956 if not changesets:
changesets = ['.']
Thomas Arendsen Hein
export: catch exporting empty revsets (issue3353)...
r16357 revs = scmutil.revrange(repo, changesets)
if not revs:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 raise util.Abort(_("export requires at least one changeset"))
Vadim Gelfer
refactor text diff/patch code....
r2874 if len(revs) > 1:
ui.note(_('exporting patches:\n'))
else:
ui.note(_('exporting patch:\n'))
Benoit Boissinot
patch/diff: move patch.export() to cmdutil.export()...
r10611 cmdutil.export(repo, revs, template=opts.get('output'),
Alexander Solovyov
commands: optional options where possible...
r7131 switch_parent=opts.get('switch_parent'),
Matt Mackall
Move ui.diffopts to patch.diffopts where it belongs
r2888 opts=patch.diffopts(ui, opts))
mpm@selenic.com
Migrate rawcommit, import, export, history, and merge...
r246
Gregory Szorc
commands: define inferrepo in command decorator
r21778 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
Steve Losh
Add a forget command for easily untracking files....
r8902 def forget(ui, repo, *pats, **opts):
"""forget the specified files on the next commit
Mark the specified files so they will no longer be tracked
after the next commit.
This only removes files from the current branch, not from the
entire project history, and it does not delete them from the
working directory.
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 To undo a forget before the next commit, see :hg:`add`.
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
forget: add help examples
r15118 .. container:: verbose
Examples:
- forget newly-added binary files::
hg forget "set:added() and binary()"
- forget files that would be excluded by .hgignore::
hg forget "set:hgignore()"
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Steve Losh
Add a forget command for easily untracking files....
r8902 """
if not pats:
raise util.Abort(_('no files specified'))
David M. Carr
forget: fix subrepo recursion for explicit path handling...
r15912 m = scmutil.match(repo[None], pats, opts)
rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
return rejected and 1 or 0
Steve Losh
Add a forget command for easily untracking files....
r8902
Matt Mackall
graft: add user, date, and tool options
r15240 @command(
'graft',
Thomas Arendsen Hein
graft: allow -r to specify revisions
r16992 [('r', 'rev', [], _('revisions to graft'), _('REV')),
('c', 'continue', False, _('resume interrupted graft')),
Matt Mackall
graft: add --continue support
r15241 ('e', 'edit', False, _('invoke editor on commit messages')),
Levi Bard
graft: implement --log (issue3438)
r16660 ('', 'log', None, _('append graft info to log message')),
Siddharth Agarwal
graft: allow regrafting ancestors with --force (issue3220)
r21979 ('f', 'force', False, _('force graft')),
Matt Mackall
graft: add --continue support
r15241 ('D', 'currentdate', False,
_('record the current date as commit date')),
('U', 'currentuser', False,
_('record the current user as committer'), _('DATE'))]
Matt Mackall
graft: add --dry-run support (issue3362)
r16389 + commitopts2 + mergetoolopts + dryrunopts,
Thomas Arendsen Hein
graft: allow -r to specify revisions
r16992 _('[OPTION]... [-r] REV...'))
Matt Mackall
graft: add --continue support
r15241 def graft(ui, repo, *revs, **opts):
Matt Mackall
graft: add initial implementation
r15238 '''copy changes from other branches onto the current branch
This command uses Mercurial's merge logic to copy individual
changes from other branches without merging branches in the
history graph. This is sometimes known as 'backporting' or
Matt Mackall
graft: add examples and information about copied metadata
r15242 'cherry-picking'. By default, graft will copy user, date, and
description from the source changesets.
Matt Mackall
graft: add initial implementation
r15238
Changesets that are ancestors of the current revision, that have
already been grafted, or that are merges will be skipped.
Levi Bard
graft: implement --log (issue3438)
r16660 If --log is specified, log messages will have a comment appended
of the form::
(grafted from CHANGESETHASH)
Siddharth Agarwal
graft: allow regrafting ancestors with --force (issue3220)
r21979 If --force is specified, revisions will be grafted even if they
are already ancestors of or have been grafted to the destination.
This is useful when the revisions have since been backed out.
Matt Mackall
graft: add --continue support
r15241 If a graft merge results in conflicts, the graft process is
Kevin Bullock
graft: use consistent language in help...
r15701 interrupted so that the current merge can be manually resolved.
Once all conflicts are addressed, the graft process can be
continued with the -c/--continue option.
Matt Mackall
graft: add --continue support
r15241
.. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Siddharth Agarwal
graft: make --force apply across continues (issue3220)...
r21980 The -c/--continue option does not reapply earlier options, except
for --force.
Matt Mackall
graft: add --continue support
r15241
Matt Mackall
graft: add examples and information about copied metadata
r15242 .. container:: verbose
Examples:
- copy a single change to the stable branch and edit its description::
hg update stable
hg graft --edit 9393
- graft a range of changesets with one exception, updating dates::
hg graft -D "2085::2093 and not 2091"
- continue a graft after resolving conflicts::
hg graft -c
- show the source of a grafted changeset::
Matt Mackall
log: remove tip from example
r19401 hg log --debug -r .
Matt Mackall
graft: add examples and information about copied metadata
r15242
Alexander Becher
graft: add a reference to revsets to the help text (issue3362)
r21949 See :hg:`help revisions` and :hg:`help revsets` for more about
specifying revisions.
Matt Mackall
graft: add initial implementation
r15238 Returns 0 on successful completion.
'''
Thomas Arendsen Hein
graft: allow -r to specify revisions
r16992 revs = list(revs)
revs.extend(opts['rev'])
Matt Mackall
graft: add user, date, and tool options
r15240 if not opts.get('user') and opts.get('currentuser'):
opts['user'] = ui.username()
if not opts.get('date') and opts.get('currentdate'):
opts['date'] = "%d %d" % util.makedate()
FUJIWARA Katsunori
graft: pass 'editform' argument to 'cmdutil.getcommiteditor'...
r22008 editor = cmdutil.getcommiteditor(editform='graft', **opts)
Matt Mackall
graft: add --edit
r15239
Matt Mackall
graft: add --continue support
r15241 cont = False
if opts['continue']:
cont = True
if revs:
raise util.Abort(_("can't specify --continue and revisions"))
# read in unfinished revisions
try:
nodes = repo.opener.read('graftstate').splitlines()
revs = [repo[node].rev() for node in nodes]
except IOError, inst:
if inst.errno != errno.ENOENT:
raise
raise util.Abort(_("no graft state found, can't continue"))
else:
Matt Mackall
commands: add checks for unfinished operations (issue3955)...
r19476 cmdutil.checkunfinished(repo)
Matt Mackall
graft: add --continue support
r15241 cmdutil.bailifchanged(repo)
if not revs:
raise util.Abort(_('no revisions specified'))
revs = scmutil.revrange(repo, revs)
Matt Mackall
graft: add initial implementation
r15238
# check for merges
Matt Mackall
localrepo: convert various repo.set() users to repo.revs()
r15404 for rev in repo.revs('%ld and merge()', revs):
ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
revs.remove(rev)
Matt Mackall
graft: add initial implementation
r15238 if not revs:
return -1
Siddharth Agarwal
graft: make --force apply across continues (issue3220)...
r21980 # Don't check in the --continue case, in effect retaining --force across
# --continues. That's because without --force, any revisions we decided to
# skip would have been filtered out here, so they wouldn't have made their
# way to the graftstate. With --force, any revisions we would have otherwise
# skipped would not have been filtered out, and if they hadn't been applied
# already, they'd have been in the graftstate.
if not (cont or opts.get('force')):
# check for ancestors of dest branch
Siddharth Agarwal
graft: allow regrafting ancestors with --force (issue3220)
r21979 crev = repo['.'].rev()
ancestors = repo.changelog.ancestors([crev], inclusive=True)
# Cannot use x.remove(y) on smart set, this has to be a list.
# XXX make this lazy in the future
revs = list(revs)
# don't mutate while iterating, create a copy
for rev in list(revs):
if rev in ancestors:
ui.warn(_('skipping ancestor revision %s\n') % rev)
# XXX remove on list is slow
revs.remove(rev)
if not revs:
return -1
# analyze revs for earlier grafts
ids = {}
for ctx in repo.set("%ld", revs):
ids[ctx.hex()] = ctx.rev()
n = ctx.extra().get('source')
if n:
ids[n] = ctx.rev()
# check ancestors for earlier grafts
ui.debug('scanning for duplicate grafts\n')
for rev in repo.changelog.findmissingrevs(revs, [crev]):
ctx = repo[rev]
n = ctx.extra().get('source')
if n in ids:
r = repo[n].rev()
if r in revs:
ui.warn(_('skipping revision %s (already grafted to %s)\n')
% (r, rev))
revs.remove(r)
elif ids[n] in revs:
ui.warn(_('skipping already grafted revision %s '
'(%s also has origin %d)\n') % (ids[n], rev, r))
revs.remove(ids[n])
elif ctx.hex() in ids:
r = ids[ctx.hex()]
ui.warn(_('skipping already grafted revision %s '
'(was grafted from %d)\n') % (r, rev))
Matt Mackall
graft: fix duplicate filter logic
r15360 revs.remove(r)
Siddharth Agarwal
graft: allow regrafting ancestors with --force (issue3220)
r21979 if not revs:
return -1
Matt Mackall
graft: add initial implementation
r15238
Idan Kamara
commands: add missing wlock to graft
r16473 wlock = repo.wlock()
try:
David Schleimer
graft: explicit current node tracking...
r18039 current = repo['.']
Idan Kamara
commands: add missing wlock to graft
r16473 for pos, ctx in enumerate(repo.set("%ld", revs)):
ui.status(_('grafting revision %s\n') % ctx.rev())
if opts.get('dry_run'):
continue
David Schleimer
graft: move commit info building...
r18038 source = ctx.extra().get('source')
if not source:
source = ctx.hex()
extra = {'source': source}
user = ctx.user()
if opts.get('user'):
user = opts['user']
date = ctx.date()
if opts.get('date'):
date = opts['date']
message = ctx.description()
if opts.get('log'):
message += '\n(grafted from %s)' % ctx.hex()
Idan Kamara
commands: add missing wlock to graft
r16473 # we don't merge the first commit when continuing
if not cont:
# perform the graft merge with p1(rev) as 'ancestor'
try:
# ui.forcemerge is an internal variable, do not document
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
'graft')
Idan Kamara
commands: add missing wlock to graft
r16473 stats = mergemod.update(repo, ctx.node(), True, True, False,
Durham Goode
graft: customize graft conflict markers (BC)...
r21525 ctx.p1().node(),
labels=['local', 'graft'])
Idan Kamara
commands: add missing wlock to graft
r16473 finally:
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
Idan Kamara
commands: add missing wlock to graft
r16473 # report any conflicts
if stats and stats[3] > 0:
# write out state for --continue
nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
repo.opener.write('graftstate', ''.join(nodelines))
raise util.Abort(
_("unresolved conflicts, can't continue"),
hint=_('use hg resolve and hg graft --continue'))
else:
cont = False
Yuya Nishihara
graft: don't drop the second parent on unsuccessful merge (issue3498)...
r17045 # drop the second merge parent
repo.setparents(current.node(), nullid)
repo.dirstate.write()
# fix up dirstate for copies and renames
cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
Idan Kamara
commands: add missing wlock to graft
r16473 # commit
Levi Bard
graft: implement --log (issue3438)
r16660 node = repo.commit(text=message, user=user,
Idan Kamara
commands: add missing wlock to graft
r16473 date=date, extra=extra, editor=editor)
Matt Mackall
graft: remark on empty graft
r16600 if node is None:
ui.status(_('graft for revision %s is empty\n') % ctx.rev())
David Schleimer
graft: explicit current node tracking...
r18039 else:
current = repo[node]
Idan Kamara
commands: add missing wlock to graft
r16473 finally:
wlock.release()
Matt Mackall
graft: add initial implementation
r15238
Matt Mackall
graft: add --continue support
r15241 # remove state when we complete successfully
Mads Kiilerich
refactoring: use unlinkpath with ignoremissing
r18386 if not opts.get('dry_run'):
util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
Matt Mackall
graft: add --continue support
r15241
Matt Mackall
graft: add initial implementation
r15238 return 0
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('grep',
[('0', 'print0', None, _('end fields with NUL')),
('', 'all', None, _('print all revisions that match')),
('a', 'text', None, _('treat all files as text')),
('f', 'follow', None,
_('follow changeset history,'
' or file history across copies and renames')),
('i', 'ignore-case', None, _('ignore case when matching')),
('l', 'files-with-matches', None,
_('print only filenames and revisions that match')),
('n', 'line-number', None, _('print matching line numbers')),
('r', 'rev', [],
_('only search files changed within revision range'), _('REV')),
('u', 'user', None, _('list the author (long with -v)')),
('d', 'date', None, _('list the date (short with -q)')),
] + walkopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... PATTERN [FILE]...'),
inferrepo=True)
Thomas Arendsen Hein
Remove some options from 'hg grep':...
r1108 def grep(ui, repo, pattern, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """search for a pattern in specified files and revisions
Search revisions of files for a regular expression.
Christian Ebert
Consistently 1 space after full stops in command doc strings...
r6448 This command behaves differently than Unix grep. It only accepts
Python/Perl regexps. It searches repository history, not the
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 working directory. It always prints the revision number in which a
match appears.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
By default, grep only prints output for the first revision of a
Christian Ebert
Consistently 1 space after full stops in command doc strings...
r6448 file in which it finds a match. To get it to print every revision
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 that contains a change in match status ("-" for a match that
becomes a non-match, or "+" for a non-match that becomes a match),
use the --all flag.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 if a match is found, 1 otherwise.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
grep: make multiline mode the default (BC)...
r15765 reflags = re.M
Alexander Solovyov
commands: optional options where possible...
r7131 if opts.get('ignore_case'):
Thomas Arendsen Hein
Cleanups to commands.py
r1065 reflags |= re.I
Giorgos Keramidas
hg grep: handle re.compile errors & update tests/test-grep
r4877 try:
Siddharth Agarwal
commands: use util.re.compile instead of util.compilere
r21911 regexp = util.re.compile(pattern, reflags)
Brodie Rao
grep: only catch re.error when compiling regular expressions
r12385 except re.error, inst:
Thomas Arendsen Hein
Remove trailing ! from two error messages as this was confusing.
r6057 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
Matt Mackall
commands: initial audit of exit codes...
r11177 return 1
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 sep, eol = ':', '\n'
Alexander Solovyov
commands: optional options where possible...
r7131 if opts.get('print0'):
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 sep = eol = '\0'
Bryan O'Sullivan
Add grep command....
r1057
Matt Mackall
fix memory usage of revlog caches by limiting cache size [issue1639]
r9097 getfile = util.lrucachefunc(repo.file)
Bryan O'Sullivan
Add grep command....
r1057
def matchlines(body):
bos@serpentine.internal.keyresearch.com
grep: speed up matching, and only return one match per line.
r1059 begin = 0
linenum = 0
Kevin Bullock
grep: remove useless while condition...
r17949 while begin < len(body):
bos@serpentine.internal.keyresearch.com
grep: speed up matching, and only return one match per line.
r1059 match = regexp.search(body, begin)
Thomas Arendsen Hein
Cleanups to commands.py
r1065 if not match:
break
bos@serpentine.internal.keyresearch.com
grep: speed up matching, and only return one match per line.
r1059 mstart, mend = match.span()
linenum += body.count('\n', begin, mstart) + 1
lstart = body.rfind('\n', begin, mstart) + 1 or begin
Mads Kiilerich
grep: correct handling of matching lines without line ending (issue3050)...
r15293 begin = body.find('\n', mend) + 1 or len(body) + 1
Matt Mackall
grep: avoid infinite loop when trailing newline is missing
r7230 lend = begin - 1
bos@serpentine.internal.keyresearch.com
grep: speed up matching, and only return one match per line.
r1059 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
Bryan O'Sullivan
Add grep command....
r1057
Eric Hopper
Convert all classes to new-style classes by deriving them from object.
r1559 class linestate(object):
Bryan O'Sullivan
Add grep command....
r1057 def __init__(self, line, linenum, colstart, colend):
self.line = line
self.linenum = linenum
self.colstart = colstart
self.colend = colend
Brendan Cully
grep: display correct user/revision for --all in reverse....
r2869
Paul Moore
python 2.6 compatibility: add __hash__ to classes that have __eq__
r6469 def __hash__(self):
return hash((self.linenum, self.line))
Thomas Arendsen Hein
Cleanups to commands.py
r1065 def __eq__(self, other):
return self.line == other.line
Bryan O'Sullivan
Add grep command....
r1057
Takumi IINO
grep: highlight all matched words...
r21011 def __iter__(self):
yield (self.line[:self.colstart], '')
yield (self.line[self.colstart:self.colend], 'grep.match')
rest = self.line[self.colend:]
while rest != '':
match = regexp.search(rest)
if not match:
yield (rest, '')
break
mstart, mend = match.span()
yield (rest[:mstart], '')
yield (rest[mstart:mend], 'grep.match')
rest = rest[mend:]
Bryan O'Sullivan
Add grep command....
r1057 matches = {}
Brendan Cully
grep: add --follow support.
r2870 copies = {}
Bryan O'Sullivan
Add grep command....
r1057 def grepbody(fn, rev, body):
Brendan Cully
grep: display correct user/revision for --all in reverse....
r2869 matches[rev].setdefault(fn, [])
Bryan O'Sullivan
Add grep command....
r1057 m = matches[rev][fn]
for lnum, cstart, cend, line in matchlines(body):
s = linestate(line, lnum, cstart, cend)
Brendan Cully
grep: display correct user/revision for --all in reverse....
r2869 m.append(s)
def difflinestates(a, b):
sm = difflib.SequenceMatcher(None, a, b)
for tag, alo, ahi, blo, bhi in sm.get_opcodes():
if tag == 'insert':
Benoit Boissinot
use xrange instead of range
r3472 for i in xrange(blo, bhi):
Brendan Cully
grep: display correct user/revision for --all in reverse....
r2869 yield ('+', b[i])
elif tag == 'delete':
Benoit Boissinot
use xrange instead of range
r3472 for i in xrange(alo, ahi):
Brendan Cully
grep: display correct user/revision for --all in reverse....
r2869 yield ('-', a[i])
elif tag == 'replace':
Benoit Boissinot
use xrange instead of range
r3472 for i in xrange(alo, ahi):
Brendan Cully
grep: display correct user/revision for --all in reverse....
r2869 yield ('-', a[i])
Benoit Boissinot
use xrange instead of range
r3472 for i in xrange(blo, bhi):
Brendan Cully
grep: display correct user/revision for --all in reverse....
r2869 yield ('+', b[i])
Matt Mackall
walkchangerevs: internalize ctx caching
r9655 def display(fn, ctx, pstates, states):
rev = ctx.rev()
Thomas Arendsen Hein
Make annotae/grep print short dates with -q/--quiet....
r6134 datefunc = ui.quiet and util.shortdate or util.datestr
Benoit Boissinot
grep: remove count handling, simplify, fix issue337
r3951 found = False
FUJIWARA Katsunori
grep: reuse the first "util.binary()" result for efficiency...
r20836 @util.cachefunc
Md. O. Shayan
grep: don't print data from binary files for matches (issue2614)
r13920 def binary():
flog = getfile(fn)
return util.binary(flog.read(ctx.filenode(fn)))
Alexander Solovyov
commands: optional options where possible...
r7131 if opts.get('all'):
FUJIWARA Katsunori
compare grep result between target and its parent...
r8849 iter = difflinestates(pstates, states)
Brendan Cully
grep: display correct user/revision for --all in reverse....
r2869 else:
FUJIWARA Katsunori
compare grep result between target and its parent...
r8849 iter = [('', l) for l in states]
Benoit Boissinot
grep: remove count handling, simplify, fix issue337
r3951 for change, l in iter:
Idan Kamara
grep: colorize all fields...
r17806 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
Alexander Solovyov
commands: optional options where possible...
r7131 if opts.get('line_number'):
Idan Kamara
grep: colorize all fields...
r17806 cols.append((str(l.linenum), 'grep.linenumber'))
Alexander Solovyov
commands: optional options where possible...
r7131 if opts.get('all'):
Idan Kamara
grep: colorize all fields...
r17806 cols.append((change, 'grep.change'))
Alexander Solovyov
commands: optional options where possible...
r7131 if opts.get('user'):
Idan Kamara
grep: colorize all fields...
r17806 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
Thomas Arendsen Hein
Add hg grep -d/--date to list the commit date of matched revisions....
r6133 if opts.get('date'):
Idan Kamara
grep: colorize all fields...
r17806 cols.append((datefunc(ctx.date()), 'grep.date'))
for col, label in cols[:-1]:
ui.write(col, label=label)
ui.write(sep, label='grep.sep')
ui.write(cols[-1][0], label=cols[-1][1])
Takumi IINO
grep: highlight all matched words...
r21011 if not opts.get('files_with_matches'):
Idan Kamara
grep: colorize all fields...
r17806 ui.write(sep, label='grep.sep')
Md. O. Shayan
grep: don't print data from binary files for matches (issue2614)
r13920 if not opts.get('text') and binary():
Idan Kamara
grep: colorize all fields...
r17806 ui.write(" Binary file matches")
Md. O. Shayan
grep: don't print data from binary files for matches (issue2614)
r13920 else:
Takumi IINO
grep: highlight all matched words...
r21011 for s, label in l:
ui.write(s, label=label)
Brodie Rao
grep: make use of output labeling
r10816 ui.write(eol)
Benoit Boissinot
grep: remove count handling, simplify, fix issue337
r3951 found = True
Takumi IINO
grep: highlight all matched words...
r21011 if opts.get('files_with_matches'):
FUJIWARA Katsunori
grep: exit loop immediately, if matching is found in the file for "hg grep -l"...
r20838 break
Benoit Boissinot
grep: remove count handling, simplify, fix issue337
r3951 return found
Bryan O'Sullivan
Add grep command....
r1057
Bryan O'Sullivan
grep: change default to printing first matching rev....
r1145 skip = {}
FUJIWARA Katsunori
compare grep result between target and its parent...
r8849 revfiles = {}
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 matchfn = scmutil.match(repo[None], pats, opts)
Benoit Boissinot
grep: remove count handling, simplify, fix issue337
r3951 found = False
Brendan Cully
grep: add --follow support.
r2870 follow = opts.get('follow')
Matt Mackall
walkchangerevs: move 'add' to callback...
r9662
def prep(ctx, fns):
rev = ctx.rev()
Matt Mackall
misc: replace .parents()[0] with p1()
r13878 pctx = ctx.p1()
Matt Mackall
walkchangerevs: move 'add' to callback...
r9662 parent = pctx.rev()
matches.setdefault(rev, {})
matches.setdefault(parent, {})
files = revfiles.setdefault(rev, [])
for fn in fns:
flog = getfile(fn)
try:
fnode = ctx.filenode(fn)
except error.LookupError:
continue
copied = flog.renamed(fnode)
copy = follow and copied and copied[0]
if copy:
copies.setdefault(rev, {})[fn] = copy
if fn in skip:
if copy:
skip[copy] = True
continue
files.append(fn)
if fn not in matches[rev]:
grepbody(fn, rev, flog.read(fnode))
pfn = copy or fn
if pfn not in matches[parent]:
Bryan O'Sullivan
Add grep command....
r1057 try:
Matt Mackall
walkchangerevs: move 'add' to callback...
r9662 fnode = pctx.filenode(pfn)
grepbody(pfn, parent, flog.read(fnode))
Matt Mackall
errors: move revlog errors...
r7633 except error.LookupError:
Matt Mackall
walkchangerevs: move 'add' to callback...
r9662 pass
Matt Mackall
walkchangerevs: drop ui arg
r9665 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
Matt Mackall
walkchangerevs: move 'add' to callback...
r9662 rev = ctx.rev()
Matt Mackall
misc: replace .parents()[0] with p1()
r13878 parent = ctx.p1().rev()
Matt Mackall
walkchangerevs: move 'add' to callback...
r9662 for fn in sorted(revfiles.get(rev, [])):
states = matches[rev][fn]
copy = copies.get(rev, {}).get(fn)
if fn in skip:
FUJIWARA Katsunori
compare grep result between target and its parent...
r8849 if copy:
Matt Mackall
walkchangerevs: move 'add' to callback...
r9662 skip[copy] = True
continue
pstates = matches.get(parent, {}).get(copy or fn, [])
if pstates or states:
r = display(fn, ctx, pstates, states)
found = found or r
if r and not opts.get('all'):
skip[fn] = True
FUJIWARA Katsunori
compare grep result between target and its parent...
r8849 if copy:
skip[copy] = True
Matt Mackall
walkchangerevs: move 'add' to callback...
r9662 del matches[rev]
del revfiles[rev]
Bryan O'Sullivan
Add grep command....
r1057
Matt Mackall
commands: initial audit of exit codes...
r11177 return not found
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('heads',
[('r', 'rev', '',
_('show only heads which are descendants of STARTREV'), _('STARTREV')),
('t', 'topo', False, _('show topological heads only')),
('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
('c', 'closed', False, _('show normal and closed branch heads')),
] + templateopts,
Matt Mackall
help: drop -a from heads syntax summary (issue3483)
r16869 _('[-ct] [-r STARTREV] [REV]...'))
Eric Hopper
Add option to heads to show only heads for current branch.
r4648 def heads(ui, repo, *branchrevs, **opts):
Matt Mackall
heads: modernize documentation (issue3992)...
r19469 """show branch heads
With no arguments, show all open branch heads in the repository.
Matt Mackall
heads: fix children/descendants in doc (issue3992)
r19493 Branch heads are changesets that have no descendants on the
Matt Mackall
heads: modernize documentation (issue3992)...
r19469 same branch. They are where development generally takes place and
are the usual targets for update and merge operations.
If one or more REVs are given, only open branch heads on the
branches associated with the specified changesets are shown. This
means that you can use :hg:`heads .` to see the heads on the
currently checked-out branch.
Greg Ward
commands: tweak help for 'heads'....
r9502
If -c/--closed is specified, also show branch heads marked closed
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 (see :hg:`commit --close-branch`).
Greg Ward
commands: tweak help for 'heads'....
r9502
If STARTREV is specified, only those heads that are descendants of
STARTREV will be displayed.
Dirkjan Ochtman
commands: do all branch heads by default, demote topological to -t/--topo
r10350
If -t/--topo is specified, named branch mechanics will be ignored and only
Matt Mackall
heads: modernize documentation (issue3992)...
r19469 topological heads (changesets with no children) will be shown.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 if matching heads are found, 1 if not.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Dirkjan Ochtman
commands: simplify heads a little bit before I start hacking it up
r10328
Matt Mackall
commands: add revset support to most commands
r12925 start = None
if 'rev' in opts:
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 start = scmutil.revsingle(repo, opts['rev'], None).node()
Dirkjan Ochtman
commands: simplify heads a little bit before I start hacking it up
r10328
Dirkjan Ochtman
commands: do all branch heads by default, demote topological to -t/--topo
r10350 if opts.get('topo'):
heads = [repo[h] for h in repo.heads(start)]
Benoit Boissinot
add a -r/--rev option to heads to show only heads descendant from rev
r1550 else:
Dirkjan Ochtman
commands: externalize branchheads so we can do it for all branches at once
r10348 heads = []
Martin Geisler
commands: use repo.branchheads in heads command
r14466 for branch in repo.branchmap():
heads += repo.branchheads(branch, start, opts.get('closed'))
heads = [repo[h] for h in heads]
Dirkjan Ochtman
commands: do all branch heads by default, demote topological to -t/--topo
r10350
if branchrevs:
Matt Mackall
branch: operate on branch names in local string space where possible...
r13047 branches = set(repo[br].branch() for br in branchrevs)
Dirkjan Ochtman
commands: do all branch heads by default, demote topological to -t/--topo
r10350 heads = [h for h in heads if h.branch() in branches]
Dirkjan Ochtman
commands: simplify heads a little bit before I start hacking it up
r10328
Dirkjan Ochtman
commands: actually implement --closed for topological heads
r10349 if opts.get('active') and branchrevs:
dagheads = repo.heads(start)
Dirkjan Ochtman
commands: do all branch heads by default, demote topological to -t/--topo
r10350 heads = [h for h in heads if h.node() in dagheads]
Dirkjan Ochtman
commands: actually implement --closed for topological heads
r10349
if branchrevs:
Dirkjan Ochtman
commands: do all branch heads by default, demote topological to -t/--topo
r10350 haveheads = set(h.branch() for h in heads)
Dirkjan Ochtman
commands: don't do too much work for error messages
r10346 if branches - haveheads:
Matt Mackall
branch: operate on branch names in local string space where possible...
r13047 headless = ', '.join(b for b in branches - haveheads)
Dirkjan Ochtman
commands: don't do too much work for error messages
r10346 msg = _('no open branch heads found on branches %s')
if opts.get('rev'):
Matt Mackall
i18n: fix all remaining uses of % inside _()
r16231 msg += _(' (started at %s)') % opts['rev']
Dirkjan Ochtman
commands: don't do too much work for error messages
r10346 ui.warn((msg + '\n') % headless)
Eric Hopper
Add option to heads to show only heads for current branch.
r4648 if not heads:
return 1
Dirkjan Ochtman
commands: simplify heads a little bit before I start hacking it up
r10328
Dirkjan Ochtman
commands: do all branch heads by default, demote topological to -t/--topo
r10350 heads = sorted(heads, key=lambda x: -x.rev())
Matt Mackall
templates: move changeset templating bits to cmdutils
r3643 displayer = cmdutil.show_changeset(ui, repo, opts)
Dirkjan Ochtman
commands: always order heads recent to oldest
r10331 for ctx in heads:
displayer.show(ctx)
Robert Bachmann
Added support for templatevar "footer" to cmdutil.py
r10152 displayer.close()
mpm@selenic.com
Beginning of multi-head support...
r221
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('help',
[('e', 'extension', None, _('show only help for extensions')),
Augie Fackler
help: add --keyword (-k) for searching help
r16711 ('c', 'command', None, _('show only help for commands')),
('k', 'keyword', '', _('show topics matching keyword')),
],
Gregory Szorc
commands: define norepo in command decorator
r21768 _('[-ec] [TOPIC]'),
norepo=True)
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 def help_(ui, name=None, **opts):
Matt Mackall
help: update help...
r7210 """show help for a given topic or a help overview
Matt Mackall
alphabetize help_ in commands
r3655
timeless
Improve English for help text of many core hg commands....
r8779 With no arguments, print a list of commands with short help messages.
Matt Mackall
alphabetize help_ in commands
r3655
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 Given a topic, extension, or command name, print help for that
Matt Mackall
commands: initial audit of exit codes...
r11177 topic.
Returns 0 if successful.
"""
Matt Mackall
help: move option text display into a helper function
r15023
Dirkjan Ochtman
help: limit documentation width to at most 80 characters...
r13608 textwidth = min(ui.termwidth(), 80) - 2
Matt Mackall
alphabetize help_ in commands
r3655
Olav Reinert
help: format all output using RST...
r16854 keep = ui.verbose and ['verbose'] or []
Dan Villiom Podlaski Christiansen
help: move the majority of the help command to the help module...
r18746 text = help.help_(ui, name, **opts)
FUJIWARA Katsunori
help: indicate help omitting if help document is not fully displayed...
r17837 formatted, pruned = minirst.format(text, textwidth, keep=keep)
if 'verbose' in pruned:
keep.append('omitted')
else:
keep.append('notomitted')
formatted, pruned = minirst.format(text, textwidth, keep=keep)
Olav Reinert
help: format all output using RST...
r16854 ui.write(formatted)
Johannes Stezenbach
help: list special help topics with -v
r6653
mpm@selenic.com
Beginning of multi-head support...
r221
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('identify|id',
[('r', 'rev', '',
_('identify the specified revision'), _('REV')),
('n', 'num', None, _('show local revision number')),
('i', 'id', None, _('show global revision id')),
('b', 'branch', None, _('show branch')),
('t', 'tags', None, _('show tags')),
Mads Kiilerich
id: add command line options for handling ssh and https urls
r15580 ('B', 'bookmarks', None, _('show bookmarks')),
] + remoteopts,
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 _('[-nibtB] [-r REV] [SOURCE]'),
optionalrepo=True)
Kevin Bullock
id: add bookmarks to id...
r13477 def identify(ui, repo, source=None, rev=None,
Mads Kiilerich
id: add command line options for handling ssh and https urls
r15580 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
Matt Mackall
identify: accept a revision argument
r4665 """identify the working copy or specified revision
Kevin Bullock
identify: further clarification of help...
r13963 Print a summary identifying the repository state at REV using one or
two parent hash identifiers, followed by a "+" if the working
directory has uncommitted changes, the branch name (if not default),
a list of tags, and a list of bookmarks.
Idan Kamara
identify/help: say what the command does first, mention bookmarks
r13952
When REV is not given, print a summary of the current state of the
Martin Geisler
expand "repo" to "repository" in help texts
r8027 repository.
Matt Mackall
identify: take a path to a remote repo...
r4671
timeless
Improve English for help text of many core hg commands....
r8779 Specifying a path to a repository root or Mercurial bundle will
cause lookup to operate on that repository/bundle.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Matt Mackall
id: add some help examples
r15112 .. container:: verbose
Examples:
- generate a build identifier for the working directory::
hg id --id > build-id.dat
- find the revision corresponding to a tag::
hg id -n -r 1.3
- check the most recent revision of a remote repository::
hg id -r tip http://selenic.com/hg/
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 if successful.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
identify: show nullid for empty repo
r4662
Alexis S. L. Carvalho
make identify an optionalrepo command...
r5330 if not repo and not source:
Martin Geisler
Lowercase error messages
r12067 raise util.Abort(_("there is no Mercurial repository here "
Alexis S. L. Carvalho
make identify an optionalrepo command...
r5330 "(.hg not found)"))
Matt Mackall
Only show long hashes with --debug, not --verbose
r2966 hexfunc = ui.debugflag and hex or short
Kevin Bullock
id: add bookmarks to id...
r13477 default = not (num or id or branch or tags or bookmarks)
Matt Mackall
identify: add support for output flags
r4666 output = []
Dirkjan Ochtman
identify: have consistent output for local repositories...
r7757 revs = []
Idan Kamara
identify: restructure code to make it more readable
r13953
Matt Mackall
identify: take a path to a remote repo...
r4671 if source:
Sune Foldager
interpret repo#name url syntax as branch instead of revision...
r10365 source, branches = hg.parseurl(ui.expandpath(source))
Simon Heimberg
subrepo: more isolation, only use ui for hg.peer when there is no repo...
r17875 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 repo = peer.local()
revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
if not repo:
Idan Kamara
identify: restructure code to make it more readable
r13953 if num or branch or tags:
raise util.Abort(
_("can't query remote revision number, branch, or tags"))
Matt Mackall
identify: take a path to a remote repo...
r4671 if not rev and revs:
rev = revs[0]
Matt Mackall
identify: work with remote repos
r4667 if not rev:
rev = "tip"
Nils Adermann
identify: list bookmarks for remote repositories
r13644
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 remoterev = peer.lookup(rev)
Matt Mackall
identify: add support for output flags
r4666 if default or id:
Nils Adermann
identify: list bookmarks for remote repositories
r13644 output = [hexfunc(remoterev)]
Idan Kamara
identify: restructure code to make it more readable
r13953 def getbms():
bms = []
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 if 'bookmarks' in peer.listkeys('namespaces'):
Idan Kamara
identify: restructure code to make it more readable
r13953 hexremoterev = hex(remoterev)
Sune Foldager
peer: introduce peer methods to prepare for peer classes...
r17191 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
Idan Kamara
identify: restructure code to make it more readable
r13953 if bmr == hexremoterev]
Mads Kiilerich
identity: report bookmarks sorted
r18366 return sorted(bms)
Idan Kamara
identify: restructure code to make it more readable
r13953
if bookmarks:
output.extend(getbms())
elif default and not ui.quiet:
# multiple bookmarks for a single parent separated by '/'
bm = '/'.join(getbms())
if bm:
output.append(bm)
Matt Mackall
identify: accept a revision argument
r4665 else:
Idan Kamara
identify: restructure code to make it more readable
r13953 if not rev:
ctx = repo[None]
parents = ctx.parents()
changed = ""
if default or id or num:
Patrick Mezard
identity: show trailing '+' for dirty subrepos (issue2839)
r17255 if (util.any(repo.status())
or util.any(ctx.sub(s).dirty() for s in ctx.substate)):
changed = '+'
Idan Kamara
identify: restructure code to make it more readable
r13953 if default or id:
output = ["%s%s" %
('+'.join([hexfunc(p.node()) for p in parents]), changed)]
if num:
output.append("%s%s" %
('+'.join([str(p.rev()) for p in parents]), changed))
else:
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 ctx = scmutil.revsingle(repo, rev)
Idan Kamara
identify: restructure code to make it more readable
r13953 if default or id:
output = [hexfunc(ctx.node())]
if num:
output.append(str(ctx.rev()))
if default and not ui.quiet:
b = ctx.branch()
if b != 'default':
output.append("(%s)" % b)
# multiple tags for a single parent separated by '/'
t = '/'.join(ctx.tags())
if t:
output.append(t)
# multiple bookmarks for a single parent separated by '/'
bm = '/'.join(ctx.bookmarks())
if bm:
output.append(bm)
else:
if branch:
output.append(ctx.branch())
if tags:
output.extend(ctx.tags())
if bookmarks:
output.extend(ctx.bookmarks())
Kevin Bullock
id: add bookmarks to id...
r13477
Thomas Arendsen Hein
Improvements for hg identify:...
r386 ui.write("%s\n" % ' '.join(output))
Thomas Arendsen Hein
added hg identify|id (based on a patch from Andrew Thompson)...
r339
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('import|patch',
[('p', 'strip', 1,
_('directory strip option for patch. This has the same '
'meaning as the corresponding patch option'), _('NUM')),
Patrick Mezard
import: deprecate --base...
r14532 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
Matt Mackall
import: add --edit switch
r15221 ('e', 'edit', False, _('invoke editor on commit messages')),
Matt Mackall
rollback: mark as deprecated
r19409 ('f', 'force', None,
_('skip check for outstanding uncommitted changes (DEPRECATED)')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('', 'no-commit', None,
_("don't commit, just update the working directory")),
Patrick Mezard
import: add --bypass option...
r14611 ('', 'bypass', None,
_("apply patch without touching the working directory")),
Pierre-Yves David
import: add --partial flag to create a changeset despite failed hunks...
r21553 ('', 'partial', None,
_('commit even if some hunks fail')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('', 'exact', None,
_('apply patch to the nodes from which it was generated')),
('', 'import-branch', None,
_('use any branch information in patch (implied by --exact)'))] +
commitopts + commitopts2 + similarityopts,
_('[OPTION]... PATCH...'))
Kevin Bullock
import: abort usefully if no patch name given
r15327 def import_(ui, repo, patch1=None, *patches, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """import an ordered set of patches
timeless@mozdev.org
minor documentation improvements
r9649 Import a list of patches and commit them individually (unless
--no-commit is specified).
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Matt Mackall
rollback: mark as deprecated
r19409 Because import first applies changes to the working directory,
import will abort if there are outstanding changes.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Christian Ebert
Consistently 1 space after full stops in command doc strings...
r6448 You can import a patch straight from a mail message. Even patches
timeless
Improve English for help text of many core hg commands....
r8779 as attachments work (to use the body part, it must have type
text/plain or text/x-patch). From and Subject headers of email
Christian Ebert
Consistently 1 space after full stops in command doc strings...
r6448 message are used as default committer and commit message. All
Vadim Gelfer
import: make help clearer. suggested by asak.
r2515 text/plain body parts before first diff are added to commit
message.
Vadim Gelfer
import: parse email messages
r2504
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 If the imported patch was generated by :hg:`export`, user and
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 description from patch override values from message headers and
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 body. Values given on command line with -m/--message and -u/--user
override these.
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004
If --exact is specified, import will set the working directory to
the parent of each patch before applying it, and will abort if the
resulting changeset has a different ID than the one recorded in
the patch. This may happen due to character set problems or other
deficiencies in the text patch format.
Brendan Cully
Add import --exact....
r4263
Patrick Mezard
import: add --bypass option...
r14611 Use --bypass to apply and commit patches directly to the
repository, not touching the working directory. Without --exact,
patches will be applied on top of the working directory parent
revision.
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 With -s/--similarity, hg will attempt to discover renames and
Martin Geisler
commands: add link to addremove in commit help text
r15779 copies in the patch in the same way as :hg:`addremove`.
Brendan Cully
import: add similarity option (issue295)
r7402
Pierre-Yves David
import: add --partial flag to create a changeset despite failed hunks...
r21553 Use --partial to ensure a changeset will be created from the patch
even if some hunks fail to apply. Hunks that fail to apply will be
written to a <target-file>.rej file. Conflicts can then be resolved
by hand before :hg:`commit --amend` is run to update the created
changeset. This flag exists to let people import patches that
partially apply without losing the associated metadata (author,
Wagner Bruna
commands: fix typo in import documentation
r21929 date, description, ...). Note that when none of the hunk applies
Pierre-Yves David
import: add --partial flag to create a changeset despite failed hunks...
r21553 cleanly, :hg:`import --partial` will create an empty changeset,
importing only the patch metadata.
Dirkjan Ochtman
commands: add note about import retrieving patches from URLs
r8931 To read a patch from standard input, use "-" as the patch name. If
a URL is specified, the patch will be downloaded from it.
Martin Geisler
Use hg role in help strings
r10973 See :hg:`help dates` for a list of formats valid for -d/--date.
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
import: add help examples
r15113 .. container:: verbose
Examples:
- import a traditional patch from a website and detect renames::
hg import -s 80 http://example.com/bugfix.patch
- import a changeset from an hgweb server::
hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
- import all the patches in an Unix-style mbox::
hg import incoming-patches.mbox
- attempt to exactly restore an exported changeset (not always
possible)::
hg import --exact proposed-fix.patch
Pierre-Yves David
import: add --partial flag to create a changeset despite failed hunks...
r21553 Returns 0 on success, 1 on partial success (see --partial).
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Kevin Bullock
import: abort usefully if no patch name given
r15327
if not patch1:
raise util.Abort(_('need at least one patch to import'))
mpm@selenic.com
Commands cleanup...
r437 patches = (patch1,) + patches
mpm@selenic.com
[PATCH] Clean up destination directory if a clone fails....
r500
Thomas Arendsen Hein
Fix bad behaviour when specifying an invalid date (issue700)...
r6139 date = opts.get('date')
if date:
opts['date'] = util.parsedate(date)
Patrick Mezard
import: add --bypass option...
r14611 update = not opts.get('bypass')
if not update and opts.get('no_commit'):
raise util.Abort(_('cannot use --no-commit with --bypass'))
Brendan Cully
import: add similarity option (issue295)
r7402 try:
sim = float(opts.get('similarity') or 0)
except ValueError:
raise util.Abort(_('similarity must be a number'))
if sim < 0 or sim > 100:
raise util.Abort(_('similarity must be between 0 and 100'))
Patrick Mezard
import: add --bypass option...
r14611 if sim and not update:
raise util.Abort(_('cannot use --similarity with --bypass'))
Matt Mackall
commands: add checks for unfinished operations (issue3955)...
r19476 if update:
cmdutil.checkunfinished(repo)
Patrick Mezard
import: add --bypass option...
r14611 if (opts.get('exact') or not opts.get('force')) and update:
Matt Mackall
cmdutil: bail_if_changed to bailifchanged
r14289 cmdutil.bailifchanged(repo)
mpm@selenic.com
hg import: abort with uncommitted changes, override with --force
r966
Greg Ward
import: rename some local variables
r15195 base = opts["base"]
Greg Ward
import: wrap a transaction around the whole command...
r15198 wlock = lock = tr = None
Steve Borho
import: --no-commit should update .hg/last-message.txt...
r12913 msgs = []
Pierre-Yves David
import: add --partial flag to create a changeset despite failed hunks...
r21553 ret = 0
Brendan Cully
import: import each patch in a file or stream as a separate change...
r10384
Peter Arrenbrecht
whitespace cleanup
r10405
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 try:
Thomas Arendsen Hein
commands: use separate try/except and try/finally as needed for python2.4...
r15278 try:
wlock = repo.wlock()
Matt Mackall
encoding: tune fast-path of tolocal a bit
r16274 if not opts.get('no_commit'):
lock = repo.lock()
tr = repo.transaction('import')
Thomas Arendsen Hein
commands: use separate try/except and try/finally as needed for python2.4...
r15278 parents = repo.parents()
for patchurl in patches:
if patchurl == '-':
ui.status(_('applying patch from stdin\n'))
patchfile = ui.fin
patchurl = 'stdin' # for error message
Patrick Mezard
import: add --bypass option...
r14611 else:
Thomas Arendsen Hein
commands: use separate try/except and try/finally as needed for python2.4...
r15278 patchurl = os.path.join(base, patchurl)
ui.status(_('applying %s\n') % patchurl)
Siddharth Agarwal
url: use open and not url.open for local files (issue3624)
r17887 patchfile = hg.openpath(ui, patchurl)
Thomas Arendsen Hein
commands: use separate try/except and try/finally as needed for python2.4...
r15278
haspatch = False
for hunk in patch.split(patchfile):
Pierre-Yves David
import: add --partial flag to create a changeset despite failed hunks...
r21553 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
parents, opts,
msgs, hg.clean)
Thomas Arendsen Hein
commands: use separate try/except and try/finally as needed for python2.4...
r15278 if msg:
haspatch = True
ui.note(msg + '\n')
if update or opts.get('exact'):
parents = repo.parents()
else:
parents = [repo[node]]
Pierre-Yves David
import: add --partial flag to create a changeset despite failed hunks...
r21553 if rej:
ui.write_err(_("patch applied partially\n"))
FUJIWARA Katsunori
commands: make the warning message for "patch --partial" translatable...
r21959 ui.write_err(_("(fix the .rej files and run "
"`hg commit --amend`)\n"))
Pierre-Yves David
import: add --partial flag to create a changeset despite failed hunks...
r21553 ret = 1
break
Thomas Arendsen Hein
commands: use separate try/except and try/finally as needed for python2.4...
r15278
if not haspatch:
raise util.Abort(_('%s: no diffs found') % patchurl)
Matt Mackall
encoding: tune fast-path of tolocal a bit
r16274 if tr:
tr.close()
Thomas Arendsen Hein
commands: use separate try/except and try/finally as needed for python2.4...
r15278 if msgs:
repo.savecommitmessage('\n* * *\n'.join(msgs))
Pierre-Yves David
import: add --partial flag to create a changeset despite failed hunks...
r21553 return ret
Brodie Rao
check-code: ignore naked excepts with a "re-raise" comment...
r16705 except: # re-raises
Thomas Arendsen Hein
commands: use separate try/except and try/finally as needed for python2.4...
r15278 # wlock.release() indirectly calls dirstate.write(): since
# we're crashing, we do not want to change the working dir
# parent after all, so make sure it writes nothing
repo.dirstate.invalidate()
raise
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 finally:
Greg Ward
import: wrap a transaction around the whole command...
r15198 if tr:
tr.release()
Ronny Pfannschmidt
switch lock releasing in the core from gc to explicit
r8109 release(lock, wlock)
mpm@selenic.com
Commands cleanup...
r437
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('incoming|in',
[('f', 'force', None,
_('run even if remote repository is unrelated')),
('n', 'newest-first', None, _('show newest record first')),
('', 'bundle', '',
_('file to store the bundles into'), _('FILE')),
('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
('B', 'bookmarks', False, _("compare bookmarks")),
('b', 'branch', [],
_('a specific branch you would like to pull'), _('BRANCH')),
] + logopts + remoteopts + subrepoopts,
_('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
TK Soh
Add -p to incoming and outgoing commands to show patch
r1192 def incoming(ui, repo, source="default", **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """show new changesets found in source
Thomas Arendsen Hein
More detailed documentation about ssh:// URLs; fixes issue170.
r1979 Show new changesets found in the specified path/URL or the default
timeless
Improve English for help text of many core hg commands....
r8779 pull location. These are the changesets that would have been pulled
if a pull at the time you issued this command.
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004
For remote repository, using --bundle avoids downloading the
changesets twice if the incoming is followed by a pull.
Thomas Arendsen Hein
More detailed documentation about ssh:// URLs; fixes issue170.
r1979
See pull for valid source format details.
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
help: add examples to incoming
r20834 .. container:: verbose
Examples:
- show incoming changes with patches and full description::
hg incoming -vp
- show incoming changes excluding merges, store a bundle::
hg in -vpM --bundle incoming.hg
hg pull incoming.hg
- briefly list changes inside a bundle::
hg in changes.hg -T "{desc|firstline}\\n"
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 if there are incoming changes, 1 otherwise.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Patrick Mezard
incoming/outgoing: handle --graph in core
r17182 if opts.get('graph'):
cmdutil.checkunsupportedgraphflags([], opts)
def display(other, chlist, displayer):
revdag = cmdutil.graphrevs(other, chlist, opts)
showparents = [ctx.node() for ctx in repo[None].parents()]
cmdutil.displaygraph(ui, revdag, displayer, showparents,
graphmod.asciiedges)
hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
return 0
Martin Geisler
incoming: recurse into subrepositories with --subrepos/-S flag...
r12274 if opts.get('bundle') and opts.get('subrepos'):
raise util.Abort(_('cannot combine --bundle and --subrepos'))
Matt Mackall
bookmarks: merge incoming/outgoing into core
r13366 if opts.get('bookmarks'):
source, branches = hg.parseurl(ui.expandpath(source),
opts.get('branch'))
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 other = hg.peer(repo, opts, source)
David Soria Parra
bookmarks: issue a warning if remote doesn't support comparing bookmarks...
r13453 if 'bookmarks' not in other.listkeys('namespaces'):
ui.warn(_("remote doesn't support bookmarks\n"))
return 0
Brodie Rao
url: move URL parsing functions into util to improve startup time...
r14076 ui.status(_('comparing with %s\n') % util.hidepassword(source))
Matt Mackall
bookmarks: merge incoming/outgoing into core
r13366 return bookmarks.diff(ui, repo, other)
Martin Geisler
subrepo: respect non-default path for incoming/outgoing...
r14360 repo._subtoppath = ui.expandpath(source)
try:
Martin Geisler
commands: replace 'x = f(); return x' with 'return f()'
r14362 return hg.incoming(ui, repo, source, opts)
Martin Geisler
subrepo: respect non-default path for incoming/outgoing...
r14360 finally:
del repo._subtoppath
Benoit Boissinot
incoming: add support for remote repo using bundlerepo
r1944
Gregory Szorc
commands: define norepo in command decorator
r21768 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
norepo=True)
Thomas Arendsen Hein
Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out....
r2598 def init(ui, dest=".", **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """create a new repository in the given directory
Christian Ebert
Consistently 1 space after full stops in command doc strings...
r6448 Initialize a new repository in the given directory. If the given
timeless
Improve English for help text of many core hg commands....
r8779 directory does not exist, it will be created.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
If no directory is given, the current directory is used.
Thomas Arendsen Hein
Additional information about URLs in pull/push/clone/init:...
r2590
Martin Geisler
commands: mark "ssh://" as inline literals in help texts
r9970 It is possible to specify an ``ssh://`` URL as the destination.
Martin Geisler
Use hg role in help strings
r10973 See :hg:`help urls` for more information.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 hg.peer(ui, opts, ui.expandpath(dest), create=True)
mpm@selenic.com
default path support with .hg/hgrc...
r338
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('locate',
[('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
('f', 'fullpath', None, _('print complete paths from the filesystem root')),
] + walkopts,
_('[OPTION]... [PATTERN]...'))
Bryan O'Sullivan
Add locate command....
r627 def locate(ui, repo, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """locate files matching specific patterns
timeless
Improve English for help text of many core hg commands....
r8779 Print files under Mercurial control in the working directory whose
names match the given patterns.
By default, this command searches all directories in the working
directory. To search just the current directory and its
subdirectories, use "--include .".
If no patterns are given to match, this command prints the names
of all files under Mercurial control in the working directory.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
If you want to feed the output of this command into the "xargs"
Martin Geisler
commands: use double quotes consistently in help texts
r8032 command, use the -0 option to both this command and "xargs". This
will avoid the problem of "xargs" treating single filenames that
timeless
Improve English for help text of many core hg commands....
r8779 contain whitespace as multiple filenames.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 if a match is found, 1 otherwise.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Alexander Solovyov
commands: optional options where possible...
r7131 end = opts.get('print0') and '\0' or '\n'
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
mpm@selenic.com
Refactor matchpats and walk...
r742
Alexis S. L. Carvalho
locate: exit(1) if we didn't print any file
r4196 ret = 1
Siddharth Agarwal
locate: use ctx.matches instead of ctx.walk...
r21986 ctx = repo[rev]
m = scmutil.match(ctx, pats, opts, default='relglob')
Matt Mackall
many, many trivial check-code fixups
r10282 m.bad = lambda x, y: False
Siddharth Agarwal
locate: use ctx.matches instead of ctx.walk...
r21986
for abs in ctx.matches(m):
Alexander Solovyov
commands: optional options where possible...
r7131 if opts.get('fullpath'):
Martin Geisler
use repo.wjoin(f) instead of os.path.join(repo.root, f)
r7570 ui.write(repo.wjoin(abs), end)
Bryan O'Sullivan
Get add and locate to use new repo and dirstate walk code....
r724 else:
Matt Mackall
walk: remove rel and exact returns
r6584 ui.write(((pats and m.rel(abs)) or abs), end)
Alexis S. L. Carvalho
locate: exit(1) if we didn't print any file
r4196 ret = 0
return ret
Bryan O'Sullivan
Add locate command....
r627
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^log|history',
[('f', 'follow', None,
_('follow changeset history, or file history across copies and renames')),
('', 'follow-first', None,
Matt Mackall
log: hide some low-utility options
r15405 _('only follow the first parent of merge changesets (DEPRECATED)')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
('C', 'copies', None, _('show copied files')),
('k', 'keyword', [],
_('do case-insensitive search for a given text'), _('TEXT')),
('r', 'rev', [], _('show the specified revision or range'), _('REV')),
('', 'removed', None, _('include revisions where files were removed')),
Matt Mackall
log: hide some low-utility options
r15405 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('u', 'user', [], _('revisions committed by user'), _('USER')),
('', 'only-branch', [],
_('show only changesets within the given named branch (DEPRECATED)'),
_('BRANCH')),
('b', 'branch', [],
_('show changesets within the given named branch'), _('BRANCH')),
('P', 'prune', [],
_('do not display revision or any of its ancestors'), _('REV')),
] + logopts + walkopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... [FILE]'),
inferrepo=True)
Bryan O'Sullivan
Rewrite log command. New version is faster and more featureful....
r1031 def log(ui, repo, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """show revision history of entire repository or files
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 Print the revision history of the specified files or the entire
project.
Matt Mackall
log: rearrange the help text a bit
r15104 If no revision range is specified, the default is ``tip:0`` unless
--follow is set, in which case the working directory parent is
used as the starting revision.
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 File history is shown without following rename or copy history of
timeless
Generally replace "file name" with "filename" in help and comments.
r8761 files. Use -f/--follow with a filename to follow history across
renames and copies. --follow without a filename will only show
Matt Mackall
log: rearrange the help text a bit
r15104 ancestors or descendants of the starting revision.
Thomas Arendsen Hein
Document log date ranges and mention 'hg help dates' for all commands (issue998)
r6163
timeless
Improve English for help text of many core hg commands....
r8779 By default this command prints revision number and changeset id,
tags, non-trivial parents, user, date and time, and a summary for
each commit. When the -v/--verbose switch is used, the list of
changed files and full commit message are shown.
Matt Mackall
Add notes about diff/merge asymmetry to export, diff, and log
r3822
Mads Kiilerich
log: describe graph symbols in the help...
r20544 With --graph the revisions are shown as an ASCII art DAG with the most
recent changeset at the top.
'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
and '+' represents a fork where the changeset from the lines below is a
Wagner Bruna
commands: fix typo in --graph description
r21174 parent of the 'o' merge on the same line.
Mads Kiilerich
log: describe graph symbols in the help...
r20544
Christian Ebert
Use more note admonitions in help texts
r12390 .. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Christian Ebert
Use more note admonitions in help texts
r12390 log -p/--patch may generate unexpected diff output for merge
changesets, as it will only compare the merge changeset against
its first parent. Also, only files different from BOTH parents
will appear in files:.
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
log: add a usage note about --removed
r15105 .. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Matt Mackall
log: add a usage note about --removed
r15105 for performance reasons, log FILE may omit duplicate changes
made on branches and will not show deletions. To see all
changes including duplicates and deletions, use the --removed
switch.
Matt Mackall
log: add some usage examples to verbose help
r15103 .. container:: verbose
Some examples:
- changesets with full descriptions and file lists::
hg log -v
- changesets ancestral to the working directory::
hg log -f
- last 10 commits on the current branch::
hg log -l 10 -b .
- changesets showing all modifications of a file, including removals::
hg log --removed file.c
- all changesets that touch a directory, with diffs, excluding merges::
hg log -Mp lib/
- all revision numbers that match a keyword::
hg log -k bug --template "{rev}\\n"
Matt Mackall
templates: re-add template listing support...
r21944 - list available log templates::
hg log -T list
Matt Mackall
log: add some usage examples to verbose help
r15103 - check if a given changeset is included is a tagged release::
hg log -r "a21ccf and ancestor(1.9)"
- find all changesets by some user in a date range::
hg log -k alice -d "may 2008 to jul 2008"
- summary of all changesets after the last tag::
hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
Matt Mackall
log: rearrange the help text a bit
r15104 See :hg:`help dates` for a list of formats valid for -d/--date.
See :hg:`help revisions` and :hg:`help revsets` for more about
specifying revisions.
A. S. Budden
help: add reference to template help (issue3413)...
r16568 See :hg:`help templates` for more about pre-packaged styles and
specifying custom templates.
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Patrick Mezard
log: support --graph without graphlog extension...
r17181 if opts.get('graph'):
return cmdutil.graphlog(ui, repo, *pats, **opts)
Vadim Gelfer
add -l,--limit to log command.
r1756
Lucas Moscovicz
log: changed implementation to use graphlog code...
r21127 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
Thomas Arendsen Hein
Move finding/checking the log limit to cmdutil
r6190 limit = cmdutil.loglimit(opts)
Vadim Gelfer
add -l,--limit to log command.
r1756 count = 0
Lucas Moscovicz
log: changed implementation to use graphlog code...
r21127 getrenamed = None
Patrick Mezard
log: restore cache used by --copies...
r16175 if opts.get('copies'):
Lucas Moscovicz
log: changed implementation to use graphlog code...
r21127 endrev = None
Patrick Mezard
log: restore cache used by --copies...
r16175 if opts.get('rev'):
Lucas Moscovicz
log: changed implementation to use graphlog code...
r21127 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
Patrick Mezard
log: restore cache used by --copies...
r16175 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
Brendan Cully
Show copies in hg log....
r3197
Lucas Moscovicz
log: changed implementation to use graphlog code...
r21127 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
for rev in revs:
if count == limit:
break
ctx = repo[rev]
Patrick Mezard
templatekw: change {file_copies} behaviour, add {file_copies_switch}...
r10060 copies = None
Patrick Mezard
log: restore cache used by --copies...
r16175 if getrenamed is not None and rev:
Patrick Mezard
templatekw: change {file_copies} behaviour, add {file_copies_switch}...
r10060 copies = []
Matt Mackall
walkchangerevs: move 'add' to callback...
r9662 for fn in ctx.files():
rename = getrenamed(fn, rev)
if rename:
copies.append((fn, rename[0]))
Lucas Moscovicz
log: changed implementation to use graphlog code...
r21127 revmatchfn = filematcher and filematcher(ctx.rev()) or None
Mads Kiilerich
log: follow filenames through renames (issue647)...
r11488 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
Lucas Moscovicz
log: changed implementation to use graphlog code...
r21127 if displayer.flush(rev):
Bryan O'Sullivan
commands: exit from the log loop at the right time...
r18711 count += 1
Lucas Moscovicz
log: changed implementation to use graphlog code...
r21127
Robert Bachmann
Added support for templatevar "footer" to cmdutil.py
r10152 displayer.close()
mpm@selenic.com
hg help: use docstrings only...
r255
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('manifest',
Adrian Buehlmann
add new option --all to manifest command...
r14399 [('r', 'rev', '', _('revision to display'), _('REV')),
('', 'all', False, _("list files from all revisions"))],
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 _('[-r REV]'))
Adrian Buehlmann
add new option --all to manifest command...
r14399 def manifest(ui, repo, node=None, rev=None, **opts):
Thomas Arendsen Hein
doc string fix: hg cat and manifest default to current parent revision.
r3914 """output the current or given revision of the project manifest
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Print a list of version controlled files for the given revision.
Patrick Mezard
Fix manifest default rev doc when no rev is checked out (issue1603)
r8041 If no revision is given, the first parent of the working directory
timeless
Improve English for help text of many core hg commands....
r8779 is used, or the null revision if no revision is checked out.
With -v, print file permissions, symlink and executable bits.
With --debug, print file revision hashes.
Matt Mackall
commands: initial audit of exit codes...
r11177
Adrian Buehlmann
add new option --all to manifest command...
r14399 If option --all is specified, the list of all files from all revisions
is printed. This includes deleted and renamed files.
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
manifest: add formatter support
r17911
fm = ui.formatter('manifest', opts)
Adrian Buehlmann
add new option --all to manifest command...
r14399 if opts.get('all'):
if rev or node:
raise util.Abort(_("can't specify a revision with --all"))
res = []
prefix = "data/"
suffix = ".i"
plen = len(prefix)
slen = len(suffix)
lock = repo.lock()
try:
for fn, b, size in repo.store.datafiles():
if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
res.append(fn[plen:-slen])
finally:
lock.release()
Adrian Buehlmann
manifest: remove redundant sorted() call for --all...
r17376 for f in res:
Matt Mackall
manifest: add formatter support
r17911 fm.startitem()
fm.write("path", '%s\n', f)
fm.end()
Adrian Buehlmann
add new option --all to manifest command...
r14399 return
Matt Mackall
make manifest friendlier...
r3736
Bryan O'Sullivan
manifest: accept -r for rev specification
r5155 if rev and node:
raise util.Abort(_("please specify just one revision"))
if not node:
node = rev
Matt Mackall
manifest: add formatter support
r17911 char = {'l': '@', 'x': '*', '': ''}
mode = {'l': '644', 'x': '755', '': '644'}
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 ctx = scmutil.revsingle(repo, node)
Matt Mackall
manifest: add formatter support
r17911 mf = ctx.manifest()
Matt Mackall
manifest: remove execf/linkf methods
r6749 for f in ctx:
Matt Mackall
manifest: add formatter support
r17911 fm.startitem()
fl = ctx[f].flags()
fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
fm.write('path', '%s\n', f)
fm.end()
mpm@selenic.com
hg help: use docstrings only...
r255
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^merge',
Florence Laguzet
merge: deprecate the --force option...
r19439 [('f', 'force', None,
_('force a merge including outstanding changes (DEPRECATED)')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('r', 'rev', '', _('revision to merge'), _('REV')),
('P', 'preview', None,
Martin Geisler
commands: use mergetoolopts when a command supports --tool
r14852 _('review revisions to merge (no merge is performed)'))
] + mergetoolopts,
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 _('[-P] [-f] [[-r] REV]'))
Dirkjan Ochtman
merge: add -S/--show option to review revisions without merging
r8387 def merge(ui, repo, node=None, **opts):
Benoit Boissinot
various doc fixes...
r4014 """merge working directory with another revision
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019
timeless
Improve English for help text of many core hg commands....
r8779 The current working directory is updated with all changes made in
the requested revision since the last common predecessor revision.
Martin Geisler
commands: better merge help text
r7977
Files that changed between either parent are marked as changed for
the next commit and a commit must be performed before any further
timeless
Improve English for help text of many core hg commands....
r8779 updates to the repository are allowed. The next commit will have
two parents.
Vadim Gelfer
merge with other head by default, not tip....
r2915
Steve Borho
merge: add --tool argument to merge and resolve...
r12750 ``--tool`` can be used to specify the merge tool used for file
merges. It overrides the HGMERGE environment variable and your
Arne Babenhauserheide
merge: added info that hg help merge-tools shows the options for --tool
r13891 configuration files. See :hg:`help merge-tools` for options.
Steve Borho
merge: add --tool argument to merge and resolve...
r12750
Vadim Gelfer
merge with other head by default, not tip....
r2915 If no revision is specified, the working directory's parent is a
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 head revision, and the current branch contains exactly one other
head, the other head is merged with by default. Otherwise, an
timeless
Improve English for help text of many core hg commands....
r8779 explicit revision with which to merge with must be provided.
Matt Mackall
commands: initial audit of exit codes...
r11177
Steve Borho
merge: add --tool argument to merge and resolve...
r12750 :hg:`resolve` must be used to resolve unresolved files.
Matt Mackall
merge: document how to 'undo' a merge
r11452 To undo an uncommitted merge, use :hg:`update --clean .` which
will check out a clean copy of the original merge parent, losing
all changes.
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success, 1 if there are unresolved files.
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 """
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806
Dirkjan Ochtman
merge: add -S/--show option to review revisions without merging
r8387 if opts.get('rev') and node:
Daniel Holth
accept -r REV in more places...
r4450 raise util.Abort(_("please specify just one revision"))
if not node:
Dirkjan Ochtman
merge: add -S/--show option to review revisions without merging
r8387 node = opts.get('rev')
Daniel Holth
accept -r REV in more places...
r4450
David Soria Parra
merge: respect bookmarks during merge...
r16708 if node:
node = scmutil.revsingle(repo, node).node()
if not node and repo._bookmarkcurrent:
bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
Mads Kiilerich
bookmarks: fix head selection for merge with two bookmarked heads...
r18122 curhead = repo[repo._bookmarkcurrent].node()
David Soria Parra
merge: respect bookmarks during merge...
r16708 if len(bmheads) == 2:
if curhead == bmheads[0]:
node = bmheads[1]
else:
node = bmheads[0]
elif len(bmheads) > 2:
raise util.Abort(_("multiple matching bookmarks to merge - "
"please merge with an explicit rev or bookmark"),
hint=_("run 'hg heads' to see all heads"))
elif len(bmheads) <= 1:
raise util.Abort(_("no matching bookmark to merge - "
"please merge with an explicit rev or bookmark"),
hint=_("run 'hg heads' to see all heads"))
if not node and not repo._bookmarkcurrent:
Matt Mackall
branch: operate on branch names in local string space where possible...
r13047 branch = repo[None].branch()
Dirkjan Ochtman
merge: use correct branch name for counting heads
r6844 bheads = repo.branchheads(branch)
David Soria Parra
merge: respect bookmarks during merge...
r16708 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
if len(nbhs) > 2:
Martin Geisler
commands: use util.Abort's hint some more
r14198 raise util.Abort(_("branch '%s' has %d heads - "
"please merge with an explicit rev")
% (branch, len(bheads)),
hint=_("run 'hg heads .' to see heads"))
Dirkjan Ochtman
merge: only in-branch merges can be implicit
r6723
Matt Mackall
misc: replace .parents()[0] with p1()
r13878 parent = repo.dirstate.p1()
John Li
merge: handle case when heads are all bookmarks...
r17386 if len(nbhs) <= 1:
David Soria Parra
merge: respect bookmarks during merge...
r16708 if len(bheads) > 1:
raise util.Abort(_("heads are bookmarked - "
"please merge with an explicit rev"),
hint=_("run 'hg heads' to see all heads"))
Dirkjan Ochtman
merge: only in-branch merges can be implicit
r6723 if len(repo.heads()) > 1:
Martin Geisler
commands: use util.Abort's hint some more
r14198 raise util.Abort(_("branch '%s' has one head - "
"please merge with an explicit rev")
% branch,
hint=_("run 'hg heads' to see all heads"))
Kevin Bullock
merge: make 'nothing to merge' aborts consistent...
r15619 msg, hint = _('nothing to merge'), None
Kevin Bullock
merge: remove excess creation of changectx
r15618 if parent != repo.lookup(branch):
Kevin Bullock
merge: make 'nothing to merge' aborts consistent...
r15619 hint = _("use 'hg update' instead")
raise util.Abort(msg, hint=hint)
Benoit Boissinot
improve error message for 'hg merge' when repo already at branchtip
r5242
Dirkjan Ochtman
merge: only in-branch merges can be implicit
r6723 if parent not in bheads:
Martin Geisler
commands: use util.Abort's hint some more
r14198 raise util.Abort(_('working directory not at a head revision'),
hint=_("use 'hg update' or merge with an "
"explicit revision"))
David Soria Parra
merge: respect bookmarks during merge...
r16708 if parent == nbhs[0]:
node = nbhs[-1]
else:
node = nbhs[0]
Dirkjan Ochtman
merge: add -S/--show option to review revisions without merging
r8387
Dirkjan Ochtman
merge: rename -S/--show option to -P/--preview
r8834 if opts.get('preview'):
Greg Ward
merge: fix --preview to show all nodes that will be merged (issue2043)....
r10505 # find nodes that are ancestors of p2 but not of p1
p1 = repo.lookup('.')
p2 = repo.lookup(node)
nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
Dirkjan Ochtman
merge: add -S/--show option to review revisions without merging
r8387 displayer = cmdutil.show_changeset(ui, repo, opts)
Greg Ward
merge: fix --preview to show all nodes that will be merged (issue2043)....
r10505 for node in nodes:
displayer.show(repo[node])
Robert Bachmann
Added support for templatevar "footer" to cmdutil.py
r10152 displayer.close()
Dirkjan Ochtman
merge: add -S/--show option to review revisions without merging
r8387 return 0
Steve Borho
merge: implement --tool arguments using new ui.forcemerge configurable...
r12788 try:
# ui.forcemerge is an internal variable, do not document
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
Steve Borho
merge: implement --tool arguments using new ui.forcemerge configurable...
r12788 return hg.merge(repo, node, force=opts.get('force'))
finally:
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 ui.setconfig('ui', 'forcemerge', '', 'merge')
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('outgoing|out',
[('f', 'force', None, _('run even when the destination is unrelated')),
('r', 'rev', [],
_('a changeset intended to be included in the destination'), _('REV')),
('n', 'newest-first', None, _('show newest record first')),
('B', 'bookmarks', False, _('compare bookmarks')),
('b', 'branch', [], _('a specific branch you would like to push'),
_('BRANCH')),
] + logopts + remoteopts + subrepoopts,
_('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
Vadim Gelfer
push, outgoing, bundle: fall back to "default" if "default-push" not defined
r2494 def outgoing(ui, repo, dest=None, **opts):
timeless
help: Improved body text
r10376 """show changesets not found in the destination
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 Show changesets not found in the specified destination repository
or the default push location. These are the changesets that would
be pushed if a push was requested.
Benoit Boissinot
resync commands.py docstrings with hg.1.txt
r1811
timeless
help: Improved body text
r10376 See pull for details of valid destination formats.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 if there are outgoing changes, 1 otherwise.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Patrick Mezard
incoming/outgoing: handle --graph in core
r17182 if opts.get('graph'):
cmdutil.checkunsupportedgraphflags([], opts)
FUJIWARA Katsunori
hg: make "_outgoing()" return peer object for remote repository...
r21050 o, other = hg._outgoing(ui, repo, dest, opts)
FUJIWARA Katsunori
hg: make "_outgoing()" return empty list instead of "None"...
r21049 if not o:
FUJIWARA Katsunori
outgoing: introduce "outgoinghooks" to avoid redundant outgoing check...
r21051 cmdutil.outgoinghooks(ui, repo, other, opts, o)
Patrick Mezard
incoming/outgoing: handle --graph in core
r17182 return
revdag = cmdutil.graphrevs(repo, o, opts)
displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
showparents = [ctx.node() for ctx in repo[None].parents()]
cmdutil.displaygraph(ui, revdag, displayer, showparents,
graphmod.asciiedges)
FUJIWARA Katsunori
outgoing: introduce "outgoinghooks" to avoid redundant outgoing check...
r21051 cmdutil.outgoinghooks(ui, repo, other, opts, o)
Patrick Mezard
incoming/outgoing: handle --graph in core
r17182 return 0
Matt Mackall
bookmarks: merge incoming/outgoing into core
r13366
if opts.get('bookmarks'):
dest = ui.expandpath(dest or 'default-push', dest or 'default')
dest, branches = hg.parseurl(dest, opts.get('branch'))
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 other = hg.peer(repo, opts, dest)
David Soria Parra
bookmarks: issue a warning if remote doesn't support comparing bookmarks...
r13453 if 'bookmarks' not in other.listkeys('namespaces'):
ui.warn(_("remote doesn't support bookmarks\n"))
return 0
Brodie Rao
url: move URL parsing functions into util to improve startup time...
r14076 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
Matt Mackall
bookmarks: merge incoming/outgoing into core
r13366 return bookmarks.diff(ui, other, repo)
Martin Geisler
subrepo: respect non-default path for incoming/outgoing...
r14360 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
try:
Martin Geisler
commands: replace 'x = f(); return x' with 'return f()'
r14362 return hg.outgoing(ui, repo, dest, opts)
Martin Geisler
subrepo: respect non-default path for incoming/outgoing...
r14360 finally:
del repo._subtoppath
mpm@selenic.com
Add hg outgoing command
r920
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('parents',
[('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
] + templateopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[-r REV] [FILE]'),
inferrepo=True)
Matt Mackall
remove legacy hg parents REV syntax
r3658 def parents(ui, repo, file_=None, **opts):
Martin Geisler
expand "dir" to "directory" in help texts
r8026 """show the parents of the working directory or revision
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 Print the working directory's parent revisions. If a revision is
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 given via -r/--rev, the parent of that revision will be printed.
timeless
Improve English for help text of many core hg commands....
r8779 If a file argument is given, the revision in which the file was
last changed (before the working directory revision or the
argument to --rev if given) is printed.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
commands: add revset support to most commands
r12925
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
Patrick Mezard
parents: make it match the doc when called on a file...
r5298
Brendan Cully
Make parents with a file but not a revision use working directory revision.
r4586 if file_:
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(ctx, (file_,), opts)
Matt Mackall
walk: remove remaining users of cmdutils.matchpats
r6582 if m.anypats() or len(m.files()) != 1:
timeless
Generally replace "file name" with "filename" in help and comments.
r8761 raise util.Abort(_('can only specify an explicit filename'))
Matt Mackall
walk: remove remaining users of cmdutils.matchpats
r6582 file_ = m.files()[0]
Patrick Mezard
parents: make it match the doc when called on a file...
r5298 filenodes = []
for cp in ctx.parents():
if not cp:
continue
try:
filenodes.append(cp.filenode(file_))
Matt Mackall
errors: move revlog errors...
r7633 except error.LookupError:
Patrick Mezard
parents: make it match the doc when called on a file...
r5298 pass
if not filenodes:
raise util.Abort(_("'%s' not found in manifest!") % file_)
Durham Goode
parents: change parents command to use filectx...
r19333 p = []
for fn in filenodes:
fctx = repo.filectx(file_, fileid=fn)
p.append(fctx.node())
mpm@selenic.com
hg help: use docstrings only...
r255 else:
Patrick Mezard
parents: make it match the doc when called on a file...
r5298 p = [cp.node() for cp in ctx.parents()]
mpm@selenic.com
hg help: use docstrings only...
r255
Matt Mackall
templates: move changeset templating bits to cmdutils
r3643 displayer = cmdutil.show_changeset(ui, repo, opts)
mpm@selenic.com
hg help: use docstrings only...
r255 for n in p:
mpm@selenic.com
commands: use node functions directly
r1092 if n != nullid:
Martin Geisler
commands: fix paths command docstring indention
r7743 displayer.show(repo[n])
Robert Bachmann
Added support for templatevar "footer" to cmdutil.py
r10152 displayer.close()
mpm@selenic.com
hg help: use docstrings only...
r255
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 @command('paths', [], _('[NAME]'), optionalrepo=True)
Thomas Arendsen Hein
Make hg paths and hg debugconfig work with -R/--repository option....
r1858 def paths(ui, repo, search=None):
Bill Barry
Clarified 'hg paths' command help
r7691 """show aliases for remote repositories
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 Show definition of symbolic path name NAME. If no name is given,
timeless
Improve English for help text of many core hg commands....
r8779 show definition of all available names.
Martin Geisler
commands: fix paths command docstring indention
r7743
Thomas Arendsen Hein
paths: Add support for -q/--quiet...
r14331 Option -q/--quiet suppresses all output when searching for NAME
and shows only the path names when listing all definitions.
Brodie Rao
help: refer to user configuration file more consistently...
r12083 Path names are defined in the [paths] section of your
configuration file and in ``/etc/mercurial/hgrc``. If run inside a
Martin Geisler
commands: better markup in "hg help paths"
r11009 repository, ``.hg/hgrc`` is used, too.
Bill Barry
consolidated url help into urls help topic and added information about path aliases
r7693
Faheem Mitha
commands: revised documentation of 'default' and 'default-push'...
r11007 The path names ``default`` and ``default-push`` have a special
meaning. When performing a push or pull operation, they are used
as fallbacks if no location is specified on the command-line.
When ``default-push`` is set, it will be used for push and
``default`` will be used for pull; otherwise ``default`` is used
as the fallback for both. When cloning a repository, the clone
source is written as ``default`` in ``.hg/hgrc``. Note that
Martin Geisler
commands: better markup in "hg help paths"
r11009 ``default`` and ``default-push`` apply to all inbound (e.g.
:hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
:hg:`bundle`) operations.
Faheem Mitha
Document 'default' and 'default-push' in paths docstring
r10933
Martin Geisler
Use hg role in help strings
r10973 See :hg:`help urls` for more information.
Nicolas Dumazet
commands: document return values of add and paths commands
r11507
Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
TK Soh
Add paths command...
r779 if search:
for name, path in ui.configitems("paths"):
if name == search:
Thomas Arendsen Hein
paths: Add support for -q/--quiet...
r14331 ui.status("%s\n" % util.hidepassword(path))
TK Soh
Add paths command...
r779 return
Thomas Arendsen Hein
paths: Add support for -q/--quiet...
r14331 if not ui.quiet:
ui.warn(_("not found!\n"))
TK Soh
Add paths command...
r779 return 1
else:
for name, path in ui.configitems("paths"):
Thomas Arendsen Hein
paths: Add support for -q/--quiet...
r14331 if ui.quiet:
ui.write("%s\n" % name)
else:
ui.write("%s = %s\n" % (name, util.hidepassword(path)))
TK Soh
Add paths command...
r779
Pierre-Yves David
command: remove phase from the list of basic command...
r17981 @command('phase',
Martin Geisler
phase: lowercase option help, rephrase slightly
r15849 [('p', 'public', False, _('set changeset phase to public')),
('d', 'draft', False, _('set changeset phase to draft')),
('s', 'secret', False, _('set changeset phase to secret')),
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 ('f', 'force', False, _('allow to move boundary backward')),
Martin Geisler
phase: add metavar to -r help text
r15855 ('r', 'rev', [], _('target revision'), _('REV')),
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 ],
Martin Geisler
phase: the REV argument can be repeated
r15854 _('[-p|-d|-s] [-f] [-r] REV...'))
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 def phase(ui, repo, *revs, **opts):
"""set or show the current phase name
With no argument, show the phase name of specified revisions.
Martin Geisler
phase: use standard syntax for command line flags...
r15851 With one of -p/--public, -d/--draft or -s/--secret, change the
Martin Geisler
phase: fix RST markup (use ``...`` for literal text)
r15850 phase value of the specified revisions.
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830
Unless -f/--force is specified, :hg:`phase` won't move changeset from a
Martin Geisler
phase: fix RST markup (use ``...`` for literal text)
r15850 lower phase to an higher phase. Phases are ordered as follows::
Matt Mackall
phase: fix up help string
r15832
public < draft < secret
Pierre-Yves David
phase: report phase movement...
r15906
Yuya Nishihara
phase: say "Returns 0" instead of "Return 0" like other command help
r20633 Returns 0 on success, 1 if no phases were changed or some could not
Patrick Mezard
phase: when phase cannot be reduced, hint at --force and return 1 (BC)...
r16097 be changed.
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 """
# search for a unique phase argument
targetphase = None
Martin Geisler
commands: no need to rename merge and phases on import
r15853 for idx, name in enumerate(phases.phasenames):
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 if opts[name]:
if targetphase is not None:
Matt Mackall
phase: mark messages for i18n
r15833 raise util.Abort(_('only one phase can be specified'))
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 targetphase = idx
# look for specified revision
revs = list(revs)
revs.extend(opts['rev'])
if not revs:
Idan Kamara
commands: drop exclamation mark in abort message
r15958 raise util.Abort(_('no revisions specified'))
Matt Mackall
phase: drop reference to working directory phase
r15831
Pierre-Yves David
phase: accept old style revision specification
r16024 revs = scmutil.revrange(repo, revs)
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 lock = None
Pierre-Yves David
phase: report phase movement...
r15906 ret = 0
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 if targetphase is None:
# display
Pierre-Yves David
phase: accept old style revision specification
r16024 for r in revs:
ctx = repo[r]
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
else:
Pierre-Yves David
phase: wrap `hg phases` phase movement in a transaction...
r22050 tr = None
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 lock = repo.lock()
try:
Pierre-Yves David
phase: wrap `hg phases` phase movement in a transaction...
r22050 tr = repo.transaction("phase")
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 # set phase
Patrick Mezard
phase: make if abort on nullid for the good reason...
r16659 if not revs:
Mads Kiilerich
check-code: indent 4 spaces in py files
r17299 raise util.Abort(_('empty revision set'))
Patrick Mezard
phase: make if abort on nullid for the good reason...
r16659 nodes = [repo[r].node() for r in revs]
Patrick Mezard
phases: introduce phasecache...
r16657 olddata = repo._phasecache.getphaserevs(repo)[:]
Pierre-Yves David
phase: add a transaction argument to advanceboundary...
r22069 phases.advanceboundary(repo, tr, targetphase, nodes)
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 if opts['force']:
Pierre-Yves David
phase: add a transaction argument to retractboundary...
r22070 phases.retractboundary(repo, tr, targetphase, nodes)
Pierre-Yves David
phase: wrap `hg phases` phase movement in a transaction...
r22050 tr.close()
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 finally:
Pierre-Yves David
phase: wrap `hg phases` phase movement in a transaction...
r22050 if tr is not None:
tr.release()
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830 lock.release()
Pierre-Yves David
phases: prepare phase command for filtering...
r18210 # moving revision from public to draft may hide them
# We have to check result on an unfiltered repository
unfi = repo.unfiltered()
newdata = repo._phasecache.getphaserevs(unfi)
Patrick Mezard
phase: remove useless test, olddata is never None
r16715 changes = sum(o != newdata[i] for i, o in enumerate(olddata))
Pierre-Yves David
phases: prepare phase command for filtering...
r18210 cl = unfi.changelog
Patrick Mezard
phase: remove useless test, olddata is never None
r16715 rejected = [n for n in nodes
Pierre-Yves David
phases: avoid changectx creation while checking command result...
r18209 if newdata[cl.rev(n)] < targetphase]
Patrick Mezard
phase: remove useless test, olddata is never None
r16715 if rejected:
Martin Geisler
phase: better error message when --force is needed...
r20093 ui.warn(_('cannot move %i changesets to a higher '
Patrick Mezard
phase: remove useless test, olddata is never None
r16715 'phase, use --force\n') % len(rejected))
ret = 1
if changes:
msg = _('phase changed for %i changesets\n') % changes
if ret:
ui.status(msg)
Pierre-Yves David
phase: report phase movement...
r15906 else:
Patrick Mezard
phase: remove useless test, olddata is never None
r16715 ui.note(msg)
else:
ui.warn(_('no phases changed\n'))
ret = 1
Pierre-Yves David
phase: alway return a value...
r15968 return ret
Pierre-Yves David
phases: add a phases command to display and manipulate phases
r15830
Alexis S. L. Carvalho
pull -u: if "url#rev" was given, update to rev
r5224 def postincoming(ui, repo, modheads, optupdate, checkout):
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 if modheads == 0:
Matt Mackall
pull: backout change to return code...
r16107 return
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 if optupdate:
Kevin Bullock
bookmarks: pull --update updates to active bookmark if it moved (issue4007)...
r19523 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
Brendan Cully
Make pull -u behave like pull && update...
r14485 try:
Matt Mackall
bookmarks: move current bookmark on update -u and bare pull -u (issue3222)...
r16019 ret = hg.update(repo, checkout)
Brendan Cully
Make pull -u behave like pull && update...
r14485 except util.Abort, inst:
Javi Merino
update: don't translate the abort message twice...
r16230 ui.warn(_("not updating: %s\n") % str(inst))
Siddharth Agarwal
pull: for pull --update with failed update, print hint if any...
r19797 if inst.hint:
ui.warn(_("(%s)\n") % inst.hint)
Brendan Cully
Make pull -u behave like pull && update...
r14485 return 0
Matt Mackall
bookmarks: move current bookmark on update -u and bare pull -u (issue3222)...
r16019 if not ret and not checkout:
if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
return ret
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 if modheads > 1:
Kevin Berridge
pull: new output message when there are multiple branches...
r13804 currentbranchheads = len(repo.branchheads())
if currentbranchheads == modheads:
Kevin Berridge
pull: don't suggest running hg merge when new heads are on different branches...
r13803 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
Kevin Berridge
pull: new output message when there are multiple branches...
r13804 elif currentbranchheads > 1:
Brodie Rao
cleanup: eradicate long lines
r16683 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
"merge)\n"))
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 else:
Kevin Berridge
pull: don't suggest running hg merge when new heads are on different branches...
r13803 ui.status(_("(run 'hg heads' to see heads)\n"))
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 else:
ui.status(_("(run 'hg update' to get a working copy)\n"))
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^pull',
[('u', 'update', None,
_('update to new branch head if changesets were pulled')),
('f', 'force', None, _('run even when remote repository is unrelated')),
('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
('b', 'branch', [], _('a specific branch you would like to pull'),
_('BRANCH')),
] + remoteopts,
_('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
mpm@selenic.com
[PATCH] Unintuive use...
r404 def pull(ui, repo, source="default", **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """pull changes from the specified source
timeless
Improve English for help text of many core hg commands....
r8779 Pull changes from a remote repository to a local one.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
This finds all changes from the repository at the specified path
timeless
Improve English for help text of many core hg commands....
r8779 or URL and adds them to a local repository (the current one unless
-R is specified). By default, this does not update the copy of the
project in the working directory.
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 Use :hg:`incoming` if you want to see what would have been added
by a pull at the time you issued this command. If you then decide
to add those changes to the repository, you should use :hg:`pull
-r X` where ``X`` is the last changeset listed by :hg:`incoming`.
Martin Geisler
commands: make pull help point to the incoming command
r7980
Bill Barry
consolidated url help into urls help topic and added information about path aliases
r7693 If SOURCE is omitted, the 'default' path will be used.
Martin Geisler
Use hg role in help strings
r10973 See :hg:`help urls` for more information.
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
pull: backout change to return code...
r16107 Returns 0 on success, 1 if an update had unresolved files.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Sune Foldager
add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
r10379 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
Matt Mackall
hg: change various repository() users to use peer() where appropriate...
r14556 other = hg.peer(repo, opts, source)
Piotr Klecha
pull: close peer repo on completion (issue2491) (issue2797)...
r20576 try:
ui.status(_('pulling from %s\n') % util.hidepassword(source))
revs, checkout = hg.addbranchrevs(repo, other, branches,
opts.get('rev'))
remotebookmarks = other.listkeys('bookmarks')
if opts.get('bookmark'):
if not revs:
revs = []
for b in opts['bookmark']:
if b not in remotebookmarks:
raise util.Abort(_('remote bookmark %s not found!') % b)
revs.append(remotebookmarks[b])
if revs:
try:
revs = [other.lookup(rev) for rev in revs]
except error.CapabilityError:
err = _("other repository doesn't support revision lookup, "
"so a rev cannot be specified.")
raise util.Abort(err)
modheads = repo.pull(other, heads=revs, force=opts.get('force'))
bookmarks.updatefromremote(ui, repo, remotebookmarks, source)
if checkout:
checkout = str(repo.changelog.rev(other.lookup(checkout)))
repo._subtoppath = source
Bryan O'Sullivan
Push capability checking into protocol-level code.
r5259 try:
Piotr Klecha
pull: close peer repo on completion (issue2491) (issue2797)...
r20576 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
finally:
del repo._subtoppath
# update specified bookmarks
if opts.get('bookmark'):
marks = repo._bookmarks
for b in opts['bookmark']:
# explicit pull overrides local bookmark if any
ui.status(_("importing bookmark %s\n") % b)
marks[b] = repo[remotebookmarks[b]].node()
marks.write()
Mads Kiilerich
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
r12852 finally:
Piotr Klecha
pull: close peer repo on completion (issue2491) (issue2797)...
r20576 other.close()
Matt Mackall
bookmarks: move push/pull command features to core
r13368 return ret
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^push',
[('f', 'force', None, _('force push')),
('r', 'rev', [],
_('a changeset intended to be included in the destination'),
_('REV')),
('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
('b', 'branch', [],
_('a specific branch you would like to push'), _('BRANCH')),
('', 'new-branch', False, _('allow pushing a new branch')),
] + remoteopts,
_('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
Vadim Gelfer
push, outgoing, bundle: fall back to "default" if "default-push" not defined
r2494 def push(ui, repo, dest=None, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """push changes to the specified destination
Faheem Mitha
commands: updates to push docstring....
r11217 Push changesets from the local repository to the specified
destination.
This operation is symmetrical to pull: it is identical to a pull
in the destination repository from the current one.
By default, push will not allow creation of new heads at the
destination, since multiple heads would make it unclear which head
to use. In this situation, it is recommended to pull and merge
before pushing.
Martin Geisler
commands: document --new-branch flag for push
r11219 Use --new-branch if you want to allow push to create a new named
branch that is not present at the destination. This allows you to
only create a new branch without forcing other changes.
FUJIWARA Katsunori
push: add more detailed explanation about "--force" to online help document...
r19935 .. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Matt Mackall
help: minor tweak to push help
r19941 Extra care should be taken with the -f/--force option,
FUJIWARA Katsunori
push: add more detailed explanation about "--force" to online help document...
r19935 which will push all new heads on all branches, an action which will
almost always cause confusion for collaborators.
Faheem Mitha
commands: updates to push docstring....
r11217
If -r/--rev is used, the specified revision and all its ancestors
will be pushed to the remote repository.
Bill Barry
consolidated url help into urls help topic and added information about path aliases
r7693
Augie Fackler
bookmarks: document behavior of -B/--bookmark in help
r17190 If -B/--bookmark is used, the specified bookmarked revision, its
ancestors, and the bookmark will be pushed to the remote
repository.
Martin Geisler
Use hg role in help strings
r10973 Please see :hg:`help urls` for important details about ``ssh://``
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 URLs. If DESTINATION is omitted, a default path will be used.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 if push was successful, 1 if nothing to push.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
bookmarks: move push/pull command features to core
r13368
if opts.get('bookmark'):
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
Matt Mackall
bookmarks: move push/pull command features to core
r13368 for b in opts['bookmark']:
# translate -B options to -r so changesets get pushed
if b in repo._bookmarks:
opts.setdefault('rev', []).append(b)
else:
# if we try to push a deleted bookmark, translate it to null
# this lets simultaneous -r, -b options continue working
opts.setdefault('rev', []).append("null")
Sune Foldager
interpret repo#name url syntax as branch instead of revision...
r10365 dest = ui.expandpath(dest or 'default-push', dest or 'default')
Sune Foldager
add -b/--branch option to clone, bundle, incoming, outgoing, pull, push
r10379 dest, branches = hg.parseurl(dest, opts.get('branch'))
Brodie Rao
url: move URL parsing functions into util to improve startup time...
r14076 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
Sune Foldager
interpret repo#name url syntax as branch instead of revision...
r10365 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
anuraggoel
push: provide a hint when no paths in configured (issue3692)...
r20558 try:
other = hg.peer(repo, opts, dest)
except error.RepoError:
if dest == "default-push":
raise util.Abort(_("default repository not configured!"),
hint=_('see the "path" section in "hg help config"'))
else:
raise
Matt Mackall
Add support for url#id syntax...
r4478 if revs:
Pierre-Yves David
push: accept revset argument for --rev
r17168 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
Matt Mackall
subrepo: basic push support
r8815
Mads Kiilerich
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
r12852 repo._subtoppath = dest
try:
# push subrepos depth-first for coherent ordering
c = repo['']
subs = c.substate # only repos that are committed
for s in sorted(subs):
Matt Mackall
subrepo: return non-zero exit code when a subrepo push doesn't succeed
r21034 result = c.sub(s).push(opts)
if result == 0:
return not result
Mads Kiilerich
subrepo: propagate non-default pull/push path to relative subrepos (issue1852)
r12852 finally:
del repo._subtoppath
Matt Mackall
bookmarks: move push/pull command features to core
r13368 result = repo.push(other, opts.get('force'), revs=revs,
newbranch=opts.get('new_branch'))
Matt Mackall
push: return 1 if no changes found (issue3228)...
r16023 result = not result
Matt Mackall
bookmarks: move push/pull command features to core
r13368
if opts.get('bookmark'):
FUJIWARA Katsunori
bookmarks: rewrite pushing local bookmarks in "commands.push()" by "compare()"...
r20026 bresult = bookmarks.pushtoremote(ui, repo, other, opts['bookmark'])
if bresult == 2:
return 2
if not result and bresult:
result = 2
Matt Mackall
bookmarks: move push/pull command features to core
r13368
return result
mpm@selenic.com
stopgap hg push support...
r319
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('recover', [])
mpm@selenic.com
big heap of command clean-up work...
r245 def recover(ui, repo):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """roll back an interrupted transaction
Recover from an interrupted commit or pull.
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 This command tries to fix the repository status after an
interrupted operation. It should only be necessary when Mercurial
suggests it.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 if successful, 1 if nothing to recover or verify fails.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
Automatically run "verify" whenever we run "recover"
r1516 if repo.recover():
Matt Mackall
Move repo.verify
r2778 return hg.verify(repo)
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 return 1
mpm@selenic.com
big heap of command clean-up work...
r245
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^remove|rm',
[('A', 'after', None, _('record delete for missing files')),
('f', 'force', None,
_('remove (and delete) file even if added or modified')),
] + walkopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... FILE...'),
inferrepo=True)
Vadim Gelfer
add --after option to remove command.
r2179 def remove(ui, repo, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """remove the specified files on the next commit
Matt Mackall
remove: simplify help...
r15114 Schedule the indicated files for removal from the current branch.
This command schedules the files to be removed at the next commit.
To undo a remove before that, see :hg:`revert`. To undo added
files, see :hg:`forget`.
.. container:: verbose
-A/--after can be used to remove only files that have already
been deleted, -f/--force can be used to force deletion, and -Af
can be used to remove files from the next revision without
deleting them from the working directory.
The following table details the behavior of remove for different
file states (columns) and option combinations (rows). The file
states are Added [A], Clean [C], Modified [M] and Missing [!]
(as reported by :hg:`status`). The actions are Warn, Remove
(from branch) and Delete (from disk):
Matt Mackall
minirst: add simple table support...
r15037
FUJIWARA Katsunori
doc: put text into header of 1st column in table to generate page correctly...
r19960 ========= == == == ==
opt/state A C M !
========= == == == ==
none W RD W R
-f R RD RD R
-A W W W R
-Af R R R R
========= == == == ==
Vadim Gelfer
remove: rewrite to be ~400x faster, bit more friendly...
r2309
Matt Mackall
remove: simplify help...
r15114 Note that remove never deletes files in Added [A] state from the
working directory, not even if option --force is specified.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success, 1 if any warnings encountered.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Dirkjan Ochtman
improved semantics for remove (issue438)...
r6346
Matt Mackall
commands: initial audit of exit codes...
r11177 ret = 0
Dirkjan Ochtman
improved semantics for remove (issue438)...
r6346 after, force = opts.get('after'), opts.get('force')
if not pats and not after:
Vadim Gelfer
add --after option to remove command.
r2179 raise util.Abort(_('no files specified'))
Dirkjan Ochtman
improved semantics for remove (issue438)...
r6346
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 m = scmutil.match(repo[None], pats, opts)
Matt Mackall
remove: work directly off status...
r6761 s = repo.status(match=m, clean=True)
modified, added, deleted, clean = s[0], s[1], s[3], s[6]
Matt Mackall
remove: don't return error on directories with tracked files...
r17848 # warn about failure to delete explicit files/dirs
wctx = repo[None]
Benoit Boissinot
remove: warn if unversionned files are specified (issue1454)
r8533 for f in m.files():
Matt Mackall
remove: don't return error on directories with tracked files...
r17848 if f in repo.dirstate or f in wctx.dirs():
continue
if os.path.exists(m.rel(f)):
if os.path.isdir(m.rel(f)):
ui.warn(_('not removing %s: no tracked files\n') % m.rel(f))
else:
Idan Kamara
forget, remove: don't note on nonexistent file twice...
r14604 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
Matt Mackall
remove: don't return error on directories with tracked files...
r17848 # missing files will generate a warning elsewhere
ret = 1
Benoit Boissinot
remove: warn if unversionned files are specified (issue1454)
r8533
Matt Mackall
remove: work directly off status...
r6761 if force:
Adrian Buehlmann
commands.remove: don't use workingctx.remove(list, unlink=True)...
r14450 list = modified + deleted + clean + added
Matt Mackall
remove: work directly off status...
r6761 elif after:
Adrian Buehlmann
commands.remove: don't use workingctx.remove(list, unlink=True)...
r14450 list = deleted
Brodie Rao
remove: properly set return code when warnings are issued...
r12129 for f in modified + added + clean:
Mads Kiilerich
rm: drop misleading 'use -f' hint for the rm --after 'not removing' warning...
r18053 ui.warn(_('not removing %s: file still exists\n') % m.rel(f))
Brodie Rao
remove: properly set return code when warnings are issued...
r12129 ret = 1
Matt Mackall
remove: work directly off status...
r6761 else:
Adrian Buehlmann
commands.remove: don't use workingctx.remove(list, unlink=True)...
r14450 list = deleted + clean
Brodie Rao
remove: properly set return code when warnings are issued...
r12129 for f in modified:
ui.warn(_('not removing %s: file is modified (use -f'
' to force removal)\n') % m.rel(f))
ret = 1
for f in added:
Matt Mackall
remove: suggest forget to undo adds
r15115 ui.warn(_('not removing %s: file has been marked for add'
' (use forget to undo)\n') % m.rel(f))
Brodie Rao
remove: properly set return code when warnings are issued...
r12129 ret = 1
Matt Mackall
remove: work directly off status...
r6761
Adrian Buehlmann
commands.remove: don't use workingctx.remove(list, unlink=True)...
r14450 for f in sorted(list):
Matt Mackall
remove: work directly off status...
r6761 if ui.verbose or not m.exact(f):
ui.status(_('removing %s\n') % m.rel(f))
Dirkjan Ochtman
improved semantics for remove (issue438)...
r6346
Adrian Buehlmann
commands.remove: don't use workingctx.remove(list, unlink=True)...
r14450 wlock = repo.wlock()
try:
if not after:
for f in list:
if f in added:
continue # we never unlink added files on remove
Mads Kiilerich
util: fold ENOENT check into unlinkpath, controlled by new ignoremissing flag...
r18143 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
Adrian Buehlmann
commands.remove: don't use workingctx.remove(list, unlink=True)...
r14450 repo[None].forget(list)
finally:
wlock.release()
Matt Mackall
commands: initial audit of exit codes...
r11177 return ret
mpm@selenic.com
big heap of command clean-up work...
r245
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('rename|move|mv',
[('A', 'after', None, _('record a rename that has already occurred')),
('f', 'force', None, _('forcibly copy over an existing managed file')),
] + walkopts + dryrunopts,
_('[OPTION]... SOURCE... DEST'))
Bryan O'Sullivan
Add rename/mv command....
r1253 def rename(ui, repo, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """rename files; equivalent of copy + remove
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 Mark dest as copies of sources; mark sources for deletion. If dest
is a directory, copies are put in that directory. If dest is a
file, there can only be one source.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
By default, this command copies the contents of files as they
Martin Geisler
commands: consistently write switches as -a/--abc
r8033 exist in the working directory. If invoked with -A/--after, the
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 operation is recorded, but no copying is performed.
timeless
help: miscellaneous language fixes
r7807 This command takes effect at the next commit. To undo a rename
Martin Geisler
Use our custom hg reStructuredText role some more...
r11193 before that, see :hg:`revert`.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success, 1 if errors are encountered.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
repo locks: use True/False
r4914 wlock = repo.wlock(False)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 try:
Matt Mackall
copy: handle rename internally...
r5610 return cmdutil.copy(ui, repo, pats, opts, rename=True)
Matt Mackall
Use try/finally pattern to cleanup locks and transactions
r4915 finally:
Ronny Pfannschmidt
switch lock releasing in the core from gc to explicit
r8109 wlock.release()
Bryan O'Sullivan
Add rename/mv command....
r1253
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('resolve',
[('a', 'all', None, _('select all unresolved files')),
('l', 'list', None, _('list state of files needing merge')),
('m', 'mark', None, _('mark files as resolved')),
('u', 'unmark', None, _('mark files as unresolved')),
('n', 'no-status', None, _('hide status prefix'))]
Martin Geisler
commands: use mergetoolopts when a command supports --tool
r14852 + mergetoolopts + walkopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... [FILE]...'),
inferrepo=True)
Matt Mackall
resolve: new command...
r6518 def resolve(ui, repo, *pats, **opts):
Mark Edgington
resolve: updated help documentation for improved clarity
r11836 """redo merges or set/view the merge status of files
Merges with unresolved conflicts are often the result of
Brodie Rao
help: refer to user configuration file more consistently...
r12083 non-interactive merging using the ``internal:merge`` configuration
setting, or a command-line merge tool like ``diff3``. The resolve
command is used to manage the files involved in a merge, after
:hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
Augie Fackler
resolve: mention merge-tools topic in help
r16009 working directory must have two parents). See :hg:`help
merge-tools` for information on configuring merge tools.
Mark Edgington
resolve: updated help documentation for improved clarity
r11836
The resolve command can be used in the following ways:
Mads Kiilerich
help: improve merge-tools topic, describe --tool and clarify details...
r12809 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
Steve Borho
merge: add --tool argument to merge and resolve...
r12750 files, discarding any previous merge attempts. Re-merging is not
Mark Edgington
resolve: updated help documentation for improved clarity
r11836 performed for files already marked as resolved. Use ``--all/-a``
Pang Yan Han
commands: fix grammar in resolve help text
r15042 to select all unresolved files. ``--tool`` can be used to specify
Steve Borho
merge: add --tool argument to merge and resolve...
r12750 the merge tool used for the given files. It overrides the HGMERGE
Pierre-Yves David
resolve: update documentation to mention the .orig backup
r15232 environment variable and your configuration files. Previous file
contents are saved with a ``.orig`` suffix.
Mark Edgington
resolve: updated help documentation for improved clarity
r11836
- :hg:`resolve -m [FILE]`: mark a file as having been resolved
(e.g. after having manually fixed-up the files). The default is
to mark all unresolved files.
- :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
default is to mark all resolved files.
- :hg:`resolve -l`: list files which had or still have conflicts.
In the printed list, ``U`` = unresolved and ``R`` = resolved.
Note that Mercurial will not let you commit files with unresolved
merge conflicts. You must use :hg:`resolve -m ...` before you can
commit after a conflicting merge.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success, 1 if any files fail a resolve attempt.
Matt Mackall
resolve: new command...
r6518 """
timeless
commands: adding --no-status to resolve to match status
r9646 all, mark, unmark, show, nostatus = \
[opts.get(o) for o in 'all mark unmark list no_status'.split()]
Matt Mackall
resolve: require -a switch to resolve all files...
r7527
if (show and (mark or unmark)) or (mark and unmark):
Matt Mackall
resolve: new command...
r6518 raise util.Abort(_("too many options specified"))
Matt Mackall
resolve: require -a switch to resolve all files...
r7527 if pats and all:
raise util.Abort(_("can't specify --all and patterns"))
if not (all or pats or show or mark or unmark):
Nathan Goldbaum
resolve: report no argument warning using a hint...
r21940 raise util.Abort(_('no files or directories specified'),
hint=('use --all to remerge all files'))
Matt Mackall
resolve: new command...
r6518
Mads Kiilerich <madski at unity3d.com>
resolve: keep wlock while resolving...
r21709 wlock = repo.wlock()
try:
ms = mergemod.mergestate(repo)
Matt Mackall
merge with stable
r21720
if not ms.active() and not show:
raise util.Abort(
_('resolve command not applicable when not merging'))
Mads Kiilerich <madski at unity3d.com>
resolve: keep wlock while resolving...
r21709 m = scmutil.match(repo[None], pats, opts)
ret = 0
Matt Mackall
merge with stable
r21720 didwork = False
Mads Kiilerich <madski at unity3d.com>
resolve: keep wlock while resolving...
r21709
for f in ms:
Matt Mackall
merge with stable
r21720 if not m(f):
continue
didwork = True
if show:
if nostatus:
ui.write("%s\n" % f)
timeless
commands: adding --no-status to resolve to match status
r9646 else:
Matt Mackall
merge with stable
r21720 ui.write("%s %s\n" % (ms[f].upper(), f),
label='resolve.' +
{'u': 'unresolved', 'r': 'resolved'}[ms[f]])
elif mark:
ms.mark(f, "r")
elif unmark:
ms.mark(f, "u")
Matt Mackall
resolve: new command...
r6518 else:
Matt Mackall
merge with stable
r21720 wctx = repo[None]
# backup pre-resolve (merge uses .orig for its own purposes)
a = repo.wjoin(f)
util.copyfile(a, a + ".resolve")
try:
# resolve file
ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
'resolve')
if ms.resolve(f, wctx):
ret = 1
finally:
ui.setconfig('ui', 'forcemerge', '', 'resolve')
ms.commit()
# replace filemerge's .orig file with our resolve file
util.rename(a + ".resolve", a + ".orig")
Mads Kiilerich <madski at unity3d.com>
resolve: keep wlock while resolving...
r21709
ms.commit()
Matt Mackall
merge with stable
r21720
if not didwork and pats:
Matt Mackall
resolve: fix grammar of no matching files message
r21721 ui.warn(_("arguments do not match paths that need resolving\n"))
Matt Mackall
merge with stable
r21720
Mads Kiilerich <madski at unity3d.com>
resolve: keep wlock while resolving...
r21709 finally:
wlock.release()
Gregory Szorc
resolve: print message when no unresolved files remain (issue4214)...
r21266 # Nudge users into finishing an unfinished operation. We don't print
# this with the list/show operation because we want list/show to remain
# machine readable.
if not list(ms.unresolved()) and not show:
Pierre-Yves David
resolve: add parenthesis around "no more unresolved files" message...
r21947 ui.status(_('(no more unresolved files)\n'))
Gregory Szorc
resolve: print message when no unresolved files remain (issue4214)...
r21266
Matt Mackall
commands: initial audit of exit codes...
r11177 return ret
Matt Mackall
resolve: keep .orig files
r7847
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('revert',
[('a', 'all', None, _('revert all changes when no arguments given')),
('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
('r', 'rev', '', _('revert to the specified revision'), _('REV')),
Adrian Buehlmann
revert: introduce short option -C for --no-backup...
r15009 ('C', 'no-backup', None, _('do not save backup copies of files')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ] + walkopts + dryrunopts,
_('[OPTION]... [-r REV] [NAME]...'))
Benoit Boissinot
make revert use standard matcher
r1472 def revert(ui, repo, *pats, **opts):
Matt Mackall
revert: rewrite help summary...
r14540 """restore files to their checkout state
Matt Mackall
imported patch rev-help
r5574
Christian Ebert
Use more note admonitions in help texts
r12390 .. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Matt Mackall
revert: simplify usage note...
r14541 To check out earlier revisions, you should use :hg:`update REV`.
Matt Mackall
help: fix role/option confusion in RST...
r19217 To cancel an uncommitted merge (and lose your changes),
use :hg:`update --clean .`.
Vadim Gelfer
fix doc comments for revert command. people found them confusing.
r2204
Matt Mackall
revert: rearrange the date help
r14544 With no revision specified, revert the specified files or directories
Matt Mackall
revert: restore check for uncommitted merge (issue2915) (BC)...
r14903 to the contents they had in the parent of the working directory.
Matt Mackall
revert: rearrange the date help
r14544 This restores the contents of files to an unmodified
Matt Mackall
revert: restore check for uncommitted merge (issue2915) (BC)...
r14903 state and unschedules adds, removes, copies, and renames. If the
working directory has two parents, you must explicitly specify a
revision.
Benoit Boissinot
resync commands.py docstrings with hg.1.txt
r1811
Matt Mackall
revert: rearrange the date help
r14544 Using the -r/--rev or -d/--date options, revert the given files or
Adrian Buehlmann
revert: is reverting file states, not just file contents...
r14557 directories to their states as of a specific revision. Because
Matt Mackall
revert: replace mention of 'roll back' with pointer to 'backout'
r14546 revert does not change the working directory parents, this will
cause these files to appear modified. This can be helpful to "back
Matt Mackall
revert: actually add pointer to backout
r14547 out" some or all of an earlier change. See :hg:`backout` for a
related method.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Matt Mackall
imported patch rev-help
r5574 Modified files are saved with a .orig suffix before reverting.
To disable these backups, use --no-backup.
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
revert: rearrange the date help
r14544 See :hg:`help dates` for a list of formats valid for -d/--date.
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Vadim Gelfer
revert: require --all to revert all files.
r2982
Xavier Snelgrove
revert: use opts.get...
r11941 if opts.get("date"):
if opts.get("rev"):
Matt Mackall
Add --date support to update and revert...
r3814 raise util.Abort(_("you can't specify a revision and a date"))
opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
timeless
revert: improve merge advice and favor its error over all
r13022 parent, p2 = repo.dirstate.parents()
Matt Mackall
revert: restore check for uncommitted merge (issue2915) (BC)...
r14903 if not opts.get('rev') and p2 != nullid:
# revert after merge is a trap for new users (issue2915)
raise util.Abort(_('uncommitted merge with no revision specified'),
hint=_('use "hg update" or see "hg help revert"'))
Adrian Buehlmann
revert: mention update in hint of abort when reverting to non-parent...
r14726 ctx = scmutil.revsingle(repo, opts.get('rev'))
timeless
revert: improve merge advice and favor its error over all
r13022
Alexander Solovyov
commands: optional options where possible...
r7131 if not pats and not opts.get('all'):
Adrian Buehlmann
revert: be more helpful on uncommitted merges...
r14721 msg = _("no files or directories specified")
if p2 != nullid:
hint = _("uncommitted merge, use --all to discard all changes,"
" or 'hg update -C .' to abort the merge")
Adrian Buehlmann
revert: improve hints on abort when reverting to parent without --all...
r14755 raise util.Abort(msg, hint=hint)
dirty = util.any(repo.status())
Angel Ezquerra
revert: move bulk of revert command from commands to cmdutil...
r16304 node = ctx.node()
Adrian Buehlmann
revert: improve hints on abort when reverting to parent without --all...
r14755 if node != parent:
if dirty:
Adrian Buehlmann
revert: mention update in hint of abort when reverting to non-parent...
r14726 hint = _("uncommitted changes, use --all to discard all"
" changes, or 'hg update %s' to update") % ctx.rev()
else:
hint = _("use --all to revert all files,"
" or 'hg update %s' to update") % ctx.rev()
Adrian Buehlmann
revert: improve hints on abort when reverting to parent without --all...
r14755 elif dirty:
hint = _("uncommitted changes, use --all to discard all changes")
else:
hint = _("use --all to revert all files")
Adrian Buehlmann
revert: be more helpful on uncommitted merges...
r14721 raise util.Abort(msg, hint=hint)
Vadim Gelfer
revert: require --all to revert all files.
r2982
Angel Ezquerra
revert: move bulk of revert command from commands to cmdutil...
r16304 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
mpm@selenic.com
[PATCH] hg revert...
r588
Greg Ward
rollback: avoid unsafe rollback when not at tip (issue2998)...
r15183 @command('rollback', dryrunopts +
[('f', 'force', False, _('ignore safety measures'))])
Steve Borho
rollback: add dry-run argument, emit transaction description
r10882 def rollback(ui, repo, **opts):
Matt Mackall
rollback: mark as deprecated
r19409 """roll back the last transaction (DANGEROUS) (DEPRECATED)
Matt Mackall
imported patch rollback-help
r5575
Martin Geisler
rollback: add reference to "hg commit --amend"...
r19421 Please use :hg:`commit --amend` instead of rollback to correct
mistakes in the last commit.
Matt Mackall
imported patch rollback-help
r5575 This command should be used with care. There is only one level of
rollback, and there is no way to undo a rollback. It will also
restore the dirstate at the time of the last transaction, losing
Matt Mackall
rollback: minor clarification (issue828)
r8856 any dirstate changes since that time. This command does not alter
the working directory.
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227
Transactions are used to encapsulate the effects of all commands
that create new changesets or propagate existing changesets into a
Adrian Buehlmann
rollback: split off command example paragraph in help
r17141 repository.
Adrian Buehlmann
rollback: move examples and --force note in help into verbose section...
r17142 .. container:: verbose
For example, the following commands are transactional, and their
effects can be rolled back:
- commit
- import
- pull
- push (with this repository as the destination)
- unbundle
To avoid permanent data loss, rollback will refuse to rollback a
commit transaction if it isn't checked out. Use --force to
override this protection.
Greg Ward
rollback: avoid unsafe rollback when not at tip (issue2998)...
r15183
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227 This command is not intended for use on public repositories. Once
changes are visible for pull by other users, rolling a transaction
back locally is ineffective (someone else may already have pulled
the changes). Furthermore, a race is possible with readers of the
repository; for example an in-progress pull from the repository
may fail if a rollback is performed.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success, 1 if no rollback data is available.
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227 """
Greg Ward
rollback: avoid unsafe rollback when not at tip (issue2998)...
r15183 return repo.rollback(dryrun=opts.get('dry_run'),
force=opts.get('force'))
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('root', [])
mpm@selenic.com
[PATCH] add "root" command...
r468 def root(ui, repo):
Martin Geisler
expand "dir" to "directory" in help texts
r8026 """print the root (top) of the current working directory
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Print the root directory of the current repository.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
mpm@selenic.com
[PATCH] add "root" command...
r468 ui.write(repo.root + "\n")
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^serve',
[('A', 'accesslog', '', _('name of access log file to write to'),
_('FILE')),
('d', 'daemon', None, _('run server in background')),
('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('NUM')),
('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
# use string type, then we can check if something was passed
('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
('a', 'address', '', _('address to listen on (default: all interfaces)'),
_('ADDR')),
('', 'prefix', '', _('prefix path to serve from (default: server root)'),
_('PREFIX')),
('n', 'name', '',
_('name to show in web pages (default: working directory)'), _('NAME')),
('', 'web-conf', '',
_('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
_('FILE')),
('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
('', 'stdio', None, _('for remote clients')),
Idan Kamara
serve: add --cmdserver option to communicate with hg over a pipe
r14647 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
('', 'style', '', _('template style to use'), _('STYLE')),
('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
Gregory Szorc
commands: define optionalrepo in command decorator
r21775 _('[OPTION]...'),
optionalrepo=True)
mpm@selenic.com
big heap of command clean-up work...
r245 def serve(ui, repo, **opts):
Matt Mackall
commands: improve some command summaries
r10889 """start stand-alone webserver
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: explain that "hg serve" is mostly for ad-hoc sharing
r11102 Start a local HTTP repository browser and pull server. You can use
Adrian Buehlmann
serve: fix doc typo
r13065 this for ad-hoc sharing and browsing of repositories. It is
Martin Geisler
commands: explain that "hg serve" is mostly for ad-hoc sharing
r11102 recommended to use a real web server to serve a repository for
longer periods of time.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: explain that "hg serve" does not do authentication
r11103 Please note that the server does not implement access control.
This means that, by default, anybody can read from the server and
nobody can write to it by default. Set the ``web.allow_push``
option to ``*`` to allow everybody to push to the server. You
should use a real web server if you need to authenticate users.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 By default, the server logs accesses to stdout and errors to
Martin Geisler
write options in "-r/--rev" style in help texts
r8277 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
files.
Bryan O'Sullivan
serve: allow --port=0 to specify "server chooses the port number"
r10629
To have the server choose a free port number to listen on, specify
a port number of 0; in this case, the server will print the port
number it uses.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
Add an sshrepository class and hg serve --stdio
r624
Idan Kamara
serve: add --cmdserver option to communicate with hg over a pipe
r14647 if opts["stdio"] and opts["cmdserver"]:
raise util.Abort(_("cannot use --stdio with --cmdserver"))
Yuya Nishihara
serve: inline checkrepo() that is used only when --stdio is specified...
r21818 if opts["stdio"]:
Thomas Arendsen Hein
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
r2127 if repo is None:
Martin Geisler
serve: lowercase "no repo here" message
r16935 raise error.RepoError(_("there is no Mercurial repository here"
Yuya Nishihara
serve: tidy up indent level of repository not found message
r21819 " (.hg not found)"))
Vadim Gelfer
refactor ssh server.
r2396 s = sshserver.sshserver(ui, repo)
s.serve_forever()
Matt Mackall
Give a response to unknown SSH commands
r2363
Idan Kamara
serve: add --cmdserver option to communicate with hg over a pipe
r14647 if opts["cmdserver"]:
s = commandserver.server(ui, repo, opts["cmdserver"])
return s.serve()
Benoit Boissinot
serve: fix port config
r10635 # this way we can check if something was given in the command-line
if opts.get('port'):
Brodie Rao
mail/hgweb: support service names for ports (issue2350)...
r12076 opts['port'] = util.getport(opts.get('port'))
Benoit Boissinot
serve: fix port config
r10635
Matt Mackall
ui: kill most users of parentui name and arg, replace with .copy()
r8190 baseui = repo and repo.baseui or ui
Michele Cella
adding "prefix" option to "hg serve" (command line and [web] section)...
r5835 optlist = ("name templates style address port prefix ipv6"
Dirkjan Ochtman
server: initialize wsgi app in command, then wrap server around it
r10644 " accesslog errorlog certificate encoding")
mpm@selenic.com
hgweb: change startup argument processing...
r987 for o in optlist.split():
Benoit Boissinot
serve: fix options recording, trailing whitespace
r10630 val = opts.get(o, '')
Thomas Arendsen Hein
make expression shorter, now the line fits into 80 chars
r10631 if val in (None, ''): # should check against default options instead
Benoit Boissinot
serve: fix options recording, trailing whitespace
r10630 continue
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 baseui.setconfig("web", o, val, 'serve')
Benoit Boissinot
serve: fix options recording, trailing whitespace
r10630 if repo and repo.ui != baseui:
Mads Kiilerich
config: set a 'source' in most cases where config don't come from file but code...
r20790 repo.ui.setconfig("web", o, val, 'serve')
mpm@selenic.com
hgweb: change startup argument processing...
r987
Matt Mackall
serve: webdir_conf -> webconf
r11003 o = opts.get('web_conf') or opts.get('webdir_conf')
Matt Mackall
hgweb: unify hgweb calls in serve
r11004 if not o:
if not repo:
Martin Geisler
serve: lowercase "no repo here" message
r16935 raise error.RepoError(_("there is no Mercurial repository"
Matt Mackall
hgweb: unify hgweb calls in serve
r11004 " here (.hg not found)"))
Simon Heimberg
serve: pass on the repo instad of recreating it in hgweb...
r18828 o = repo
Matt Mackall
hgweb: unify hgweb calls in serve
r11004
Simon Heimberg
serve: pass the prepared baseui to hgweb...
r18827 app = hgweb.hgweb(o, baseui=baseui)
Mads Kiilerich
commands: refactor 'serve', extract the http service class
r19919 service = httpservice(ui, app, opts)
Bryan O'Sullivan
Refactor commands.serve to allow other commands to run as services....
r4380 cmdutil.service(opts, initfn=service.init, runfn=service.run)
mpm@selenic.com
[PATCH] Clean up destination directory if a clone fails....
r500
Mads Kiilerich
commands: refactor 'serve', extract the http service class
r19919 class httpservice(object):
def __init__(self, ui, app, opts):
self.ui = ui
self.app = app
self.opts = opts
def init(self):
util.setsignalhandler()
self.httpd = hgweb_server.create_server(self.ui, self.app)
if self.opts['port'] and not self.ui.verbose:
return
if self.httpd.prefix:
prefix = self.httpd.prefix.strip('/') + '/'
else:
prefix = ''
port = ':%d' % self.httpd.port
if port == ':80':
port = ''
bindaddr = self.httpd.addr
if bindaddr == '0.0.0.0':
bindaddr = '*'
elif ':' in bindaddr: # IPv6
bindaddr = '[%s]' % bindaddr
fqaddr = self.httpd.fqaddr
if ':' in fqaddr:
fqaddr = '[%s]' % fqaddr
if self.opts['port']:
write = self.ui.status
else:
write = self.ui.write
write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
(fqaddr, port, prefix, bindaddr, self.httpd.port))
Yuya Nishihara
serve: make sure to print "listening at" message immediately...
r21817 self.ui.flush() # avoid buffering of status message
Mads Kiilerich
commands: refactor 'serve', extract the http service class
r19919
def run(self):
self.httpd.serve_forever()
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^status|st',
[('A', 'all', None, _('show status of all files')),
('m', 'modified', None, _('show only modified files')),
('a', 'added', None, _('show only added files')),
('r', 'removed', None, _('show only removed files')),
('d', 'deleted', None, _('show only deleted (but tracked) files')),
('c', 'clean', None, _('show only files without changes')),
('u', 'unknown', None, _('show only unknown (not tracked) files')),
('i', 'ignored', None, _('show only ignored files')),
('n', 'no-status', None, _('hide status prefix')),
('C', 'copies', None, _('show source of copied files')),
('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
('', 'rev', [], _('show difference from revision'), _('REV')),
('', 'change', '', _('list the changed files of a revision'), _('REV')),
] + walkopts + subrepoopts,
Gregory Szorc
commands: define inferrepo in command decorator
r21778 _('[OPTION]... [FILE]...'),
inferrepo=True)
Bryan O'Sullivan
Add name matching to status command.
r731 def status(ui, repo, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """show changed files in the working directory
mpm@selenic.com
commands: migrate status and branch...
r213
Christian Ebert
Consistently 1 space after full stops in command doc strings...
r6448 Show status of files in the repository. If names are given, only
files that match are shown. Files that are clean or ignored or
timeless
Improve English for help text of many core hg commands....
r8779 the source of a copy/move operation, are not listed unless
-c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
Unless options described with "show only ..." are given, the
options -mardu are used.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Thomas Arendsen Hein
Extend/correct acc40572da5b regarding -qA and ignored files....
r6201 Option -q/--quiet hides untracked (unknown and ignored) files
Wagner Bruna
commands: fix typo on flag description
r8009 unless explicitly requested with -u/--unknown or -i/--ignored.
Zoran Bosnjak
'hg status -q' output skips non-tracked files....
r6200
Christian Ebert
Use more note admonitions in help texts
r12390 .. note::
Simon Heimberg
documentation: add an extra newline after note directive...
r19997
Christian Ebert
Use more note admonitions in help texts
r12390 status may appear to disagree with diff if permissions have
changed or a merge has occurred. The standard diff format does
not report permission changes and diff only reports changes
relative to one merge parent.
Matt Mackall
Add notes about diff/merge asymmetry to export, diff, and log
r3822
Brendan Cully
Add --rev option to status
r3467 If one revision is given, it is used as the base revision.
timeless
Improve English for help text of many core hg commands....
r8779 If two revisions are given, the differences between them are
Gilles Moris
status: add the --change option to display files changed in a revision...
r10014 shown. The --change option can also be used as a shortcut to list
the changed files of a revision from its first parent.
Brendan Cully
Add --rev option to status
r3467
Martin Geisler
commands: use minirst parser when displaying help
r9157 The codes used to show the status of files are::
M = modified
A = added
R = removed
C = clean
! = missing (deleted by non-hg command, but still tracked)
? = not tracked
I = ignored
Matt Mackall
status: improve explanation of ' ' status...
r20660 = origin of the previous file (with --copies)
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
status: add some help examples
r15119 .. container:: verbose
Examples:
Martin Geisler
status: add missing ":" to help text
r15633 - show changes in the working directory relative to a
changeset::
Matt Mackall
status: add some help examples
r15119
hg status --rev 9353
- show all changes including copies in an existing changeset::
hg status --copies --change 9353
- get a NUL separated list of added files, suitable for xargs::
hg status -an0
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
mpm@selenic.com
Optimize diff and status in subdirectories...
r312
Gilles Moris
status: add the --change option to display files changed in a revision...
r10014 revs = opts.get('rev')
change = opts.get('change')
if revs and change:
msg = _('cannot specify --rev and --change at the same time')
raise util.Abort(msg)
elif change:
Patrick Mezard
status: support revsets with --change
r15578 node2 = scmutil.revsingle(repo, change, None).node()
Matt Mackall
misc: replace .parents()[0] with p1()
r13878 node1 = repo[node2].p1().node()
Gilles Moris
status: add the --change option to display files changed in a revision...
r10014 else:
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 node1, node2 = scmutil.revpair(repo, revs)
Gilles Moris
status: add the --change option to display files changed in a revision...
r10014
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 cwd = (pats and repo.getcwd()) or ''
Alexander Solovyov
commands: optional options where possible...
r7131 end = opts.get('print0') and '\0' or '\n'
Matt Mackall
status: find copies and renames beyond the working directory
r6276 copy = {}
Matt Mackall
status: refactor status command...
r6605 states = 'modified added removed deleted unknown ignored clean'.split()
Alexander Solovyov
status: make options optional (issue1481)
r7684 show = [k for k in states if opts.get(k)]
Alexander Solovyov
commands: optional options where possible...
r7131 if opts.get('all'):
Matt Mackall
status: refactor status command...
r6605 show += ui.quiet and (states[:4] + ['clean']) or states
if not show:
show = ui.quiet and states[:4] or states[:5]
Matt Mackall
scmutil: switch match users to supplying contexts...
r14671 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
Martin Geisler
status: recurse into subrepositories with --subrepos/-S flag
r12166 'ignored' in show, 'clean' in show, 'unknown' in show,
opts.get('subrepos'))
Matt Mackall
status: refactor status command...
r6605 changestates = zip(states, 'MAR!?IC', stat)
Alexander Solovyov
commands: optional options where possible...
r7131 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
Matt Mackall
copies: rewrite copy detection for non-merge users...
r15775 copy = copies.pathcopies(repo[node1], repo[node2])
Matt Mackall
status: find copies and renames beyond the working directory
r6276
Matt Mackall
formatter: convert status command
r16136 fm = ui.formatter('status', opts)
Matt Mackall
status: use condwrite to avoid zero-width format string hack
r17910 fmt = '%s' + end
showchar = not opts.get('no_status')
Matt Mackall
formatter: convert status command
r16136
Matt Mackall
status: refactor status command...
r6605 for state, char, files in changestates:
if state in show:
Matt Mackall
formatter: convert status command
r16136 label = 'status.' + state
Matt Mackall
status: refactor status command...
r6605 for f in files:
Matt Mackall
formatter: convert status command
r16136 fm.startitem()
Matt Mackall
status: use condwrite to avoid zero-width format string hack
r17910 fm.condwrite(showchar, 'status', '%s ', char, label=label)
fm.write('path', fmt, repo.pathto(f, cwd), label=label)
Matt Mackall
status: refactor status command...
r6605 if f in copy:
Matt Mackall
formatter: convert status command
r16136 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
Brodie Rao
status: make use of output labeling
r10817 label='status.copied')
Matt Mackall
formatter: convert status command
r16136 fm.end()
mpm@selenic.com
commands: migrate status and branch...
r213
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^summary|sum',
[('', 'remote', None, _('check for push and pull'))], '[--remote]')
Matt Mackall
summary: add --remote
r9620 def summary(ui, repo, **opts):
Matt Mackall
Introduce summary command
r9603 """summarize working directory state
This generates a brief summary of the working directory state,
including parents, branch, commit status, and available updates.
Matt Mackall
summary: add --remote
r9620
With the --remote option, this will check the default paths for
incoming and outgoing changes. This can be time-consuming.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Matt Mackall
Introduce summary command
r9603 """
ctx = repo[None]
parents = ctx.parents()
pnode = parents[0].node()
Augie Fackler
summary: show bookmarks separate from tags and note active mark (issue2892)
r14906 marks = []
Matt Mackall
Introduce summary command
r9603
for p in parents:
Eric Eisner
summary: make use of output labeling...
r10832 # label with log.changeset (instead of log.parent) since this
# shows a working directory parent *changeset*:
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Eric Eisner
summary: make use of output labeling...
r10832 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
Sean Farley
color: add additional changeset.phase label to log.changeset and log.parent...
r17788 label='log.changeset changeset.%s' % p.phasestr())
Martin Geisler
commands: retrieve tags from context object
r10833 ui.write(' '.join(p.tags()), label='log.tag')
David Soria Parra
summary: add bookmarks to summary
r13454 if p.bookmarks():
Augie Fackler
summary: show bookmarks separate from tags and note active mark (issue2892)
r14906 marks.extend(p.bookmarks())
Matt Mackall
summary: add empty repository and no revision checked out hints
r9618 if p.rev() == -1:
if not len(repo):
Martin Geisler
commands: small refactoring in summary
r10834 ui.write(_(' (empty repository)'))
Matt Mackall
summary: add empty repository and no revision checked out hints
r9618 else:
Martin Geisler
commands: small refactoring in summary
r10834 ui.write(_(' (no revision checked out)'))
Eric Eisner
summary: make use of output labeling...
r10832 ui.write('\n')
Matt Mackall
summary: add empty repository and no revision checked out hints
r9618 if p.description():
Eric Eisner
summary: make use of output labeling...
r10832 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
label='log.summary')
Matt Mackall
Introduce summary command
r9603
branch = ctx.branch()
bheads = repo.branchheads(branch)
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Matt Mackall
summary: note non-default branches with -q
r9873 m = _('branch: %s\n') % branch
if branch != 'default':
Eric Eisner
summary: make use of output labeling...
r10832 ui.write(m, label='log.branch')
Matt Mackall
summary: note non-default branches with -q
r9873 else:
Eric Eisner
summary: make use of output labeling...
r10832 ui.status(m, label='log.branch')
Matt Mackall
Introduce summary command
r9603
Augie Fackler
summary: show bookmarks separate from tags and note active mark (issue2892)
r14906 if marks:
current = repo._bookmarkcurrent
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Augie Fackler
summary: allow color to highlight active bookmark
r14907 ui.write(_('bookmarks:'), label='log.bookmark')
Augie Fackler
summary: show bookmarks separate from tags and note active mark (issue2892)
r14906 if current is not None:
Kevin Bullock
summary: show active bookmark even if not at current changeset...
r18622 if current in marks:
Augie Fackler
summary: allow color to highlight active bookmark
r14907 ui.write(' *' + current, label='bookmarks.current')
Kevin Bullock
summary: show active bookmark even if not at current changeset...
r18622 marks.remove(current)
else:
Matt Mackall
summary: add missing space for updated active bookmark display
r18623 ui.write(' [%s]' % current, label='bookmarks.current')
Augie Fackler
summary: allow color to highlight active bookmark
r14907 for m in marks:
Mads Kiilerich
check-code: indent 4 spaces in py files
r17299 ui.write(' ' + m, label='log.bookmark')
Augie Fackler
summary: allow color to highlight active bookmark
r14907 ui.write('\n', label='log.bookmark')
Augie Fackler
summary: show bookmarks separate from tags and note active mark (issue2892)
r14906
Matt Mackall
summary: various fixes, add a test...
r10390 st = list(repo.status(unknown=True))[:6]
Matt Mackall
summary: add subrepo status
r11088
Matt Mackall
summary: report copies and renames
r11331 c = repo.dirstate.copies()
copied, renamed = [], []
for d, s in c.iteritems():
if s in st[2]:
st[2].remove(s)
renamed.append(d)
else:
copied.append(d)
if d in st[1]:
st[1].remove(d)
st.insert(3, renamed)
st.insert(4, copied)
Martin Geisler
commands: partial backout of fbb68b382040
r15856 ms = mergemod.mergestate(repo)
Matt Mackall
summary: various fixes, add a test...
r10390 st.append([f for f in ms if ms[f] == 'u'])
Matt Mackall
summary: add subrepo status
r11088
subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
st.append(subs)
Eric Eisner
summary: make use of output labeling...
r10832 labels = [ui.label(_('%d modified'), 'status.modified'),
ui.label(_('%d added'), 'status.added'),
ui.label(_('%d removed'), 'status.removed'),
Matt Mackall
summary: report copies and renames
r11331 ui.label(_('%d renamed'), 'status.copied'),
ui.label(_('%d copied'), 'status.copied'),
Eric Eisner
summary: make use of output labeling...
r10832 ui.label(_('%d deleted'), 'status.deleted'),
ui.label(_('%d unknown'), 'status.unknown'),
ui.label(_('%d ignored'), 'status.ignored'),
Matt Mackall
summary: add subrepo status
r11088 ui.label(_('%d unresolved'), 'resolve.unresolved'),
ui.label(_('%d subrepos'), 'status.modified')]
Matt Mackall
Introduce summary command
r9603 t = []
Matt Mackall
many, many trivial check-code fixups
r10282 for s, l in zip(st, labels):
Martin Geisler
commands: do not split a translated string...
r9607 if s:
t.append(l % len(s))
Matt Mackall
Introduce summary command
r9603
t = ', '.join(t)
FUJIWARA Katsunori
summary: L10N messages hide clean-ness of workdir from 'hg summary'...
r10269 cleanworkdir = False
Matt Mackall
Introduce summary command
r9603
Matt Mackall
update: add tracking of interrupted updates (issue3113)...
r19482 if repo.vfs.exists('updatestate'):
t += _(' (interrupted update)')
elif len(parents) > 1:
Steve Borho
Backed out changeset: e1dde7363601
r11310 t += _(' (merge)')
Matt Mackall
Introduce summary command
r9603 elif branch != parents[0].branch():
Steve Borho
Backed out changeset: e1dde7363601
r11310 t += _(' (new branch)')
Brodie Rao
context: add changectx.closesbranch() method...
r16720 elif (parents[0].closesbranch() and
Gilles Moris
summary: show if commit will be from a closed head
r11165 pnode in repo.branchheads(branch, closed=True)):
Steve Borho
Backed out changeset: e1dde7363601
r11310 t += _(' (head closed)')
Matt Mackall
summary: report copies and renames
r11331 elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
Steve Borho
Backed out changeset: e1dde7363601
r11310 t += _(' (clean)')
FUJIWARA Katsunori
summary: L10N messages hide clean-ness of workdir from 'hg summary'...
r10269 cleanworkdir = True
Matt Mackall
Introduce summary command
r9603 elif pnode not in bheads:
Steve Borho
Backed out changeset: e1dde7363601
r11310 t += _(' (new branch head)')
Matt Mackall
Introduce summary command
r9603
FUJIWARA Katsunori
summary: L10N messages hide clean-ness of workdir from 'hg summary'...
r10269 if cleanworkdir:
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Steve Borho
Backed out changeset: e1dde7363601
r11310 ui.status(_('commit: %s\n') % t.strip())
Matt Mackall
summary: quieter with -q
r9605 else:
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Steve Borho
Backed out changeset: e1dde7363601
r11310 ui.write(_('commit: %s\n') % t.strip())
Matt Mackall
Introduce summary command
r9603
# all ancestors of branch heads - all ancestors of parent = new csets
Siddharth Agarwal
summary: use missing ancestors algorithm to find new commits...
r19394 new = len(repo.changelog.findmissing([ctx.node() for ctx in parents],
bheads))
Matt Mackall
Introduce summary command
r9603
if new == 0:
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Matt Mackall
summary: quieter with -q
r9605 ui.status(_('update: (current)\n'))
Matt Mackall
Introduce summary command
r9603 elif pnode not in bheads:
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Matt Mackall
Introduce summary command
r9603 ui.write(_('update: %d new changesets (update)\n') % new)
else:
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Matt Mackall
Introduce summary command
r9603 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
(new, len(bheads)))
Bryan O'Sullivan
summary: augment output with info from extensions
r19211 cmdutil.summaryhooks(ui, repo)
Matt Mackall
summary: add --remote
r9620 if opts.get('remote'):
FUJIWARA Katsunori
summary: separate checking incoming/outgoing and showing remote summary...
r21045 needsincoming, needsoutgoing = True, True
else:
needsincoming, needsoutgoing = False, False
FUJIWARA Katsunori
summary: introduce "summaryremotehooks" to avoid redundant incoming/outgoing check...
r21047 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
if i:
needsincoming = True
if o:
needsoutgoing = True
if not needsincoming and not needsoutgoing:
return
FUJIWARA Katsunori
summary: separate checking incoming/outgoing and showing remote summary...
r21045
def getincoming():
Sune Foldager
fix remaining hg.parseurl uses
r10389 source, branches = hg.parseurl(ui.expandpath('default'))
FUJIWARA Katsunori
summary: clear "commonincoming" also if branches are different...
r18997 sbranch = branches[0]
FUJIWARA Katsunori
summary: introduce "summaryremotehooks" to avoid redundant incoming/outgoing check...
r21047 try:
other = hg.peer(repo, {}, source)
except error.RepoError:
if opts.get('remote'):
raise
return source, sbranch, None, None, None
Simon Heimberg
summary: remove passing of rev because summary does not have this...
r19379 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
FUJIWARA Katsunori
summary: make "incoming" information sensitive to branch in URL (issue3830)...
r18996 if revs:
revs = [other.lookup(rev) for rev in revs]
Brodie Rao
url: move URL parsing functions into util to improve startup time...
r14076 ui.debug('comparing with %s\n' % util.hidepassword(source))
Matt Mackall
summary: add --remote
r9620 repo.ui.pushbuffer()
FUJIWARA Katsunori
summary: make "incoming" information sensitive to branch in URL (issue3830)...
r18996 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
Matt Mackall
summary: add --remote
r9620 repo.ui.popbuffer()
FUJIWARA Katsunori
summary: separate checking incoming/outgoing and showing remote summary...
r21045 return source, sbranch, other, commoninc, commoninc[1]
if needsincoming:
source, sbranch, sother, commoninc, incoming = getincoming()
else:
source = sbranch = sother = commoninc = incoming = None
def getoutgoing():
Sune Foldager
fix remaining hg.parseurl uses
r10389 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
FUJIWARA Katsunori
summary: clear "commonincoming" also if branches are different...
r18997 dbranch = branches[0]
Sune Foldager
fix remaining hg.parseurl uses
r10389 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
Peter Arrenbrecht
summary: run discovery only once for in/out against same repo...
r14214 if source != dest:
FUJIWARA Katsunori
summary: introduce "summaryremotehooks" to avoid redundant incoming/outgoing check...
r21047 try:
dother = hg.peer(repo, {}, dest)
except error.RepoError:
if opts.get('remote'):
raise
return dest, dbranch, None, None
FUJIWARA Katsunori
summary: clear "commonincoming" also if branches are different...
r18997 ui.debug('comparing with %s\n' % util.hidepassword(dest))
FUJIWARA Katsunori
summary: introduce "summaryremotehooks" to avoid redundant incoming/outgoing check...
r21047 elif sother is None:
# there is no explicit destination peer, but source one is invalid
return dest, dbranch, None, None
FUJIWARA Katsunori
summary: separate checking incoming/outgoing and showing remote summary...
r21045 else:
dother = sother
FUJIWARA Katsunori
summary: clear "commonincoming" also if branches are different...
r18997 if (source != dest or (sbranch is not None and sbranch != dbranch)):
FUJIWARA Katsunori
summary: separate checking incoming/outgoing and showing remote summary...
r21045 common = None
else:
common = commoninc
FUJIWARA Katsunori
summary: make "outgoing" information sensitive to branch in URL (issue3829)...
r18994 if revs:
revs = [repo.lookup(rev) for rev in revs]
Matt Mackall
summary: add --remote
r9620 repo.ui.pushbuffer()
FUJIWARA Katsunori
summary: separate checking incoming/outgoing and showing remote summary...
r21045 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
commoninc=common)
Matt Mackall
summary: add --remote
r9620 repo.ui.popbuffer()
FUJIWARA Katsunori
summary: separate checking incoming/outgoing and showing remote summary...
r21045 return dest, dbranch, dother, outgoing
if needsoutgoing:
dest, dbranch, dother, outgoing = getoutgoing()
else:
dest = dbranch = dother = outgoing = None
if opts.get('remote'):
t = []
if incoming:
t.append(_('1 or more incoming'))
Pierre-Yves David
discovery: introduce outgoing object for result of findcommonoutgoing...
r15837 o = outgoing.missing
Matt Mackall
summary: add --remote
r9620 if o:
t.append(_('%d outgoing') % len(o))
FUJIWARA Katsunori
summary: separate checking incoming/outgoing and showing remote summary...
r21045 other = dother or sother
David Soria Parra
summary: add bookmarks to summary
r13454 if 'bookmarks' in other.listkeys('namespaces'):
lmarks = repo.listkeys('bookmarks')
rmarks = other.listkeys('bookmarks')
diff = set(rmarks) - set(lmarks)
if len(diff) > 0:
t.append(_('%d incoming bookmarks') % len(diff))
diff = set(lmarks) - set(rmarks)
if len(diff) > 0:
t.append(_('%d outgoing bookmarks') % len(diff))
Matt Mackall
summary: add --remote
r9620
if t:
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Matt Mackall
summary: add --remote
r9620 ui.write(_('remote: %s\n') % (', '.join(t)))
else:
FUJIWARA Katsunori
i18n: add "i18n" comment to column positioning messages of "hg summary"...
r17892 # i18n: column positioning for "hg summary"
Matt Mackall
summary: add --remote
r9620 ui.status(_('remote: (synced)\n'))
FUJIWARA Katsunori
summary: introduce "summaryremotehooks" to avoid redundant incoming/outgoing check...
r21047 cmdutil.summaryremotehooks(ui, repo, opts,
((source, sbranch, sother, commoninc),
(dest, dbranch, dother, outgoing)))
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('tag',
[('f', 'force', None, _('force tag')),
('l', 'local', None, _('make the tag local')),
('r', 'rev', '', _('revision to tag'), _('REV')),
('', 'remove', None, _('remove a tag')),
# -l/--local is already there, commitopts cannot be used
FUJIWARA Katsunori
doc: unify help text for "--edit" option...
r21952 ('e', 'edit', None, _('invoke editor on commit messages')),
FUJIWARA Katsunori
doc: unify help text for "--message" option...
r21951 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 ] + commitopts2,
_('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
John Coomes
tag: allow multiple tags to be added or removed...
r6321 def tag(ui, repo, name1, *names, **opts):
"""add one or more tags for the current or given revision
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Name a particular revision using <name>.
Tags are used to name particular revisions of the repository and are
Thomas Arendsen Hein
Fixed typo in tag help, found by John Coomes
r6220 very useful to compare different revisions, to go back to significant
Kevin Bullock
tag: abort if not at a branch head (issue2552)...
r13135 earlier versions or to mark branch points as releases, etc. Changing
an existing tag is normally disallowed; use -f/--force to override.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 If no revision is given, the parent of the working directory is
Matt Mackall
tag: remove incorrect reference to tip
r19402 used.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
To facilitate version control, distribution, and merging of tags,
Kevin Bullock
tag: abort if not at a branch head (issue2552)...
r13135 they are stored as a file named ".hgtags" which is managed similarly
to other project files and can be hand-edited if necessary. This
also means that tagging creates a new commit. The file
".hg/localtags" is used for local tags (not shared among
repositories).
Tag commits are usually made at the head of a branch. If the parent
of the working directory is not a branch head, :hg:`tag` aborts; use
-f/--force to force the tag commit to be based on a non-head
changeset.
Thomas Arendsen Hein
Document log date ranges and mention 'hg help dates' for all commands (issue998)
r6163
Martin Geisler
Use hg role in help strings
r10973 See :hg:`help dates` for a list of formats valid for -d/--date.
Nicolas Dumazet
tag: warn users about tag/branch possible name conflicts...
r11063
Since tag names have priority over branch names during revision
lookup, using an existing branch name as a tag name is discouraged.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Mads Kiilerich
tag: lock before tagging
r15877 wlock = lock = None
try:
wlock = repo.wlock()
lock = repo.lock()
rev_ = "."
names = [t.strip() for t in (name1,) + names]
if len(names) != len(set(names)):
raise util.Abort(_('tag names must be unique'))
John Coomes
tag: allow multiple tags to be added or removed...
r6321 for n in names:
Kevin Bullock
scmutil: add bad character checking to checknewlabel...
r17821 scmutil.checknewlabel(repo, n, 'tag')
Mads Kiilerich
tag: lock before tagging
r15877 if not n:
raise util.Abort(_('tag names cannot consist entirely of '
'whitespace'))
if opts.get('rev') and opts.get('remove'):
raise util.Abort(_("--rev and --remove are incompatible"))
if opts.get('rev'):
rev_ = opts['rev']
message = opts.get('message')
if opts.get('remove'):
expectedtype = opts.get('local') and 'local' or 'global'
for n in names:
if not repo.tagtype(n):
raise util.Abort(_("tag '%s' does not exist") % n)
if repo.tagtype(n) != expectedtype:
if expectedtype == 'global':
raise util.Abort(_("tag '%s' is not a global tag") % n)
else:
raise util.Abort(_("tag '%s' is not a local tag") % n)
rev_ = nullid
if not message:
# we don't translate commit messages
message = 'Removed tag %s' % ', '.join(names)
elif not opts.get('force'):
for n in names:
if n in repo.tags():
raise util.Abort(_("tag '%s' already exists "
"(use -f to force)") % n)
if not opts.get('local'):
p1, p2 = repo.dirstate.parents()
if p2 != nullid:
raise util.Abort(_('uncommitted merge'))
bheads = repo.branchheads()
if not opts.get('force') and bheads and p1 not in bheads:
raise util.Abort(_('not at a branch head (use -f to force)'))
r = scmutil.revsingle(repo, rev_).node()
Matt Mackall
tags: add --remove
r4213 if not message:
Martin Geisler
do not translate commit messages...
r9183 # we don't translate commit messages
Mads Kiilerich
tag: lock before tagging
r15877 message = ('Added tag %s for changeset %s' %
(', '.join(names), short(r)))
date = opts.get('date')
if date:
date = util.parsedate(date)
FUJIWARA Katsunori
tag: pass 'editform' argument to 'cmdutil.getcommiteditor'...
r22009 if opts.get('remove'):
editform = 'tag.remove'
else:
editform = 'tag.add'
editor = cmdutil.getcommiteditor(editform=editform, **opts)
Mads Kiilerich
tag: lock before tagging
r15877
Brad Hall
tag: don't allow tagging the null revision (issue1915)...
r17260 # don't allow tagging the null rev
if (not opts.get('remove') and
scmutil.revsingle(repo, rev_).rev() == nullrev):
Mads Kiilerich
tag: clarify cryptic error message when tagging null revision
r18906 raise util.Abort(_("cannot tag null revision"))
Brad Hall
tag: don't allow tagging the null revision (issue1915)...
r17260
FUJIWARA Katsunori
localrepo: add "editor" argument to "tag()"...
r21237 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
editor=editor)
Mads Kiilerich
tag: lock before tagging
r15877 finally:
release(lock, wlock)
mpm@selenic.com
From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>...
r401
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('tags', [], '')
Matt Mackall
tags: add formatter support
r17912 def tags(ui, repo, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """list repository tags
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 This lists both regular and local tags. When the -v/--verbose
switch is used, a third column "local" is printed for local tags.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Thomas Arendsen Hein
Handle errors in .hgtags or hgrc [tags] section more gracefully....
r477
Matt Mackall
tags: add formatter support
r17912 fm = ui.formatter('tags', opts)
Matt Mackall
Only show long hashes with --debug, not --verbose
r2966 hexfunc = ui.debugflag and hex or short
Osku Salerma
Add --verbose support to tags command.
r5658 tagtype = ""
Matt Mackall
replace various uses of list.reverse()
r8210 for t, n in reversed(repo.tagslist()):
Idan Kamara
tags: no need to check for valid nodes...
r13893 hn = hexfunc(n)
Matt Mackall
tags: add formatter support
r17912 label = 'tags.normal'
tagtype = ''
if repo.tagtype(t) == 'local':
label = 'tags.local'
tagtype = 'local'
fm.startitem()
fm.write('tag', '%s', t, label=label)
fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
fm.condwrite(not ui.quiet, 'rev id', fmt,
repo.changelog.rev(n), hn, label=label)
fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
tagtype, label=label)
fm.plain('\n')
fm.end()
mpm@selenic.com
migrate remaining commands...
r248
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('tip',
[('p', 'patch', None, _('show patch')),
('g', 'git', None, _('use git extended diff format')),
] + templateopts,
_('[-p] [-g]'))
Vadim Gelfer
add -p option to tip. for issue 64.
r1731 def tip(ui, repo, **opts):
Matt Mackall
tip: deprecate the tip command
r19403 """show the tip revision (DEPRECATED)
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
timeless
Improve English for help text of many core hg commands....
r8779 The tip revision (usually just called the tip) is the changeset
most recently added to the repository (and therefore the most
recently changed head).
Patrick Mezard
Make tip help more helpful
r6364
Patrick Mezard
Remove unexpected "Alternately" word from tip help.
r6367 If you have just made a commit, that commit will be the tip. If
you have just pulled changes from another repository, the tip of
that repository becomes the current tip. The "tip" tag is special
and cannot be renamed or assigned to a different changeset.
Matt Mackall
commands: initial audit of exit codes...
r11177
Matt Mackall
tip: deprecate the tip command
r19403 This command is deprecated, please use :hg:`heads` instead.
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Robert Bachmann
Added support for templatevar "footer" to cmdutil.py
r10152 displayer = cmdutil.show_changeset(ui, repo, opts)
Pierre-Yves David
changectx: fix the handling of `tip`...
r18464 displayer.show(repo['tip'])
Robert Bachmann
Added support for templatevar "footer" to cmdutil.py
r10152 displayer.close()
mpm@selenic.com
big heap of command clean-up work...
r245
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('unbundle',
[('u', 'update', None,
_('update to new branch head if changesets were unbundled'))],
_('[-u] FILE...'))
Giorgos Keramidas
unbundle: accept multiple file arguments...
r4699 def unbundle(ui, repo, fname1, *fnames, **opts):
"""apply one or more changegroup files
Apply one or more compressed changegroup files generated by the
bundle command.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success, 1 if an update has unresolved files.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Giorgos Keramidas
unbundle: accept multiple file arguments...
r4699 fnames = (fname1,) + fnames
Patrick Mezard
commands: lock() the repo while unbundling (issue1004)
r6180
Ronny Pfannschmidt
switch lock releasing in the core from gc to explicit
r8109 lock = repo.lock()
Patrick Mezard
commands: lock() the repo while unbundling (issue1004)
r6180 try:
for fname in fnames:
Siddharth Agarwal
url: use open and not url.open for local files (issue3624)
r17887 f = hg.openpath(ui, fname)
Pierre-Yves David
bundle2: add a ui argument to readbundle...
r21064 gen = exchange.readbundle(ui, f, fname)
Pierre-Yves David
localrepo: move the addchangegroup method in changegroup module...
r20933 modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
'bundle:' + fname)
Patrick Mezard
commands: lock() the repo while unbundling (issue1004)
r6180 finally:
Ronny Pfannschmidt
switch lock releasing in the core from gc to explicit
r8109 lock.release()
Matt Mackall
unbundle: don't advance bookmarks (issue4322) (BC)...
r22091
Alexander Solovyov
commands: optional options where possible...
r7131 return postincoming(ui, repo, modheads, opts.get('update'), None)
mpm@selenic.com
Add preliminary support for the bundle and unbundle commands
r1218
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('^update|up|checkout|co',
[('C', 'clean', None, _('discard uncommitted changes (no backup)')),
('c', 'check', None,
_('update across branches if no uncommitted changes')),
('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
Mads Kiilerich
update: introduce --tool for controlling the merge tool...
r21552 ('r', 'rev', '', _('revision'), _('REV'))
] + mergetoolopts,
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 _('[-c] [-C] [-d DATE] [[-r] REV]'))
Mads Kiilerich
update: introduce --tool for controlling the merge tool...
r21552 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
tool=None):
Matt Mackall
commands: improve some command summaries
r10889 """update working directory (or switch revisions)
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Martin Geisler
commands: word-wrap help texts at 70 characters
r8004 Update the repository's working directory to the specified
Kevin Bullock
help: improve description of update --check
r12688 changeset. If no changeset is specified, update to the tip of the
Kevin Bullock
update: note ways to avoid moving bookmark
r15957 current named branch and move the current bookmark (see :hg:`help
bookmarks`).
Kevin Bullock
help: improve description of update --check
r12688
Adrian Buehlmann
update: fix typo in help text...
r17343 Update sets the working directory's parent revision to the specified
Adrian Buehlmann
update: move help text about parent revision higher up...
r17143 changeset (see :hg:`help parents`).
Kevin Bullock
update: fix help regarding update to ancestor...
r16877 If the changeset is not a descendant or ancestor of the working
directory's parent, the update is aborted. With the -c/--check
option, the working directory is checked for uncommitted changes; if
none are found, the working directory is updated to the specified
Stuart W Marks
help: describe new cross-branch behavior in update help text, plus cleanups
r9718 changeset.
Adrian Buehlmann
update: put rules for uncommitted changes into verbose help section
r17218 .. container:: verbose
The following rules apply when the working directory contains
uncommitted changes:
1. If neither -c/--check nor -C/--clean is specified, and if
the requested changeset is an ancestor or descendant of
the working directory's parent, the uncommitted changes
are merged into the requested changeset and the merged
result is left uncommitted. If the requested changeset is
not an ancestor or descendant (that is, it is on another
branch), the update is aborted and the uncommitted changes
are preserved.
2. With the -c/--check option, the update is aborted and the
uncommitted changes are preserved.
3. With the -C/--clean option, uncommitted changes are discarded and
the working directory is updated to the requested changeset.
Stuart W Marks
help: describe new cross-branch behavior in update help text, plus cleanups
r9718
Adrian Buehlmann
update: mention how update can be used to cancel an uncommitted merge
r17144 To cancel an uncommitted merge (and lose your changes), use
:hg:`update --clean .`.
Martin Geisler
Use hg role in help strings
r10973 Use null as the changeset to remove the working directory (like
:hg:`clone -U`).
Adrian Buehlmann
update: do not use the term 'update' when mentioning reverting one file...
r14729 If you want to revert just one file to an older revision, use
:hg:`revert [-r REV] NAME`.
Martin Geisler
Use hg role in help strings
r10973
See :hg:`help dates` for a list of formats valid for -d/--date.
Matt Mackall
commands: initial audit of exit codes...
r11177
Returns 0 on success, 1 if there are unresolved files.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Daniel Holth
accept -r REV in more places...
r4450 if rev and node:
raise util.Abort(_("please specify just one revision"))
Mark Drago
commands.update() now works properly with a revision of 0...
r13568 if rev is None or rev == '':
Daniel Holth
accept -r REV in more places...
r4450 rev = node
Matt Mackall
update: clear any clearable unfinished operations (issue3955)...
r19475 cmdutil.clearunfinished(repo)
Matt Mackall
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
r15935 # with no argument, we also move the current bookmark, if any
Kevin Bullock
bookmarks: pull --update updates to active bookmark if it moved (issue4007)...
r19523 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
Matt Mackall
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
r15935
David Soria Parra
update: preserve possible bookmark name to set current bookmark correctly
r13415 # if we defined a bookmark, we have to remember the original bookmark name
brev = rev
Matt Mackall
scmutil: move revsingle/pair/range from cmdutil...
r14319 rev = scmutil.revsingle(repo, rev, rev).rev()
Augie Fackler
update: use revsingle to enable use of revsets as update targets (issue1993)
r12726
Stuart W Marks
commands: forbid 'hg update --check --clean'
r9450 if check and clean:
Martin Geisler
commands: expand -c and -C in update error message
r9451 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
Stuart W Marks
commands: forbid 'hg update --check --clean'
r9450
Matt Mackall
update: use normal update path with --check (issue2450)...
r16092 if date:
if rev is not None:
raise util.Abort(_("you can't specify a revision and a date"))
rev = cmdutil.finddate(ui, repo, date)
Stuart W Marks
commands: forbid 'hg update --check --clean'
r9450 if check:
Matt Mackall
update: add --check option
r8855 c = repo[None]
Matt Mackall
update: check for missing files with --check (issue3595)
r17849 if c.dirty(merge=False, branch=False, missing=True):
Siddharth Agarwal
update: standardize error message for dirty update --check...
r19801 raise util.Abort(_("uncommitted changes"))
Patrick Mezard
update: fix "not rev" vs "rev is None"
r16490 if rev is None:
Matt Mackall
update: use normal update path with --check (issue2450)...
r16092 rev = repo[repo[None].branch()].rev()
Matt Mackall
update: just merge unknown file collisions...
r16095 mergemod._checkunknown(repo, repo[None], repo[rev])
Matt Mackall
update: use normal update path with --check (issue2450)...
r16092
Mads Kiilerich
update: introduce --tool for controlling the merge tool...
r21552 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
Matt Mackall
update: use normal update path with --check (issue2450)...
r16092 if clean:
Matt Mackall
bookmarks: merge current tracking on update into core
r13367 ret = hg.clean(repo, rev)
Matt Mackall
Introduce update helper functions: update, merge, clean, and revert
r2808 else:
Matt Mackall
bookmarks: merge current tracking on update into core
r13367 ret = hg.update(repo, rev)
Matt Mackall
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
r15935 if not ret and movemarkfrom:
Kevin Bullock
update: note updated bookmark...
r16010 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
Matt Mackall
bookmarks: automatically advance bookmark on naked update (BC) (issue2894)
r15935 elif brev in repo._bookmarks:
David Soria Parra
update: preserve possible bookmark name to set current bookmark correctly
r13415 bookmarks.setcurrent(repo, brev)
Stephen Lee
update: show message when a bookmark is activated by update...
r21503 ui.status(_("(activating bookmark %s)\n") % brev)
Idan Kamara
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
r16191 elif brev:
Siddharth Agarwal
update: when deactivating a bookmark, print a message...
r21404 if repo._bookmarkcurrent:
ui.status(_("(leaving bookmark %s)\n") %
repo._bookmarkcurrent)
Idan Kamara
update: delete bookmarks.current when explicitly updating to a rev (issue3276)
r16191 bookmarks.unsetcurrent(repo)
Matt Mackall
bookmarks: merge current tracking on update into core
r13367
return ret
mpm@selenic.com
unify checkout and resolve into update...
r254
Adrian Buehlmann
commands: use a decorator to build table incrementally...
r14297 @command('verify', [])
mpm@selenic.com
migrate verify...
r247 def verify(ui, repo):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """verify the integrity of the repository
Verify the integrity of the current repository.
This will perform an extensive check of the repository's
integrity, validating the hashes and checksums of each entry in
the changelog, manifest, and tracked files, as well as the
integrity of their crosslinks and indices.
Matt Mackall
commands: initial audit of exit codes...
r11177
FUJIWARA Katsunori
help: add information about recovery from corruption to help of "verify"...
r17717 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption
for more information about recovery from corruption of the
repository.
Matt Mackall
commands: initial audit of exit codes...
r11177 Returns 0 on success, 1 if errors are encountered.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
Move repo.verify
r2778 return hg.verify(repo)
mpm@selenic.com
migrate verify...
r247
Gregory Szorc
commands: define norepo in command decorator
r21768 @command('version', [], norepo=True)
Matt Mackall
move show_version to version_
r3651 def version_(ui):
"""output version and copyright information"""
ui.write(_("Mercurial Distributed SCM (version %s)\n")
Matt Mackall
refactor version code...
r7632 % util.version())
Matt Mackall
move show_version to version_
r3651 ui.status(_(
Matt Mackall
version: replace email address with url to reduce private mail
r12829 "(see http://mercurial.selenic.com for more information)\n"
Kevin Bullock
doc: bump copyright year
r20227 "\nCopyright (C) 2005-2014 Matt Mackall and others\n"
Matt Mackall
move show_version to version_
r3651 "This is free software; see the source for copying conditions. "
"There is NO\nwarranty; "
"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
))
anatoly techtonik
version: show enabled extensions (issue4209)...
r21848
ui.note(_("\nEnabled extensions:\n\n"))
if ui.verbose:
# format names and versions into columns
names = []
vers = []
for name, module in extensions.extensions():
names.append(name)
vers.append(extensions.moduleversion(module))
Matt Mackall
version: don't traceback if no extensions to list (issue4312)
r21937 if names:
maxnamelen = max(len(n) for n in names)
for i, name in enumerate(names):
ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))