##// END OF EJS Templates
merge git patch code.
merge git patch code.

File last commit:

r2865:71e78f2c merge default
r2865:71e78f2c merge default
Show More
commands.py
3722 lines | 136.6 KiB | text/x-python | PythonLexer
mpm@selenic.com
import and startup cleanups...
r249 # commands.py - command processing for mercurial
#
Vadim Gelfer
update copyrights.
r2859 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
mpm@selenic.com
import and startup cleanups...
r249 #
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 from demandload import demandload
mpm@selenic.com
commands: use node functions directly
r1092 from node import *
Benoit Boissinot
i18n first part: make '_' available for files who need it
r1400 from i18n import gettext as _
Vadim Gelfer
tidy up mtime patch of andrea, get back half of performance loss....
r2461 demandload(globals(), "os re sys signal shutil imp urllib pdb")
Benoit Boissinot
incoming: add support for remote repo using bundlerepo
r1944 demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo")
Brendan Cully
Move patch-related code into its own module.
r2861 demandload(globals(), "fnmatch mdiff patch random signal tempfile time")
Benoit Boissinot
incoming: add support for remote repo using bundlerepo
r1944 demandload(globals(), "traceback errno socket version struct atexit sets bz2")
Vadim Gelfer
import: parse email messages
r2504 demandload(globals(), "archival cStringIO changegroup email.Parser")
Vadim Gelfer
refactor ssh server.
r2396 demandload(globals(), "hgweb.server sshserver")
mpm@selenic.com
Beginning of new command parsing interface...
r209
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 class UnknownCommand(Exception):
"""Exception raised if command is not in the command table."""
Thomas Arendsen Hein
Improved error message for ambiguous command shortcuts.
r1518 class AmbiguousCommand(Exception):
"""Exception raised if command shortcut matches more than one command."""
mpm@selenic.com
Beginning of new command parsing interface...
r209
Vadim Gelfer
add backout command....
r2158 def bail_if_changed(repo):
modified, added, removed, deleted, unknown = repo.changes()
if modified or added or removed or deleted:
raise util.Abort(_("outstanding uncommitted changes"))
mpm@selenic.com
big heap of command clean-up work...
r245 def filterfiles(filters, files):
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 l = [x for x in files if x in filters]
mpm@selenic.com
commands: migrate status and branch...
r213
mpm@selenic.com
big heap of command clean-up work...
r245 for t in filters:
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 if t and t[-1] != "/":
t += "/"
l += [x for x in files if x.startswith(t)]
mpm@selenic.com
commands: migrate status and branch...
r213 return l
mpm@selenic.com
Beginning of new command parsing interface...
r209 def relpath(repo, args):
Bryan O'Sullivan
Use repo.getcwd() in a few obvious places....
r628 cwd = repo.getcwd()
if cwd:
Bryan O'Sullivan
Fix walk path handling on Windows
r886 return [util.normpath(os.path.join(cwd, x)) for x in args]
mpm@selenic.com
Beginning of new command parsing interface...
r209 return args
mpm@selenic.com
big heap of command clean-up work...
r245
Vadim Gelfer
commands.logmessage: simplify calling.
r2799 def logmessage(opts):
"Mathieu Clabaut "
MQ: uniformise message and logfile option....
r2694 """ get the log message according to -m and -l option """
message = opts['message']
logfile = opts['logfile']
if message and logfile:
raise util.Abort(_('options --message and --logfile are mutually '
'exclusive'))
if not message and logfile:
try:
if logfile == '-':
message = sys.stdin.read()
else:
message = open(logfile).read()
except IOError, inst:
raise util.Abort(_("can't read commit message '%s': %s") %
(logfile, inst.strerror))
return message
Benoit Boissinot
make all commands be repo-wide by default...
r1568 def matchpats(repo, pats=[], opts={}, head=''):
cwd = repo.getcwd()
if not pats and cwd:
opts['include'] = [os.path.join(cwd, i) for i in opts['include']]
opts['exclude'] = [os.path.join(cwd, x) for x in opts['exclude']]
cwd = ''
Benoit Boissinot
Do not use 'glob' expansion by default on OS != 'nt'
r1413 return util.cmdmatcher(repo.root, cwd, pats or ['.'], opts.get('include'),
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 opts.get('exclude'), head)
Bryan O'Sullivan
Get add and locate to use new repo and dirstate walk code....
r724
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 def makewalk(repo, pats, opts, node=None, head='', badmatch=None):
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 files, matchfn, anypats = matchpats(repo, pats, opts, head)
Bryan O'Sullivan
Modify commands.walk to yield a 4-tuple....
r942 exact = dict(zip(files, files))
Bryan O'Sullivan
Fix performance of hg diff....
r837 def walk():
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 for src, fn in repo.walk(node=node, files=files, match=matchfn,
Vadim Gelfer
small changes to revert command....
r2042 badmatch=badmatch):
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact
Bryan O'Sullivan
Fix performance of hg diff....
r837 return files, matchfn, walk()
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 def walk(repo, pats, opts, node=None, head='', badmatch=None):
files, matchfn, results = makewalk(repo, pats, opts, node, head, badmatch)
Thomas Arendsen Hein
Cleanups to commands.py
r1065 for r in results:
yield r
Bryan O'Sullivan
Get add and locate to use new repo and dirstate walk code....
r724
Benoit Boissinot
make all commands be repo-wide by default...
r1568 def walkchangerevs(ui, repo, pats, opts):
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 '''Iterate over files and the revs they changed in.
Callers most commonly need to iterate backwards over the history
it is interested in. Doing so has awful (quadratic-looking)
performance, so we use iterators in a "windowed" way.
We walk a window of revisions in the desired order. Within the
window, we first walk forwards to gather data, then in the desired
order (usually backwards) to display it.
Benoit Boissinot
hg log -p should show file deletions
r1570 This function returns an (iterator, getchange, matchfn) tuple. The
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 getchange function returns the changelog entry for a numeric
revision. The iterator yields 3-tuples. They will be of one of
the following forms:
"window", incrementing, lastrev: stepping through a window,
positive if walking forwards through revs, last rev in the
sequence iterated over - use to reset state for the current window
"add", rev, fns: out-of-order traversal of the given file names
fns, which changed during revision rev - use to gather data for
possible display
"iter", rev, None: in-order traversal of the revs earlier iterated
over with "add" - use to display data'''
mpm@selenic.com
Fix up some bugs for log and grep with empty repo
r1337
Thomas Arendsen Hein
Replaced fixed window size for walkchangerevs with an increasing one. Window...
r1799 def increasing_windows(start, end, windowsize=8, sizelimit=512):
if start < end:
while start < end:
yield start, min(windowsize, end-start)
start += windowsize
if windowsize < sizelimit:
windowsize *= 2
else:
while start > end:
yield start, min(windowsize, start-end-1)
start -= windowsize
if windowsize < sizelimit:
windowsize *= 2
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 files, matchfn, anypats = matchpats(repo, pats, opts)
Brendan Cully
Add log option --follow-first to follow only the first parent of...
r2784 follow = opts.get('follow') or opts.get('follow_first')
Benoit Boissinot
hg log -p should show file deletions
r1570
mpm@selenic.com
Fix up some bugs for log and grep with empty repo
r1337 if repo.changelog.count() == 0:
Benoit Boissinot
hg log -p should show file deletions
r1570 return [], False, matchfn
mpm@selenic.com
Fix up some bugs for log and grep with empty repo
r1337
Brendan Cully
Make log --follow revision range start default to working dir parent.
r2783 if follow:
p = repo.dirstate.parents()[0]
if p == nullid:
ui.warn(_('No working directory revision; defaulting to tip\n'))
start = 'tip'
else:
start = repo.changelog.rev(p)
defrange = '%s:0' % start
else:
defrange = 'tip:0'
revs = map(int, revrange(ui, repo, opts['rev'] or [defrange]))
Bryan O'Sullivan
Add grep command....
r1057 wanted = {}
slowpath = anypats
fncache = {}
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146
chcache = {}
def getchange(rev):
ch = chcache.get(rev)
if ch is None:
chcache[rev] = ch = repo.changelog.read(repo.lookup(str(rev)))
return ch
Bryan O'Sullivan
Add grep command....
r1057 if not slowpath and not files:
# No files, no patterns. Display all revs.
wanted = dict(zip(revs, revs))
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 copies = []
Bryan O'Sullivan
Add grep command....
r1057 if not slowpath:
# Only files, no patterns. Check the history of each file.
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 def filerevgen(filelog, node):
Benoit Boissinot
walkchangerevs: fix race in fast path...
r2626 cl_count = repo.changelog.count()
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 if node is None:
last = filelog.count() - 1
else:
last = filelog.rev(node)
for i, window in increasing_windows(last, -1):
Bryan O'Sullivan
Add grep command....
r1057 revs = []
Thomas Arendsen Hein
Removed now obsolete min/max check in walkchangerevs().
r1800 for j in xrange(i - window, i + 1):
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 n = filelog.node(j)
revs.append((filelog.linkrev(n),
follow and filelog.renamed(n)))
Bryan O'Sullivan
Add grep command....
r1057 revs.reverse()
for rev in revs:
Benoit Boissinot
walkchangerevs: fix race in fast path...
r2626 # only yield rev for which we have the changelog, it can
# happen while doing "hg log" during a pull or commit
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 if rev[0] < cl_count:
Benoit Boissinot
walkchangerevs: fix race in fast path...
r2626 yield rev
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 def iterfiles():
for filename in files:
yield filename, None
for filename_node in copies:
yield filename_node
Bryan O'Sullivan
Add grep command....
r1057 minrev, maxrev = min(revs), max(revs)
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 for file_, node in iterfiles():
Benoit Boissinot
fix warnings from pychecker (unused variables and shadowing)
r1749 filelog = repo.file(file_)
Bryan O'Sullivan
Add grep command....
r1057 # A zero count may be a directory or deleted file, so
# try to find matching entries on the slow path.
if filelog.count() == 0:
slowpath = True
break
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 for rev, copied in filerevgen(filelog, node):
Bryan O'Sullivan
Add grep command....
r1057 if rev <= maxrev:
Thomas Arendsen Hein
Cleanups to commands.py
r1065 if rev < minrev:
break
Bryan O'Sullivan
Add grep command....
r1057 fncache.setdefault(rev, [])
Benoit Boissinot
fix warnings from pychecker (unused variables and shadowing)
r1749 fncache[rev].append(file_)
Bryan O'Sullivan
Add grep command....
r1057 wanted[rev] = 1
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 if follow and copied:
copies.append(copied)
Bryan O'Sullivan
Add grep command....
r1057 if slowpath:
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 if follow:
raise util.Abort(_('can only follow copies/renames for explicit '
'file names'))
Bryan O'Sullivan
Add grep command....
r1057 # The slow path checks files modified in every changeset.
def changerevgen():
Thomas Arendsen Hein
Replaced fixed window size for walkchangerevs with an increasing one. Window...
r1799 for i, window in increasing_windows(repo.changelog.count()-1, -1):
Thomas Arendsen Hein
Removed now obsolete min/max check in walkchangerevs().
r1800 for j in xrange(i - window, i + 1):
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 yield j, getchange(j)[3]
Bryan O'Sullivan
Add grep command....
r1057
for rev, changefiles in changerevgen():
matches = filter(matchfn, changefiles)
if matches:
fncache[rev] = matches
wanted[rev] = 1
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 def iterate():
Brendan Cully
Make log --follow without a file list follow a single head....
r2782 class followfilter:
Brendan Cully
Add log option --follow-first to follow only the first parent of...
r2784 def __init__(self, onlyfirst=False):
Brendan Cully
Make log --follow without a file list follow a single head....
r2782 self.startrev = -1
self.roots = []
Brendan Cully
Add log option --follow-first to follow only the first parent of...
r2784 self.onlyfirst = onlyfirst
Brendan Cully
Make log --follow without a file list follow a single head....
r2782
def match(self, rev):
def realparents(rev):
Brendan Cully
Add log option --follow-first to follow only the first parent of...
r2784 if self.onlyfirst:
return repo.changelog.parentrevs(rev)[0:1]
else:
return filter(lambda x: x != -1, repo.changelog.parentrevs(rev))
Brendan Cully
Make log --follow without a file list follow a single head....
r2782
if self.startrev == -1:
self.startrev = rev
return True
if rev > self.startrev:
# forward: all descendants
if not self.roots:
self.roots.append(self.startrev)
for parent in realparents(rev):
if parent in self.roots:
self.roots.append(rev)
return True
else:
# backwards: all parents
if not self.roots:
self.roots.extend(realparents(self.startrev))
if rev in self.roots:
self.roots.remove(rev)
self.roots.extend(realparents(rev))
return True
return False
if follow and not files:
Brendan Cully
Add log option --follow-first to follow only the first parent of...
r2784 ff = followfilter(onlyfirst=opts.get('follow_first'))
Brendan Cully
Make log --follow without a file list follow a single head....
r2782 def want(rev):
if rev not in wanted:
return False
return ff.match(rev)
else:
def want(rev):
return rev in wanted
Thomas Arendsen Hein
Replaced fixed window size for walkchangerevs with an increasing one. Window...
r1799 for i, window in increasing_windows(0, len(revs)):
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 yield 'window', revs[0] < revs[-1], revs[-1]
Brendan Cully
Make log --follow without a file list follow a single head....
r2782 nrevs = [rev for rev in revs[i:i+window] if want(rev)]
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 srevs = list(nrevs)
srevs.sort()
for rev in srevs:
fns = fncache.get(rev) or filter(matchfn, getchange(rev)[3])
yield 'add', rev, fns
for rev in nrevs:
yield 'iter', rev, None
Benoit Boissinot
hg log -p should show file deletions
r1570 return iterate(), getchange, matchfn
Bryan O'Sullivan
Add grep command....
r1057
mpm@selenic.com
[PATCH] New export patch...
r580 revrangesep = ':'
Vadim Gelfer
diff: allow to use -rA:B syntax as well as -rA -rB
r2331 def revfix(repo, val, defval):
'''turn user-level id of changeset into rev number.
user-level id can be tag, changeset, rev number, or negative rev
number relative to number of revs (-1 is tip, etc).'''
if not val:
return defval
try:
num = int(val)
if str(num) != val:
raise ValueError
if num < 0:
num += repo.changelog.count()
if num < 0:
num = 0
elif num >= repo.changelog.count():
raise ValueError
except ValueError:
mpm@selenic.com
[PATCH] New export patch...
r580 try:
Vadim Gelfer
diff: allow to use -rA:B syntax as well as -rA -rB
r2331 num = repo.changelog.rev(repo.lookup(val))
except KeyError:
raise util.Abort(_('invalid revision identifier %s'), val)
return num
def revpair(ui, repo, revs):
'''return pair of nodes, given list of revisions. second item can
be None, meaning use working dir.'''
if not revs:
return repo.dirstate.parents()[0], None
end = None
if len(revs) == 1:
start = revs[0]
if revrangesep in start:
start, end = start.split(revrangesep, 1)
start = revfix(repo, start, 0)
end = revfix(repo, end, repo.changelog.count() - 1)
else:
start = revfix(repo, start, None)
elif len(revs) == 2:
if revrangesep in revs[0] or revrangesep in revs[1]:
raise util.Abort(_('too many revisions specified'))
start = revfix(repo, revs[0], None)
end = revfix(repo, revs[1], None)
else:
raise util.Abort(_('too many revisions specified'))
if end is not None: end = repo.lookup(str(end))
return repo.lookup(str(start)), end
def revrange(ui, repo, revs):
"""Yield revision as strings from a list of revision specifications."""
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 seen = {}
mpm@selenic.com
[PATCH] New export patch...
r580 for spec in revs:
Benoit Boissinot
use __contains__, index or split instead of str.find...
r2579 if revrangesep in spec:
mpm@selenic.com
[PATCH] New export patch...
r580 start, end = spec.split(revrangesep, 1)
Vadim Gelfer
diff: allow to use -rA:B syntax as well as -rA -rB
r2331 start = revfix(repo, start, 0)
end = revfix(repo, end, repo.changelog.count() - 1)
Thomas Arendsen Hein
Shortened commands.revrange() a little bit, added docstring.
r1066 step = start > end and -1 or 1
for rev in xrange(start, end+step, step):
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if rev in seen:
continue
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 seen[rev] = 1
mpm@selenic.com
[PATCH] New export patch...
r580 yield str(rev)
else:
Vadim Gelfer
diff: allow to use -rA:B syntax as well as -rA -rB
r2331 rev = revfix(repo, spec, None)
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if rev in seen:
continue
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 seen[rev] = 1
yield str(rev)
mpm@selenic.com
[PATCH] New export patch...
r580
Matt Mackall
simplify make_filename, fix hg cat bug...
r2562 def make_filename(repo, pat, node,
Bryan O'Sullivan
Switch cat command to use walk code....
r1254 total=None, seqno=None, revwidth=None, pathname=None):
thananck@yahoo.com
Provides output option to cat command...
r632 node_expander = {
mpm@selenic.com
commands: use node functions directly
r1092 'H': lambda: hex(node),
Matt Mackall
simplify make_filename, fix hg cat bug...
r2562 'R': lambda: str(repo.changelog.rev(node)),
mpm@selenic.com
commands: use node functions directly
r1092 'h': lambda: short(node),
thananck@yahoo.com
Provides output option to cat command...
r632 }
expander = {
'%': lambda: '%',
'b': lambda: os.path.basename(repo.root),
}
Bryan O'Sullivan
Get commands to raise Abort instead of ui.warn(...),sys.exit(1).
r727 try:
if node:
expander.update(node_expander)
if node and revwidth is not None:
Christian Ebert
fix output file format %r
r2736 expander['r'] = (lambda:
str(repo.changelog.rev(node)).zfill(revwidth))
Bryan O'Sullivan
Get commands to raise Abort instead of ui.warn(...),sys.exit(1).
r727 if total is not None:
expander['N'] = lambda: str(total)
if seqno is not None:
expander['n'] = lambda: str(seqno)
if total is not None and seqno is not None:
expander['n'] = lambda:str(seqno).zfill(len(str(total)))
Bryan O'Sullivan
Switch cat command to use walk code....
r1254 if pathname is not None:
expander['s'] = lambda: os.path.basename(pathname)
expander['d'] = lambda: os.path.dirname(pathname) or '.'
expander['p'] = lambda: pathname
thananck@yahoo.com
Provides output option to cat command...
r632
Bryan O'Sullivan
Get commands to raise Abort instead of ui.warn(...),sys.exit(1).
r727 newname = []
patlen = len(pat)
i = 0
while i < patlen:
c = pat[i]
if c == '%':
i += 1
c = pat[i]
c = expander[c]()
newname.append(c)
thananck@yahoo.com
Provides output option to cat command...
r632 i += 1
Bryan O'Sullivan
Split make_file back out into make_filename and make_file....
r739 return ''.join(newname)
Bryan O'Sullivan
Get commands to raise Abort instead of ui.warn(...),sys.exit(1).
r727 except KeyError, inst:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 raise util.Abort(_("invalid format spec '%%%s' in output file name"),
Bryan O'Sullivan
Get commands to raise Abort instead of ui.warn(...),sys.exit(1).
r727 inst.args[0])
thananck@yahoo.com
Provides output option to cat command...
r632
Matt Mackall
simplify make_filename, fix hg cat bug...
r2562 def make_file(repo, pat, node=None,
Bryan O'Sullivan
Switch cat command to use walk code....
r1254 total=None, seqno=None, revwidth=None, mode='wb', pathname=None):
Bryan O'Sullivan
Split make_file back out into make_filename and make_file....
r739 if not pat or pat == '-':
Thomas Arendsen Hein
Cleanups to commands.py
r1065 return 'w' in mode and sys.stdout or sys.stdin
Bryan O'Sullivan
Split make_file back out into make_filename and make_file....
r739 if hasattr(pat, 'write') and 'w' in mode:
return pat
if hasattr(pat, 'read') and 'r' in mode:
return pat
Matt Mackall
simplify make_filename, fix hg cat bug...
r2562 return open(make_filename(repo, pat, node, total, seqno, revwidth,
Bryan O'Sullivan
Switch cat command to use walk code....
r1254 pathname),
Bryan O'Sullivan
Split make_file back out into make_filename and make_file....
r739 mode)
Thomas Arendsen Hein
Delete bundle file of hg incoming in case of errors, preserve existing files....
r1974 def write_bundle(cg, filename=None, compress=True):
"""Write a bundle file and return its filename.
Existing files will not be overwritten.
If no filename is specified, a temporary file is created.
bz2 compression can be turned off.
The bundle file will be deleted in case of errors.
Thomas Arendsen Hein
Documented behaviour of write_bundle regarding file handles.
r1972 """
Benoit Boissinot
refactor the bundle writing code, since we will reuse it later
r1943 class nocompress(object):
def compress(self, x):
return x
def flush(self):
return ""
Thomas Arendsen Hein
Delete bundle file of hg incoming in case of errors, preserve existing files....
r1974
fh = None
cleanup = None
Benoit Boissinot
refactor the bundle writing code, since we will reuse it later
r1943 try:
Thomas Arendsen Hein
Delete bundle file of hg incoming in case of errors, preserve existing files....
r1974 if filename:
if os.path.exists(filename):
raise util.Abort(_("file '%s' already exists"), filename)
fh = open(filename, "wb")
else:
Thomas Arendsen Hein
Use better names (hg-{usage}-{random}.{suffix}) for temporary files.
r2165 fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg")
Thomas Arendsen Hein
Delete bundle file of hg incoming in case of errors, preserve existing files....
r1974 fh = os.fdopen(fd, "wb")
cleanup = filename
Benoit Boissinot
refactor the bundle writing code, since we will reuse it later
r1943 if compress:
fh.write("HG10")
z = bz2.BZ2Compressor(9)
else:
Benoit Boissinot
use HG10UN header for uncompressed bundle...
r1980 fh.write("HG10UN")
Benoit Boissinot
refactor the bundle writing code, since we will reuse it later
r1943 z = nocompress()
Thomas Arendsen Hein
make incoming work via ssh (issue139); move chunk code into separate module....
r1981 # parse the changegroup data, otherwise we will block
# in case of sshrepo because we don't know the end of the stream
# an empty chunkiter is the end of the changegroup
empty = False
while not empty:
empty = True
for chunk in changegroup.chunkiter(cg):
empty = False
fh.write(z.compress(changegroup.genchunk(chunk)))
fh.write(z.compress(changegroup.closechunk()))
Benoit Boissinot
refactor the bundle writing code, since we will reuse it later
r1943 fh.write(z.flush())
Thomas Arendsen Hein
Delete bundle file of hg incoming in case of errors, preserve existing files....
r1974 cleanup = None
return filename
finally:
if fh is not None:
fh.close()
if cleanup is not None:
os.unlink(cleanup)
Benoit Boissinot
refactor the bundle writing code, since we will reuse it later
r1943
mpm@selenic.com
Clean up argument passing for dodiff
r1014 def dodiff(fp, ui, repo, node1, node2, files=None, match=util.always,
Vadim Gelfer
add -w and -p options to diff. this is for issue 126.
r1728 changes=None, text=False, opts={}):
Benoit Boissinot
refactor the dodiff optimization
r1804 if not node1:
node1 = repo.dirstate.parents()[0]
# reading the data for node1 early allows it to play nicely
# with repo.changes and the revlog cache.
change = repo.changelog.read(node1)
mmap = repo.manifest.read(change[0])
date1 = util.datestr(change[2])
Alexis S. L. Carvalho
speed up hg log --patch...
r1803
mason@suse.com
Add optional parameter for changed/added/del/unknown files to commands.dodiff...
r904 if not changes:
Thomas Arendsen Hein
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
r1618 changes = repo.changes(node1, node2, files, match=match)
Thomas Arendsen Hein
Distinguish removed and deleted files. Tests are not fixed yet....
r1619 modified, added, removed, deleted, unknown = changes
mpm@selenic.com
Propagate file list through dodiff...
r537 if files:
Benoit Boissinot
make the order of the arguments for filterfiles consistent...
r1626 modified, added, removed = map(lambda x: filterfiles(files, x),
Thomas Arendsen Hein
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
r1618 (modified, added, removed))
mpm@selenic.com
Propagate file list through dodiff...
r537
Thomas Arendsen Hein
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
r1618 if not modified and not added and not removed:
mpm@selenic.com
Propagate file list through dodiff...
r537 return
mpm@selenic.com
big heap of command clean-up work...
r245 if node2:
change = repo.changelog.read(node2)
mmap2 = repo.manifest.read(change[0])
andrea@suse.de
report correct mtime in the hg diff output
r2460 _date2 = util.datestr(change[2])
def date2(f):
return _date2
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 def read(f):
return repo.file(f).read(mmap2[f])
mpm@selenic.com
big heap of command clean-up work...
r245 else:
Vadim Gelfer
tidy up mtime patch of andrea, get back half of performance loss....
r2461 tz = util.makedate()[1]
andrea@suse.de
report correct mtime in the hg diff output
r2460 _date2 = util.datestr()
def date2(f):
try:
Vadim Gelfer
tidy up mtime patch of andrea, get back half of performance loss....
r2461 return util.datestr((os.lstat(repo.wjoin(f)).st_mtime, tz))
andrea@suse.de
Fix hg diff regression
r2482 except OSError, err:
Vadim Gelfer
tidy up mtime patch of andrea, get back half of performance loss....
r2461 if err.errno != errno.ENOENT: raise
andrea@suse.de
report correct mtime in the hg diff output
r2460 return _date2
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 def read(f):
Petr Mazanec
Process working files through encode filters in dodiff()
r1648 return repo.wread(f)
mpm@selenic.com
big heap of command clean-up work...
r245
Thomas Arendsen Hein
Show revisions in diffs like CVS, based on a patch from Goffredo Baroncelli....
r396 if ui.quiet:
r = None
else:
mpm@selenic.com
commands: use node functions directly
r1092 hexfunc = ui.verbose and hex or short
Thomas Arendsen Hein
Show revisions in diffs like CVS, based on a patch from Goffredo Baroncelli....
r396 r = [hexfunc(node) for node in [node1, node2] if node]
mason@suse.com
Add new bdiff based unidiff generation.
r1637 diffopts = ui.diffopts()
Vadim Gelfer
add -w and -p options to diff. this is for issue 126.
r1728 showfunc = opts.get('show_function') or diffopts['showfunc']
ignorews = opts.get('ignore_all_space') or diffopts['ignorews']
Haakon Riiser
diff: add -b/-B options
r2580 ignorewsamount = opts.get('ignore_space_change') or \
diffopts['ignorewsamount']
ignoreblanklines = opts.get('ignore_blank_lines') or \
diffopts['ignoreblanklines']
Benoit Boissinot
makes 'hg diff' diff the file in sorted order
r2718
all = modified + added + removed
all.sort()
for f in all:
mpm@selenic.com
various merge improvements...
r275 to = None
Benoit Boissinot
makes 'hg diff' diff the file in sorted order
r2718 tn = None
mpm@selenic.com
various merge improvements...
r275 if f in mmap:
to = repo.file(f).read(mmap[f])
Benoit Boissinot
makes 'hg diff' diff the file in sorted order
r2718 if f not in removed:
tn = read(f)
andrea@suse.de
report correct mtime in the hg diff output
r2460 fp.write(mdiff.unidiff(to, date1, tn, date2(f), f, r, text=text,
Haakon Riiser
diff: add -b/-B options
r2580 showfunc=showfunc, ignorews=ignorews,
ignorewsamount=ignorewsamount,
ignoreblanklines=ignoreblanklines))
Thomas Arendsen Hein
Use common output function show_changeset() for hg heads|history|log|tip....
r329
bos@serpentine.internal.keyresearch.com
Merge with TAH.
r1147 def trimuser(ui, name, rev, revcache):
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 """trim the name of the user who committed a change"""
bos@serpentine.internal.keyresearch.com
Merge with TAH.
r1147 user = revcache.get(rev)
if user is None:
user = revcache[rev] = ui.shortuser(name)
return user
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146
Vadim Gelfer
let commands that show changesets use templates....
r1907 class changeset_printer(object):
Vadim Gelfer
add doc comments to template code.
r1909 '''show changeset information when templating not requested.'''
Vadim Gelfer
let commands that show changesets use templates....
r1907 def __init__(self, ui, repo):
self.ui = ui
self.repo = repo
def show(self, rev=0, changenode=None, brinfo=None):
Vadim Gelfer
add doc comments to template code.
r1909 '''show a single changeset or file revision'''
Vadim Gelfer
let commands that show changesets use templates....
r1907 log = self.repo.changelog
if changenode is None:
changenode = log.node(rev)
elif not rev:
rev = log.rev(changenode)
if self.ui.quiet:
self.ui.write("%d:%s\n" % (rev, short(changenode)))
return
changes = log.read(changenode)
date = util.datestr(changes[2])
parents = [(log.rev(p), self.ui.verbose and hex(p) or short(p))
for p in log.parents(changenode)
if self.ui.debugflag or p != nullid]
if (not self.ui.debugflag and len(parents) == 1 and
parents[0][0] == rev-1):
parents = []
if self.ui.verbose:
self.ui.write(_("changeset: %d:%s\n") % (rev, hex(changenode)))
else:
self.ui.write(_("changeset: %d:%s\n") % (rev, short(changenode)))
for tag in self.repo.nodetags(changenode):
self.ui.status(_("tag: %s\n") % tag)
for parent in parents:
self.ui.write(_("parent: %d:%s\n") % parent)
if brinfo and changenode in brinfo:
br = brinfo[changenode]
self.ui.write(_("branch: %s\n") % " ".join(br))
self.ui.debug(_("manifest: %d:%s\n") %
(self.repo.manifest.rev(changes[0]), hex(changes[0])))
self.ui.status(_("user: %s\n") % changes[1])
self.ui.status(_("date: %s\n") % date)
if self.ui.debugflag:
files = self.repo.changes(log.parents(changenode)[0], changenode)
for key, value in zip([_("files:"), _("files+:"), _("files-:")],
files):
if value:
self.ui.note("%-12s %s\n" % (key, " ".join(value)))
else:
self.ui.note(_("files: %s\n") % " ".join(changes[3]))
description = changes[4].strip()
if description:
if self.ui.verbose:
self.ui.status(_("description:\n"))
self.ui.status(description)
self.ui.status("\n\n")
else:
self.ui.status(_("summary: %s\n") %
description.splitlines()[0])
self.ui.status("\n")
def show_changeset(ui, repo, opts):
Vadim Gelfer
add doc comments to template code.
r1909 '''show one changeset. uses template or regular display. caller
Vadim Gelfer
fix some things people wanted to be cleaner....
r1913 can pass in 'style' and 'template' options in opts.'''
Vadim Gelfer
add doc comments to template code.
r1909
Vadim Gelfer
let commands that show changesets use templates....
r1907 tmpl = opts.get('template')
if tmpl:
tmpl = templater.parsestring(tmpl, quoted=False)
mpm@selenic.com
Shorten hashes displayed in log
r778 else:
Vadim Gelfer
let commands that show changesets use templates....
r1907 tmpl = ui.config('ui', 'logtemplate')
if tmpl: tmpl = templater.parsestring(tmpl)
Vadim Gelfer
make --style=compact look for map-cmdline.compact....
r1914 mapfile = opts.get('style') or ui.config('ui', 'style')
Vadim Gelfer
let commands that show changesets use templates....
r1907 if tmpl or mapfile:
if mapfile:
if not os.path.isfile(mapfile):
Vadim Gelfer
make --style=compact look for map-cmdline.compact....
r1914 mapname = templater.templatepath('map-cmdline.' + mapfile)
if not mapname: mapname = templater.templatepath(mapfile)
Vadim Gelfer
let commands that show changesets use templates....
r1907 if mapname: mapfile = mapname
try:
Vadim Gelfer
move changeset_templater into templater module.
r2189 t = templater.changeset_templater(ui, repo, mapfile)
Vadim Gelfer
let commands that show changesets use templates....
r1907 except SyntaxError, inst:
raise util.Abort(inst.args[0])
if tmpl: t.use_template(tmpl)
return t
return changeset_printer(ui, repo)
Thomas Arendsen Hein
Use common output function show_changeset() for hg heads|history|log|tip....
r329
Matt Mackall
Kill ui.setconfig_remoteopts...
r2731 def setremoteconfig(ui, opts):
"copy remote options to ui tree"
if opts.get('ssh'):
ui.setconfig("ui", "ssh", opts['ssh'])
if opts.get('remotecmd'):
ui.setconfig("ui", "remotecmd", opts['remotecmd'])
mpm@selenic.com
Fix up version module name and command conflict...
r470 def show_version(ui):
Thomas Arendsen Hein
Support for 'hg --version'. setup.py stores version from hg repository....
r423 """output version and copyright information"""
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.write(_("Mercurial Distributed SCM (version %s)\n")
Thomas Arendsen Hein
Further help improvements:...
r849 % version.get_version())
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.status(_(
Vadim Gelfer
update copyrights.
r2859 "\nCopyright (C) 2005, 2006 Matt Mackall <mpm@selenic.com>\n"
Thomas Arendsen Hein
Support for 'hg --version'. setup.py stores version from hg repository....
r423 "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"
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ))
Thomas Arendsen Hein
Support for 'hg --version'. setup.py stores version from hg repository....
r423
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 def help_(ui, name=None, with_version=False):
"""show help for a command, extension, or list of commands
With no arguments, print a list of commands and short help.
Vadim Gelfer
clean up trailing white space.
r2600
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 Given a command name, print help for that command.
Given an extension name, print help for that extension, and the
commands it provides."""
Thomas Arendsen Hein
Adjust display and alignment of command options to match global options.
r1052 option_lists = []
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553
def helpcmd(name):
Thomas Arendsen Hein
Allow --help and --version being used together.
r1049 if with_version:
show_version(ui)
ui.write('\n')
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 aliases, i = findcmd(name)
Thomas Arendsen Hein
Further help improvements:...
r849 # synopsis
Thomas Arendsen Hein
Always show short help when an unknown command is given.
r848 ui.write("%s\n\n" % i[2])
mpm@selenic.com
hg help improvements...
r293
Thomas Arendsen Hein
Further help improvements:...
r849 # description
doc = i[0].__doc__
Thomas Arendsen Hein
Show "(No help text available)" for commands without doc string....
r1710 if not doc:
doc = _("(No help text available)")
Thomas Arendsen Hein
Further help improvements:...
r849 if ui.quiet:
doc = doc.splitlines(0)[0]
ui.write("%s\n" % doc.rstrip())
if not ui.quiet:
Thomas Arendsen Hein
Adjust display and alignment of command options to match global options.
r1052 # aliases
Thomas Arendsen Hein
Canonicalize command when using aliases or prefix matching....
r1517 if len(aliases) > 1:
ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
Thomas Arendsen Hein
Further help improvements:...
r849
Thomas Arendsen Hein
Adjust display and alignment of command options to match global options.
r1052 # options
if i[1]:
option_lists.append(("options", i[1]))
Vadim Gelfer
clean up trailing white space.
r2600
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 def helplist(select=None):
mpm@selenic.com
hg help: use docstrings only...
r255 h = {}
kreijack@inwind.REMOVEME.it
'hg help -v' mentions the alias of the commands
r844 cmds = {}
Thomas Arendsen Hein
Cleaned up command alias handling in help....
r479 for c, e in table.items():
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 f = c.split("|", 1)[0]
if select and not select(f):
continue
if name == "shortlist" and not f.startswith("^"):
Thomas Arendsen Hein
Cleaned up command alias handling in help....
r479 continue
Thomas Arendsen Hein
Further help improvements:...
r849 f = f.lstrip("^")
mpm@selenic.com
Shorten help...
r593 if not ui.debugflag and f.startswith("debug"):
continue
Thomas Arendsen Hein
Show "(No help text available)" for commands without doc string....
r1710 doc = e[0].__doc__
if not doc:
doc = _("(No help text available)")
h[f] = doc.splitlines(0)[0].rstrip()
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 cmds[f] = c.lstrip("^")
mpm@selenic.com
hg help: use docstrings only...
r255
fns = h.keys()
fns.sort()
m = max(map(len, fns))
for f in fns:
kreijack@inwind.REMOVEME.it
'hg help -v' mentions the alias of the commands
r844 if ui.verbose:
commands = cmds[f].replace("|",", ")
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ui.write(" %s:\n %s\n"%(commands, h[f]))
kreijack@inwind.REMOVEME.it
'hg help -v' mentions the alias of the commands
r844 else:
ui.write(' %-*s %s\n' % (m, f, h[f]))
mpm@selenic.com
hg help: use docstrings only...
r255
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 def helpext(name):
try:
mod = findext(name)
except KeyError:
raise UnknownCommand(name)
doc = (mod.__doc__ or _('No help text available')).splitlines(0)
ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0]))
for d in doc[1:]:
ui.write(d, '\n')
ui.status('\n')
if ui.verbose:
ui.status(_('list of commands:\n\n'))
else:
ui.status(_('list of commands (use "hg help -v %s" '
'to show aliases and global options):\n\n') % name)
modcmds = dict.fromkeys([c.split('|', 1)[0] for c in mod.cmdtable])
helplist(modcmds.has_key)
if name and name != 'shortlist':
try:
helpcmd(name)
except UnknownCommand:
helpext(name)
else:
# program name
if ui.verbose or with_version:
show_version(ui)
else:
ui.status(_("Mercurial Distributed SCM\n"))
ui.status('\n')
# list of commands
if name == "shortlist":
ui.status(_('basic commands (use "hg help" '
'for the full list or option "-v" for details):\n\n'))
elif ui.verbose:
ui.status(_('list of commands:\n\n'))
else:
ui.status(_('list of commands (use "hg help -v" '
'to show aliases and global options):\n\n'))
helplist()
Thomas Arendsen Hein
Further help improvements:...
r849 # global options
if ui.verbose:
Thomas Arendsen Hein
Adjust display and alignment of command options to match global options.
r1052 option_lists.append(("global options", globalopts))
# list all option lists
opt_output = []
for title, options in option_lists:
opt_output.append(("\n%s:\n" % title, None))
for shortopt, longopt, default, desc in options:
opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
longopt and " --%s" % longopt),
"%s%s" % (desc,
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 default
and _(" (default: %s)") % default
Thomas Arendsen Hein
Adjust display and alignment of command options to match global options.
r1052 or "")))
if opt_output:
opts_len = max([len(line[0]) for line in opt_output if line[1]])
for first, second in opt_output:
if second:
ui.write(" %-*s %s\n" % (opts_len, first, second))
else:
ui.write("%s\n" % first)
Thomas Arendsen Hein
Further help improvements:...
r849
mpm@selenic.com
hg help: use docstrings only...
r255 # Commands start here, listed alphabetically
mpm@selenic.com
Beginning of new command parsing interface...
r209
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
Schedule files to be version controlled and added to the repository.
The files will be added to the repository at the next commit.
Benoit Boissinot
make all commands be repo-wide by default...
r1568 If no names are given, add all files in the repository.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Bryan O'Sullivan
Get add and locate to use new repo and dirstate walk code....
r724 names = []
Bryan O'Sullivan
Modify commands.walk to yield a 4-tuple....
r942 for src, abs, rel, exact in walk(repo, pats, opts):
if exact:
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if ui.verbose:
ui.status(_('adding %s\n') % rel)
Bryan O'Sullivan
Get add and locate to use new repo and dirstate walk code....
r724 names.append(abs)
elif repo.dirstate.state(abs) == '?':
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.status(_('adding %s\n') % rel)
Bryan O'Sullivan
Get add and locate to use new repo and dirstate walk code....
r724 names.append(abs)
Thomas Arendsen Hein
Don't require opts['dry_run'] to be set to fix external tools like tailor.
r2503 if not opts.get('dry_run'):
Vadim Gelfer
add: add -n/--dry-run option
r2411 repo.add(names)
mpm@selenic.com
commands: migrate status and branch...
r213
Bryan O'Sullivan
Get addremove to use new walk code....
r766 def addremove(ui, repo, *pats, **opts):
Vadim Gelfer
deprecate addremove command.
r2181 """add all new files, delete all missing files (DEPRECATED)
(DEPRECATED)
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 Add all new files and remove all missing files from the repository.
New files are ignored if they match any of the patterns in .hgignore. As
with add, these changes take effect at the next commit.
Vadim Gelfer
deprecate addremove command.
r2181
This command is now deprecated and will be removed in a future
release. Please use add and remove --after instead.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Vadim Gelfer
deprecate addremove command.
r2181 ui.warn(_('(the addremove command is deprecated; use add and remove '
'--after instead)\n'))
mason@suse.com
Allow callers to pass in the dirstate lock in most localrepo.py funcs....
r1712 return addremove_lock(ui, repo, pats, opts)
def addremove_lock(ui, repo, pats, opts, wlock=None):
Bryan O'Sullivan
Fix performance regression in addremove command....
r809 add, remove = [], []
Bryan O'Sullivan
Modify commands.walk to yield a 4-tuple....
r942 for src, abs, rel, exact in walk(repo, pats, opts):
mason@suse.com
addremove was not correctly finding removed files when given...
r880 if src == 'f' and repo.dirstate.state(abs) == '?':
add.append(abs)
Bryan O'Sullivan
Get all commands that operate on files to honour --verbose and --quiet....
r1255 if ui.verbose or not exact:
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 ui.status(_('adding %s\n') % ((pats and rel) or abs))
mason@suse.com
addremove was not correctly finding removed files when given...
r880 if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
Bryan O'Sullivan
Fix performance regression in addremove command....
r809 remove.append(abs)
Bryan O'Sullivan
Get all commands that operate on files to honour --verbose and --quiet....
r1255 if ui.verbose or not exact:
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 ui.status(_('removing %s\n') % ((pats and rel) or abs))
Vadim Gelfer
addremove: add -n/--dry-run option
r2412 if not opts.get('dry_run'):
repo.add(add, wlock=wlock)
repo.remove(remove, wlock=wlock)
mpm@selenic.com
hg checkout: refuse to checkout if there are outstanding changes...
r219
Bryan O'Sullivan
Convert annotate over to walk interface....
r733 def annotate(ui, repo, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """show changeset information per file line
List changes in files, showing the revision id responsible for each line
This command is useful to discover who did a change or when a change took
place.
Without the -a option, annotate will avoid processing files it
detects as binary. With -a, annotate will generate an annotation
anyway, probably with undesirable results.
"""
mpm@selenic.com
Beginning of new command parsing interface...
r209 def getnode(rev):
mpm@selenic.com
commands: use node functions directly
r1092 return short(repo.changelog.node(rev))
mpm@selenic.com
Beginning of new command parsing interface...
r209
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 ucache = {}
mpm@selenic.com
Beginning of new command parsing interface...
r209 def getname(rev):
Matt Mackall
Convert hg annotate to context api
r2566 try:
return ucache[rev]
except:
u = trimuser(ui, repo.changectx(rev).user(), rev, ucache)
ucache[rev] = u
return u
mpm@selenic.com
[PATCH] Clean up destination directory if a clone fails....
r500
lupus@debian.org
Added --date option to annotate.
r1522 dcache = {}
def getdate(rev):
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 datestr = dcache.get(rev)
lupus@debian.org
Added --date option to annotate.
r1522 if datestr is None:
Matt Mackall
Convert hg annotate to context api
r2566 datestr = dcache[rev] = util.datestr(repo.changectx(rev).date())
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 return datestr
lupus@debian.org
Added --date option to annotate.
r1522
mpm@selenic.com
Handle empty file list for annotate
r744 if not pats:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 raise util.Abort(_('at least one file name or pattern required'))
mpm@selenic.com
Handle empty file list for annotate
r744
Matt Mackall
Fix line wrapping
r1523 opmap = [['user', getname], ['number', str], ['changeset', getnode],
['date', getdate]]
lupus@debian.org
Added --date option to annotate.
r1522 if not opts['user'] and not opts['changeset'] and not opts['date']:
Thomas Arendsen Hein
Some cleanups in commands.annotate()....
r714 opts['number'] = 1
mpm@selenic.com
Beginning of new command parsing interface...
r209
Matt Mackall
Convert hg annotate to context api
r2566 ctx = repo.changectx(opts['rev'] or repo.dirstate.parents()[0])
mpm@selenic.com
Teach annotate about binary files
r1016
Matt Mackall
Fix annotate breakage
r2568 for src, abs, rel, exact in walk(repo, pats, opts, node=ctx.node()):
Matt Mackall
Convert hg annotate to context api
r2566 fctx = ctx.filectx(abs)
if not opts['text'] and util.binary(fctx.data()):
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 ui.write(_("%s: binary file\n") % ((pats and rel) or abs))
mpm@selenic.com
Teach annotate about binary files
r1016 continue
Matt Mackall
Convert hg annotate to context api
r2566 lines = fctx.annotate()
mpm@selenic.com
Beginning of new command parsing interface...
r209 pieces = []
for o, f in opmap:
Thomas Arendsen Hein
Some cleanups in commands.annotate()....
r714 if opts[o]:
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 l = [f(n) for n, dummy in lines]
mpm@selenic.com
Fixes for annotate...
r771 if l:
m = max(map(len, l))
pieces.append(["%*s" % (m, x) for x in l])
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):
ui.write("%s: %s" % (" ".join(p), l[1]))
mpm@selenic.com
Beginning of new command parsing interface...
r209
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112 def archive(ui, repo, dest, **opts):
'''create unversioned archive of a repository revision
By default, the revision used is the parent of the working
directory; use "-r" to specify a different revision.
To specify the type of archive to create, use "-t". Valid
types are:
"files" (default): a directory full of files
"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
The exact name of the destination archive or directory is given
using a format string; see "hg help export" for details.
Each member added to an archive file has a directory prefix
prepended. Use "-p" to specify a format string for the prefix.
The default is the basename of the archive, with suffixes removed.
'''
if opts['rev']:
node = repo.lookup(opts['rev'])
else:
node, p2 = repo.dirstate.parents()
if p2 != nullid:
raise util.Abort(_('uncommitted merge - please provide a '
'specific revision'))
Matt Mackall
simplify make_filename, fix hg cat bug...
r2562 dest = make_filename(repo, dest, node)
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112 if os.path.realpath(dest) == repo.root:
raise util.Abort(_('repository root cannot be destination'))
Thomas Arendsen Hein
Cleanup archive command: Don't overwrite gettext, quoting in cmd table entry.
r2160 dummy, matchfn, dummy = matchpats(repo, [], opts)
Vadim Gelfer
archive: make "hg archive -t XXX -" to write to stdout
r2476 kind = opts.get('type') or 'files'
prefix = opts['prefix']
if dest == '-':
if kind == 'files':
raise util.Abort(_('cannot archive plain files to stdout'))
dest = sys.stdout
if not prefix: prefix = os.path.basename(repo.root) + '-%h'
Matt Mackall
simplify make_filename, fix hg cat bug...
r2562 prefix = make_filename(repo, prefix, node)
Vadim Gelfer
archive: make "hg archive -t XXX -" to write to stdout
r2476 archival.archive(repo, dest, node, kind, not opts['no_decode'],
matchfn, prefix)
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112
Vadim Gelfer
add backout command....
r2158 def backout(ui, repo, rev, **opts):
'''reverse effect of earlier changeset
Vadim Gelfer
backout command: better help.
r2254 Commit the backed out changes as a new changeset. The new
changeset is a child of the backed out changeset.
Vadim Gelfer
add backout command....
r2158
If you back out a changeset other than the tip, a new head is
Vadim Gelfer
backout command: better help.
r2254 created. This head is the parent of the working directory. If
you back out an old changeset, your working directory will appear
old after the backout. You should merge the backout changeset
with another head.
The --merge option remembers the parent of the working directory
before starting the backout, then merges the new head with that
changeset afterwards. This saves you from doing the merge by
hand. The result of this merge is not committed, as for a normal
merge.'''
Vadim Gelfer
add backout command....
r2158
bail_if_changed(repo)
op1, op2 = repo.dirstate.parents()
if op2 != nullid:
raise util.Abort(_('outstanding uncommitted merge'))
node = repo.lookup(rev)
Vadim Gelfer
backout: allow backout of merge changeset with --parent option....
r2614 p1, p2 = repo.changelog.parents(node)
if p1 == nullid:
Vadim Gelfer
add backout command....
r2158 raise util.Abort(_('cannot back out a change with no parents'))
if p2 != nullid:
Vadim Gelfer
backout: allow backout of merge changeset with --parent option....
r2614 if not opts['parent']:
raise util.Abort(_('cannot back out a merge changeset without '
'--parent'))
p = repo.lookup(opts['parent'])
if p not in (p1, p2):
raise util.Abort(_('%s is not a parent of %s' %
(short(p), short(node))))
parent = p
else:
if opts['parent']:
raise util.Abort(_('cannot use --parent on non-merge changeset'))
parent = p1
Matt Mackall
Introduce update helper functions: update, merge, clean, and revert
r2808 hg.clean(repo, node, show_stats=False)
Vadim Gelfer
add backout command....
r2158 revert_opts = opts.copy()
revert_opts['rev'] = hex(parent)
revert(ui, repo, **revert_opts)
commit_opts = opts.copy()
commit_opts['addremove'] = False
Thomas Arendsen Hein
Small cleanups to backout command:...
r2159 if not commit_opts['message'] and not commit_opts['logfile']:
Vadim Gelfer
add backout command....
r2158 commit_opts['message'] = _("Backed out changeset %s") % (hex(node))
Vadim Gelfer
fix coding style of backout editor change.
r2268 commit_opts['force_editor'] = True
Vadim Gelfer
add backout command....
r2158 commit(ui, repo, **commit_opts)
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)))
Vadim Gelfer
print message after backout that tells that backout adds new head.
r2493 if op1 != node:
if opts['merge']:
ui.status(_('merging with changeset %s\n') % nice(op1))
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806 n = _lookup(repo, hex(op1))
Matt Mackall
Introduce update helper functions: update, merge, clean, and revert
r2808 hg.merge(repo, n)
Vadim Gelfer
print message after backout that tells that backout adds new head.
r2493 else:
ui.status(_('the backout changeset is a new head - '
'do not forget to merge\n'))
Christian Ebert
fix hg backup option recommendation for auto-merge
r2761 ui.status(_('(use "backout --merge" '
'if you want to auto-merge)\n'))
Vadim Gelfer
add backout command....
r2158
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
Generate a compressed changegroup file collecting all changesets
not found in the other repository.
This file can then be transferred using conventional means and
applied to another repository with the unbundle command. This is
useful when native push and pull are not available or when
exporting an entire repository is undesirable. The standard file
extension is ".hg".
Unlike import/export, this exactly preserves all changeset
contents including permissions, rename data, and revision history.
"""
Vadim Gelfer
push, outgoing, bundle: fall back to "default" if "default-push" not defined
r2494 dest = ui.expandpath(dest or 'default-push', dest or 'default')
mpm@selenic.com
Add preliminary support for the bundle and unbundle commands
r1218 other = hg.repository(ui, dest)
Vadim Gelfer
add -f/--force to pull, incoming, outgoing, to work on unrelated repo....
r1959 o = repo.findoutgoing(other, force=opts['force'])
Vadim Gelfer
add preoutgoing and outgoing hooks....
r1736 cg = repo.changegroup(o, 'bundle')
Benoit Boissinot
refactor the bundle writing code, since we will reuse it later
r1943 write_bundle(cg, fname)
mpm@selenic.com
Add preliminary support for the bundle and unbundle commands
r1218
Bryan O'Sullivan
Switch cat command to use walk code....
r1254 def cat(ui, repo, file1, *pats, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """output the latest or given revisions of files
Print the specified files as they were at the given revision.
If no revision is given then the tip is used.
Output may be to a file, in which case the name of the file is
given using a format string. The formatting rules are the same as
for the export command, with the following additions:
%s basename of file being printed
%d dirname of file being printed, or '.' if in repo root
%p root-relative path name of file being printed
"""
Benoit Boissinot
fix 'hg cat' broken by 156fb1feab62
r2645 ctx = repo.changectx(opts['rev'] or "-1")
Matt Mackall
convert hg cat to new context api
r2565 for src, abs, rel, exact in walk(repo, (file1,) + pats, opts, ctx.node()):
fp = make_file(repo, opts['output'], ctx.node(), pathname=abs)
fp.write(ctx.filectx(abs).data())
mpm@selenic.com
migrate remaining commands...
r248
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
.hg/hgrc file, as the default to be used for future pulls.
For efficiency, hardlinks are used for cloning whenever the source
Inaky Perez-Gonzalez
Expand clone help with hardlink information
r2762 and destination are on the same filesystem (note this applies only
to the repository data, not to the checked out files). Some
filesystems, such as AFS, implement hardlinking incorrectly, but
do not report errors. In these cases, use the --pull option to
avoid hardlinking.
You can safely clone repositories and checked out files using full
hardlinks with
$ cp -al REPO REPOCLONE
which is the fastest way to clone. However, 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).
Benoit Boissinot
resync commands.py docstrings with hg.1.txt
r1811
Vadim Gelfer
clone: replace long help string of inaky with doc comment.
r2764 If you use the -r option to clone up to a specific revision, no
subsequent revisions will be present in the cloned repository.
This option implies --pull, even on local repositories.
Benoit Boissinot
resync commands.py docstrings with hg.1.txt
r1811 See pull for valid source format details.
Thomas Arendsen Hein
Additional information about URLs in pull/push/clone/init:...
r2590
It is possible to specify an ssh:// URL as the destination, but no
.hg/hgrc will be created on the remote side. Look at the help text
for the pull command for important details about ssh:// URLs.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
Kill ui.setconfig_remoteopts...
r2731 setremoteconfig(ui, opts)
Vadim Gelfer
clone: move code into hg module. make doc better....
r2597 hg.clone(ui, ui.expandpath(source), dest,
pull=opts['pull'],
Vadim Gelfer
clone: change name of --stream to --uncompressed....
r2620 stream=opts['uncompressed'],
Vadim Gelfer
clone: move code into hg module. make doc better....
r2597 rev=opts['rev'],
update=not opts['noupdate'])
mpm@selenic.com
Whitespace cleanups...
r515
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
Commit changes to the given files into the repository.
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
Thomas Arendsen Hein
Don't mention deprecated HGEDITOR variable in the help text of commit.
r1996 If no commit message is specified, the editor configured in your hgrc
or in the EDITOR environment variable is started to enter a message.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Vadim Gelfer
commands.logmessage: simplify calling.
r2799 message = logmessage(opts)
mpm@selenic.com
hg commit: add -t and -l options...
r289
mpm@selenic.com
hg commit: add -A flag...
r354 if opts['addremove']:
Vadim Gelfer
deprecate addremove command.
r2181 addremove_lock(ui, repo, pats, opts)
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 fns, match, anypats = matchpats(repo, pats, opts)
Bryan O'Sullivan
Adapt commit to use file matching code....
r813 if pats:
Thomas Arendsen Hein
Distinguish removed and deleted files. Tests are not fixed yet....
r1619 modified, added, removed, deleted, unknown = (
Thomas Arendsen Hein
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
r1618 repo.changes(files=fns, match=match))
Thomas Arendsen Hein
Distinguish removed and deleted files. Tests are not fixed yet....
r1619 files = modified + added + removed
Bryan O'Sullivan
Adapt commit to use file matching code....
r813 else:
files = []
Bryan O'Sullivan
Commit date validation: more stringent checks, more useful error messages.
r1202 try:
john.levon@sun.com
Force editor to appear for an 'hg backout' if a message or logfile aren't...
r2267 repo.commit(files, message, opts['user'], opts['date'], match,
Vadim Gelfer
fix coding style of backout editor change.
r2268 force_editor=opts.get('force_editor'))
Bryan O'Sullivan
Commit date validation: more stringent checks, more useful error messages.
r1202 except ValueError, inst:
raise util.Abort(str(inst))
mpm@selenic.com
big heap of command clean-up work...
r245
Robin Farine
copy/rename to a removed destination file...
r1822 def docopy(ui, repo, pats, opts, wlock):
# called with the repo lock held
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 cwd = repo.getcwd()
errors = 0
copied = []
Robin Farine
avoid to copy more than one file to the same destination file
r1514 targets = {}
Bryan O'Sullivan
Fix up copy command to behave more like regular "cp"....
r1249
def okaytocopy(abs, rel, exact):
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 reasons = {'?': _('is not managed'),
Robin Farine
copy & rename can ignore removed source files...
r1634 'a': _('has been marked for add'),
'r': _('has been marked for remove')}
Robin Farine
transitive copy/rename...
r1747 state = repo.dirstate.state(abs)
reason = reasons.get(state)
Bryan O'Sullivan
Fix up copy command to behave more like regular "cp"....
r1249 if reason:
Robin Farine
transitive copy/rename...
r1747 if state == 'a':
origsrc = repo.dirstate.copied(abs)
if origsrc is not None:
return origsrc
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if exact:
ui.warn(_('%s: not copying - file %s\n') % (rel, reason))
Bryan O'Sullivan
Fix up copy command to behave more like regular "cp"....
r1249 else:
Robin Farine
transitive copy/rename...
r1747 return abs
def copy(origsrc, abssrc, relsrc, target, exact):
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 abstarget = util.canonpath(repo.root, cwd, target)
reltarget = util.pathto(cwd, abstarget)
Robin Farine
avoid to copy more than one file to the same destination file
r1514 prevsrc = targets.get(abstarget)
if prevsrc is not None:
ui.warn(_('%s: not overwriting - %s collides with %s\n') %
(reltarget, abssrc, prevsrc))
return
Robin Farine
fix rename --after
r1565 if (not opts['after'] and os.path.exists(reltarget) or
opts['after'] and repo.dirstate.state(abstarget) not in '?r'):
if not opts['force']:
Robin Farine
copy & rename don't overwrite unless --force is specified
r1513 ui.warn(_('%s: not overwriting - file exists\n') %
reltarget)
return
Thomas Arendsen Hein
Don't require opts['dry_run'] to be set to fix external tools like tailor.
r2503 if not opts['after'] and not opts.get('dry_run'):
Robin Farine
fix rename --after
r1565 os.unlink(reltarget)
if opts['after']:
if not os.path.exists(reltarget):
return
else:
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 targetdir = os.path.dirname(reltarget) or '.'
Thomas Arendsen Hein
Don't require opts['dry_run'] to be set to fix external tools like tailor.
r2503 if not os.path.isdir(targetdir) and not opts.get('dry_run'):
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 os.makedirs(targetdir)
Bryan O'Sullivan
Fix up copy command to behave more like regular "cp"....
r1249 try:
Robin Farine
copy/rename to a removed destination file...
r1822 restore = repo.dirstate.state(abstarget) == 'r'
Thomas Arendsen Hein
Don't require opts['dry_run'] to be set to fix external tools like tailor.
r2503 if restore and not opts.get('dry_run'):
Robin Farine
copy/rename to a removed destination file...
r1822 repo.undelete([abstarget], wlock)
try:
Thomas Arendsen Hein
Don't require opts['dry_run'] to be set to fix external tools like tailor.
r2503 if not opts.get('dry_run'):
Vadim Gelfer
remove: add -n/--dry-run option
r2414 shutil.copyfile(relsrc, reltarget)
shutil.copymode(relsrc, reltarget)
Robin Farine
copy/rename to a removed destination file...
r1822 restore = False
finally:
if restore:
repo.remove([abstarget], wlock)
Bryan O'Sullivan
Add rename/mv command....
r1253 except shutil.Error, inst:
raise util.Abort(str(inst))
Bryan O'Sullivan
Fix up copy command to behave more like regular "cp"....
r1249 except IOError, inst:
if inst.errno == errno.ENOENT:
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 ui.warn(_('%s: deleted in working copy\n') % relsrc)
Bryan O'Sullivan
Fix up copy command to behave more like regular "cp"....
r1249 else:
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 ui.warn(_('%s: cannot copy - %s\n') %
(relsrc, inst.strerror))
errors += 1
return
Robin Farine
fix rename --after
r1565 if ui.verbose or not exact:
ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
Robin Farine
avoid to copy more than one file to the same destination file
r1514 targets[abstarget] = abssrc
Thomas Arendsen Hein
Don't require opts['dry_run'] to be set to fix external tools like tailor.
r2503 if abstarget != origsrc and not opts.get('dry_run'):
Robin Farine
copy/rename to a removed destination file...
r1822 repo.copy(origsrc, abstarget, wlock)
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 copied.append((abssrc, relsrc, exact))
Robin Farine
fix rename --after
r1565 def targetpathfn(pat, dest, srcs):
if os.path.isdir(pat):
Robin Farine
copy/rename '.' or '..' correctly
r1633 abspfx = util.canonpath(repo.root, cwd, pat)
Robin Farine
fix rename --after
r1565 if destdirexists:
Robin Farine
copy/rename '.' or '..' correctly
r1633 striplen = len(os.path.split(abspfx)[0])
Robin Farine
fix rename --after
r1565 else:
Robin Farine
copy/rename '.' or '..' correctly
r1633 striplen = len(abspfx)
Robin Farine
fix rename --after
r1565 if striplen:
striplen += len(os.sep)
res = lambda p: os.path.join(dest, p[striplen:])
elif destdirexists:
res = lambda p: os.path.join(dest, os.path.basename(p))
else:
res = lambda p: dest
return res
def targetpathafterfn(pat, dest, srcs):
if util.patkind(pat, None)[0]:
# a mercurial pattern
res = lambda p: os.path.join(dest, os.path.basename(p))
Robin Farine
copy/rename '.' or '..' correctly
r1633 else:
abspfx = util.canonpath(repo.root, cwd, pat)
if len(abspfx) < len(srcs[0][0]):
# A directory. Either the target path contains the last
# component of the source path or it does not.
def evalpath(striplen):
score = 0
for s in srcs:
t = os.path.join(dest, s[0][striplen:])
if os.path.exists(t):
score += 1
return score
Robin Farine
fix rename --after
r1565
Robin Farine
copy/rename '.' or '..' correctly
r1633 striplen = len(abspfx)
if striplen:
striplen += len(os.sep)
if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])):
score = evalpath(striplen)
striplen1 = len(os.path.split(abspfx)[0])
if striplen1:
striplen1 += len(os.sep)
if evalpath(striplen1) > score:
striplen = striplen1
res = lambda p: os.path.join(dest, p[striplen:])
Robin Farine
fix rename --after
r1565 else:
Robin Farine
copy/rename '.' or '..' correctly
r1633 # a file
if destdirexists:
res = lambda p: os.path.join(dest, os.path.basename(p))
else:
res = lambda p: dest
Robin Farine
fix rename --after
r1565 return res
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 pats = list(pats)
if not pats:
raise util.Abort(_('no source or destination specified'))
if len(pats) == 1:
raise util.Abort(_('no destination specified'))
dest = pats.pop()
destdirexists = os.path.isdir(dest)
Robin Farine
fix rename --after
r1565 if (len(pats) > 1 or util.patkind(pats[0], None)[0]) and not destdirexists:
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 raise util.Abort(_('with multiple sources, destination must be an '
'existing directory'))
Robin Farine
fix rename --after
r1565 if opts['after']:
tfn = targetpathafterfn
else:
tfn = targetpathfn
copylist = []
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 for pat in pats:
Robin Farine
fix rename --after
r1565 srcs = []
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 for tag, abssrc, relsrc, exact in walk(repo, [pat], opts):
Robin Farine
transitive copy/rename...
r1747 origsrc = okaytocopy(abssrc, relsrc, exact)
if origsrc:
srcs.append((origsrc, abssrc, relsrc, exact))
Robin Farine
fix rename --after
r1565 if not srcs:
continue
copylist.append((tfn(pat, dest, srcs), srcs))
if not copylist:
raise util.Abort(_('no files to copy'))
Vadim Gelfer
remove: add -n/--dry-run option
r2414 for targetpath, srcs in copylist:
for origsrc, abssrc, relsrc, exact in srcs:
copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact)
Robin Farine
generalize copy/rename to handle more than one source directory
r1512
if errors:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.warn(_('(consider using --after)\n'))
Robin Farine
generalize copy/rename to handle more than one source directory
r1512 return errors, copied
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
Mark dest as having copies of source files. If dest is a
directory, copies are put in that directory. If dest is a file,
there can only be one source.
By default, this command copies the contents of files as they
stand in the working directory. If invoked with --after, the
operation is recorded, but no copying is performed.
This command takes effect in the next commit.
NOTE: This command should be treated as experimental. While it
should properly record copied files, this information is not yet
fully used by merge, nor fully reported by log.
"""
Vadim Gelfer
fix backtrace printed when cannot get lock....
r2016 wlock = repo.wlock(0)
errs, copied = docopy(ui, repo, pats, opts, wlock)
Bryan O'Sullivan
Fix up copy command to behave more like regular "cp"....
r1249 return errs
mpm@selenic.com
Add hg copy...
r363
mpm@selenic.com
Add debugancestor command
r1262 def debugancestor(ui, index, rev1, rev2):
"""find the ancestor revision of two revisions in a given index"""
mason@suse.com
Implement revlogng....
r2072 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index, "", 0)
mpm@selenic.com
Add debugancestor command
r1262 a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
ui.write("%d:%s\n" % (r.rev(a), hex(a)))
Alexis S. L. Carvalho
add --options to debugcomplete and change bash_completion to use it...
r2034 def debugcomplete(ui, cmd='', **opts):
Benoit Boissinot
new command debugcomplete...
r1887 """returns the completion list associated with the given command"""
Alexis S. L. Carvalho
add --options to debugcomplete and change bash_completion to use it...
r2034
if opts['options']:
options = []
otables = [globalopts]
if cmd:
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 aliases, entry = findcmd(cmd)
Alexis S. L. Carvalho
add --options to debugcomplete and change bash_completion to use it...
r2034 otables.append(entry[1])
for t in otables:
for o in t:
if o[0]:
options.append('-%s' % o[0])
options.append('--%s' % o[1])
ui.write("%s\n" % "\n".join(options))
return
Benoit Boissinot
new command debugcomplete...
r1887 clist = findpossible(cmd).keys()
clist.sort()
Alexis S. L. Carvalho
add --options to debugcomplete and change bash_completion to use it...
r2034 ui.write("%s\n" % "\n".join(clist))
Benoit Boissinot
new command debugcomplete...
r1887
Benoit Boissinot
add 'debugrebuildstate' to rebuild the dirstate from a given revision...
r1755 def debugrebuildstate(ui, repo, rev=None):
"""rebuild the dirstate as it would look like for the given revision"""
if not rev:
rev = repo.changelog.tip()
else:
rev = repo.lookup(rev)
change = repo.changelog.read(rev)
n = change[0]
Matt Mackall
Change remaining users of manifest flags
r2840 files = repo.manifest.read(n)
Benoit Boissinot
fix typo in debugrebuildstate
r1760 wlock = repo.wlock()
Matt Mackall
Change remaining users of manifest flags
r2840 repo.dirstate.rebuild(rev, files)
Benoit Boissinot
add 'debugrebuildstate' to rebuild the dirstate from a given revision...
r1755
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()
mpm@selenic.com
Unbreak dirstate debug commands...
r555 repo.dirstate.read()
dc = repo.dirstate.map
mpm@selenic.com
add dirstate debugging commands...
r460 keys = dc.keys()
keys.sort()
m1n = repo.changelog.read(parent1)[0]
m2n = repo.changelog.read(parent2)[0]
m1 = repo.manifest.read(m1n)
m2 = repo.manifest.read(m2n)
errors = 0
for f in dc:
state = repo.dirstate.state(f)
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:
state = repo.dirstate.state(f)
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
Vadim Gelfer
debugconfig: allow to print by section and exact item name
r2410 def debugconfig(ui, repo, *values):
"""show combined config settings from all hgrc files
With no args, print names and values of all config items.
With one arg of the form section.name, print just the value of
that config item.
With multiple args, print names and values of all config items
with matching section names."""
if values:
if len([v for v in values if '.' in v]) > 1:
raise util.Abort(_('only one config item permitted'))
Bryan O'Sullivan
Add commands.debugconfig....
r1028 for section, name, value in ui.walkconfig():
Vadim Gelfer
debugconfig: allow to print by section and exact item name
r2410 sectname = section + '.' + name
if values:
for v in values:
if v == section:
ui.write('%s=%s\n' % (sectname, value))
elif v == sectname:
ui.write(value, '\n')
else:
ui.write('%s=%s\n' % (sectname, value))
Bryan O'Sullivan
Add commands.debugconfig....
r1028
Matt Mackall
Add debugsetparents command
r1395 def debugsetparents(ui, repo, rev1, rev2=None):
TK Soh
minor fix on command help docstrings
r1470 """manually set the parents of the current working directory
Matt Mackall
Add debugsetparents command
r1395
This is useful for writing repository conversion tools, but should
be used with care.
"""
if not rev2:
rev2 = hex(nullid)
repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
mpm@selenic.com
A bunch of parsing/help updates...
r596 def debugstate(ui, repo):
"""show the contents of the current dirstate"""
mpm@selenic.com
Unbreak dirstate debug commands...
r555 repo.dirstate.read()
dc = repo.dirstate.map
mpm@selenic.com
add dirstate debugging commands...
r460 keys = dc.keys()
keys.sort()
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 for file_ in keys:
Thomas Arendsen Hein
Show all dirstate info for 'hg debugstate'.
r791 ui.write("%c %3o %10d %s %s\n"
% (dc[file_][0], dc[file_][1] & 0777, dc[file_][2],
time.strftime("%x %X",
time.localtime(dc[file_][3])), file_))
mpm@selenic.com
Add some rename debugging support
r1116 for f in repo.dirstate.copies:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copies[f], f))
mpm@selenic.com
add dirstate debugging commands...
r460
mpm@selenic.com
Add debugdata for dumping revlog revision data
r1039 def debugdata(ui, file_, rev):
"""dump the contents of an data file revision"""
Thomas Arendsen Hein
Validate paths before reading or writing files in repository or working dir....
r1835 r = revlog.revlog(util.opener(os.getcwd(), audit=False),
mason@suse.com
Implement revlogng....
r2072 file_[:-2] + ".i", file_, 0)
Anupam Kapoor
Fix traceback during invalid rev identifier for debugdata
r1313 try:
ui.write(r.revision(r.lookup(rev)))
except KeyError:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 raise util.Abort(_('invalid revision identifier %s'), rev)
mpm@selenic.com
Add debugdata for dumping revlog revision data
r1039
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 def debugindex(ui, file_):
mpm@selenic.com
A bunch of parsing/help updates...
r596 """dump the contents of an index file"""
mason@suse.com
Implement revlogng....
r2072 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0)
mpm@selenic.com
Remove all remaining print statements...
r582 ui.write(" rev offset length base linkrev" +
mpm@selenic.com
Reformat debugindex output
r989 " nodeid p1 p2\n")
mpm@selenic.com
migrate remaining commands...
r248 for i in range(r.count()):
mason@suse.com
Implement revlogng....
r2072 node = r.node(i)
pp = r.parents(node)
mpm@selenic.com
Reformat debugindex output
r989 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
mason@suse.com
Implement revlogng....
r2072 i, r.start(i), r.length(i), r.base(i), r.linkrev(node),
short(node), short(pp[0]), short(pp[1])))
mpm@selenic.com
migrate remaining commands...
r248
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 def debugindexdot(ui, file_):
mpm@selenic.com
A bunch of parsing/help updates...
r596 """dump an index DAG as a .dot file"""
mason@suse.com
Implement revlogng....
r2072 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, "", 0)
mpm@selenic.com
Remove all remaining print statements...
r582 ui.write("digraph G {\n")
mpm@selenic.com
migrate remaining commands...
r248 for i in range(r.count()):
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
mpm@selenic.com
Add some rename debugging support
r1116 def debugrename(ui, repo, file, rev=None):
bos@serpentine.internal.keyresearch.com
Add doc string for debugrename.
r1194 """dump rename information"""
mpm@selenic.com
Add some rename debugging support
r1116 r = repo.file(relpath(repo, [file])[0])
if rev:
try:
# assume all revision numbers are for changesets
n = repo.lookup(rev)
change = repo.changelog.read(n)
m = repo.manifest.read(change[0])
n = m[relpath(repo, [file])[0]]
twaldmann@thinkmo.de
fixed some stuff pychecker shows, marked unclear/wrong stuff with XXX
r1541 except (hg.RepoError, KeyError):
mpm@selenic.com
Add some rename debugging support
r1116 n = r.lookup(rev)
else:
n = r.tip()
m = r.renamed(n)
if m:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.write(_("renamed from %s:%s\n") % (m[0], hex(m[1])))
mpm@selenic.com
Add some rename debugging support
r1116 else:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.write(_("not renamed\n"))
mpm@selenic.com
Add some rename debugging support
r1116
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"""
Bryan O'Sullivan
Clean up walk and changes code to use normalised names properly....
r820 items = list(walk(repo, pats, opts))
Thomas Arendsen Hein
Cleanups to commands.py
r1065 if not items:
return
Thomas Arendsen Hein
Make debugwalk strip trailing spaces and remove these from test-walk.out
r1309 fmt = '%%s %%-%ds %%-%ds %%s' % (
Bryan O'Sullivan
Modify commands.walk to yield a 4-tuple....
r942 max([len(abs) for (src, abs, rel, exact) in items]),
max([len(rel) for (src, abs, rel, exact) in items]))
for src, abs, rel, exact in items:
Thomas Arendsen Hein
Make debugwalk strip trailing spaces and remove these from test-walk.out
r1309 line = fmt % (src, abs, rel, exact and 'exact' or '')
ui.write("%s\n" % line.rstrip())
Bryan O'Sullivan
Clean up walk and changes code to use normalised names properly....
r820
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.
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.
Without the -a option, diff will avoid generating diffs of files
it detects as binary. With -a, diff will generate a diff anyway,
probably with undesirable results.
"""
Vadim Gelfer
diff: allow to use -rA:B syntax as well as -rA -rB
r2331 node1, node2 = revpair(ui, repo, opts['rev'])
mpm@selenic.com
big heap of command clean-up work...
r245
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 fns, matchfn, anypats = matchpats(repo, pats, opts)
mpm@selenic.com
Clean up argument passing for dodiff
r1014
Bryan O'Sullivan
Fix diff command so it doesn't walk the dirstate unnecessarily.
r1267 dodiff(sys.stdout, ui, repo, node1, node2, fns, match=matchfn,
Vadim Gelfer
add -w and -p options to diff. this is for issue 126.
r1728 text=opts['text'], opts=opts)
mpm@selenic.com
big heap of command clean-up work...
r245
mpm@selenic.com
[PATCH] New export patch...
r580 def doexport(ui, repo, changeset, seqno, total, revwidth, opts):
mpm@selenic.com
Migrate rawcommit, import, export, history, and merge...
r246 node = repo.lookup(changeset)
Benoit Boissinot
add a --switch-parent option to export against the other parent
r1571 parents = [p for p in repo.changelog.parents(node) if p != nullid]
Benoit Boissinot
fix a bug in hg export --switch-parent
r1589 if opts['switch_parent']:
parents.reverse()
Benoit Boissinot
add a --switch-parent option to export against the other parent
r1571 prev = (parents and parents[0]) or nullid
mpm@selenic.com
Migrate rawcommit, import, export, history, and merge...
r246 change = repo.changelog.read(node)
mpm@selenic.com
[PATCH] New export patch...
r580
Matt Mackall
simplify make_filename, fix hg cat bug...
r2562 fp = make_file(repo, opts['output'], node, total=total, seqno=seqno,
Bryan O'Sullivan
Turn make_filename into make_file, which returns a file handle.
r729 revwidth=revwidth)
if fp != sys.stdout:
Thomas Arendsen Hein
Show filenames for hg export in verbose mode on a separate lines....
r755 ui.note("%s\n" % fp.name)
mpm@selenic.com
[PATCH] New export patch...
r580
mpm@selenic.com
Remove all remaining print statements...
r582 fp.write("# HG changeset patch\n")
fp.write("# User %s\n" % change[1])
Thomas Arendsen Hein
Use "# Date" instead of "# Timestamp" for dated export/import of patches....
r2300 fp.write("# Date %d %d\n" % change[2])
mpm@selenic.com
commands: use node functions directly
r1092 fp.write("# Node ID %s\n" % hex(node))
fp.write("# Parent %s\n" % hex(prev))
Benoit Boissinot
add a --switch-parent option to export against the other parent
r1571 if len(parents) > 1:
fp.write("# Parent %s\n" % hex(parents[1]))
mpm@selenic.com
Remove all remaining print statements...
r582 fp.write(change[4].rstrip())
fp.write("\n\n")
mpm@selenic.com
[PATCH] New export patch...
r580
mpm@selenic.com
Add automatic binary file detection to diff and export...
r1015 dodiff(fp, ui, repo, prev, node, text=opts['text'])
Thomas Arendsen Hein
Cleanups to commands.py
r1065 if fp != sys.stdout:
fp.close()
Thomas Arendsen Hein
Show revisions in diffs like CVS, based on a patch from Goffredo Baroncelli....
r396
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.
The information shown in the changeset header is: author,
changeset hash, parent and commit comment.
Output may be to a file, in which case the name of the file is
given using a format string. The formatting rules are as follows:
%% literal "%" character
%H changeset hash (40 bytes of hexadecimal)
%N number of patches being generated
%R changeset revision number
%b basename of the exporting repository
%h short-form changeset hash (12 bytes of hexadecimal)
%n zero-padded sequence number, starting at 1
%r zero-padded changeset revision number
Without the -a option, export will avoid generating diffs of files
it detects as binary. With -a, export will generate a diff anyway,
probably with undesirable results.
Benoit Boissinot
add a --switch-parent option to export against the other parent
r1571
With the --switch-parent option, the diff will be against the second
parent. It can be useful to review a merge.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
shaleh@speakeasy.net
check export options for changeset before running...
r610 if not changesets:
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"))
mpm@selenic.com
[PATCH] New export patch...
r580 seqno = 0
revs = list(revrange(ui, repo, changesets))
total = len(revs)
Thomas Arendsen Hein
Fixed zero-padded filenames with %r if there is a longer number in the middle....
r1067 revwidth = max(map(len, revs))
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 msg = len(revs) > 1 and _("Exporting patches:\n") or _("Exporting patch:\n")
ui.note(msg)
mpm@selenic.com
[PATCH] New export patch...
r580 for cset in revs:
seqno += 1
doexport(ui, repo, cset, seqno, total, revwidth, opts)
mpm@selenic.com
Migrate rawcommit, import, export, history, and merge...
r246
Bryan O'Sullivan
Move commands.forget over to using new walk code....
r810 def forget(ui, repo, *pats, **opts):
Vadim Gelfer
mark forget command as deprecated....
r2135 """don't add the specified files on the next commit (DEPRECATED)
(DEPRECATED)
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 Undo an 'hg add' scheduled for the next commit.
Vadim Gelfer
mark forget command as deprecated....
r2135
This command is now deprecated and will be removed in a future
release. Please use revert instead.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Vadim Gelfer
mark forget command as deprecated....
r2135 ui.warn(_("(the forget command is deprecated; use revert instead)\n"))
Bryan O'Sullivan
Move commands.forget over to using new walk code....
r810 forget = []
Bryan O'Sullivan
Modify commands.walk to yield a 4-tuple....
r942 for src, abs, rel, exact in walk(repo, pats, opts):
Bryan O'Sullivan
Move commands.forget over to using new walk code....
r810 if repo.dirstate.state(abs) == 'a':
forget.append(abs)
Bryan O'Sullivan
Get all commands that operate on files to honour --verbose and --quiet....
r1255 if ui.verbose or not exact:
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 ui.status(_('forgetting %s\n') % ((pats and rel) or abs))
Bryan O'Sullivan
Move commands.forget over to using new walk code....
r810 repo.forget(forget)
mpm@selenic.com
big heap of command clean-up work...
r245
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.
This command behaves differently than Unix grep. It only accepts
Python/Perl regexps. It searches repository history, not the
working directory. It always prints the revision number in which
a match appears.
By default, grep only prints output for the first revision of a
file in which it finds a match. To get it to print every revision
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.
"""
Bryan O'Sullivan
Add grep command....
r1057 reflags = 0
Thomas Arendsen Hein
Cleanups to commands.py
r1065 if opts['ignore_case']:
reflags |= re.I
Bryan O'Sullivan
Add grep command....
r1057 regexp = re.compile(pattern, reflags)
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 sep, eol = ':', '\n'
Thomas Arendsen Hein
Remove some options from 'hg grep':...
r1108 if opts['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
fcache = {}
def getfile(fn):
if fn not in fcache:
fcache[fn] = repo.file(fn)
return fcache[fn]
def matchlines(body):
bos@serpentine.internal.keyresearch.com
grep: speed up matching, and only return one match per line.
r1059 begin = 0
linenum = 0
while True:
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
lend = body.find('\n', mend)
yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
begin = lend + 1
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
Thomas Arendsen Hein
Cleanups to commands.py
r1065 def __eq__(self, other):
return self.line == other.line
def __hash__(self):
return hash(self.line)
Bryan O'Sullivan
Add grep command....
r1057
matches = {}
def grepbody(fn, rev, body):
matches[rev].setdefault(fn, {})
m = matches[rev][fn]
for lnum, cstart, cend, line in matchlines(body):
s = linestate(line, lnum, cstart, cend)
m[s] = s
Benoit Boissinot
fix warnings from pychecker (unused variables and shadowing)
r1749 # FIXME: prev isn't used, why ?
Bryan O'Sullivan
Add grep command....
r1057 prev = {}
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 ucache = {}
Bryan O'Sullivan
Add grep command....
r1057 def display(fn, rev, states, prevstates):
mpm@selenic.com
Fix set type usage for Python 2.3
r1061 diff = list(sets.Set(states).symmetric_difference(sets.Set(prevstates)))
Bryan O'Sullivan
Add grep command....
r1057 diff.sort(lambda x, y: cmp(x.linenum, y.linenum))
Bryan O'Sullivan
grep: change default to printing first matching rev....
r1145 counts = {'-': 0, '+': 0}
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 filerevmatches = {}
Bryan O'Sullivan
Add grep command....
r1057 for l in diff:
mpm@selenic.com
Change grep -e to grep --all...
r1212 if incrementing or not opts['all']:
Bryan O'Sullivan
Add grep command....
r1057 change = ((l in prevstates) and '-') or '+'
r = rev
else:
change = ((l in states) and '-') or '+'
r = prev[fn]
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 cols = [fn, str(rev)]
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if opts['line_number']:
cols.append(str(l.linenum))
if opts['all']:
cols.append(change)
if opts['user']:
cols.append(trimuser(ui, getchange(rev)[1], rev,
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 ucache))
if opts['files_with_matches']:
c = (fn, rev)
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if c in filerevmatches:
continue
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 filerevmatches[c] = 1
else:
cols.append(l.line)
ui.write(sep.join(cols), eol)
Bryan O'Sullivan
grep: change default to printing first matching rev....
r1145 counts[change] += 1
return counts['+'], counts['-']
Bryan O'Sullivan
Add grep command....
r1057
fstate = {}
Bryan O'Sullivan
grep: change default to printing first matching rev....
r1145 skip = {}
Benoit Boissinot
hg log -p should show file deletions
r1570 changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts)
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 count = 0
mpm@selenic.com
Fix up some bugs for log and grep with empty repo
r1337 incrementing = False
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 for st, rev, fns in changeiter:
Bryan O'Sullivan
Add grep command....
r1057 if st == 'window':
incrementing = rev
matches.clear()
elif st == 'add':
change = repo.changelog.read(repo.lookup(str(rev)))
mf = repo.manifest.read(change[0])
matches[rev] = {}
for fn in fns:
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if fn in skip:
continue
Bryan O'Sullivan
Add grep command....
r1057 fstate.setdefault(fn, {})
try:
grepbody(fn, rev, getfile(fn).read(mf[fn]))
except KeyError:
pass
elif st == 'iter':
states = matches[rev].items()
states.sort()
for fn, m in states:
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if fn in skip:
continue
mpm@selenic.com
Change grep -e to grep --all...
r1212 if incrementing or not opts['all'] or fstate[fn]:
Bryan O'Sullivan
grep: change default to printing first matching rev....
r1145 pos, neg = display(fn, rev, m, fstate[fn])
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 count += pos + neg
mpm@selenic.com
Change grep -e to grep --all...
r1212 if pos and not opts['all']:
Bryan O'Sullivan
grep: change default to printing first matching rev....
r1145 skip[fn] = True
Bryan O'Sullivan
Add grep command....
r1057 fstate[fn] = m
prev[fn] = rev
if not incrementing:
fstate = fstate.items()
fstate.sort()
for fn, state in fstate:
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if fn in skip:
continue
Bryan O'Sullivan
Add grep command....
r1057 display(fn, rev, {}, state)
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 return (count == 0 and 1) or 0
Bryan O'Sullivan
Add grep command....
r1057
mason@suse.com
Add searching for named branches...
r898 def heads(ui, repo, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """show current repository heads
Show all repository head changesets.
Repository "heads" are changesets that don't have children
changesets. They are where development generally takes place and
are the usual targets for update and merge operations.
"""
Benoit Boissinot
add a -r/--rev option to heads to show only heads descendant from rev
r1550 if opts['rev']:
Thomas Arendsen Hein
Fixes to "hg heads -r FOO":...
r1551 heads = repo.heads(repo.lookup(opts['rev']))
Benoit Boissinot
add a -r/--rev option to heads to show only heads descendant from rev
r1550 else:
heads = repo.heads()
mason@suse.com
Add searching for named branches...
r898 br = None
if opts['branches']:
Thomas Arendsen Hein
Fixes to "hg heads -r FOO":...
r1551 br = repo.branchlookup(heads)
Vadim Gelfer
let commands that show changesets use templates....
r1907 displayer = show_changeset(ui, repo, opts)
Benoit Boissinot
add a -r/--rev option to heads to show only heads descendant from rev
r1550 for n in heads:
Vadim Gelfer
let commands that show changesets use templates....
r1907 displayer.show(changenode=n, brinfo=br)
mpm@selenic.com
Beginning of multi-head support...
r221
Thomas Arendsen Hein
added hg identify|id (based on a patch from Andrew Thompson)...
r339 def identify(ui, repo):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """print information about the working copy
TK Soh
minor fix on command help docstrings
r1470
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 Print a short summary of the current state of the repo.
This summary identifies the repository state using one or two parent
hash identifiers, followed by a "+" if there are uncommitted changes
in the working directory, followed by a list of tags for this revision.
"""
mpm@selenic.com
commands: use node functions directly
r1092 parents = [p for p in repo.dirstate.parents() if p != nullid]
Thomas Arendsen Hein
Handle the case where the current working copy is not based on a checkout....
r340 if not parents:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.write(_("unknown\n"))
Thomas Arendsen Hein
Handle the case where the current working copy is not based on a checkout....
r340 return
mpm@selenic.com
commands: use node functions directly
r1092 hexfunc = ui.verbose and hex or short
Thomas Arendsen Hein
Distinguish removed and deleted files. Tests are not fixed yet....
r1619 modified, added, removed, deleted, unknown = repo.changes()
output = ["%s%s" %
('+'.join([hexfunc(parent) for parent in parents]),
(modified or added or removed or deleted) and "+" or "")]
Thomas Arendsen Hein
Improvements for hg identify:...
r386
Thomas Arendsen Hein
added hg identify|id (based on a patch from Andrew Thompson)...
r339 if not ui.quiet:
Thomas Arendsen Hein
Improvements for hg identify:...
r386 # multiple tags for a single parent separated by '/'
parenttags = ['/'.join(tags)
for tags in map(repo.nodetags, parents) if tags]
# tags for multiple parents separated by ' + '
Thomas Arendsen Hein
There was an extra space after 'hg id' when there are no tags.
r758 if parenttags:
output.append(' + '.join(parenttags))
Thomas Arendsen Hein
added hg identify|id (based on a patch from Andrew Thompson)...
r339
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
mpm@selenic.com
Commands cleanup...
r437 def import_(ui, repo, patch1, *patches, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """import an ordered set of patches
Import a list of patches and commit them individually.
If there are outstanding changes in the working directory, import
will abort unless given the -f flag.
Vadim Gelfer
import: parse email messages
r2504 You can import a patch straight from a mail message. Even patches
as attachments work (body part must be type text/plain or
Vadim Gelfer
import: make help clearer. suggested by asak.
r2515 text/x-patch to be used). From and Subject headers of email
message are used as default committer and commit message. All
text/plain body parts before first diff are added to commit
message.
Vadim Gelfer
import: parse email messages
r2504
If imported patch was generated by hg export, user and description
from patch override values from message headers and body. Values
given on command line with -m and -u override these.
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400
To read a patch from standard input, use patch name "-".
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
mpm@selenic.com
Commands cleanup...
r437 patches = (patch1,) + patches
mpm@selenic.com
[PATCH] Clean up destination directory if a clone fails....
r500
mpm@selenic.com
hg import: abort with uncommitted changes, override with --force
r966 if not opts['force']:
Vadim Gelfer
add backout command....
r2158 bail_if_changed(repo)
mpm@selenic.com
hg import: abort with uncommitted changes, override with --force
r966
mpm@selenic.com
Commands cleanup...
r437 d = opts["base"]
strip = opts["strip"]
bos@serpentine.internal.keyresearch.com
Fortify the recognition of a diff header.
r1193 mailre = re.compile(r'(?:From |[\w-]+:)')
Matt Mackall
Borrow patch header detection heuristic from quilt
r1390
# attempt to detect the start of a patch
# (this heuristic is borrowed from quilt)
Vadim Gelfer
import: parse email messages
r2504 diffre = re.compile(r'^(?:Index:[ \t]|diff[ \t]|RCS file: |' +
Matt Mackall
Borrow patch header detection heuristic from quilt
r1390 'retrieving revision [0-9]+(\.[0-9]+)*$|' +
Vadim Gelfer
import: parse email messages
r2504 '(---|\*\*\*)[ \t])', re.MULTILINE)
bos@serpentine.internal.keyresearch.com
Make import command reject patches that resemble email messages....
r1190
Vadim Gelfer
import: get lock and wlock one time...
r2854 wlock = repo.wlock()
lock = repo.lock()
Brendan Cully
Move patch-related code into its own module.
r2861 for p in patches:
pf = os.path.join(d, p)
mpm@selenic.com
Commands cleanup...
r437
Vadim Gelfer
import: parse email messages
r2504 message = None
Thomas Arendsen Hein
On importing the result of 'hg export', parse while reading and drop headers....
r701 user = None
Danek Duvall
Add timestamp field to export format. Make import and mq use it.
r2299 date = None
Thomas Arendsen Hein
On importing the result of 'hg export', parse while reading and drop headers....
r701 hgpatch = False
Vadim Gelfer
import: parse email messages
r2504
Brendan Cully
Move patch-related code into its own module.
r2861 parser = email.Parser.Parser()
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400 if pf == '-':
Brendan Cully
Move patch-related code into its own module.
r2861 msg = parser.parse(sys.stdin)
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400 ui.status(_("applying patch from stdin\n"))
else:
Brendan Cully
Move patch-related code into its own module.
r2861 msg = parser.parse(file(pf))
ui.status(_("applying %s\n") % p)
Vadim Gelfer
import: parse email messages
r2504
fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
tmpfp = os.fdopen(fd, 'w')
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400 try:
Vadim Gelfer
import: parse email messages
r2504 message = msg['Subject']
if message:
message = message.replace('\n\t', ' ')
ui.debug('Subject: %s\n' % message)
user = msg['From']
if user:
ui.debug('From: %s\n' % user)
diffs_seen = 0
Vadim Gelfer
import: switch from application/x-patch to text/x-diff...
r2743 ok_types = ('text/plain', 'text/x-diff', 'text/x-patch')
Vadim Gelfer
import: parse email messages
r2504 for part in msg.walk():
content_type = part.get_content_type()
ui.debug('Content-Type: %s\n' % content_type)
if content_type not in ok_types:
continue
payload = part.get_payload(decode=True)
m = diffre.search(payload)
if m:
ui.debug(_('found patch at byte %d\n') % m.start(0))
diffs_seen += 1
hgpatch = False
fp = cStringIO.StringIO()
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513 if message:
fp.write(message)
fp.write('\n')
Vadim Gelfer
import: parse email messages
r2504 for line in payload[:m.start(0)].splitlines():
if line.startswith('# HG changeset patch'):
ui.debug(_('patch generated by hg export\n'))
hgpatch = True
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513 # drop earlier commit message content
fp.seek(0)
fp.truncate()
Vadim Gelfer
import: parse email messages
r2504 elif hgpatch:
if line.startswith('# User '):
user = line[7:]
ui.debug('From: %s\n' % user)
elif line.startswith("# Date "):
date = line[7:]
if not line.startswith('# '):
fp.write(line)
fp.write('\n')
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513 message = fp.getvalue()
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400 if tmpfp:
Vadim Gelfer
import: parse email messages
r2504 tmpfp.write(payload)
if not payload.endswith('\n'):
tmpfp.write('\n')
elif not diffs_seen and message and content_type == 'text/plain':
message += '\n' + payload
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400
Benoit Boissinot
change log message creation when using 'hg import'...
r2458 if opts['message']:
# pickup the cmdline msg
message = opts['message']
elif message:
# pickup the patch msg
Vadim Gelfer
import: parse email messages
r2504 message = message.strip()
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400 else:
Benoit Boissinot
change log message creation when using 'hg import'...
r2458 # launch the editor
message = None
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400 ui.debug(_('message:\n%s\n') % message)
Vadim Gelfer
import: parse email messages
r2504 tmpfp.close()
if not diffs_seen:
raise util.Abort(_('no diffs found'))
Brendan Cully
Move patch-related code into its own module.
r2861 files = patch.patch(strip, tmpname, ui, cwd=repo.root)
Brendan Cully
Teach import to understand git diff extensions....
r2860 removes = []
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400 if len(files) > 0:
Brendan Cully
Teach import to understand git diff extensions....
r2860 cfiles = files.keys()
copies = []
copts = {'after': False, 'force': False}
Vadim Gelfer
import: make patch apply if run in subdir...
r2760 cwd = repo.getcwd()
if cwd:
Brendan Cully
Teach import to understand git diff extensions....
r2860 cfiles = [util.pathto(cwd, f) for f in files.keys()]
for f in files:
ctype, gp = files[f]
if ctype == 'RENAME':
copies.append((gp.oldpath, gp.path, gp.copymod))
removes.append(gp.oldpath)
elif ctype == 'COPY':
copies.append((gp.oldpath, gp.path, gp.copymod))
elif ctype == 'DELETE':
removes.append(gp.path)
for src, dst, after in copies:
absdst = os.path.join(repo.root, dst)
if not after and os.path.exists(absdst):
raise util.Abort(_('patch creates existing file %s') % dst)
if cwd:
src, dst = [util.pathto(cwd, f) for f in (src, dst)]
copts['after'] = after
errs, copied = docopy(ui, repo, (src, dst), copts, wlock=wlock)
if errs:
raise util.Abort(errs)
if removes:
repo.remove(removes, True, wlock=wlock)
for f in files:
ctype, gp = files[f]
if gp and gp.mode:
x = gp.mode & 0100 != 0
dst = os.path.join(repo.root, gp.path)
util.set_exec(dst, x)
Vadim Gelfer
import: get lock and wlock one time...
r2854 addremove_lock(ui, repo, cfiles, {}, wlock=wlock)
Brendan Cully
Teach import to understand git diff extensions....
r2860 files = files.keys()
files.extend([r for r in removes if r not in files])
Vadim Gelfer
import: get lock and wlock one time...
r2854 repo.commit(files, message, user, date, wlock=wlock, lock=lock)
Vadim Gelfer
import: allow to import stdin with file name "-"
r2400 finally:
Vadim Gelfer
import: parse email messages
r2504 os.unlink(tmpname)
mpm@selenic.com
Commands cleanup...
r437
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
pull location. These are the changesets that would be pulled if a pull
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 was requested.
Benoit Boissinot
incoming: add support for remote repo using bundlerepo
r1944 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.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Thomas Arendsen Hein
Read paths specified in .hg/hgrc relative to repo root, otherwise to home dir.
r1893 source = ui.expandpath(source)
Matt Mackall
Kill ui.setconfig_remoteopts...
r2731 setremoteconfig(ui, opts)
Benoit Boissinot
add remotecmd/ssh option support to incoming/outgoing
r1965
mpm@selenic.com
Add hg incoming command for local repositories
r927 other = hg.repository(ui, source)
Vadim Gelfer
add -f/--force to pull, incoming, outgoing, to work on unrelated repo....
r1959 incoming = repo.findincoming(other, force=opts["force"])
Benoit Boissinot
incoming: add support for remote repo using bundlerepo
r1944 if not incoming:
TK Soh
show message if no changes found on incoming
r1993 ui.status(_("no changes found\n"))
mpm@selenic.com
Fix incoming for empty set
r931 return
Benoit Boissinot
incoming: add support for remote repo using bundlerepo
r1944
cleanup = None
Thomas Arendsen Hein
Delete bundle file of hg incoming in case of errors, preserve existing files....
r1974 try:
fname = opts["bundle"]
if fname or not other.local():
# create a bundle (uncompressed if other repo is not local)
cg = other.changegroup(incoming, "incoming")
fname = cleanup = write_bundle(cg, fname, compress=other.local())
# keep written bundle?
if opts["bundle"]:
cleanup = None
if not other.local():
# use the created uncompressed bundlerepo
other = bundlerepo.bundlerepository(ui, repo.root, fname)
Benoit Boissinot
add -r/--rev arguments to incoming and outgoing
r2521 revs = None
if opts['rev']:
revs = [other.lookup(rev) for rev in opts['rev']]
o = other.changelog.nodesbetween(incoming, revs)[0]
Thomas Arendsen Hein
Delete bundle file of hg incoming in case of errors, preserve existing files....
r1974 if opts['newest_first']:
o.reverse()
displayer = show_changeset(ui, other, opts)
for n in o:
parents = [p for p in other.changelog.parents(n) if p != nullid]
if opts['no_merges'] and len(parents) == 2:
continue
displayer.show(changenode=n)
if opts['patch']:
prev = (parents and parents[0]) or nullid
dodiff(ui, ui, other, prev, n)
ui.write("\n")
finally:
if hasattr(other, 'close'):
other.close()
if cleanup:
os.unlink(cleanup)
Benoit Boissinot
incoming: add support for remote repo using bundlerepo
r1944
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
Initialize a new repository in the given directory. If the given
directory does not exist, it is created.
If no directory is given, the current directory is used.
Thomas Arendsen Hein
Additional information about URLs in pull/push/clone/init:...
r2590
It is possible to specify an ssh:// URL as the destination.
Look at the help text for the pull command for important details
about ssh:// URLs.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
Kill ui.setconfig_remoteopts...
r2731 setremoteconfig(ui, opts)
Bryan O'Sullivan
Modify init command to take an optional directory to set up....
r907 hg.repository(ui, dest, create=1)
mpm@selenic.com
default path support with .hg/hgrc...
r338
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
Print all files under Mercurial control whose names match the
given patterns.
This command searches the current directory and its
subdirectories. To search an entire repository, move to the root
of the repository.
If no patterns are given to match, this command prints all file
names.
If you want to feed the output of this command into the "xargs"
command, use the "-0" option to both this command and "xargs".
This will avoid the problem of "xargs" treating single filenames
that contain white space as multiple filenames.
"""
Thomas Arendsen Hein
Cleanups to commands.py
r1065 end = opts['print0'] and '\0' or '\n'
Benoit Boissinot
fix locate broken since 63799b01985c...
r1622 rev = opts['rev']
if rev:
node = repo.lookup(rev)
else:
node = None
mpm@selenic.com
Refactor matchpats and walk...
r742
Benoit Boissinot
fix locate broken since 63799b01985c...
r1622 for src, abs, rel, exact in walk(repo, pats, opts, node=node,
head='(?:.*/|)'):
if not node and repo.dirstate.state(abs) == '?':
Thomas Arendsen Hein
Cleanups to commands.py
r1065 continue
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 if opts['fullpath']:
Bryan O'Sullivan
Get add and locate to use new repo and dirstate walk code....
r724 ui.write(os.path.join(repo.root, abs), end)
else:
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 ui.write(((pats and rel) or abs), end)
Bryan O'Sullivan
Add locate command....
r627
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.
File history is shown without following rename or copy history of
Brendan Cully
Make log --follow without a file list follow a single head....
r2782 files. Use -f/--follow with a file name to follow history across
renames and copies. --follow without a file name will only show
Brendan Cully
Add log option --follow-first to follow only the first parent of...
r2784 ancestors or descendants of the starting revision. --follow-first
only follows the first parent of merge revisions.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Brendan Cully
Make log --follow revision range start default to working dir parent.
r2783 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.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 By default this command outputs: changeset id and hash, tags,
Thomas Arendsen Hein
Updated help text for 'hg log'.
r1557 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 is shown.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Eric Hopper
Convert all classes to new-style classes by deriving them from object.
r1559 class dui(object):
Bryan O'Sullivan
Add grep command....
r1057 # Implement and delegate some ui protocol. Save hunks of
# output for later display in the desired order.
def __init__(self, ui):
self.ui = ui
self.hunk = {}
Thomas Arendsen Hein
Group changes done by the same developer on the same with --style=changelog...
r2033 self.header = {}
Bryan O'Sullivan
Add grep command....
r1057 def bump(self, rev):
self.rev = rev
self.hunk[rev] = []
Thomas Arendsen Hein
Group changes done by the same developer on the same with --style=changelog...
r2033 self.header[rev] = []
Bryan O'Sullivan
Add grep command....
r1057 def note(self, *args):
Thomas Arendsen Hein
Cleanups to commands.py
r1065 if self.verbose:
self.write(*args)
Bryan O'Sullivan
Add grep command....
r1057 def status(self, *args):
Thomas Arendsen Hein
Cleanups to commands.py
r1065 if not self.quiet:
self.write(*args)
Bryan O'Sullivan
Add grep command....
r1057 def write(self, *args):
self.hunk[self.rev].append(args)
Thomas Arendsen Hein
Group changes done by the same developer on the same with --style=changelog...
r2033 def write_header(self, *args):
self.header[self.rev].append(args)
TK Soh
log --debug: fix misplaced manifest field...
r1381 def debug(self, *args):
if self.debugflag:
self.write(*args)
Bryan O'Sullivan
Add grep command....
r1057 def __getattr__(self, key):
return getattr(self.ui, key)
Vadim Gelfer
add -l,--limit to log command.
r1756
Benoit Boissinot
hg log -p should show file deletions
r1570 changeiter, getchange, matchfn = walkchangerevs(ui, repo, pats, opts)
Vadim Gelfer
add -l,--limit to log command.
r1756
if opts['limit']:
try:
limit = int(opts['limit'])
except ValueError:
raise util.Abort(_('limit must be a positive integer'))
if limit <= 0: raise util.Abort(_('limit must be positive'))
else:
limit = sys.maxint
count = 0
Vadim Gelfer
let commands that show changesets use templates....
r1907 displayer = show_changeset(ui, repo, opts)
bos@serpentine.internal.keyresearch.com
grep: extend functionality, add man page entry, add unit test....
r1146 for st, rev, fns in changeiter:
Bryan O'Sullivan
Add grep command....
r1057 if st == 'window':
Bryan O'Sullivan
Rewrite log command. New version is faster and more featureful....
r1031 du = dui(ui)
Vadim Gelfer
let commands that show changesets use templates....
r1907 displayer.ui = du
Bryan O'Sullivan
Add grep command....
r1057 elif st == 'add':
du.bump(rev)
Benoit Boissinot
add --no-merges (-M) for log, outgoing, incoming
r1435 changenode = repo.changelog.node(rev)
parents = [p for p in repo.changelog.parents(changenode)
if p != nullid]
if opts['no_merges'] and len(parents) == 2:
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 continue
Benoit Boissinot
add --only-merges (-m) log
r1436 if opts['only_merges'] and len(parents) != 2:
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 continue
Benoit Boissinot
add --no-merges (-M) for log, outgoing, incoming
r1435
Matt Mackall
hg log: add -k for keyword searching
r1373 if opts['keyword']:
Benoit Boissinot
hg log -p should show file deletions
r1570 changes = getchange(rev)
Matt Mackall
hg log: add -k for keyword searching
r1373 miss = 0
TK Soh
log: make keyword search truly case-insensitive
r1404 for k in [kw.lower() for kw in opts['keyword']]:
Matt Mackall
hg log: add -k for keyword searching
r1373 if not (k in changes[1].lower() or
k in changes[4].lower() or
k in " ".join(changes[3][:20]).lower()):
miss = 1
break
if miss:
continue
Thomas Arendsen Hein
Cleanup: Put initialization of br in front of --branches option handling.
r1764 br = None
Thomas Arendsen Hein
Make option --branch vs. --branches more consistent....
r1763 if opts['branches']:
TK Soh
log: speedup keyword search when used with --branch...
r1405 br = repo.branchlookup([repo.changelog.node(rev)])
Vadim Gelfer
let commands that show changesets use templates....
r1907 displayer.show(rev, brinfo=br)
Bryan O'Sullivan
Add grep command....
r1057 if opts['patch']:
Benoit Boissinot
add --no-merges (-M) for log, outgoing, incoming
r1435 prev = (parents and parents[0]) or nullid
Benoit Boissinot
hg log -p should show file deletions
r1570 dodiff(du, du, repo, prev, changenode, match=matchfn)
Bryan O'Sullivan
Add grep command....
r1057 du.write("\n\n")
elif st == 'iter':
Vadim Gelfer
add -l,--limit to log command.
r1756 if count == limit: break
Thomas Arendsen Hein
Group changes done by the same developer on the same with --style=changelog...
r2033 if du.header[rev]:
for args in du.header[rev]:
ui.write_header(*args)
Thomas Arendsen Hein
hg log --limit shouldn't count unprinted revisions (found by TK Soh)
r1765 if du.hunk[rev]:
count += 1
for args in du.hunk[rev]:
ui.write(*args)
mpm@selenic.com
hg help: use docstrings only...
r255
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 def manifest(ui, repo, rev=None):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """output the latest or given revision of the project manifest
Print a list of version controlled files for the given revision.
The manifest is the list of files being version controlled. If no revision
is given then the tip is used.
"""
mpm@selenic.com
hg help: use docstrings only...
r255 if rev:
mpm@selenic.com
Make manifest lookup use changeset ids...
r689 try:
# assume all revision numbers are for changesets
n = repo.lookup(rev)
change = repo.changelog.read(n)
n = change[0]
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 except hg.RepoError:
mpm@selenic.com
Make manifest lookup use changeset ids...
r689 n = repo.manifest.lookup(rev)
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 else:
n = repo.manifest.tip()
mpm@selenic.com
hg help: use docstrings only...
r255 m = repo.manifest.read(n)
files = m.keys()
files.sort()
for f in files:
Matt Mackall
Start using manifestflags methods
r2832 ui.write("%40s %3s %s\n" % (hex(m[f]),
Matt Mackall
Change remaining users of manifest flags
r2840 m.execf(f) and "755" or "644", f))
mpm@selenic.com
hg help: use docstrings only...
r255
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806 def merge(ui, repo, node=None, force=None, branch=None):
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 """Merge working directory with another revision
Merge the contents of the current working directory and the
requested revision. Files that changed between either parent are
marked as changed for the next commit and a commit must be
performed before any further updates are allowed.
"""
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806
node = _lookup(repo, node, branch)
Matt Mackall
Introduce update helper functions: update, merge, clean, and revert
r2808 return hg.merge(repo, node, force=force)
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029
Vadim Gelfer
push, outgoing, bundle: fall back to "default" if "default-push" not defined
r2494 def outgoing(ui, repo, dest=None, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """show changesets not found in destination
Thomas Arendsen Hein
More detailed documentation about ssh:// URLs; fixes issue170.
r1979 Show changesets not found in the specified destination repository or
the default push location. These are the changesets that would be pushed
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 if a push was requested.
Benoit Boissinot
resync commands.py docstrings with hg.1.txt
r1811
Thomas Arendsen Hein
More detailed documentation about ssh:// URLs; fixes issue170.
r1979 See pull for valid destination format details.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Vadim Gelfer
push, outgoing, bundle: fall back to "default" if "default-push" not defined
r2494 dest = ui.expandpath(dest or 'default-push', dest or 'default')
Matt Mackall
Kill ui.setconfig_remoteopts...
r2731 setremoteconfig(ui, opts)
Benoit Boissinot
add -r/--rev arguments to incoming and outgoing
r2521 revs = None
if opts['rev']:
revs = [repo.lookup(rev) for rev in opts['rev']]
Benoit Boissinot
add remotecmd/ssh option support to incoming/outgoing
r1965
mpm@selenic.com
Add hg outgoing command
r920 other = hg.repository(ui, dest)
Vadim Gelfer
add -f/--force to pull, incoming, outgoing, to work on unrelated repo....
r1959 o = repo.findoutgoing(other, force=opts['force'])
Thomas Arendsen Hein
show message if no changes found on outgoing...
r1994 if not o:
ui.status(_("no changes found\n"))
return
Benoit Boissinot
add -r/--rev arguments to incoming and outgoing
r2521 o = repo.changelog.nodesbetween(o, revs)[0]
Michal Kvasnica
allow 'hg out' / 'hg in' to show newest commit first
r1439 if opts['newest_first']:
o.reverse()
Vadim Gelfer
let commands that show changesets use templates....
r1907 displayer = show_changeset(ui, repo, opts)
mpm@selenic.com
Add hg outgoing command
r920 for n in o:
Benoit Boissinot
add --no-merges (-M) for log, outgoing, incoming
r1435 parents = [p for p in repo.changelog.parents(n) if p != nullid]
if opts['no_merges'] and len(parents) == 2:
continue
Vadim Gelfer
let commands that show changesets use templates....
r1907 displayer.show(changenode=n)
TK Soh
Add -p to incoming and outgoing commands to show patch
r1192 if opts['patch']:
Benoit Boissinot
add --no-merges (-M) for log, outgoing, incoming
r1435 prev = (parents and parents[0]) or nullid
TK Soh
Add -p to incoming and outgoing commands to show patch
r1192 dodiff(ui, ui, repo, prev, n)
ui.write("\n")
mpm@selenic.com
Add hg outgoing command
r920
Benoit Boissinot
allow specifying a file to hg parents, change the syntax to use -r/--rev
r2644 def parents(ui, repo, file_=None, rev=None, branches=None, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """show the parents of the working dir or revision
Print the working directory's parent revisions.
"""
Benoit Boissinot
allow specifying a file to hg parents, change the syntax to use -r/--rev
r2644 # legacy
if file_ and not rev:
try:
rev = repo.lookup(file_)
file_ = None
except hg.RepoError:
pass
else:
ui.warn(_("'hg parent REV' is deprecated, "
"please use 'hg parents -r REV instead\n"))
Thomas Arendsen Hein
Make "hg parents REV" work (again?)...
r706 if rev:
Benoit Boissinot
allow specifying a file to hg parents, change the syntax to use -r/--rev
r2644 if file_:
ctx = repo.filectx(file_, changeid=rev)
else:
ctx = repo.changectx(rev)
p = [cp.node() for cp in ctx.parents()]
mpm@selenic.com
hg help: use docstrings only...
r255 else:
p = repo.dirstate.parents()
Benoit Boissinot
add a -b/--branch option to 'hg parents'
r1724 br = None
Thomas Arendsen Hein
Make option --branch vs. --branches more consistent....
r1763 if branches is not None:
Benoit Boissinot
add a -b/--branch option to 'hg parents'
r1724 br = repo.branchlookup(p)
Vadim Gelfer
let commands that show changesets use templates....
r1907 displayer = 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:
Vadim Gelfer
let commands that show changesets use templates....
r1907 displayer.show(changenode=n, brinfo=br)
mpm@selenic.com
hg help: use docstrings only...
r255
Thomas Arendsen Hein
Make hg paths and hg debugconfig work with -R/--repository option....
r1858 def paths(ui, repo, search=None):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """show definition of symbolic path names
Show definition of symbolic path name NAME. If no name is given, show
definition of available names.
Path names are defined in the [paths] section of /etc/mercurial/hgrc
and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
"""
TK Soh
Add paths command...
r779 if search:
for name, path in ui.configitems("paths"):
if name == search:
ui.write("%s\n" % path)
return
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.warn(_("not found!\n"))
TK Soh
Add paths command...
r779 return 1
else:
for name, path in ui.configitems("paths"):
ui.write("%s = %s\n" % (name, path))
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 def postincoming(ui, repo, modheads, optupdate):
if modheads == 0:
return
if optupdate:
if modheads == 1:
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806 return hg.update(repo, repo.changelog.tip()) # update
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 else:
ui.status(_("not updating, since new heads added\n"))
if modheads > 1:
ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
else:
ui.status(_("(run 'hg update' to get a working copy)\n"))
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029
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
Pull changes from a remote repository to a local one.
This finds all changes from the repository at the specified path
or URL and adds them to the local repository. By default, this
does not update the copy of the project in the working directory.
Valid URLs are of the form:
local/filesystem/path
"Aurelien Jacobs "
disambiguate help about url syntax
r2589 http://[user@]host[:port]/[path]
https://[user@]host[:port]/[path]
ssh://[user@]host[:port]/[path]
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Thomas Arendsen Hein
More detailed documentation about ssh:// URLs; fixes issue170.
r1979 Some notes about using SSH with Mercurial:
- SSH requires an accessible shell account on the destination machine
and a copy of hg in the remote path or specified with as remotecmd.
"Aurelien Jacobs "
disambiguate help about url syntax
r2589 - path is relative to the remote user's home directory by default.
Thomas Arendsen Hein
Additional information about URLs in pull/push/clone/init:...
r2590 Use an extra slash at the start of a path to specify an absolute path:
ssh://example.com//tmp/repository
Thomas Arendsen Hein
More detailed documentation about ssh:// URLs; fixes issue170.
r1979 - Mercurial doesn't use its own compression via SSH; the right thing
to do is to configure it in your ~/.ssh/ssh_config, e.g.:
Host *.mylocalnetwork.example.com
Compression off
Host *
Compression on
Alternatively specify "ssh -C" as your ssh command in your hgrc or
with the --ssh command line option.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Thomas Arendsen Hein
Read paths specified in .hg/hgrc relative to repo root, otherwise to home dir.
r1893 source = ui.expandpath(source)
Matt Mackall
Kill ui.setconfig_remoteopts...
r2731 setremoteconfig(ui, opts)
mpm@selenic.com
Add -e and --remotecmd for clone and pull too
r963
mpm@selenic.com
Migrate rawcommit, import, export, history, and merge...
r246 other = hg.repository(ui, source)
Vadim Gelfer
change some repo messages in small ways....
r2473 ui.status(_('pulling from %s\n') % (source))
Eric Hopper
Implementing pull -r and changing clone -r. Both now support...
r1465 revs = None
if opts['rev'] and not other.local():
Muli Ben-Yehuda
add '_' to several strings
r1607 raise util.Abort(_("pull -r doesn't work for remote repositories yet"))
Eric Hopper
Implementing pull -r and changing clone -r. Both now support...
r1465 elif opts['rev']:
revs = [other.lookup(rev) for rev in opts['rev']]
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 modheads = repo.pull(other, heads=revs, force=opts['force'])
return postincoming(ui, repo, modheads, opts['update'])
mpm@selenic.com
Migrate rawcommit, import, export, history, and merge...
r246
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
Push changes from the local repository to the given destination.
This is the symmetrical operation for pull. It helps to move
changes from the current repository to a different one. If the
destination is local this is identical to a pull in that directory
from the current one.
By default, push will refuse to run if it detects the result would
increase the number of remote heads. This generally indicates the
the client has forgotten to sync and merge before pushing.
Valid URLs are of the form:
local/filesystem/path
"Aurelien Jacobs "
disambiguate help about url syntax
r2589 ssh://[user@]host[:port]/[path]
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Thomas Arendsen Hein
More detailed documentation about ssh:// URLs; fixes issue170.
r1979 Look at the help text for the pull command for important details
about ssh:// URLs.
Thomas Arendsen Hein
Additional information about URLs in pull/push/clone/init:...
r2590
Pushing to http:// and https:// URLs is possible, too, if this
feature is enabled on the remote Mercurial server.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Vadim Gelfer
push, outgoing, bundle: fall back to "default" if "default-push" not defined
r2494 dest = ui.expandpath(dest or 'default-push', dest or 'default')
Matt Mackall
Kill ui.setconfig_remoteopts...
r2731 setremoteconfig(ui, opts)
mpm@selenic.com
Add --ssh and --remotecmd to push...
r961
Matt Mackall
Switch push over to the new scheme...
r640 other = hg.repository(ui, dest)
Vadim Gelfer
change some repo messages in small ways....
r2473 ui.status('pushing to %s\n' % (dest))
Benoit Boissinot
add an optional argument to push only the specified revisions (push -r)
r1781 revs = None
if opts['rev']:
revs = [repo.lookup(rev) for rev in opts['rev']]
r = repo.push(other, opts['force'], revs=revs)
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 return r == 0
mpm@selenic.com
stopgap hg push support...
r319
mpm@selenic.com
[PATCH] rawcommit fix again...
r403 def rawcommit(ui, repo, *flist, **rc):
Benoit Boissinot
fix the synopsis of some commands, mark rawcommit as deprecated in short help
r1812 """raw commit interface (DEPRECATED)
Benoit Boissinot
resync commands.py docstrings with hg.1.txt
r1811
(DEPRECATED)
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 Lowlevel commit, for use in helper scripts.
This command is not intended to be used by normal users, as it is
primarily useful for importing from other SCMs.
Matt Mackall
deprecate the rawcommit command
r1657
This command is now deprecated and will be removed in a future
release, please use debugsetparents and commit instead.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Matt Mackall
deprecate the rawcommit command
r1657
ui.warn(_("(the rawcommit command is deprecated)\n"))
Benoit Boissinot
remove the deprecated --text (t) option to rawcommit and tag
r1496 message = rc['message']
Thomas Arendsen Hein
Changed more occurances of 'text' to 'message'.
r762 if not message and rc['logfile']:
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 try:
Thomas Arendsen Hein
Changed more occurances of 'text' to 'message'.
r762 message = open(rc['logfile']).read()
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 except IOError:
pass
Thomas Arendsen Hein
Changed more occurances of 'text' to 'message'.
r762 if not message and not rc['logfile']:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 raise util.Abort(_("missing commit message"))
mpm@selenic.com
Migrate rawcommit, import, export, history, and merge...
r246
mpm@selenic.com
[PATCH] rawcommit fix again...
r403 files = relpath(repo, list(flist))
mpm@selenic.com
Migrate rawcommit, import, export, history, and merge...
r246 if rc['files']:
files += open(rc['files']).read().splitlines()
mpm@selenic.com
rawcommit: do lookup of parents at the appropriate layer...
r452
rc['parent'] = map(repo.lookup, rc['parent'])
mpm@selenic.com
[PATCH] Clean up destination directory if a clone fails....
r500
Bryan O'Sullivan
Commit date validation: more stringent checks, more useful error messages.
r1202 try:
repo.rawcommit(files, message, rc['user'], rc['date'], *rc['parent'])
except ValueError, inst:
raise util.Abort(str(inst))
mpm@selenic.com
[PATCH] Clean up destination directory if a clone fails....
r500
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.
This command tries to fix the repository status after an interrupted
operation. It should only be necessary when Mercurial suggests it.
"""
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
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
Schedule the indicated files for removal from the repository.
This command schedules the files to be removed at the next commit.
This only removes files from the current branch, not from the
entire project history. If the files still exist in the working
Vadim Gelfer
add --after option to remove command.
r2179 directory, they will be deleted from it. If invoked with --after,
files that have been manually deleted are marked as removed.
Vadim Gelfer
remove: rewrite to be ~400x faster, bit more friendly...
r2309
Modified files and added files are not removed by default. To
remove them, use the -f/--force option.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Bryan O'Sullivan
Fix up remove command to use walk code.
r1188 names = []
Vadim Gelfer
add --after option to remove command.
r2179 if not opts['after'] and not pats:
raise util.Abort(_('no files specified'))
Vadim Gelfer
remove: rewrite to be ~400x faster, bit more friendly...
r2309 files, matchfn, anypats = matchpats(repo, pats, opts)
exact = dict.fromkeys(files)
mardu = map(dict.fromkeys, repo.changes(files=files, match=matchfn))
modified, added, removed, deleted, unknown = mardu
remove, forget = [], []
for src, abs, rel, exact in walk(repo, pats, opts):
Bryan O'Sullivan
Make removal check more complete and informative.
r1189 reason = None
Vadim Gelfer
remove: rewrite to be ~400x faster, bit more friendly...
r2309 if abs not in deleted and opts['after']:
Vadim Gelfer
add --after option to remove command.
r2179 reason = _('is still present')
Vadim Gelfer
remove: rewrite to be ~400x faster, bit more friendly...
r2309 elif abs in modified and not opts['force']:
reason = _('is modified (use -f to force removal)')
elif abs in added:
if opts['force']:
forget.append(abs)
continue
reason = _('has been marked for add (use -f to force removal)')
elif abs in unknown:
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 reason = _('is not managed')
Vadim Gelfer
remove: rewrite to be ~400x faster, bit more friendly...
r2309 elif abs in removed:
continue
Bryan O'Sullivan
Get all commands that operate on files to honour --verbose and --quiet....
r1255 if reason:
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if exact:
ui.warn(_('not removing %s: file %s\n') % (rel, reason))
Bryan O'Sullivan
Make removal check more complete and informative.
r1189 else:
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 if ui.verbose or not exact:
ui.status(_('removing %s\n') % rel)
Vadim Gelfer
remove: rewrite to be ~400x faster, bit more friendly...
r2309 remove.append(abs)
repo.forget(forget)
repo.remove(remove, unlink=not opts['after'])
mpm@selenic.com
big heap of command clean-up work...
r245
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
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.
By default, this command copies the contents of files as they
stand in the working directory. If invoked with --after, the
operation is recorded, but no copying is performed.
This command takes effect in the next commit.
NOTE: This command should be treated as experimental. While it
should properly record rename files, this information is not yet
fully used by merge, nor fully reported by log.
"""
Vadim Gelfer
fix backtrace printed when cannot get lock....
r2016 wlock = repo.wlock(0)
errs, copied = docopy(ui, repo, pats, opts, wlock)
names = []
for abs, rel, exact in copied:
if ui.verbose or not exact:
ui.status(_('removing %s\n') % rel)
names.append(abs)
Thomas Arendsen Hein
Don't require opts['dry_run'] to be set to fix external tools like tailor.
r2503 if not opts.get('dry_run'):
Vadim Gelfer
remove: add -n/--dry-run option
r2414 repo.remove(names, True, wlock)
Bryan O'Sullivan
Add rename/mv command....
r1253 return errs
Benoit Boissinot
make revert use standard matcher
r1472 def revert(ui, repo, *pats, **opts):
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227 """revert files or dirs to their states as of some revision
Vadim Gelfer
fix doc comments for revert command. people found them confusing.
r2204
Vadim Gelfer
revert: require explicit revision when working dir has two parents.
r2212 With no revision specified, revert the named files or directories
to the contents they had in the parent of the working directory.
This restores the contents of the affected files to an unmodified
state. If the working directory has two parents, you must
explicitly specify the revision to revert to.
Benoit Boissinot
resync commands.py docstrings with hg.1.txt
r1811
Thomas Arendsen Hein
Don't abort when backup files already exist. Don't allow alternative names....
r2036 Modified files are saved with a .orig suffix before reverting.
To disable these backups, use --no-backup.
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029
Vadim Gelfer
fix doc comments for revert command. people found them confusing.
r2204 Using the -r option, revert the given files or directories to
their contents as of a specific revision. This can be helpful to"roll
Benoit Boissinot
resync commands.py docstrings with hg.1.txt
r1811 back" some or all of a change that should not have been committed.
Revert modifies the working directory. It does not commit any
Vadim Gelfer
fix doc comments for revert command. people found them confusing.
r2204 changes, or change the parent of the working directory. If you
revert to a revision other than the parent of the working
directory, the reverted files will thus appear modified
afterwards.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
If a file has been deleted, it is recreated. If the executable
mode of a file was changed, it is reset.
Benoit Boissinot
make revert use standard matcher
r1472 If names are given, all files matching the names are reverted.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
Benoit Boissinot
make all commands be repo-wide by default...
r1568 If no arguments are given, all files in the repository are reverted.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Vadim Gelfer
revert: require explicit revision when working dir has two parents.
r2212 parent, p2 = repo.dirstate.parents()
if opts['rev']:
node = repo.lookup(opts['rev'])
elif p2 != nullid:
raise util.Abort(_('working dir has two parents; '
'you must specify the revision to revert to'))
else:
node = parent
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 mf = repo.manifest.read(repo.changelog.read(node)[0])
Vadim Gelfer
revert: better fix for not printing 'reverting' message
r2407 if node == parent:
pmf = mf
else:
pmf = None
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029
wlock = repo.wlock()
Vadim Gelfer
small changes to revert command....
r2042 # need all matching names in dirstate and manifest of target rev,
# so have to walk both. do not print errors if files exist in one
# but not other.
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 names = {}
Vadim Gelfer
small changes to revert command....
r2042 target_only = {}
# walk dirstate.
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 for src, abs, rel, exact in walk(repo, pats, opts, badmatch=mf.has_key):
Vadim Gelfer
small changes to revert command....
r2042 names[abs] = (rel, exact)
if src == 'b':
target_only[abs] = True
# walk target manifest.
for src, abs, rel, exact in walk(repo, pats, opts, node=node,
badmatch=names.has_key):
if abs in names: continue
names[abs] = (rel, exact)
target_only[abs] = True
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029
Vadim Gelfer
revert: better fix for not printing 'reverting' message
r2407 changes = repo.changes(match=names.has_key, wlock=wlock)
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 modified, added, removed, deleted, unknown = map(dict.fromkeys, changes)
revert = ([], _('reverting %s\n'))
add = ([], _('adding %s\n'))
remove = ([], _('removing %s\n'))
forget = ([], _('forgetting %s\n'))
undelete = ([], _('undeleting %s\n'))
update = {}
disptable = (
# dispatch table:
# file state
# action if in target manifest
# action if not in target manifest
# make backup if in target manifest
# make backup if not in target manifest
(modified, revert, remove, True, True),
Thomas Arendsen Hein
Minor fix for revert: No need to make a backup when forgetting added files....
r2043 (added, revert, forget, True, False),
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 (removed, undelete, None, False, False),
(deleted, revert, remove, False, False),
(unknown, add, None, True, False),
Vadim Gelfer
small changes to revert command....
r2042 (target_only, add, None, False, False),
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 )
Vadim Gelfer
small changes to revert command....
r2042 entries = names.items()
entries.sort()
for abs, (rel, exact) in entries:
Vadim Gelfer
revert: better fix for not printing 'reverting' message
r2407 mfentry = mf.get(abs)
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 def handle(xlist, dobackup):
xlist[0].append(abs)
Vadim Gelfer
revert: better fix for not printing 'reverting' message
r2407 update[abs] = 1
Thomas Arendsen Hein
Don't abort when backup files already exist. Don't allow alternative names....
r2036 if dobackup and not opts['no_backup'] and os.path.exists(rel):
bakname = "%s.orig" % rel
ui.note(_('saving current version of %s as %s\n') %
(rel, bakname))
Vadim Gelfer
revert: add -n/--dry-run option
r2415 if not opts.get('dry_run'):
shutil.copyfile(rel, bakname)
shutil.copymode(rel, bakname)
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 if ui.verbose or not exact:
ui.status(xlist[1] % rel)
for table, hitlist, misslist, backuphit, backupmiss in disptable:
if abs not in table: continue
# file has changed in dirstate
Vadim Gelfer
revert: better fix for not printing 'reverting' message
r2407 if mfentry:
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 handle(hitlist, backuphit)
elif misslist is not None:
handle(misslist, backupmiss)
else:
if exact: ui.warn(_('file not managed: %s\n' % rel))
break
else:
# file has not changed in dirstate
if node == parent:
if exact: ui.warn(_('no changes needed to %s\n' % rel))
continue
Vadim Gelfer
revert: better fix for not printing 'reverting' message
r2407 if pmf is None:
# only need parent manifest in this unlikely case,
# so do not read by default
pmf = repo.manifest.read(repo.changelog.read(parent)[0])
if abs in pmf:
if mfentry:
# if version of file is same in parent and target
# manifests, do nothing
if pmf[abs] != mfentry:
handle(revert, False)
else:
Vadim Gelfer
revert: fix corner case found by faheem mitha....
r2272 handle(remove, False)
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029
Vadim Gelfer
revert: add -n/--dry-run option
r2415 if not opts.get('dry_run'):
repo.dirstate.forget(forget[0])
Matt Mackall
Refactor update locking slightly
r2812 r = hg.revert(repo, node, update.has_key, wlock)
Vadim Gelfer
revert: add -n/--dry-run option
r2415 repo.dirstate.update(add[0], 'a')
repo.dirstate.update(undelete[0], 'n')
repo.dirstate.update(remove[0], 'r')
return r
mpm@selenic.com
[PATCH] hg revert...
r588
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227 def rollback(ui, repo):
"""roll back the last transaction in this repository
Roll back the last transaction in this repository, restoring the
project to its state prior to the transaction.
Transactions are used to encapsulate the effects of all commands
that create new changesets or propagate existing changesets into a
repository. For example, the following commands are transactional,
and their effects can be rolled back:
commit
import
pull
push (with this repository as destination)
unbundle
This command should be used with care. There is only one level of
rollback, and there is no way to undo a rollback.
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.
"""
Thomas Arendsen Hein
Renamed localrepo.undo() to rollback() and talk about "rollback information".
r2362 repo.rollback()
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227
mpm@selenic.com
[PATCH] add "root" command...
r468 def root(ui, repo):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """print the root (top) of the current working dir
Print the root directory of the current repository.
"""
mpm@selenic.com
[PATCH] add "root" command...
r468 ui.write(repo.root + "\n")
mpm@selenic.com
big heap of command clean-up work...
r245 def serve(ui, repo, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """export the repository via HTTP
Start a local HTTP repository browser and pull server.
By default, the server logs accesses to stdout and errors to
stderr. Use the "-A" and "-E" options to log to files.
"""
Matt Mackall
Add an sshrepository class and hg serve --stdio
r624
if opts["stdio"]:
Thomas Arendsen Hein
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
r2127 if repo is None:
raise hg.RepoError(_('no repo 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
Thomas Arendsen Hein
Use string literal concatenation for optlist and import -p option
r2125 optlist = ("name templates style address port ipv6"
" accesslog errorlog webdir_conf")
mpm@selenic.com
hgweb: change startup argument processing...
r987 for o in optlist.split():
if opts[o]:
ui.setconfig("web", o, opts[o])
Thomas Arendsen Hein
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
r2127 if repo is None and not ui.config("web", "webdir_conf"):
raise hg.RepoError(_('no repo found'))
Vadim Gelfer
stop read end of pipe from staying open forever in child process.
r1741 if opts['daemon'] and not opts['daemon_pipefds']:
Vadim Gelfer
add --daemon option to serve command. for issue 45....
r1740 rfd, wfd = os.pipe()
args = sys.argv[:]
Vadim Gelfer
stop read end of pipe from staying open forever in child process.
r1741 args.append('--daemon-pipefds=%d,%d' % (rfd, wfd))
Vadim Gelfer
add --daemon option to serve command. for issue 45....
r1740 pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0),
args[0], args)
os.close(wfd)
os.read(rfd, 1)
os._exit(0)
Bryan O'Sullivan
hg serve: print a more useful error message if server can't start.
r1177 try:
Eric Hopper
Adjusting hgweb splitup to be a little cleaner.
r2392 httpd = hgweb.server.create_server(ui, repo)
Bryan O'Sullivan
hg serve: print a more useful error message if server can't start.
r1177 except socket.error, inst:
Muli Ben-Yehuda
add '_' to several strings
r1607 raise util.Abort(_('cannot start server: ') + inst.args[1])
mpm@selenic.com
hgweb: change startup argument processing...
r987
mpm@selenic.com
[PATCH] Get "hg serve" to print the URL being served...
r603 if ui.verbose:
addr, port = httpd.socket.getsockname()
if addr == '0.0.0.0':
addr = socket.gethostname()
else:
try:
addr = socket.gethostbyaddr(addr)[0]
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 except socket.error:
pass
mpm@selenic.com
[PATCH] Get "hg serve" to print the URL being served...
r603 if port != 80:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.status(_('listening at http://%s:%d/\n') % (addr, port))
mpm@selenic.com
[PATCH] Get "hg serve" to print the URL being served...
r603 else:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ui.status(_('listening at http://%s/\n') % addr)
Vadim Gelfer
add --daemon option to serve command. for issue 45....
r1740
if opts['pid_file']:
fp = open(opts['pid_file'], 'w')
Vadim Gelfer
tests: add timeouts, make run-tests.py clean up dead daemon processes...
r2571 fp.write(str(os.getpid()) + '\n')
Vadim Gelfer
add --daemon option to serve command. for issue 45....
r1740 fp.close()
Vadim Gelfer
stop read end of pipe from staying open forever in child process.
r1741 if opts['daemon_pipefds']:
rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')]
os.close(rfd)
Vadim Gelfer
add --daemon option to serve command. for issue 45....
r1740 os.write(wfd, 'y')
os.close(wfd)
sys.stdout.flush()
sys.stderr.flush()
fd = os.open(util.nulldev, os.O_RDWR)
if fd != 0: os.dup2(fd, 0)
if fd != 1: os.dup2(fd, 1)
if fd != 2: os.dup2(fd, 2)
if fd not in (0, 1, 2): os.close(fd)
mpm@selenic.com
[PATCH] Get "hg serve" to print the URL being served...
r603 httpd.serve_forever()
mpm@selenic.com
[PATCH] Clean up destination directory if a clone fails....
r500
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
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 Show status of files in the repository. If names are given, only
files that match are shown. Files that are clean or ignored, are
not listed unless -c (clean), -i (ignored) or -A is given.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
The codes used to show the status of files are:
mpm@selenic.com
Change C to M in status
r746 M = modified
mpm@selenic.com
big heap of command clean-up work...
r245 A = added
R = removed
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 C = clean
Thomas Arendsen Hein
Distinguish removed and deleted files. Tests are not fixed yet....
r1619 ! = deleted, but still tracked
Thomas Arendsen Hein
Rewritten change type selection for hg status.
r842 ? = not tracked
Thomas Arendsen Hein
New option -i/--ignored for 'hg status' to show ignored files....
r2022 I = ignored (not shown by default)
Brendan Cully
Add an option '-C|--copies' to hg status to show the source of copied files....
r2639 = the previous added file was copied from here
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
mpm@selenic.com
Optimize diff and status in subdirectories...
r312
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 all = opts['all']
Benoit Boissinot
correct the relative path when walking from a subdir...
r1625 files, matchfn, anypats = matchpats(repo, pats, opts)
cwd = (pats and repo.getcwd()) or ''
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 modified, added, removed, deleted, unknown, ignored, clean = [
Thomas Arendsen Hein
Renamed c, a, d, u to modified, added, removed, unknown for users of changes()
r1618 [util.pathto(cwd, x) for x in n]
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 for n in repo.status(files=files, match=matchfn,
list_ignored=all or opts['ignored'],
list_clean=all or opts['clean'])]
changetypes = (('modified', 'M', modified),
Thomas Arendsen Hein
hg status cleanups: Don't translate long options, remove stray semicolon.
r1966 ('added', 'A', added),
('removed', 'R', removed),
('deleted', '!', deleted),
Thomas Arendsen Hein
New option -i/--ignored for 'hg status' to show ignored files....
r2022 ('unknown', '?', unknown),
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 ('ignored', 'I', ignored))
explicit_changetypes = changetypes + (('clean', 'C', clean),)
Thomas Arendsen Hein
Rewritten change type selection for hg status.
r842
TK Soh
status: added option -p and -0 to assist xargs...
r1085 end = opts['print0'] and '\0' or '\n'
Thomas Arendsen Hein
Whitespace cleanup.
r1106
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 for opt, char, changes in ([ct for ct in explicit_changetypes
if all or opts[ct[0]]]
Thomas Arendsen Hein
Rewritten change type selection for hg status.
r842 or changetypes):
Thomas Arendsen Hein
Replaced hg status -p/--strip with -n/--no-status to not confuse with patch.
r1105 if opts['no_status']:
TK Soh
status: added option -p and -0 to assist xargs...
r1085 format = "%%s%s" % end
else:
Thomas Arendsen Hein
hg status cleanups: Don't translate long options, remove stray semicolon.
r1966 format = "%s %%s%s" % (char, end)
Thomas Arendsen Hein
Whitespace cleanup.
r1106
Thomas Arendsen Hein
Rewritten change type selection for hg status.
r842 for f in changes:
TK Soh
status: added option -p and -0 to assist xargs...
r1085 ui.write(format % f)
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 if ((all or opts.get('copies')) and not opts.get('no_status')
Brendan Cully
Add an option '-C|--copies' to hg status to show the source of copied files....
r2639 and opt == 'added' and repo.dirstate.copies.has_key(f)):
ui.write(' %s%s' % (repo.dirstate.copies[f], end))
mpm@selenic.com
commands: migrate status and branch...
r213
Benoit Boissinot
fix 'hg tag <tagname> <revision>...
r1596 def tag(ui, repo, name, rev_=None, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """add a tag for the current tip or a given revision
Name a particular revision using <name>.
Tags are used to name particular revisions of the repository and are
very useful to compare different revision, to go back to significant
earlier versions or to mark branch points as releases, etc.
Benoit Boissinot
change 'hg tag' to tag the parent rev instead of tip
r2647 If no revision is given, the parent of the working directory is used.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
To facilitate version control, distribution, and merging of tags,
they are stored as a file named ".hgtags" which is managed
similarly to other project files and can be hand-edited if
Benoit Boissinot
deprecate the use of 'hg tag NAME [REV]'...
r1654 necessary. The file '.hg/localtags' is used for local tags (not
shared among repositories).
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """
Brendan Cully
Add '.' as a shortcut revision name for the working directory parent.
r2789 if name in ['tip', '.']:
raise util.Abort(_("the name '%s' is reserved") % name)
Benoit Boissinot
deprecate the use of 'hg tag NAME [REV]'...
r1654 if rev_ is not None:
ui.warn(_("use of 'hg tag NAME [REV]' is deprecated, "
Thomas Arendsen Hein
Added missing quote in warning text.
r1661 "please use 'hg tag [-r REV] NAME' instead\n"))
Benoit Boissinot
deprecate the use of 'hg tag NAME [REV]'...
r1654 if opts['rev']:
raise util.Abort(_("use only one form to specify the revision"))
Benoit Boissinot
fix 'hg tag <tagname> <revision>...
r1596 if opts['rev']:
rev_ = opts['rev']
if rev_:
r = hex(repo.lookup(rev_))
Matt Mackall
[PATCH] hg tag: local tag support in file .hg/localtags...
r609 else:
Benoit Boissinot
change 'hg tag' to tag the parent rev instead of tip
r2647 p1, p2 = repo.dirstate.parents()
if p1 == nullid:
raise util.Abort(_('no revision to tag'))
if p2 != nullid:
Benoit Boissinot
spelling fix
r2648 raise util.Abort(_('outstanding uncommitted merges'))
Benoit Boissinot
change 'hg tag' to tag the parent rev instead of tip
r2647 r = hex(p1)
Matt Mackall
[PATCH] hg tag: local tag support in file .hg/localtags...
r609
Vadim Gelfer
move most of tag code to localrepository class.
r2601 repo.tag(name, r, opts['local'], opts['message'], opts['user'],
opts['date'])
mpm@selenic.com
From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>...
r401
mpm@selenic.com
migrate remaining commands...
r248 def tags(ui, repo):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """list repository tags
List the repository tags.
This lists both regular and local tags.
"""
Thomas Arendsen Hein
Handle errors in .hgtags or hgrc [tags] section more gracefully....
r477
mpm@selenic.com
rework all code using tags...
r343 l = repo.tagslist()
l.reverse()
Thomas Arendsen Hein
Handle errors in .hgtags or hgrc [tags] section more gracefully....
r477 for t, n in l:
mpm@selenic.com
migrate remaining commands...
r248 try:
mpm@selenic.com
commands: use node functions directly
r1092 r = "%5d:%s" % (repo.changelog.rev(n), hex(n))
mpm@selenic.com
migrate remaining commands...
r248 except KeyError:
Thomas Arendsen Hein
Handle errors in .hgtags or hgrc [tags] section more gracefully....
r477 r = " ?:?"
Thomas Arendsen Hein
Make 'hg tags -q' only list tag names without revision numbers and hashes,...
r2035 if ui.quiet:
ui.write("%s\n" % t)
else:
ui.write("%-30s %s\n" % (t, r))
mpm@selenic.com
migrate remaining commands...
r248
Vadim Gelfer
add -p option to tip. for issue 64.
r1731 def tip(ui, repo, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """show the tip revision
Show the tip revision.
"""
mpm@selenic.com
big heap of command clean-up work...
r245 n = repo.changelog.tip()
Thomas Arendsen Hein
Add option -b/--branch to hg tip (as done for hg parents).
r1762 br = None
Thomas Arendsen Hein
Make option --branch vs. --branches more consistent....
r1763 if opts['branches']:
Thomas Arendsen Hein
Add option -b/--branch to hg tip (as done for hg parents).
r1762 br = repo.branchlookup([n])
Vadim Gelfer
let commands that show changesets use templates....
r1907 show_changeset(ui, repo, opts).show(changenode=n, brinfo=br)
Vadim Gelfer
add -p option to tip. for issue 64.
r1731 if opts['patch']:
dodiff(ui, ui, repo, repo.changelog.parents(n)[0], n)
mpm@selenic.com
big heap of command clean-up work...
r245
Muli Ben-Yehuda
add --update support to 'hg unbundle'
r1600 def unbundle(ui, repo, fname, **opts):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """apply a changegroup file
Apply a compressed changegroup file generated by the bundle
command.
"""
mpm@selenic.com
Add preliminary support for the bundle and unbundle commands
r1218 f = urllib.urlopen(fname)
Benoit Boissinot
use HG10UN header for uncompressed bundle...
r1980 header = f.read(6)
if not header.startswith("HG"):
raise util.Abort(_("%s: not a Mercurial bundle file") % fname)
elif not header.startswith("HG10"):
raise util.Abort(_("%s: unknown bundle version") % fname)
elif header == "HG10BZ":
Benoit Boissinot
add a new bundle type: uncompressed bundle
r1940 def generator(f):
zd = bz2.BZ2Decompressor()
Benoit Boissinot
use HG10UN header for uncompressed bundle...
r1980 zd.decompress("BZ")
Benoit Boissinot
add a new bundle type: uncompressed bundle
r1940 for chunk in f:
yield zd.decompress(chunk)
Benoit Boissinot
use HG10UN header for uncompressed bundle...
r1980 elif header == "HG10UN":
Benoit Boissinot
add a new bundle type: uncompressed bundle
r1940 def generator(f):
for chunk in f:
yield chunk
else:
Benoit Boissinot
use HG10UN header for uncompressed bundle...
r1980 raise util.Abort(_("%s: unknown bundle compression type")
% fname)
Benoit Boissinot
add a new bundle type: uncompressed bundle
r1940 gen = generator(util.filechunkiter(f, 4096))
Vadim Gelfer
hooks: add url to changegroup, incoming, prechangegroup, pretxnchangegroup hooks...
r2673 modheads = repo.addchangegroup(util.chunkbuffer(gen), 'unbundle',
'bundle:' + fname)
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 return postincoming(ui, repo, modheads, opts['update'])
mpm@selenic.com
Add preliminary support for the bundle and unbundle commands
r1218
mpm@selenic.com
commands: better argument processing, per-command help...
r212 def undo(ui, repo):
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227 """undo the last commit or pull (DEPRECATED)
(DEPRECATED)
This command is now deprecated and will be removed in a future
release. Please use the rollback command instead. For usage
instructions, see the rollback command.
mpm@selenic.com
A bunch of parsing/help updates...
r596 """
Vadim Gelfer
undo: add "deprecated" message to output.
r2238 ui.warn(_('(the undo command is deprecated; use rollback instead)\n'))
Thomas Arendsen Hein
Renamed localrepo.undo() to rollback() and talk about "rollback information".
r2362 repo.rollback()
mpm@selenic.com
hg undo: fixup working dir state...
r210
Benoit Boissinot
abort when merging two heads and repository has local changes
r1581 def update(ui, repo, node=None, merge=False, clean=False, force=None,
Matt Mackall
Remove **opts arg from commands.doupdate
r2776 branch=None):
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 """update or merge working directory
Update the working directory to the specified revision.
mpm@selenic.com
unify checkout and resolve into update...
r254
If there are no outstanding changes in the working directory and
there is a linear relationship between the current version and the
requested version, the result is the requested version.
Vadim Gelfer
deprecate 'update -m'. use 'merge' instead.
r2283 To merge the working directory with another revision, use the
merge command.
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437
By default, update will refuse to run if doing so would require
merging or discarding local changes.
"""
Matt Mackall
Introduce update helper functions: update, merge, clean, and revert
r2808 node = _lookup(repo, node, branch)
Vadim Gelfer
deprecate 'update -m'. use 'merge' instead.
r2283 if merge:
ui.warn(_('(the -m/--merge option is deprecated; '
'use the merge command instead)\n'))
Matt Mackall
Introduce update helper functions: update, merge, clean, and revert
r2808 return hg.merge(repo, node, force=force)
elif clean:
return hg.clean(repo, node)
else:
return hg.update(repo, node)
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806
def _lookup(repo, node, branch=None):
mason@suse.com
Add searching for named branches...
r898 if branch:
br = repo.branchlookup(branch=branch)
found = []
for x in br:
if branch in br[x]:
found.append(x)
if len(found) > 1:
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806 repo.ui.warn(_("Found multiple heads for %s\n") % branch)
mason@suse.com
Add searching for named branches...
r898 for x in found:
Matt Mackall
Remove **opts arg from commands.doupdate
r2776 show_changeset(ui, repo, {}).show(changenode=x, brinfo=br)
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806 raise util.Abort("")
mason@suse.com
Add searching for named branches...
r898 if len(found) == 1:
node = found[0]
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806 repo.ui.warn(_("Using head %s for branch %s\n")
% (short(node), branch))
mason@suse.com
Add searching for named branches...
r898 else:
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806 raise util.Abort(_("branch %s not found\n") % (branch))
mason@suse.com
Add searching for named branches...
r898 else:
node = node and repo.lookup(node) or repo.changelog.tip()
Matt Mackall
Factor doupdate into _lookup + hg.update
r2806 return node
mpm@selenic.com
unify checkout and resolve into update...
r254
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
Move repo.verify
r2778 return hg.verify(repo)
mpm@selenic.com
migrate verify...
r247
mpm@selenic.com
hg help: use docstrings only...
r255 # Command options and aliases are listed here, alphabetically
mpm@selenic.com
Beginning of new command parsing interface...
r209 table = {
Thomas Arendsen Hein
Realigned command table again.
r841 "^add":
(add,
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 [('I', 'include', [], _('include names matching the given patterns')),
Vadim Gelfer
add: add -n/--dry-run option
r2411 ('X', 'exclude', [], _('exclude names matching the given patterns')),
Vadim Gelfer
make description of -n option better.
r2416 ('n', 'dry-run', None, _('do not perform actions, just print output'))],
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 _('hg add [OPTION]... [FILE]...')),
Thomas Arendsen Hein
Add debugaddremove alias to addremove, so it doesn't show up in 'hg help'....
r2184 "debugaddremove|addremove":
Thomas Arendsen Hein
Realigned command table again.
r841 (addremove,
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 [('I', 'include', [], _('include names matching the given patterns')),
Vadim Gelfer
addremove: add -n/--dry-run option
r2412 ('X', 'exclude', [], _('exclude names matching the given patterns')),
Vadim Gelfer
make description of -n option better.
r2416 ('n', 'dry-run', None, _('do not perform actions, just print output'))],
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 _('hg addremove [OPTION]... [FILE]...')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "^annotate":
(annotate,
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 [('r', 'rev', '', _('annotate the specified revision')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ('a', 'text', None, _('treat all files as text')),
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 ('u', 'user', None, _('list the author')),
lupus@debian.org
Added --date option to annotate.
r1522 ('d', 'date', None, _('list the date')),
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 ('n', 'number', None, _('list the revision number (default)')),
('c', 'changeset', None, _('list the changeset')),
('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 _('hg annotate [-r REV] [-a] [-u] [-d] [-n] [-c] FILE...')),
Thomas Arendsen Hein
Cleanup archive command: Don't overwrite gettext, quoting in cmd table entry.
r2160 "archive":
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112 (archive,
[('', 'no-decode', None, _('do not pass files through decoders')),
('p', 'prefix', '', _('directory prefix for files in archive')),
('r', 'rev', '', _('revision to distribute')),
('t', 'type', '', _('type of distribution to create')),
('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
_('hg archive [OPTION]... DEST')),
Thomas Arendsen Hein
Small cleanups to backout command:...
r2159 "backout":
Vadim Gelfer
add backout command....
r2158 (backout,
Thomas Arendsen Hein
Small cleanups to backout command:...
r2159 [('', 'merge', None,
_('merge with old dirstate parent after backout')),
('m', 'message', '', _('use <text> as commit message')),
Vadim Gelfer
add backout command....
r2158 ('l', 'logfile', '', _('read commit message from <file>')),
('d', 'date', '', _('record datecode as commit date')),
Vadim Gelfer
backout: allow backout of merge changeset with --parent option....
r2614 ('', 'parent', '', _('parent to choose when backing out merge')),
Vadim Gelfer
add backout command....
r2158 ('u', 'user', '', _('record user as committer')),
('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Thomas Arendsen Hein
Small cleanups to backout command:...
r2159 _('hg backout [OPTION]... REV')),
mpm@selenic.com
Add preliminary support for the bundle and unbundle commands
r1218 "bundle":
(bundle,
Vadim Gelfer
add -f/--force to pull, incoming, outgoing, to work on unrelated repo....
r1959 [('f', 'force', None,
_('run even when remote repository is unrelated'))],
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 _('hg bundle FILE DEST')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "cat":
(cat,
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 [('o', 'output', '', _('print output to file with formatted name')),
('r', 'rev', '', _('print the given revision')),
('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 _('hg cat [OPTION]... FILE...')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "^clone":
(clone,
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 [('U', 'noupdate', None, _('do not update the new working directory')),
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 ('r', 'rev', [],
Vadim Gelfer
clone: replace long help string of inaky with doc comment.
r2764 _('a changeset you would like to have after cloning')),
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 ('', 'pull', None, _('use pull protocol to copy metadata')),
Vadim Gelfer
clone: change name of --stream to --uncompressed....
r2620 ('', 'uncompressed', None,
_('use uncompressed transfer (fast over LAN)')),
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 ('e', 'ssh', '', _('specify ssh command to use')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('', 'remotecmd', '',
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 _('specify hg command to run on the remote side'))],
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 _('hg clone [OPTION]... SOURCE [DEST]')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "^commit|ci":
(commit,
Thomas Arendsen Hein
Add debugaddremove alias to addremove, so it doesn't show up in 'hg help'....
r2184 [('A', 'addremove', None,
_('mark new/missing files as added/removed before committing')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('m', 'message', '', _('use <text> as commit message')),
('l', 'logfile', '', _('read the commit message from <file>')),
('d', 'date', '', _('record datecode as commit date')),
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 ('u', 'user', '', _('record user as commiter')),
('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 _('hg commit [OPTION]... [FILE]...')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 "copy|cp":
(copy,
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 [('A', 'after', None, _('record a copy that has already occurred')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('f', 'force', None,
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 _('forcibly copy over an existing managed file')),
('I', 'include', [], _('include names matching the given patterns')),
Vadim Gelfer
copy: add -n/--dry-run option
r2413 ('X', 'exclude', [], _('exclude names matching the given patterns')),
Vadim Gelfer
make description of -n option better.
r2416 ('n', 'dry-run', None, _('do not perform actions, just print output'))],
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 _('hg copy [OPTION]... [SOURCE]... DEST')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')),
Alexis S. L. Carvalho
add --options to debugcomplete and change bash_completion to use it...
r2034 "debugcomplete":
(debugcomplete,
[('o', 'options', None, _('show the command options'))],
_('debugcomplete [-o] CMD')),
Benoit Boissinot
add 'debugrebuildstate' to rebuild the dirstate from a given revision...
r1755 "debugrebuildstate":
(debugrebuildstate,
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 [('r', 'rev', '', _('revision to rebuild to'))],
Benoit Boissinot
add 'debugrebuildstate' to rebuild the dirstate from a given revision...
r1755 _('debugrebuildstate [-r REV] [REV]')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')),
Vadim Gelfer
debugconfig: allow to print by section and exact item name
r2410 "debugconfig": (debugconfig, [], _('debugconfig [NAME]...')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')),
"debugstate": (debugstate, [], _('debugstate')),
"debugdata": (debugdata, [], _('debugdata FILE REV')),
"debugindex": (debugindex, [], _('debugindex FILE')),
"debugindexdot": (debugindexdot, [], _('debugindexdot FILE')),
"debugrename": (debugrename, [], _('debugrename FILE [REV]')),
Thomas Arendsen Hein
Realigned command table again.
r841 "debugwalk":
(debugwalk,
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 [('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 _('debugwalk [OPTION]... [FILE]...')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "^diff":
(diff,
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 [('r', 'rev', [], _('revision')),
('a', 'text', None, _('treat all files as text')),
Vadim Gelfer
add -w and -p options to diff. this is for issue 126.
r1728 ('p', 'show-function', None,
_('show which function each change is in')),
('w', 'ignore-all-space', None,
_('ignore white space when comparing lines')),
Haakon Riiser
diff: add -b/-B options
r2580 ('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')),
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 ('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 _('hg diff [-a] [-I] [-X] [-r REV1 [-r REV2]] [FILE]...')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "^export":
(export,
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 [('o', 'output', '', _('print output to file with formatted name')),
Benoit Boissinot
add a --switch-parent option to export against the other parent
r1571 ('a', 'text', None, _('treat all files as text')),
('', 'switch-parent', None, _('diff against the second parent'))],
Benoit Boissinot
fix the synopsis of some commands, mark rawcommit as deprecated in short help
r1812 _('hg export [-a] [-o OUTFILESPEC] REV...')),
Thomas Arendsen Hein
Make the deprecated forget an alias of debugforget....
r2140 "debugforget|forget":
Thomas Arendsen Hein
Realigned command table again.
r841 (forget,
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 [('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 _('hg forget [OPTION]... FILE...')),
Thomas Arendsen Hein
Cleanups to commands.py
r1065 "grep":
(grep,
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 [('0', 'print0', None, _('end fields with NUL')),
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 ('', 'all', None, _('print all revisions that match')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ('i', 'ignore-case', None, _('ignore case when matching')),
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 ('l', 'files-with-matches', None,
_('print only filenames and revs that match')),
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 ('n', 'line-number', None, _('print matching line numbers')),
('r', 'rev', [], _('search in given revision range')),
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 ('u', 'user', None, _('print user who committed change')),
('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 _('hg grep [OPTION]... PATTERN [FILE]...')),
Thomas Arendsen Hein
Update online help of hg heads for new --branches option.
r905 "heads":
(heads,
Thomas Arendsen Hein
Make option --branch vs. --branches more consistent....
r1763 [('b', 'branches', None, _('show branches')),
Vadim Gelfer
fix some things people wanted to be cleaner....
r1913 ('', 'style', '', _('display using template map file')),
Vadim Gelfer
let commands that show changesets use templates....
r1907 ('r', 'rev', '', _('show only heads which are descendants of rev')),
Vadim Gelfer
fix some things people wanted to be cleaner....
r1913 ('', 'template', '', _('display with template'))],
Benoit Boissinot
add a -r/--rev option to heads to show only heads descendant from rev
r1550 _('hg heads [-b] [-r <rev>]')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 "help": (help_, [], _('hg help [COMMAND]')),
"identify|id": (identify, [], _('hg identify')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "import|patch":
(import_,
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 [('p', 'strip', 1,
Thomas Arendsen Hein
Use string literal concatenation for optlist and import -p option
r2125 _('directory strip option for patch. This has the same\n'
'meaning as the corresponding patch option')),
Benoit Boissinot
change log message creation when using 'hg import'...
r2458 ('m', 'message', '', _('use <text> as commit message')),
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 ('b', 'base', '', _('base path')),
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 ('f', 'force', None,
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 _('skip check for outstanding uncommitted changes'))],
Benoit Boissinot
change log message creation when using 'hg import'...
r2458 _('hg import [-p NUM] [-b BASE] [-m MESSAGE] [-f] PATCH...')),
Bryan O'Sullivan
Add rename/mv command....
r1253 "incoming|in": (incoming,
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 [('M', 'no-merges', None, _('do not show merges')),
Vadim Gelfer
add -f/--force to pull, incoming, outgoing, to work on unrelated repo....
r1959 ('f', 'force', None,
_('run even when remote repository is unrelated')),
Vadim Gelfer
fix some things people wanted to be cleaner....
r1913 ('', 'style', '', _('display using template map file')),
Vadim Gelfer
let commands that show changesets use templates....
r1907 ('n', 'newest-first', None, _('show newest record first')),
Benoit Boissinot
incoming: add support for remote repo using bundlerepo
r1944 ('', 'bundle', '', _('file to store the bundles into')),
Michal Kvasnica
allow 'hg out' / 'hg in' to show newest commit first
r1439 ('p', 'patch', None, _('show patch')),
Benoit Boissinot
add -r/--rev arguments to incoming and outgoing
r2521 ('r', 'rev', [], _('a specific revision you would like to pull')),
Benoit Boissinot
add remotecmd/ssh option support to incoming/outgoing
r1965 ('', 'template', '', _('display with template')),
('e', 'ssh', '', _('specify ssh command to use')),
('', 'remotecmd', '',
_('specify hg command to run on the remote side'))],
Benoit Boissinot
add -r/--rev arguments to incoming and outgoing
r2521 _('hg incoming [-p] [-n] [-M] [-r REV]...'
Thomas Arendsen Hein
Added missing space in continued string.
r2544 ' [--bundle FILENAME] [SOURCE]')),
Thomas Arendsen Hein
Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out....
r2598 "^init":
(init,
[('e', 'ssh', '', _('specify ssh command to use')),
('', 'remotecmd', '',
_('specify hg command to run on the remote side'))],
_('hg init [-e FILE] [--remotecmd FILE] [DEST]')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "locate":
(locate,
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 [('r', 'rev', '', _('search the repository as it stood at rev')),
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 ('0', 'print0', None,
_('end filenames with NUL, for use with xargs')),
('f', 'fullpath', None,
_('print complete paths from the filesystem root')),
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 ('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 _('hg locate [OPTION]... [PATTERN]...')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "^log|history":
(log,
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 [('b', 'branches', None, _('show branches')),
Vadim Gelfer
log: add -f/--follow option, to follow rename/copy
r2741 ('f', 'follow', None,
Brendan Cully
Make log --follow without a file list follow a single head....
r2782 _('follow changeset history, or file history across copies and renames')),
Brendan Cully
Add log option --follow-first to follow only the first parent of...
r2784 ('', 'follow-first', None,
_('only follow the first parent of merge changesets')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ('k', 'keyword', [], _('search for a keyword')),
Vadim Gelfer
add -l,--limit to log command.
r1756 ('l', 'limit', '', _('limit number of changes displayed')),
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 ('r', 'rev', [], _('show the specified revision or range')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('M', 'no-merges', None, _('do not show merges')),
Vadim Gelfer
fix some things people wanted to be cleaner....
r1913 ('', 'style', '', _('display using template map file')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('m', 'only-merges', None, _('show only merges')),
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 ('p', 'patch', None, _('show patch')),
Vadim Gelfer
merge with crew.
r1920 ('', 'template', '', _('display with template')),
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 ('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
_('hg log [OPTION]... [FILE]')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 "manifest": (manifest, [], _('hg manifest [REV]')),
Vadim Gelfer
add merge command. means same thing as "update -m"....
r2019 "merge":
Thomas Arendsen Hein
Don't allow --style and --template for hg update and hg merge....
r2044 (merge,
[('b', 'branch', '', _('merge with head of a specific branch')),
('f', 'force', None, _('force a merge with outstanding changes'))],
_('hg merge [-b TAG] [-f] [REV]')),
Bryan O'Sullivan
Add rename/mv command....
r1253 "outgoing|out": (outgoing,
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 [('M', 'no-merges', None, _('do not show merges')),
Vadim Gelfer
add -f/--force to pull, incoming, outgoing, to work on unrelated repo....
r1959 ('f', 'force', None,
_('run even when remote repository is unrelated')),
Michal Kvasnica
allow 'hg out' / 'hg in' to show newest commit first
r1439 ('p', 'patch', None, _('show patch')),
Vadim Gelfer
fix some things people wanted to be cleaner....
r1913 ('', 'style', '', _('display using template map file')),
Benoit Boissinot
add -r/--rev arguments to incoming and outgoing
r2521 ('r', 'rev', [], _('a specific revision you would like to push')),
Vadim Gelfer
let commands that show changesets use templates....
r1907 ('n', 'newest-first', None, _('show newest record first')),
Benoit Boissinot
add remotecmd/ssh option support to incoming/outgoing
r1965 ('', 'template', '', _('display with template')),
('e', 'ssh', '', _('specify ssh command to use')),
('', 'remotecmd', '',
_('specify hg command to run on the remote side'))],
Benoit Boissinot
add -r/--rev arguments to incoming and outgoing
r2521 _('hg outgoing [-M] [-p] [-n] [-r REV]... [DEST]')),
Benoit Boissinot
add a -b/--branch option to 'hg parents'
r1724 "^parents":
(parents,
Vadim Gelfer
let commands that show changesets use templates....
r1907 [('b', 'branches', None, _('show branches')),
Benoit Boissinot
allow specifying a file to hg parents, change the syntax to use -r/--rev
r2644 ('r', 'rev', '', _('show parents from the specified rev')),
Vadim Gelfer
fix some things people wanted to be cleaner....
r1913 ('', 'style', '', _('display using template map file')),
('', 'template', '', _('display with template'))],
Benoit Boissinot
allow specifying a file to hg parents, change the syntax to use -r/--rev
r2644 _('hg parents [-b] [-r REV] [FILE]')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 "paths": (paths, [], _('hg paths [NAME]')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "^pull":
(pull,
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 [('u', 'update', None,
_('update the working directory to tip after pull')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('e', 'ssh', '', _('specify ssh command to use')),
Vadim Gelfer
add -f/--force to pull, incoming, outgoing, to work on unrelated repo....
r1959 ('f', 'force', None,
_('run even when remote repository is unrelated')),
Matt Mackall
Merge bundle -r work from Eric Hopper
r1469 ('r', 'rev', [], _('a specific revision you would like to pull')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('', 'remotecmd', '',
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 _('specify hg command to run on the remote side'))],
Thomas Arendsen Hein
Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out....
r2598 _('hg pull [-u] [-r REV]... [-e FILE] [--remotecmd FILE] [SOURCE]')),
mpm@selenic.com
Actually implement the -f switch for push
r818 "^push":
(push,
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 [('f', 'force', None, _('force push')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('e', 'ssh', '', _('specify ssh command to use')),
Benoit Boissinot
add an optional argument to push only the specified revisions (push -r)
r1781 ('r', 'rev', [], _('a specific revision you would like to push')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('', 'remotecmd', '',
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 _('specify hg command to run on the remote side'))],
Thomas Arendsen Hein
Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out....
r2598 _('hg push [-f] [-r REV]... [-e FILE] [--remotecmd FILE] [DEST]')),
Thomas Arendsen Hein
Make the deprecated rawcommit an alias of debugrawcommit....
r1818 "debugrawcommit|rawcommit":
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 (rawcommit,
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 [('p', 'parent', [], _('parent')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('d', 'date', '', _('date code')),
('u', 'user', '', _('user')),
('F', 'files', '', _('file list')),
('m', 'message', '', _('commit message')),
('l', 'logfile', '', _('commit message file'))],
Thomas Arendsen Hein
Make the deprecated rawcommit an alias of debugrawcommit....
r1818 _('hg debugrawcommit [OPTION]... [FILE]...')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 "recover": (recover, [], _('hg recover')),
"^remove|rm":
(remove,
Thomas Arendsen Hein
Added -A as an alias for --after to hg remove, like for other commands.
r2245 [('A', 'after', None, _('record remove that has already occurred')),
Vadim Gelfer
add --after option to remove command.
r2179 ('f', 'force', None, _('remove file even if modified')),
Thomas Arendsen Hein
Reordered options for remove, fixed synopsis for rename.
r1869 ('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 _('hg remove [OPTION]... FILE...')),
"rename|mv":
(rename,
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 [('A', 'after', None, _('record a rename that has already occurred')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('f', 'force', None,
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 _('forcibly copy over an existing managed file')),
('I', 'include', [], _('include names matching the given patterns')),
Vadim Gelfer
remove: add -n/--dry-run option
r2414 ('X', 'exclude', [], _('exclude names matching the given patterns')),
Vadim Gelfer
make description of -n option better.
r2416 ('n', 'dry-run', None, _('do not perform actions, just print output'))],
Thomas Arendsen Hein
Reordered options for remove, fixed synopsis for rename.
r1869 _('hg rename [OPTION]... SOURCE... DEST')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "^revert":
(revert,
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 [('r', 'rev', '', _('revision to revert to')),
Vadim Gelfer
rewrite revert command. fix issues 93, 123, 147....
r2029 ('', 'no-backup', None, _('do not save backup copies of files')),
('I', 'include', [], _('include names matching given patterns')),
Vadim Gelfer
revert: add -n/--dry-run option
r2415 ('X', 'exclude', [], _('exclude names matching given patterns')),
Vadim Gelfer
make description of -n option better.
r2416 ('n', 'dry-run', None, _('do not perform actions, just print output'))],
Thomas Arendsen Hein
Updated help synopsises and reordered some options. Dropped [-n] from revert.
r1816 _('hg revert [-r REV] [NAME]...')),
Vadim Gelfer
deprecate undo command, replace with rollback command.
r2227 "rollback": (rollback, [], _('hg rollback')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 "root": (root, [], _('hg root')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "^serve":
(serve,
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 [('A', 'accesslog', '', _('name of access log file to write to')),
Vadim Gelfer
add --daemon option to serve command. for issue 45....
r1740 ('d', 'daemon', None, _('run server in background')),
Thomas Arendsen Hein
Added help string for --daemon-pipefds
r1742 ('', 'daemon-pipefds', '', _('used internally by daemon mode')),
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 ('E', 'errorlog', '', _('name of error log file to write to')),
('p', 'port', 0, _('port to use (default: 8000)')),
('a', 'address', '', _('address to use')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('n', 'name', '',
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 _('name to show in web pages (default: working dir)')),
Alexander Schremmer <alex AT alexanderweb DOT de>
Cleaned trailing whitespace in hgweb.py, removed command line shortcut for webdir-conf.
r2124 ('', 'webdir-conf', '', _('name of the webdir config file'
' (serve more than one repo)')),
Vadim Gelfer
add --daemon option to serve command. for issue 45....
r1740 ('', 'pid-file', '', _('name of file to write process ID to')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ('', 'stdio', None, _('for remote clients')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('t', 'templates', '', _('web templates to use')),
('', 'style', '', _('template style to use')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))],
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 _('hg serve [OPTION]...')),
Matt Mackall
Add explicit 'st' alias for status
r1507 "^status|st":
tksoh@users.sourceforge.net
hg status: added options to select files by status....
r840 (status,
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 [('A', 'all', None, _('show status of all files')),
('m', 'modified', None, _('show only modified files')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ('a', 'added', None, _('show only added files')),
('r', 'removed', None, _('show only removed files')),
Thomas Arendsen Hein
Distinguish removed and deleted files. Tests are not fixed yet....
r1619 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
Vadim Gelfer
status: add -c (clean) and -A (all files) options...
r2661 ('c', 'clean', None, _('show only files without changes')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
Thomas Arendsen Hein
New option -i/--ignored for 'hg status' to show ignored files....
r2022 ('i', 'ignored', None, _('show ignored files')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 ('n', 'no-status', None, _('hide status prefix')),
Brendan Cully
Add an option '-C|--copies' to hg status to show the source of copied files....
r2639 ('C', 'copies', None, _('show source of copied files')),
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 ('0', 'print0', None,
_('end filenames with NUL, for use with xargs')),
Benoit Boissinot
import docstring from doc/hg.1.txt
r1437 ('I', 'include', [], _('include names matching the given patterns')),
('X', 'exclude', [], _('exclude names matching the given patterns'))],
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 _('hg status [OPTION]... [FILE]...')),
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 "tag":
(tag,
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 [('l', 'local', None, _('make the tag local')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('m', 'message', '', _('message for tag commit log entry')),
('d', 'date', '', _('record datecode as commit date')),
('u', 'user', '', _('record user as commiter')),
('r', 'rev', '', _('revision to tag'))],
Benoit Boissinot
fix the synopsis of some commands, mark rawcommit as deprecated in short help
r1812 _('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 "tags": (tags, [], _('hg tags')),
Thomas Arendsen Hein
Add option -b/--branch to hg tip (as done for hg parents).
r1762 "tip":
(tip,
Thomas Arendsen Hein
Make option --branch vs. --branches more consistent....
r1763 [('b', 'branches', None, _('show branches')),
Vadim Gelfer
fix some things people wanted to be cleaner....
r1913 ('', 'style', '', _('display using template map file')),
Vadim Gelfer
let commands that show changesets use templates....
r1907 ('p', 'patch', None, _('show patch')),
Vadim Gelfer
fix some things people wanted to be cleaner....
r1913 ('', 'template', '', _('display with template'))],
Benoit Boissinot
resync commands.py docstrings with hg.1.txt
r1811 _('hg tip [-b] [-p]')),
mpm@selenic.com
Add preliminary support for the bundle and unbundle commands
r1218 "unbundle":
(unbundle,
Matt Mackall
Error handling for unbundle, fix option line wrapping
r1601 [('u', 'update', None,
_('update the working directory to tip after unbundle'))],
Muli Ben-Yehuda
add --update support to 'hg unbundle'
r1600 _('hg unbundle [-u] FILE')),
Vadim Gelfer
hide deprecated undo command by making it an alias for debugundo.
r2241 "debugundo|undo": (undo, [], _('hg undo')),
mpm@selenic.com
Shorten help...
r593 "^update|up|checkout|co":
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 (update,
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 [('b', 'branch', '', _('checkout the head of a specific branch')),
Vadim Gelfer
deprecate 'update -m'. use 'merge' instead.
r2283 ('m', 'merge', None, _('allow merging of branches (DEPRECATED)')),
Benoit Boissinot
abort when merging two heads and repository has local changes
r1581 ('C', 'clean', None, _('overwrite locally modified files')),
Thomas Arendsen Hein
Don't allow --style and --template for hg update and hg merge....
r2044 ('f', 'force', None, _('force a merge with outstanding changes'))],
Benoit Boissinot
abort when merging two heads and repository has local changes
r1581 _('hg update [-b TAG] [-m] [-C] [-f] [REV]')),
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 "verify": (verify, [], _('hg verify')),
"version": (show_version, [], _('hg version')),
Thomas Arendsen Hein
Sort global options by topic: directories, ui, timing, other...
r1046 }
mpm@selenic.com
Beginning of new command parsing interface...
r209
Thomas Arendsen Hein
Sort global options by topic: directories, ui, timing, other...
r1046 globalopts = [
Thomas Arendsen Hein
Allow symbolic path names in global -R/--repository parameter.
r1894 ('R', 'repository', '',
_('repository root directory or symbolic path name')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('', 'cwd', '', _('change working directory')),
Muli Ben-Yehuda
strictly adher to 80 chars per line
r1602 ('y', 'noninteractive', None,
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 _('do not prompt, assume \'yes\' for any required answers')),
('q', 'quiet', None, _('suppress output')),
('v', 'verbose', None, _('enable additional output')),
Vadim Gelfer
add --config global option. allows to set hgrc option on command line....
r2293 ('', 'config', [], _('set/override config option')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('', 'debug', None, _('enable debugging output')),
('', 'debugger', None, _('start debugger')),
Vadim Gelfer
add --lsprof option. 3x faster than --profile, more useful output....
r2422 ('', 'lsprof', None, _('print improved command execution profile')),
Thomas Arendsen Hein
Cleanup of indentation, spacing, newlines, strings and line length
r1615 ('', 'traceback', None, _('print 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')),
Thomas Arendsen Hein
Sort global options by topic: directories, ui, timing, other...
r1046 ]
mpm@selenic.com
A bunch of parsing/help updates...
r596
Benoit Boissinot
new command debugcomplete...
r1887 norepo = ("clone init version help debugancestor debugcomplete debugdata"
Thomas Arendsen Hein
Make hg paths and hg debugconfig work with -R/--repository option....
r1858 " debugindex debugindexdot")
Thomas Arendsen Hein
Allow 'hg serve --webdir-conf foo' to be run outside a repository.
r2127 optionalrepo = ("paths serve debugconfig")
mpm@selenic.com
Beginning of new command parsing interface...
r209
Benoit Boissinot
new command debugcomplete...
r1887 def findpossible(cmd):
"""
Return cmd -> (aliases, command table entry)
Thomas Arendsen Hein
Make completion for debugindex<tab><tab> show debugindexdot, too....
r2049 for each matching command.
Return debug commands (or their aliases) only if no normal command matches.
Benoit Boissinot
new command debugcomplete...
r1887 """
choice = {}
debugchoice = {}
mpm@selenic.com
commands: better argument processing, per-command help...
r212 for e in table.keys():
Benoit Boissinot
if unambigious command name are passed, use them
r1506 aliases = e.lstrip("^").split("|")
Thomas Arendsen Hein
Make completion for debugindex<tab><tab> show debugindexdot, too....
r2049 found = None
Benoit Boissinot
if unambigious command name are passed, use them
r1506 if cmd in aliases:
Thomas Arendsen Hein
Make completion for debugindex<tab><tab> show debugindexdot, too....
r2049 found = cmd
else:
for a in aliases:
if a.startswith(cmd):
found = a
break
if found is not None:
if aliases[0].startswith("debug"):
debugchoice[found] = (aliases, table[e])
else:
choice[found] = (aliases, table[e])
Alexis S. L. Carvalho
AmbiguousCommand is raised too soon....
r1739
Thomas Arendsen Hein
Hide debug commands in ambiguous command list, unless no normal command matches....
r1850 if not choice and debugchoice:
choice = debugchoice
Benoit Boissinot
new command debugcomplete...
r1887 return choice
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 def findcmd(cmd):
Benoit Boissinot
new command debugcomplete...
r1887 """Return (aliases, command table entry) for command string."""
choice = findpossible(cmd)
if choice.has_key(cmd):
return choice[cmd]
TK Soh
show choices on ambiguous commands
r1848 if len(choice) > 1:
Benoit Boissinot
new command debugcomplete...
r1887 clist = choice.keys()
Thomas Arendsen Hein
Show ambiguous aliases, if they are not simple abbreviations. Sort output.
r1849 clist.sort()
TK Soh
show choices on ambiguous commands
r1848 raise AmbiguousCommand(cmd, clist)
Alexis S. L. Carvalho
AmbiguousCommand is raised too soon....
r1739
Thomas Arendsen Hein
Canonicalize command when using aliases or prefix matching....
r1517 if choice:
Benoit Boissinot
new command debugcomplete...
r1887 return choice.values()[0]
mpm@selenic.com
commands: better argument processing, per-command help...
r212
raise UnknownCommand(cmd)
mpm@selenic.com
catch TERM signal in command processor...
r214 def catchterm(*args):
Vadim Gelfer
move SignalInterrupt class into util module.
r2153 raise util.SignalInterrupt
mpm@selenic.com
catch TERM signal in command processor...
r214
mpm@selenic.com
import and startup cleanups...
r249 def run():
sys.exit(dispatch(sys.argv[1:]))
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 class ParseError(Exception):
"""Exception raised on errors in parsing the command line."""
mpm@selenic.com
Restructure option handling...
r592
TK Soh
get command defaults from hgrc
r1453 def parse(ui, args):
mpm@selenic.com
Beginning of new command parsing interface...
r209 options = {}
mpm@selenic.com
A bunch of parsing/help updates...
r596 cmdoptions = {}
mpm@selenic.com
Beginning of new command parsing interface...
r209
mpm@selenic.com
Restructure option handling...
r592 try:
mpm@selenic.com
A bunch of parsing/help updates...
r596 args = fancyopts.fancyopts(args, globalopts, options)
mpm@selenic.com
Restructure option handling...
r592 except fancyopts.getopt.GetoptError, inst:
Bryan O'Sullivan
Handle unrecognised options correctly....
r618 raise ParseError(None, inst)
mpm@selenic.com
Beginning of new command parsing interface...
r209
Thomas Arendsen Hein
Moved special handling of --version and no hg command from parse to dispatch....
r1047 if args:
cmd, args = args[0], args[1:]
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 aliases, i = findcmd(cmd)
TK Soh
make command defaults works for aliases
r1567 cmd = aliases[0]
TK Soh
get command defaults from hgrc
r1453 defaults = ui.config("defaults", cmd)
if defaults:
TK Soh
fix a bug where command defaults suppress global options
r1526 args = defaults.split() + args
Thomas Arendsen Hein
Moved special handling of --version and no hg command from parse to dispatch....
r1047 c = list(i[1])
mpm@selenic.com
Beginning of new command parsing interface...
r209 else:
Thomas Arendsen Hein
Moved special handling of --version and no hg command from parse to dispatch....
r1047 cmd = None
c = []
mpm@selenic.com
Beginning of new command parsing interface...
r209
mpm@selenic.com
Restructure option handling...
r592 # combine global options into local
mpm@selenic.com
A bunch of parsing/help updates...
r596 for o in globalopts:
mpm@selenic.com
Restructure option handling...
r592 c.append((o[0], o[1], options[o[1]], o[3]))
mpm@selenic.com
catch TERM signal in command processor...
r214
mpm@selenic.com
hg help improvements...
r293 try:
mpm@selenic.com
A bunch of parsing/help updates...
r596 args = fancyopts.fancyopts(args, c, cmdoptions)
mpm@selenic.com
hg help improvements...
r293 except fancyopts.getopt.GetoptError, inst:
mpm@selenic.com
A bunch of parsing/help updates...
r596 raise ParseError(cmd, inst)
mpm@selenic.com
Beginning of new command parsing interface...
r209
mpm@selenic.com
Restructure option handling...
r592 # separate global options back out
mpm@selenic.com
A bunch of parsing/help updates...
r596 for o in globalopts:
mpm@selenic.com
Restructure option handling...
r592 n = o[1]
options[n] = cmdoptions[n]
del cmdoptions[n]
Thomas Arendsen Hein
Moved special handling of --version and no hg command from parse to dispatch....
r1047 return (cmd, cmd and i[0] or None, args, options, cmdoptions)
mpm@selenic.com
A bunch of parsing/help updates...
r596
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 external = {}
def findext(name):
'''return module with given extension name'''
try:
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 return sys.modules[external[name]]
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 except KeyError:
for k, v in external.iteritems():
Brendan Cully
Check for parent/mod as well as parent.mod in findext....
r2755 if k.endswith('.' + name) or k.endswith('/' + name) or v == name:
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 return sys.modules[v]
Vadim Gelfer
help: make "hg help EXTENSION" work
r2553 raise KeyError(name)
Vadim Gelfer
clean up trailing white space.
r2600
mpm@selenic.com
A bunch of parsing/help updates...
r596 def dispatch(args):
Vadim Gelfer
add "archive" command, like "cvs export" only better....
r2112 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
Vadim Gelfer
catch SIGBREAK on windows.
r2092 num = getattr(signal, name, None)
if num: signal.signal(num, catchterm)
mpm@selenic.com
A bunch of parsing/help updates...
r596
Soh Tk-r28629
Fix traceback on bad system hgrc files
r1483 try:
Vadim Gelfer
do not check sys.argv from localrepo when running hooks....
r2166 u = ui.ui(traceback='--traceback' in sys.argv[1:])
Soh Tk-r28629
Fix traceback on bad system hgrc files
r1483 except util.Abort, inst:
sys.stderr.write(_("abort: %s\n") % inst)
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 return -1
Soh Tk-r28629
Fix traceback on bad system hgrc files
r1483
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 for ext_name, load_from_name in u.extensions():
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 try:
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 if load_from_name:
Benoit Boissinot
pick a non-conflicting module name when loading an extension...
r2405 # the module will be loaded in sys.modules
# choose an unique name so that it doesn't
# conflicts with other modules
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 module_name = "hgext_%s" % ext_name.replace('.', '_')
mod = imp.load_source(module_name, load_from_name)
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 else:
def importh(name):
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
return mod
Thomas Arendsen Hein
Try to import extensions from the hgext module first.
r1889 try:
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 mod = importh("hgext.%s" % ext_name)
Thomas Arendsen Hein
Try to import extensions from the hgext module first.
r1889 except ImportError:
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 mod = importh(ext_name)
external[ext_name] = mod.__name__
Vadim Gelfer
honor signals during load of extensions.
r2428 except (util.SignalInterrupt, KeyboardInterrupt):
raise
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 except Exception, inst:
Benoit Boissinot
fix bug introduced in b13a98bd078e
r2617 u.warn(_("*** failed to import extension %s: %s\n") % (ext_name, inst))
Vadim Gelfer
add ui.print_exc(), make all traceback printing central.
r2335 if u.print_exc():
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 return 1
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 for name in external.itervalues():
mod = sys.modules[name]
uisetup = getattr(mod, 'uisetup', None)
Vadim Gelfer
add 'uisetup' function to extension module protocol....
r2330 if uisetup:
uisetup(u)
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 cmdtable = getattr(mod, 'cmdtable', {})
Bryan O'Sullivan
Make contract with extensions optional.
r1295 for t in cmdtable:
mason@suse.com
Add support for extension modules...
r1071 if t in table:
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 u.warn(_("module %s overrides %s\n") % (name, t))
Bryan O'Sullivan
Make contract with extensions optional.
r1295 table.update(cmdtable)
mason@suse.com
Add support for extension modules...
r1071
mpm@selenic.com
A bunch of parsing/help updates...
r596 try:
TK Soh
get command defaults from hgrc
r1453 cmd, func, args, options, cmdoptions = parse(u, args)
Thomas Arendsen Hein
Catch other exceptions (e.g. util.Abort) in parse(), too....
r1875 if options["time"]:
def get_times():
t = os.times()
if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()
t = (t[0], t[1], t[2], t[3], time.clock())
return t
s = get_times()
def print_time():
t = get_times()
u.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
(t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
atexit.register(print_time)
u.updateopts(options["verbose"], options["debug"], options["quiet"],
Vadim Gelfer
add --config global option. allows to set hgrc option on command line....
r2293 not options["noninteractive"], options["traceback"],
options["config"])
Thomas Arendsen Hein
Catch other exceptions (e.g. util.Abort) in parse(), too....
r1875
# enter the debugger before command execution
if options['debugger']:
pdb.set_trace()
mpm@selenic.com
[PATCH] Add --traceback option...
r527 try:
Thomas Arendsen Hein
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
r1859 if options['cwd']:
try:
os.chdir(options['cwd'])
except OSError, inst:
raise util.Abort('%s: %s' %
(options['cwd'], inst.strerror))
Thomas Arendsen Hein
Allow symbolic path names in global -R/--repository parameter.
r1894 path = u.expandpath(options["repository"]) or ""
Thomas Arendsen Hein
Moved --cwd handling in front of -R handling again. Shorter code for initial -R.
r1859 repo = path and hg.repository(u, path=path) or None
Thomas Arendsen Hein
Always try to open the repository if -R/--repository is specified....
r1857
Thomas Arendsen Hein
Added options -h/--help.
r1048 if options['help']:
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 return help_(u, cmd, options['version'])
Thomas Arendsen Hein
Added options -h/--help.
r1048 elif options['version']:
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 return show_version(u)
Thomas Arendsen Hein
Moved special handling of --version and no hg command from parse to dispatch....
r1047 elif not cmd:
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 return help_(u, 'shortlist')
Thomas Arendsen Hein
Moved special handling of --version and no hg command from parse to dispatch....
r1047
mpm@selenic.com
[PATCH] Add --traceback option...
r527 if cmd not in norepo.split():
Thomas Arendsen Hein
Make hg paths and hg debugconfig work with -R/--repository option....
r1858 try:
if not repo:
repo = hg.repository(u, path=path)
u = repo.ui
Vadim Gelfer
fix problems with external module handling. found by benoit boissinot....
r2573 for name in external.itervalues():
mod = sys.modules[name]
if hasattr(mod, 'reposetup'):
mod.reposetup(u, repo)
Vadim Gelfer
call reposetup functions of extension modules whenever repo created
r2847 hg.repo_setup_hooks.append(mod.reposetup)
Thomas Arendsen Hein
Make hg paths and hg debugconfig work with -R/--repository option....
r1858 except hg.RepoError:
if cmd not in optionalrepo.split():
raise
mpm@selenic.com
A bunch of parsing/help updates...
r596 d = lambda: func(u, repo, *args, **cmdoptions)
mpm@selenic.com
[PATCH] Add --traceback option...
r527 else:
mpm@selenic.com
A bunch of parsing/help updates...
r596 d = lambda: func(u, *args, **cmdoptions)
mpm@selenic.com
Beginning of new command parsing interface...
r209
Benoit Boissinot
reupdate the options after loading the repo...
r2716 # reupdate the options, repo/.hg/hgrc may have changed them
u.updateopts(options["verbose"], options["debug"], options["quiet"],
not options["noninteractive"], options["traceback"],
options["config"])
Vadim Gelfer
make ui flush output. this makes error happen if printing to /dev/full....
r1837 try:
if options['profile']:
import hotshot, hotshot.stats
prof = hotshot.Profile("hg.prof")
Vadim Gelfer
generate profile even when exception raised....
r1832 try:
try:
Vadim Gelfer
make ui flush output. this makes error happen if printing to /dev/full....
r1837 return prof.runcall(d)
Vadim Gelfer
generate profile even when exception raised....
r1832 except:
Vadim Gelfer
make ui flush output. this makes error happen if printing to /dev/full....
r1837 try:
u.warn(_('exception raised - generating '
'profile anyway\n'))
except:
pass
raise
finally:
prof.close()
stats = hotshot.stats.load("hg.prof")
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(40)
Vadim Gelfer
add --lsprof option. 3x faster than --profile, more useful output....
r2422 elif options['lsprof']:
try:
from mercurial import lsprof
except ImportError:
raise util.Abort(_(
'lsprof not available - install from '
'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
p = lsprof.Profiler()
p.enable(subcalls=True)
try:
return d()
finally:
p.disable()
stats = lsprof.Stats(p.getstats())
stats.sort()
stats.pprint(top=10, file=sys.stderr, climit=5)
Vadim Gelfer
make ui flush output. this makes error happen if printing to /dev/full....
r1837 else:
return d()
finally:
u.flush()
mpm@selenic.com
[PATCH] Add --traceback option...
r527 except:
mpm@selenic.com
Add --debugger global option...
r1225 # enter the debugger when we hit an exception
if options['debugger']:
pdb.post_mortem(sys.exc_info()[2])
Vadim Gelfer
add ui.print_exc(), make all traceback printing central.
r2335 u.print_exc()
mpm@selenic.com
[PATCH] Add --traceback option...
r527 raise
Thomas Arendsen Hein
Catch other exceptions (e.g. util.Abort) in parse(), too....
r1875 except ParseError, inst:
if inst.args[0]:
u.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
help_(u, inst.args[0])
else:
u.warn(_("hg: %s\n") % inst.args[1])
help_(u, 'shortlist')
except AmbiguousCommand, inst:
Vadim Gelfer
merge with crew.
r1920 u.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
Thomas Arendsen Hein
Catch other exceptions (e.g. util.Abort) in parse(), too....
r1875 (inst.args[0], " ".join(inst.args[1])))
except UnknownCommand, inst:
u.warn(_("hg: unknown command '%s'\n") % inst.args[0])
help_(u, 'shortlist')
mpm@selenic.com
Add exception class for repository errors...
r499 except hg.RepoError, inst:
Benoit Boissinot
write to stderr with a single write call....
r2134 u.warn(_("abort: %s!\n") % inst)
Vadim Gelfer
fix backtrace printed when cannot get lock....
r2016 except lock.LockHeld, inst:
if inst.errno == errno.ETIMEDOUT:
reason = _('timed out waiting for lock held by %s') % inst.locker
else:
reason = _('lock held by %s') % inst.locker
u.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason))
except lock.LockUnavailable, inst:
u.warn(_("abort: could not lock %s: %s\n") %
(inst.desc or inst.filename, inst.strerror))
mpm@selenic.com
Smarter handling of revlog key errors...
r1214 except revlog.RevlogError, inst:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("abort: "), inst, "!\n")
Vadim Gelfer
move SignalInterrupt class into util module.
r2153 except util.SignalInterrupt:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("killed!\n"))
mpm@selenic.com
Beginning of new command parsing interface...
r209 except KeyboardInterrupt:
Thomas Arendsen Hein
Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'.
r832 try:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("interrupted!\n"))
Thomas Arendsen Hein
Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'.
r832 except IOError, inst:
if inst.errno == errno.EPIPE:
if u.debugflag:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("\nbroken pipe\n"))
Thomas Arendsen Hein
Handle broken pipe on pressing Ctrl-C with e.g. 'hg log|grep something'.
r832 else:
raise
mpm@selenic.com
Catch broken pipes in command interpreter...
r250 except IOError, inst:
mpm@selenic.com
commands: report http exceptions nicely...
r395 if hasattr(inst, "code"):
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("abort: %s\n") % inst)
mpm@selenic.com
commands: report http exceptions nicely...
r395 elif hasattr(inst, "reason"):
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("abort: error: %s\n") % inst.reason[1])
mpm@selenic.com
commands: report http exceptions nicely...
r395 elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
Thomas Arendsen Hein
Cleanups to commands.py
r1065 if u.debugflag:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("broken pipe\n"))
Matt Mackall
Fix pipe error regression
r1350 elif getattr(inst, "strerror", None):
Eric Hopper
Made the abort message for IOError nicer when the filename is known.
r1354 if getattr(inst, "filename", None):
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("abort: %s - %s\n") % (inst.strerror, inst.filename))
Eric Hopper
Made the abort message for IOError nicer when the filename is known.
r1354 else:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("abort: %s\n") % inst.strerror)
mpm@selenic.com
Catch broken pipes in command interpreter...
r250 else:
raise
mpm@selenic.com
[PATCH] Catch OSError usefully...
r549 except OSError, inst:
if hasattr(inst, "filename"):
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
mpm@selenic.com
[PATCH] Catch OSError usefully...
r549 else:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("abort: %s\n") % inst.strerror)
Bryan O'Sullivan
Teach walk code about absolute paths....
r870 except util.Abort, inst:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_('abort: '), inst.args[0] % inst.args[1:], '\n')
mpm@selenic.com
commands: better argument processing, per-command help...
r212 except TypeError, inst:
# was this an argument error?
tb = traceback.extract_tb(sys.exc_info()[2])
if len(tb) > 2: # no
raise
mpm@selenic.com
hg help improvements...
r293 u.debug(inst, "\n")
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("%s: invalid arguments\n") % cmd)
Thomas Arendsen Hein
Multiple cleanups of things detected by pylint....
r697 help_(u, cmd)
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 except SystemExit, inst:
# Commands shouldn't sys.exit directly, but give a return code.
# Just in case catch this and and pass exit code to caller.
return inst.code
mpm@selenic.com
Add reporting instructions to unknown exception backtraces
r1215 except:
Benoit Boissinot
i18n part2: use '_' for all strings who are part of the user interface
r1402 u.warn(_("** unknown exception encountered, details follow\n"))
Benoit Boissinot
mention the bts for bug reporting in traceback message
r2625 u.warn(_("** report bug details to "
"http://www.selenic.com/mercurial/bts\n"))
u.warn(_("** or mercurial@selenic.com\n"))
Thomas Arendsen Hein
Added version information to "report bug" message for unknown exceptions.
r1552 u.warn(_("** Mercurial Distributed SCM (version %s)\n")
% version.get_version())
mpm@selenic.com
Add reporting instructions to unknown exception backtraces
r1215 raise
mpm@selenic.com
hg help improvements...
r293
Thomas Arendsen Hein
Never exit directly from commands.dispatch(), but pass return code to caller....
r2057 return -1