commands.py
3474 lines
| 126.2 KiB
| text/x-python
|
PythonLexer
/ mercurial / commands.py
|
r249 | # commands.py - command processing for mercurial | ||
# | ||||
|
r4635 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | ||
|
r249 | # | ||
|
r8225 | # This software may be used and distributed according to the terms of the | ||
# GNU General Public License version 2, incorporated herein by reference. | ||||
|
r249 | |||
|
r6211 | from node import hex, nullid, nullrev, short | ||
|
r8109 | from lock import release | ||
|
r7013 | from i18n import _, gettext | ||
|
r8312 | import os, re, sys, textwrap, subprocess, difflib, time | ||
|
r7633 | import hg, util, revlog, bundlerepo, extensions, copies, context, error | ||
|
r8312 | import patch, help, mdiff, tempfile, url, encoding | ||
import archival, changegroup, cmdutil, sshserver, hbisect | ||||
from hgweb import server | ||||
|
r6518 | import merge as merge_ | ||
|
r2731 | |||
|
r255 | # Commands start here, listed alphabetically | ||
|
r209 | |||
|
r724 | def add(ui, repo, *pats, **opts): | ||
|
r1437 | """add the specified files on the next commit | ||
|
r8004 | Schedule files to be version controlled and added to the | ||
repository. | ||||
|
r1437 | |||
|
r3829 | The files will be added to the repository at the next commit. To | ||
undo an add before that, see hg revert. | ||||
|
r1437 | |||
|
r7807 | If no names are given, add all files to the repository. | ||
|
r1437 | """ | ||
|
r8679 | bad = [] | ||
|
r5688 | exacts = {} | ||
|
r724 | names = [] | ||
|
r6579 | m = cmdutil.match(repo, pats, opts) | ||
|
r8679 | oldbad = m.bad | ||
m.bad = lambda x,y: bad.append(x) or oldbad(x,y) | ||||
for f in repo.walk(m): | ||||
exact = m.exact(f) | ||||
if exact or f not in repo.dirstate: | ||||
names.append(f) | ||||
if ui.verbose or not exact: | ||||
ui.status(_('adding %s\n') % m.rel(f)) | ||||
|
r2503 | if not opts.get('dry_run'): | ||
|
r8679 | bad += [f for f in repo.add(names) if f in m.files()] | ||
return bad and 1 or 0 | ||||
|
r213 | |||
|
r766 | def addremove(ui, repo, *pats, **opts): | ||
|
r3181 | """add all new files, delete all missing files | ||
|
r2181 | |||
|
r8004 | Add all new files and remove all missing files from the | ||
repository. | ||||
New files are ignored if they match any of the patterns in | ||||
.hgignore. As with add, these changes take effect at the next | ||||
commit. | ||||
|
r2958 | |||
|
r8033 | Use the -s/--similarity option to detect renamed files. With a | ||
parameter > 0, this compares every removed file with every added | ||||
file and records those similar enough as renames. This option | ||||
takes a percentage between 0 (disabled) and 100 (files must be | ||||
identical) as its parameter. Detecting renamed files this way can | ||||
be expensive. | ||||
|
r1437 | """ | ||
|
r4966 | try: | ||
sim = float(opts.get('similarity') or 0) | ||||
except ValueError: | ||||
raise util.Abort(_('similarity must be a number')) | ||||
|
r2958 | if sim < 0 or sim > 100: | ||
raise util.Abort(_('similarity must be between 0 and 100')) | ||||
return cmdutil.addremove(repo, pats, opts, similarity=sim/100.) | ||||
|
r219 | |||
|
r733 | def annotate(ui, repo, *pats, **opts): | ||
|
r8779 | """show changeset information by line for each file | ||
|
r1437 | |||
|
r8004 | List changes in files, showing the revision id responsible for | ||
each line | ||||
|
r8779 | This command is useful for discovering when a change was made and | ||
by whom. | ||||
|
r1437 | |||
|
r8033 | Without the -a/--text option, annotate will avoid processing files | ||
|
r8779 | it detects as binary. With -a, annotate will annotate the file | ||
anyway, although the results will probably be neither useful | ||||
nor desirable. | ||||
|
r1437 | """ | ||
|
r6134 | datefunc = ui.quiet and util.shortdate or util.datestr | ||
getdate = util.cachefunc(lambda x: datefunc(x[0].date())) | ||||
|
r1522 | |||
|
r744 | if not pats: | ||
|
r8761 | raise util.Abort(_('at least one filename or pattern is required')) | ||
|
r744 | |||
|
r4857 | opmap = [('user', lambda x: ui.shortuser(x[0].user())), | ||
('number', lambda x: str(x[0].rev())), | ||||
('changeset', lambda x: short(x[0].node())), | ||||
('date', getdate), | ||||
('follow', lambda x: x[0].path()), | ||||
] | ||||
|
r7131 | if (not opts.get('user') and not opts.get('changeset') and not opts.get('date') | ||
and not opts.get('follow')): | ||||
|
r714 | opts['number'] = 1 | ||
|
r209 | |||
|
r4857 | linenumber = opts.get('line_number') is not None | ||
|
r7131 | if (linenumber and (not opts.get('changeset')) and (not opts.get('number'))): | ||
|
r4857 | raise util.Abort(_('at least one of -n/-c is required for -l')) | ||
funcmap = [func for op, func in opmap if opts.get(op)] | ||||
if linenumber: | ||||
lastfunc = funcmap[-1] | ||||
funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1]) | ||||
|
r7131 | ctx = repo[opts.get('rev')] | ||
|
r1016 | |||
|
r6579 | m = cmdutil.match(repo, pats, opts) | ||
|
r6764 | for abs in ctx.walk(m): | ||
fctx = ctx[abs] | ||||
|
r7131 | if not opts.get('text') and util.binary(fctx.data()): | ||
|
r6584 | ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs)) | ||
|
r1016 | continue | ||
|
r4857 | lines = fctx.annotate(follow=opts.get('follow'), | ||
linenumber=linenumber) | ||||
|
r209 | pieces = [] | ||
|
r4857 | for f in funcmap: | ||
l = [f(n) for n, dummy in lines] | ||||
if l: | ||||
|
r7094 | ml = max(map(len, l)) | ||
pieces.append(["%*s" % (ml, x) for x in l]) | ||||
|
r209 | |||
|
r771 | if pieces: | ||
for p, l in zip(zip(*pieces), lines): | ||||
ui.write("%s: %s" % (" ".join(p), l[1])) | ||||
|
r209 | |||
|
r2112 | def archive(ui, repo, dest, **opts): | ||
|
r8779 | '''create an unversioned archive of a repository revision | ||
|
r2112 | |||
By default, the revision used is the parent of the working | ||||
|
r8033 | directory; use -r/--rev to specify a different revision. | ||
To specify the type of archive to create, use -t/--type. Valid | ||||
|
r2112 | 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 | ||||
|
r7974 | using a format string; see 'hg help export' for details. | ||
|
r2112 | |||
Each member added to an archive file has a directory prefix | ||||
|
r8033 | prepended. Use -p/--prefix to specify a format string for the | ||
prefix. The default is the basename of the archive, with suffixes | ||||
removed. | ||||
|
r2112 | ''' | ||
|
r7131 | ctx = repo[opts.get('rev')] | ||
|
r5061 | if not ctx: | ||
|
r7528 | raise util.Abort(_('no working directory: please specify a revision')) | ||
|
r5061 | node = ctx.node() | ||
|
r2874 | dest = cmdutil.make_filename(repo, dest, node) | ||
|
r2112 | if os.path.realpath(dest) == repo.root: | ||
raise util.Abort(_('repository root cannot be destination')) | ||||
|
r6579 | matchfn = cmdutil.match(repo, [], opts) | ||
|
r2476 | kind = opts.get('type') or 'files' | ||
|
r7131 | prefix = opts.get('prefix') | ||
|
r2476 | 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' | ||||
|
r2874 | prefix = cmdutil.make_filename(repo, prefix, node) | ||
|
r7131 | archival.archive(repo, dest, node, kind, not opts.get('no_decode'), | ||
|
r2476 | matchfn, prefix) | ||
|
r2112 | |||
|
r4450 | def backout(ui, repo, node=None, rev=None, **opts): | ||
|
r2158 | '''reverse effect of earlier changeset | ||
|
r6448 | Commit the backed out changes as a new changeset. The new | ||
|
r2254 | changeset is a child of the backed out changeset. | ||
|
r2158 | |||
|
r8779 | If you backout a changeset other than the tip, a new head is | ||
|
r6448 | created. This head will be the new tip and you should merge this | ||
|
r8779 | backout changeset with another head. | ||
|
r2254 | |||
The --merge option remembers the parent of the working directory | ||||
before starting the backout, then merges the new head with that | ||||
|
r8004 | changeset afterwards. This saves you from doing the merge by hand. | ||
The result of this merge is not committed, as with a normal merge. | ||||
|
r6163 | |||
|
r8540 | See 'hg help dates' for a list of formats valid for -d/--date. | ||
|
r6163 | ''' | ||
|
r4450 | if rev and node: | ||
raise util.Abort(_("please specify just one revision")) | ||||
if not rev: | ||||
rev = node | ||||
|
r2158 | |||
|
r4726 | if not rev: | ||
raise util.Abort(_("please specify a revision to backout")) | ||||
|
r6139 | date = opts.get('date') | ||
if date: | ||||
opts['date'] = util.parsedate(date) | ||||
|
r4549 | cmdutil.bail_if_changed(repo) | ||
|
r5716 | node = repo.lookup(rev) | ||
|
r2158 | op1, op2 = repo.dirstate.parents() | ||
|
r5568 | a = repo.changelog.ancestor(op1, node) | ||
if a != node: | ||||
|
r8779 | raise util.Abort(_('cannot backout change on a different branch')) | ||
|
r5568 | |||
|
r2614 | p1, p2 = repo.changelog.parents(node) | ||
if p1 == nullid: | ||||
|
r8779 | raise util.Abort(_('cannot backout a change with no parents')) | ||
|
r2158 | if p2 != nullid: | ||
|
r7131 | if not opts.get('parent'): | ||
|
r8779 | raise util.Abort(_('cannot backout a merge changeset without ' | ||
|
r2614 | '--parent')) | ||
p = repo.lookup(opts['parent']) | ||||
if p not in (p1, p2): | ||||
|
r3679 | raise util.Abort(_('%s is not a parent of %s') % | ||
|
r3680 | (short(p), short(node))) | ||
|
r2614 | parent = p | ||
else: | ||||
|
r7131 | if opts.get('parent'): | ||
|
r2614 | raise util.Abort(_('cannot use --parent on non-merge changeset')) | ||
parent = p1 | ||||
|
r5568 | |||
|
r6423 | # the backout should appear on the same branch | ||
branch = repo.dirstate.branch() | ||||
|
r2808 | hg.clean(repo, node, show_stats=False) | ||
|
r6423 | repo.dirstate.setbranch(branch) | ||
|
r2158 | revert_opts = opts.copy() | ||
|
r3814 | revert_opts['date'] = None | ||
|
r2982 | revert_opts['all'] = True | ||
|
r2158 | revert_opts['rev'] = hex(parent) | ||
|
r6031 | revert_opts['no_backup'] = None | ||
|
r2158 | revert(ui, repo, **revert_opts) | ||
commit_opts = opts.copy() | ||||
commit_opts['addremove'] = False | ||||
|
r2159 | if not commit_opts['message'] and not commit_opts['logfile']: | ||
|
r4718 | commit_opts['message'] = _("Backed out changeset %s") % (short(node)) | ||
|
r2268 | commit_opts['force_editor'] = True | ||
|
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))) | ||||
|
r2493 | if op1 != node: | ||
|
r6161 | hg.clean(repo, op1, show_stats=False) | ||
|
r7131 | if opts.get('merge'): | ||
|
r6161 | ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip())) | ||
hg.merge(repo, hex(repo.changelog.tip())) | ||||
|
r2493 | else: | ||
ui.status(_('the backout changeset is a new head - ' | ||||
'do not forget to merge\n')) | ||||
|
r2761 | ui.status(_('(use "backout --merge" ' | ||
'if you want to auto-merge)\n')) | ||||
|
r2158 | |||
|
r7227 | def bisect(ui, repo, rev=None, extra=None, command=None, | ||
|
r5775 | reset=None, good=None, bad=None, skip=None, noupdate=None): | ||
"""subdivision search of changesets | ||||
|
r8004 | This command helps to find changesets which introduce problems. To | ||
use, mark the earliest changeset you know exhibits the problem as | ||||
bad, then mark the latest changeset which is free from the problem | ||||
as good. Bisect will update your working directory to a revision | ||||
|
r8033 | for testing (unless the -U/--noupdate option is specified). Once | ||
|
r8779 | you have performed tests, mark the working directory as good or | ||
bad, and bisect will either update to another candidate changeset | ||||
|
r6928 | or announce that it has found the bad revision. | ||
|
r7184 | |||
|
r6928 | As a shortcut, you can also use the revision argument to mark a | ||
revision as good or bad without checking it out first. | ||||
|
r7227 | |||
|
r8779 | If you supply a command, it will be used for automatic bisection. | ||
Its exit status will be used to mark revisions as good or bad: | ||||
status 0 means good, 125 means to skip the revision, 127 | ||||
(command not found) will abort the bisection, and any other | ||||
non-zero exit status means the revision is bad. | ||||
|
r5775 | """ | ||
|
r7227 | def print_result(nodes, good): | ||
|
r5775 | displayer = cmdutil.show_changeset(ui, repo, {}) | ||
|
r6858 | if len(nodes) == 1: | ||
# narrowed it down to a single revision | ||||
|
r8088 | if good: | ||
ui.write(_("The first good revision is:\n")) | ||||
else: | ||||
ui.write(_("The first bad revision is:\n")) | ||||
|
r7369 | displayer.show(repo[nodes[0]]) | ||
|
r6858 | else: | ||
# multiple possible revisions | ||||
|
r8088 | if good: | ||
ui.write(_("Due to skipped revisions, the first " | ||||
"good revision could be any of:\n")) | ||||
else: | ||||
ui.write(_("Due to skipped revisions, the first " | ||||
"bad revision could be any of:\n")) | ||||
|
r6858 | for n in nodes: | ||
|
r7369 | displayer.show(repo[n]) | ||
|
r7227 | |||
def check_state(state, interactive=True): | ||||
if not state['good'] or not state['bad']: | ||||
if (good or bad or skip or reset) and interactive: | ||||
return | ||||
if not state['good']: | ||||
raise util.Abort(_('cannot bisect (no known good revisions)')) | ||||
else: | ||||
raise util.Abort(_('cannot bisect (no known bad revisions)')) | ||||
return True | ||||
# backward compatibility | ||||
if rev in "good bad reset init".split(): | ||||
ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n")) | ||||
cmd, rev, extra = rev, extra, None | ||||
if cmd == "good": | ||||
good = True | ||||
elif cmd == "bad": | ||||
bad = True | ||||
else: | ||||
reset = True | ||||
elif extra or good + bad + skip + reset + bool(command) > 1: | ||||
raise util.Abort(_('incompatible arguments')) | ||||
if reset: | ||||
p = repo.join("bisect.state") | ||||
if os.path.exists(p): | ||||
os.unlink(p) | ||||
return | ||||
state = hbisect.load_state(repo) | ||||
if command: | ||||
|
r7590 | commandpath = util.find_exe(command) | ||
|
r8802 | if commandpath is None: | ||
raise util.Abort(_("cannot find executable: %s") % command) | ||||
|
r7227 | changesets = 1 | ||
|
r7590 | try: | ||
while changesets: | ||||
# update state | ||||
|
r8284 | status = subprocess.call([commandpath]) | ||
|
r7590 | if status == 125: | ||
transition = "skip" | ||||
elif status == 0: | ||||
transition = "good" | ||||
# status < 0 means process was killed | ||||
elif status == 127: | ||||
raise util.Abort(_("failed to execute %s") % command) | ||||
elif status < 0: | ||||
raise util.Abort(_("%s killed") % command) | ||||
else: | ||||
transition = "bad" | ||||
|
r8805 | ctx = repo[rev or '.'] | ||
state[transition].append(ctx.node()) | ||||
ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition)) | ||||
|
r7590 | check_state(state, interactive=False) | ||
# bisect | ||||
nodes, changesets, good = hbisect.bisect(repo.changelog, state) | ||||
# update to next check | ||||
cmdutil.bail_if_changed(repo) | ||||
hg.clean(repo, nodes[0], show_stats=False) | ||||
finally: | ||||
hbisect.save_state(repo, state) | ||||
|
r7227 | return print_result(nodes, not status) | ||
# update state | ||||
node = repo.lookup(rev or '.') | ||||
if good: | ||||
state['good'].append(node) | ||||
elif bad: | ||||
state['bad'].append(node) | ||||
elif skip: | ||||
state['skip'].append(node) | ||||
hbisect.save_state(repo, state) | ||||
if not check_state(state): | ||||
return | ||||
# actually bisect | ||||
nodes, changesets, good = hbisect.bisect(repo.changelog, state) | ||||
if changesets == 0: | ||||
print_result(nodes, good) | ||||
|
r6858 | else: | ||
assert len(nodes) == 1 # only a single node can be tested next | ||||
node = nodes[0] | ||||
|
r5775 | # compute the approximate number of remaining tests | ||
tests, size = 0, 2 | ||||
while size <= changesets: | ||||
tests, size = tests + 1, size * 2 | ||||
rev = repo.changelog.rev(node) | ||||
ui.write(_("Testing changeset %s:%s " | ||||
"(%s changesets remaining, ~%s tests)\n") | ||||
|
r6217 | % (rev, short(node), changesets, tests)) | ||
|
r5775 | if not noupdate: | ||
cmdutil.bail_if_changed(repo) | ||||
return hg.clean(repo, node) | ||||
|
r4202 | def branch(ui, repo, label=None, **opts): | ||
|
r3502 | """set or show the current branch name | ||
|
r4601 | With no argument, show the current branch name. With one argument, | ||
|
r8779 | set the working directory branch name (the branch will not exist | ||
in the repository until the next commit). Standard practice | ||||
recommends that primary development take place on the 'default' | ||||
branch. | ||||
|
r4202 | |||
|
r8033 | Unless -f/--force is specified, branch will not let you set a | ||
|
r8779 | branch name that already exists, even if it's inactive. | ||
|
r5999 | |||
|
r8033 | Use -C/--clean to reset the working directory branch to that of | ||
the parent of the working directory, negating a previous branch | ||||
|
r8004 | change. | ||
|
r7006 | |||
|
r5999 | Use the command 'hg update' to switch to an existing branch. | ||
|
r3502 | """ | ||
|
r7006 | if opts.get('clean'): | ||
label = repo[None].parents()[0].branch() | ||||
repo.dirstate.setbranch(label) | ||||
ui.status(_('reset working directory to branch %s\n') % label) | ||||
elif label: | ||||
|
r4202 | if not opts.get('force') and label in repo.branchtags(): | ||
|
r6747 | if label not in [p.branch() for p in repo.parents()]: | ||
|
r4202 | raise util.Abort(_('a branch of the same name already exists' | ||
' (use --force to override)')) | ||||
|
r7948 | repo.dirstate.setbranch(encoding.fromlocal(label)) | ||
|
r4601 | ui.status(_('marked working directory as branch %s\n') % label) | ||
|
r3502 | else: | ||
|
r7948 | ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch())) | ||
|
r3502 | |||
|
r4675 | def branches(ui, repo, active=False): | ||
|
r3502 | """list repository named branches | ||
|
r4675 | List the repository's named branches, indicating which ones are | ||
|
r6448 | inactive. If active is specified, only show active branches. | ||
|
r4675 | |||
|
r6631 | A branch is considered active if it contains repository heads. | ||
|
r5999 | |||
Use the command 'hg update' to switch to an existing branch. | ||||
|
r3502 | """ | ||
|
r6631 | hexfunc = ui.debugflag and hex or short | ||
|
r7948 | activebranches = [encoding.tolocal(repo[n].branch()) | ||
|
r7656 | for n in repo.heads(closed=False)] | ||
|
r8209 | branches = sorted([(tag in activebranches, repo.changelog.rev(node), tag) | ||
|
r8210 | for tag, node in repo.branchtags().items()], | ||
reverse=True) | ||||
|
r6631 | |||
for isactive, node, tag in branches: | ||||
if (not active) or isactive: | ||||
|
r4675 | if ui.quiet: | ||
|
r6631 | ui.write("%s\n" % tag) | ||
|
r4675 | else: | ||
|
r7656 | hn = repo.lookup(node) | ||
if isactive: | ||||
notice = '' | ||||
elif hn not in repo.branchheads(tag, closed=False): | ||||
notice = ' (closed)' | ||||
else: | ||||
notice = ' (inactive)' | ||||
|
r7948 | rev = str(node).rjust(31 - encoding.colwidth(tag)) | ||
|
r7656 | data = tag, rev, hexfunc(hn), notice | ||
|
r6814 | ui.write("%s %s:%s%s\n" % data) | ||
|
r3502 | |||
|
r2494 | def bundle(ui, repo, fname, dest=None, **opts): | ||
|
r1437 | """create a changegroup file | ||
|
r3511 | Generate a compressed changegroup file collecting changesets not | ||
|
r7807 | known to be in another repository. | ||
|
r3511 | |||
|
r6171 | If no destination repository is specified the destination is | ||
assumed to have all the nodes specified by one or more --base | ||||
|
r6448 | parameters. To create a bundle containing all changesets, use | ||
|
r8033 | -a/--all (or --base null). To change the compression method | ||
applied, use the -t/--type option (by default, bundles are | ||||
compressed using bz2). | ||||
|
r3511 | |||
|
r8004 | The bundle file can then be transferred using conventional means | ||
and applied to another repository with the unbundle or pull | ||||
command. This is useful when direct push and pull are not | ||||
available or when exporting an entire repository is undesirable. | ||||
|
r3511 | |||
Applying bundles preserves all changeset contents including | ||||
permissions, copy/rename information, and revision history. | ||||
|
r1437 | """ | ||
|
r3284 | revs = opts.get('rev') or None | ||
if revs: | ||||
revs = [repo.lookup(rev) for rev in revs] | ||||
|
r6171 | if opts.get('all'): | ||
base = ['null'] | ||||
else: | ||||
base = opts.get('base') | ||||
|
r3284 | if base: | ||
if dest: | ||||
|
r8669 | raise util.Abort(_("--base is incompatible with specifying " | ||
|
r3284 | "a destination")) | ||
|
r3318 | base = [repo.lookup(rev) for rev in base] | ||
# create the right base | ||||
# XXX: nodesbetween / changegroup* should be "fixed" instead | ||||
|
r3284 | o = [] | ||
|
r8464 | has = set((nullid,)) | ||
|
r3284 | for n in base: | ||
|
r3631 | has.update(repo.changelog.reachable(n)) | ||
|
r3284 | if revs: | ||
|
r3318 | visit = list(revs) | ||
|
r3284 | else: | ||
|
r3318 | visit = repo.changelog.heads() | ||
|
r3631 | seen = {} | ||
|
r3318 | while visit: | ||
n = visit.pop(0) | ||||
|
r3631 | parents = [p for p in repo.changelog.parents(n) if p not in has] | ||
|
r3318 | if len(parents) == 0: | ||
o.insert(0, n) | ||||
else: | ||||
|
r3512 | for p in parents: | ||
if p not in seen: | ||||
|
r3631 | seen[p] = 1 | ||
|
r3512 | visit.append(p) | ||
|
r3284 | else: | ||
|
r5248 | dest, revs, checkout = hg.parseurl( | ||
|
r4478 | ui.expandpath(dest or 'default-push', dest or 'default'), revs) | ||
|
r8188 | other = hg.repository(cmdutil.remoteui(repo, opts), dest) | ||
|
r7131 | o = repo.findoutgoing(other, force=opts.get('force')) | ||
|
r3284 | |||
if revs: | ||||
cg = repo.changegroupsubset(o, revs, 'bundle') | ||||
else: | ||||
cg = repo.changegroup(o, 'bundle') | ||||
|
r6570 | |||
bundletype = opts.get('type', 'bzip2').lower() | ||||
btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'} | ||||
bundletype = btypes.get(bundletype) | ||||
if bundletype not in changegroup.bundletypes: | ||||
raise util.Abort(_('unknown bundle type specified with --type')) | ||||
changegroup.writebundle(cg, fname, bundletype) | ||||
|
r1218 | |||
|
r1254 | def cat(ui, repo, file1, *pats, **opts): | ||
|
r3914 | """output the current or given revision of files | ||
|
r1437 | |||
|
r8004 | Print the specified files as they were at the given revision. If | ||
no revision is given, the parent of the working directory is used, | ||||
|
r3915 | or tip if no revision is checked out. | ||
|
r1437 | |||
Output may be to a file, in which case the name of the file is | ||||
|
r6448 | given using a format string. The formatting rules are the same as | ||
|
r1437 | for the export command, with the following additions: | ||
%s basename of file being printed | ||||
|
r8027 | %d dirname of file being printed, or '.' if in repository root | ||
|
r1437 | %p root-relative path name of file being printed | ||
""" | ||||
|
r7131 | ctx = repo[opts.get('rev')] | ||
|
r4697 | err = 1 | ||
|
r6579 | m = cmdutil.match(repo, (file1,) + pats, opts) | ||
|
r6764 | for abs in ctx.walk(m): | ||
|
r7131 | fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs) | ||
|
r6764 | data = ctx[abs].data() | ||
|
r6094 | if opts.get('decode'): | ||
|
r6093 | data = repo.wwritedata(abs, data) | ||
fp.write(data) | ||||
|
r4697 | err = 0 | ||
return err | ||||
|
r248 | |||
|
r698 | def clone(ui, source, dest=None, **opts): | ||
|
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. | ||||
|
r8033 | If you use the -r/--rev option to clone up to a specific revision, | ||
no subsequent revisions (including subsequent tags) will be | ||||
present in the cloned repository. This option implies --pull, even | ||||
on local repositories. | ||||
|
r7942 | |||
By default, clone will check out the head of the 'default' branch. | ||||
|
r8033 | If the -U/--noupdate option is used, the new clone will contain | ||
only a repository (.hg) and no working copy (the working copy | ||||
parent is the null revision). | ||||
|
r7942 | |||
See 'hg help urls' for valid source format details. | ||||
It is possible to specify an ssh:// URL as the destination, but no | ||||
.hg/hgrc and working directory will be created on the remote side. | ||||
|
r8779 | Please see 'hg help urls' for important details about ssh:// URLs. | ||
|
r7942 | |||
|
r1437 | For efficiency, hardlinks are used for cloning whenever the source | ||
|
r2762 | and destination are on the same filesystem (note this applies only | ||
|
r6448 | to the repository data, not to the checked out files). Some | ||
|
r2762 | filesystems, such as AFS, implement hardlinking incorrectly, but | ||
|
r6448 | do not report errors. In these cases, use the --pull option to | ||
|
r2762 | avoid hardlinking. | ||
|
r6509 | In some cases, you can clone repositories and checked out files | ||
using full hardlinks with | ||||
|
r2762 | |||
$ cp -al REPO REPOCLONE | ||||
|
r7983 | This is the fastest way to clone, but it is not always safe. The | ||
|
r6509 | 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 | ||||
|
r7983 | breaks hardlinks (Emacs and most Linux Kernel tools do so). Also, | ||
|
r6509 | this is not compatible with certain extensions that place their | ||
metadata under the .hg directory, such as mq. | ||||
|
r1811 | |||
|
r1437 | """ | ||
|
r8188 | hg.clone(cmdutil.remoteui(ui, opts), source, dest, | ||
|
r7131 | pull=opts.get('pull'), | ||
stream=opts.get('uncompressed'), | ||||
rev=opts.get('rev'), | ||||
update=not opts.get('noupdate')) | ||||
|
r515 | |||
|
r813 | def commit(ui, repo, *pats, **opts): | ||
|
r1437 | """commit the specified files or all outstanding changes | ||
|
r7983 | Commit changes to the given files into the repository. Unlike a | ||
centralized RCS, this operation is a local operation. See hg push | ||||
|
r8779 | for a way to actively distribute your changes. | ||
|
r1437 | |||
If a list of files is omitted, all changes reported by "hg status" | ||||
|
r1995 | will be committed. | ||
|
r1437 | |||
|
r6385 | If you are committing the result of a merge, do not provide any | ||
|
r8761 | filenames or -I/-X filters. | ||
|
r6385 | |||
|
r8004 | If no commit message is specified, the configured editor is | ||
started to prompt you for a message. | ||||
|
r6163 | |||
See 'hg help dates' for a list of formats valid for -d/--date. | ||||
|
r1437 | """ | ||
|
r7655 | extra = {} | ||
if opts.get('close_branch'): | ||||
extra['close'] = 1 | ||||
|
r8407 | e = cmdutil.commiteditor | ||
if opts.get('force_editor'): | ||||
e = cmdutil.commitforceeditor | ||||
|
r6600 | def commitfunc(ui, repo, message, match, opts): | ||
|
r8706 | return repo.commit(message, opts.get('user'), opts.get('date'), match, | ||
editor=e, extra=extra) | ||||
|
r6336 | |||
|
r6369 | node = cmdutil.commit(ui, repo, commitfunc, pats, opts) | ||
if not node: | ||||
return | ||||
cl = repo.changelog | ||||
rev = cl.rev(node) | ||||
parents = cl.parentrevs(rev) | ||||
if rev - 1 in parents: | ||||
# one of the parents was the old tip | ||||
|
r6935 | pass | ||
elif (parents == (nullrev, nullrev) or | ||||
len(cl.heads(cl.node(parents[0]))) > 1 and | ||||
(parents[1] == nullrev or len(cl.heads(cl.node(parents[1]))) > 1)): | ||||
|
r6336 | ui.status(_('created new head\n')) | ||
|
r245 | |||
|
r6935 | if ui.debugflag: | ||
ui.write(_('committed changeset %d:%s\n') % (rev,hex(node))) | ||||
elif ui.verbose: | ||||
ui.write(_('committed changeset %d:%s\n') % (rev,short(node))) | ||||
|
r1253 | def copy(ui, repo, *pats, **opts): | ||
|
r1437 | """mark files as copied for the next commit | ||
|
r6448 | Mark dest as having copies of source files. If dest is a | ||
directory, copies are put in that directory. If dest is a file, | ||||
|
r7807 | the source must be a single file. | ||
|
r1437 | |||
By default, this command copies the contents of files as they | ||||
|
r8779 | exist in the working directory. If invoked with -A/--after, the | ||
|
r1437 | operation is recorded, but no copying is performed. | ||
|
r7807 | This command takes effect with the next commit. To undo a copy | ||
|
r3829 | before that, see hg revert. | ||
|
r1437 | """ | ||
|
r4914 | wlock = repo.wlock(False) | ||
|
r4915 | try: | ||
|
r5610 | return cmdutil.copy(ui, repo, pats, opts) | ||
|
r4915 | finally: | ||
|
r8109 | wlock.release() | ||
|
r363 | |||
|
r6189 | def debugancestor(ui, repo, *args): | ||
|
r1262 | """find the ancestor revision of two revisions in a given index""" | ||
|
r6188 | if len(args) == 3: | ||
index, rev1, rev2 = args | ||||
|
r6178 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), index) | ||
|
r6253 | lookup = r.lookup | ||
|
r6188 | elif len(args) == 2: | ||
|
r6189 | if not repo: | ||
raise util.Abort(_("There is no Mercurial repository here " | ||||
"(.hg not found)")) | ||||
|
r6188 | rev1, rev2 = args | ||
|
r6178 | r = repo.changelog | ||
|
r6253 | lookup = repo.lookup | ||
|
r6178 | else: | ||
raise util.Abort(_('either two or three arguments required')) | ||||
|
r6253 | a = r.ancestor(lookup(rev1), lookup(rev2)) | ||
|
r1262 | ui.write("%d:%s\n" % (r.rev(a), hex(a))) | ||
|
r7880 | def debugcommands(ui, cmd='', *args): | ||
|
r8209 | for cmd, vals in sorted(table.iteritems()): | ||
|
r7880 | cmd = cmd.split('|')[0].strip('^') | ||
opts = ', '.join([i[1] for i in vals[1]]) | ||||
ui.write('%s: %s\n' % (cmd, opts)) | ||||
|
r2034 | def debugcomplete(ui, cmd='', **opts): | ||
|
r1887 | """returns the completion list associated with the given command""" | ||
|
r2034 | |||
|
r7131 | if opts.get('options'): | ||
|
r2034 | options = [] | ||
otables = [globalopts] | ||||
if cmd: | ||||
|
r7213 | aliases, entry = cmdutil.findcmd(cmd, table, False) | ||
|
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 | ||||
|
r7509 | cmdlist = cmdutil.findpossible(cmd, table) | ||
if ui.verbose: | ||||
cmdlist = [' '.join(c[0]) for c in cmdlist.values()] | ||||
|
r8209 | ui.write("%s\n" % "\n".join(sorted(cmdlist))) | ||
|
r1887 | |||
|
r5741 | def debugfsinfo(ui, path = "."): | ||
file('.debugfsinfo', 'w').write('') | ||||
ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no')) | ||||
ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no')) | ||||
|
r6746 | ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo') | ||
|
r5741 | and 'yes' or 'no')) | ||
os.unlink('.debugfsinfo') | ||||
|
r6747 | def debugrebuildstate(ui, repo, rev="tip"): | ||
|
r1755 | """rebuild the dirstate as it would look like for the given revision""" | ||
|
r6747 | ctx = repo[rev] | ||
|
r1760 | wlock = repo.wlock() | ||
|
r4915 | try: | ||
|
r6747 | repo.dirstate.rebuild(ctx.node(), ctx.manifest()) | ||
|
r4915 | finally: | ||
|
r8109 | wlock.release() | ||
|
r1755 | |||
|
r596 | def debugcheckstate(ui, repo): | ||
"""validate the correctness of the current dirstate""" | ||||
|
r460 | parent1, parent2 = repo.dirstate.parents() | ||
|
r6747 | m1 = repo[parent1].manifest() | ||
m2 = repo[parent2].manifest() | ||||
|
r460 | errors = 0 | ||
|
r4906 | for f in repo.dirstate: | ||
state = repo.dirstate[f] | ||||
|
r460 | if state in "nr" and f not in m1: | ||
|
r1402 | ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state)) | ||
|
r460 | errors += 1 | ||
if state in "a" and f in m1: | ||||
|
r1402 | ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state)) | ||
|
r460 | errors += 1 | ||
if state in "m" and f not in m1 and f not in m2: | ||||
|
r1402 | ui.warn(_("%s in state %s, but not in either manifest\n") % | ||
|
r582 | (f, state)) | ||
|
r460 | errors += 1 | ||
for f in m1: | ||||
|
r4906 | state = repo.dirstate[f] | ||
|
r460 | if state not in "nrm": | ||
|
r1402 | ui.warn(_("%s in manifest1, but listed as state %s") % (f, state)) | ||
|
r460 | errors += 1 | ||
if errors: | ||||
|
r1602 | error = _(".hg/dirstate inconsistent with current parent's manifest") | ||
raise util.Abort(error) | ||||
|
r460 | |||
|
r3553 | def showconfig(ui, repo, *values, **opts): | ||
|
r2410 | """show combined config settings from all hgrc files | ||
|
r8664 | With no arguments, print names and values of all config items. | ||
With one argument of the form section.name, print just the value | ||||
of that config item. | ||||
With multiple arguments, print names and values of all config | ||||
items with matching section names. | ||||
|
r8279 | |||
|
r8779 | With --debug, the source (filename and line number) is printed | ||
for each config item. | ||||
|
r8279 | """ | ||
|
r2410 | |||
|
r3553 | untrusted = bool(opts.get('untrusted')) | ||
|
r2410 | if values: | ||
if len([v for v in values if '.' in v]) > 1: | ||||
raise util.Abort(_('only one config item permitted')) | ||||
|
r3553 | for section, name, value in ui.walkconfig(untrusted=untrusted): | ||
|
r2410 | sectname = section + '.' + name | ||
if values: | ||||
for v in values: | ||||
if v == section: | ||||
|
r8182 | ui.debug('%s: ' % | ||
ui.configsource(section, name, untrusted)) | ||||
|
r2410 | ui.write('%s=%s\n' % (sectname, value)) | ||
elif v == sectname: | ||||
|
r8182 | ui.debug('%s: ' % | ||
ui.configsource(section, name, untrusted)) | ||||
|
r2410 | ui.write(value, '\n') | ||
else: | ||||
|
r8182 | ui.debug('%s: ' % | ||
ui.configsource(section, name, untrusted)) | ||||
|
r2410 | ui.write('%s=%s\n' % (sectname, value)) | ||
|
r1028 | |||
|
r1395 | def debugsetparents(ui, repo, rev1, rev2=None): | ||
|
r1470 | """manually set the parents of the current working directory | ||
|
r1395 | |||
This is useful for writing repository conversion tools, but should | ||||
be used with care. | ||||
""" | ||||
if not rev2: | ||||
rev2 = hex(nullid) | ||||
|
r4247 | wlock = repo.wlock() | ||
try: | ||||
repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2)) | ||||
finally: | ||||
|
r8109 | wlock.release() | ||
|
r1395 | |||
|
r6296 | def debugstate(ui, repo, nodates=None): | ||
|
r596 | """show the contents of the current dirstate""" | ||
|
r6296 | timestr = "" | ||
showdate = not nodates | ||||
|
r8209 | for file_, ent in sorted(repo.dirstate._map.iteritems()): | ||
|
r6296 | if showdate: | ||
if ent[3] == -1: | ||||
# Pad or slice to locale representation | ||||
locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(0))) | ||||
timestr = 'unset' | ||||
timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr)) | ||||
else: | ||||
timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(ent[3])) | ||||
|
r5156 | if ent[1] & 020000: | ||
mode = 'lnk' | ||||
else: | ||||
mode = '%3o' % (ent[1] & 0777) | ||||
|
r6296 | ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_)) | ||
|
r3159 | for f in repo.dirstate.copies(): | ||
ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f)) | ||||
|
r460 | |||
|
r1039 | def debugdata(ui, file_, rev): | ||
|
r4258 | """dump the contents of a data file revision""" | ||
r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i") | ||||
|
r1313 | try: | ||
ui.write(r.revision(r.lookup(rev))) | ||||
except KeyError: | ||||
|
r3072 | raise util.Abort(_('invalid revision identifier %s') % rev) | ||
|
r1039 | |||
|
r3812 | def debugdate(ui, date, range=None, **opts): | ||
|
r3805 | """parse and display a date""" | ||
|
r3812 | if opts["extended"]: | ||
d = util.parsedate(date, util.extendeddateformats) | ||||
else: | ||||
d = util.parsedate(date) | ||||
|
r3805 | ui.write("internal: %s %s\n" % d) | ||
ui.write("standard: %s\n" % util.datestr(d)) | ||||
|
r3812 | if range: | ||
m = util.matchdate(range) | ||||
ui.write("match: %s\n" % m(d[0])) | ||||
|
r3805 | |||
|
r697 | def debugindex(ui, file_): | ||
|
r596 | """dump the contents of an index file""" | ||
|
r4258 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) | ||
|
r7737 | ui.write(" rev offset length base linkrev" | ||
|
r989 | " nodeid p1 p2\n") | ||
|
r6750 | for i in r: | ||
|
r2072 | node = r.node(i) | ||
|
r5311 | try: | ||
pp = r.parents(node) | ||||
except: | ||||
pp = [nullid, nullid] | ||||
|
r989 | ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % ( | ||
|
r7361 | i, r.start(i), r.length(i), r.base(i), r.linkrev(i), | ||
|
r2072 | short(node), short(pp[0]), short(pp[1]))) | ||
|
r248 | |||
|
r697 | def debugindexdot(ui, file_): | ||
|
r8779 | """dump an index DAG as a graphviz dot file""" | ||
|
r4258 | r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) | ||
|
r582 | ui.write("digraph G {\n") | ||
|
r6750 | for i in r: | ||
|
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)) | ||||
|
r582 | ui.write("}\n") | ||
|
r248 | |||
|
r3844 | def debuginstall(ui): | ||
'''test Mercurial installation''' | ||||
|
r3846 | def writetemp(contents): | ||
|
r4849 | (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-") | ||
|
r3846 | f = os.fdopen(fd, "wb") | ||
f.write(contents) | ||||
f.close() | ||||
return name | ||||
|
r3844 | problems = 0 | ||
# encoding | ||||
|
r7948 | ui.status(_("Checking encoding (%s)...\n") % encoding.encoding) | ||
|
r3844 | try: | ||
|
r7948 | encoding.fromlocal("test") | ||
|
r3844 | except util.Abort, inst: | ||
ui.write(" %s\n" % inst) | ||||
|
r3848 | ui.write(_(" (check that your locale is properly set)\n")) | ||
|
r3844 | problems += 1 | ||
# compiled modules | ||||
ui.status(_("Checking extensions...\n")) | ||||
try: | ||||
import bdiff, mpatch, base85 | ||||
except Exception, inst: | ||||
ui.write(" %s\n" % inst) | ||||
|
r3848 | ui.write(_(" One or more extensions could not be found")) | ||
ui.write(_(" (check that you compiled the extensions)\n")) | ||||
|
r3844 | problems += 1 | ||
# templates | ||||
ui.status(_("Checking templates...\n")) | ||||
try: | ||||
import templater | ||||
|
r7874 | templater.templater(templater.templatepath("map-cmdline.default")) | ||
|
r3844 | except Exception, inst: | ||
ui.write(" %s\n" % inst) | ||||
|
r3848 | ui.write(_(" (templates seem to have been installed incorrectly)\n")) | ||
|
r3844 | problems += 1 | ||
# patch | ||||
ui.status(_("Checking patch...\n")) | ||||
|
r5310 | patchproblems = 0 | ||
a = "1\n2\n3\n4\n" | ||||
b = "1\n2\n3\ninsert\n4\n" | ||||
fa = writetemp(a) | ||||
|
r5482 | d = mdiff.unidiff(a, None, b, None, os.path.basename(fa), | ||
os.path.basename(fa)) | ||||
|
r5310 | fd = writetemp(d) | ||
files = {} | ||||
try: | ||||
patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files) | ||||
except util.Abort, e: | ||||
ui.write(_(" patch call failed:\n")) | ||||
ui.write(" " + str(e) + "\n") | ||||
patchproblems += 1 | ||||
|
r3846 | else: | ||
|
r5310 | if list(files) != [os.path.basename(fa)]: | ||
ui.write(_(" unexpected patch output!\n")) | ||||
patchproblems += 1 | ||||
a = file(fa).read() | ||||
if a != b: | ||||
ui.write(_(" patch test failed!\n")) | ||||
patchproblems += 1 | ||||
if patchproblems: | ||||
if ui.config('ui', 'patch'): | ||||
ui.write(_(" (Current patch tool may be incompatible with patch," | ||||
" or misconfigured. Please check your .hgrc file)\n")) | ||||
|
r4516 | else: | ||
|
r5760 | ui.write(_(" Internal patcher failure, please report this error" | ||
|
r5310 | " to http://www.selenic.com/mercurial/bts\n")) | ||
problems += patchproblems | ||||
os.unlink(fa) | ||||
os.unlink(fd) | ||||
|
r3844 | |||
# editor | ||||
ui.status(_("Checking commit editor...\n")) | ||||
|
r5660 | editor = ui.geteditor() | ||
|
r4488 | cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0]) | ||
|
r3844 | if not cmdpath: | ||
|
r3855 | if editor == 'vi': | ||
|
r3844 | ui.write(_(" No commit editor set and can't find vi in PATH\n")) | ||
|
r3848 | ui.write(_(" (specify a commit editor in your .hgrc file)\n")) | ||
|
r3844 | else: | ||
ui.write(_(" Can't find editor '%s' in PATH\n") % editor) | ||||
|
r3848 | ui.write(_(" (specify a commit editor in your .hgrc file)\n")) | ||
|
r3844 | problems += 1 | ||
|
r3848 | # check username | ||
ui.status(_("Checking username...\n")) | ||||
user = os.environ.get("HGUSER") | ||||
if user is None: | ||||
user = ui.config("ui", "username") | ||||
if user is None: | ||||
user = os.environ.get("EMAIL") | ||||
if not user: | ||||
ui.warn(" ") | ||||
ui.username() | ||||
ui.write(_(" (specify a username in your .hgrc file)\n")) | ||||
|
r3844 | if not problems: | ||
ui.status(_("No problems detected\n")) | ||||
else: | ||||
ui.write(_("%s problems detected," | ||||
" please check your install!\n") % problems) | ||||
return problems | ||||
|
r3652 | def debugrename(ui, repo, file1, *pats, **opts): | ||
|
r1194 | """dump rename information""" | ||
|
r3652 | |||
|
r6748 | ctx = repo[opts.get('rev')] | ||
|
r6579 | m = cmdutil.match(repo, (file1,) + pats, opts) | ||
|
r6764 | for abs in ctx.walk(m): | ||
fctx = ctx[abs] | ||||
|
r6579 | o = fctx.filelog().renamed(fctx.filenode()) | ||
|
r6584 | rel = m.rel(abs) | ||
|
r6579 | if o: | ||
ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1]))) | ||||
|
r3652 | else: | ||
ui.write(_("%s not renamed\n") % rel) | ||||
|
r1116 | |||
|
r820 | def debugwalk(ui, repo, *pats, **opts): | ||
|
r1053 | """show how files match on given patterns""" | ||
|
r6579 | m = cmdutil.match(repo, pats, opts) | ||
|
r6585 | items = list(repo.walk(m)) | ||
|
r1065 | if not items: | ||
return | ||||
|
r6586 | fmt = 'f %%-%ds %%-%ds %%s' % ( | ||
max([len(abs) for abs in items]), | ||||
max([len(m.rel(abs)) for abs in items])) | ||||
for abs in items: | ||||
line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '') | ||||
|
r1309 | ui.write("%s\n" % line.rstrip()) | ||
|
r820 | |||
|
r732 | def diff(ui, repo, *pats, **opts): | ||
|
r1568 | """diff repository (or selected files) | ||
|
r1437 | |||
Show differences between revisions for the specified files. | ||||
Differences between files are shown using the unified diff format. | ||||
|
r3822 | NOTE: diff may generate unexpected results for merges, as it will | ||
default to comparing against the working directory's first parent | ||||
changeset if no revisions are specified. | ||||
|
r1437 | When two revision arguments are given, then changes are shown | ||
between those revisions. If only one revision is specified then | ||||
that revision is compared to the working directory, and, when no | ||||
revisions are specified, the working directory files are compared | ||||
to its parent. | ||||
|
r8033 | Without the -a/--text option, diff will avoid generating diffs of | ||
files it detects as binary. With -a, diff will generate a diff | ||||
anyway, probably with undesirable results. | ||||
Use the -g/--git option to generate diffs in the git extended diff | ||||
|
r7974 | format. For more information, read 'hg help diffs'. | ||
|
r1437 | """ | ||
|
r7628 | |||
revs = opts.get('rev') | ||||
change = opts.get('change') | ||||
if revs and change: | ||||
msg = _('cannot specify --rev and --change at the same time') | ||||
raise util.Abort(msg) | ||||
elif change: | ||||
node2 = repo.lookup(change) | ||||
node1 = repo[node2].parents()[0].node() | ||||
else: | ||||
node1, node2 = cmdutil.revpair(repo, revs) | ||||
|
r245 | |||
|
r6582 | m = cmdutil.match(repo, pats, opts) | ||
|
r7308 | it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts)) | ||
for chunk in it: | ||||
|
r8615 | ui.write(chunk) | ||
|
r396 | |||
|
r580 | def export(ui, repo, *changesets, **opts): | ||
|
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, | ||||
|
r3822 | changeset hash, parent(s) and commit comment. | ||
|
r8004 | NOTE: export may generate unexpected diff output for merge | ||
changesets, as it will compare the merge changeset against its | ||||
first parent only. | ||||
|
r1437 | |||
Output may be to a file, in which case the name of the file is | ||||
|
r6448 | given using a format string. The formatting rules are as follows: | ||
|
r1437 | |||
%% 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 | ||||
|
r8033 | Without the -a/--text option, export will avoid generating diffs | ||
of files it detects as binary. With -a, export will generate a | ||||
diff anyway, probably with undesirable results. | ||||
Use the -g/--git option to generate diffs in the git extended diff | ||||
|
r8779 | format. See 'hg help diffs' for more information. | ||
|
r7307 | |||
|
r8004 | With the --switch-parent option, the diff will be against the | ||
second parent. It can be useful to review a merge. | ||||
|
r1437 | """ | ||
|
r610 | if not changesets: | ||
|
r1402 | raise util.Abort(_("export requires at least one changeset")) | ||
|
r3707 | revs = cmdutil.revrange(repo, changesets) | ||
|
r2874 | if len(revs) > 1: | ||
ui.note(_('exporting patches:\n')) | ||||
else: | ||||
ui.note(_('exporting patch:\n')) | ||||
|
r7131 | patch.export(repo, revs, template=opts.get('output'), | ||
switch_parent=opts.get('switch_parent'), | ||||
|
r2888 | opts=patch.diffopts(ui, opts)) | ||
|
r246 | |||
|
r1108 | def grep(ui, repo, pattern, *pats, **opts): | ||
|
r1437 | """search for a pattern in specified files and revisions | ||
Search revisions of files for a regular expression. | ||||
|
r6448 | This command behaves differently than Unix grep. It only accepts | ||
Python/Perl regexps. It searches repository history, not the | ||||
|
r8004 | working directory. It always prints the revision number in which a | ||
match appears. | ||||
|
r1437 | |||
By default, grep only prints output for the first revision of a | ||||
|
r6448 | file in which it finds a match. To get it to print every revision | ||
|
r1437 | that contains a change in match status ("-" for a match that | ||
becomes a non-match, or "+" for a non-match that becomes a match), | ||||
use the --all flag. | ||||
""" | ||||
|
r1057 | reflags = 0 | ||
|
r7131 | if opts.get('ignore_case'): | ||
|
r1065 | reflags |= re.I | ||
|
r4877 | try: | ||
regexp = re.compile(pattern, reflags) | ||||
except Exception, inst: | ||||
|
r6057 | ui.warn(_("grep: invalid match pattern: %s\n") % inst) | ||
|
r4877 | return None | ||
|
r1146 | sep, eol = ':', '\n' | ||
|
r7131 | if opts.get('print0'): | ||
|
r1146 | sep = eol = '\0' | ||
|
r1057 | |||
fcache = {} | ||||
|
r8408 | forder = [] | ||
|
r1057 | def getfile(fn): | ||
if fn not in fcache: | ||||
|
r8408 | if len(fcache) > 20: | ||
del fcache[forder.pop(0)] | ||||
|
r1057 | fcache[fn] = repo.file(fn) | ||
|
r8408 | else: | ||
forder.remove(fn) | ||||
forder.append(fn) | ||||
|
r1057 | return fcache[fn] | ||
def matchlines(body): | ||||
|
r1059 | begin = 0 | ||
linenum = 0 | ||||
while True: | ||||
match = regexp.search(body, begin) | ||||
|
r1065 | if not match: | ||
break | ||||
|
r1059 | mstart, mend = match.span() | ||
linenum += body.count('\n', begin, mstart) + 1 | ||||
lstart = body.rfind('\n', begin, mstart) + 1 or begin | ||||
|
r7230 | begin = body.find('\n', mend) + 1 or len(body) | ||
lend = begin - 1 | ||||
|
r1059 | yield linenum, mstart - lstart, mend - lstart, body[lstart:lend] | ||
|
r1057 | |||
|
r1559 | class linestate(object): | ||
|
r1057 | def __init__(self, line, linenum, colstart, colend): | ||
self.line = line | ||||
self.linenum = linenum | ||||
self.colstart = colstart | ||||
self.colend = colend | ||||
|
r2869 | |||
|
r6469 | def __hash__(self): | ||
return hash((self.linenum, self.line)) | ||||
|
r1065 | def __eq__(self, other): | ||
return self.line == other.line | ||||
|
r1057 | |||
matches = {} | ||||
|
r2870 | copies = {} | ||
|
r1057 | def grepbody(fn, rev, body): | ||
|
r2869 | matches[rev].setdefault(fn, []) | ||
|
r1057 | m = matches[rev][fn] | ||
for lnum, cstart, cend, line in matchlines(body): | ||||
s = linestate(line, lnum, cstart, cend) | ||||
|
r2869 | m.append(s) | ||
def difflinestates(a, b): | ||||
sm = difflib.SequenceMatcher(None, a, b) | ||||
for tag, alo, ahi, blo, bhi in sm.get_opcodes(): | ||||
if tag == 'insert': | ||||
|
r3472 | for i in xrange(blo, bhi): | ||
|
r2869 | yield ('+', b[i]) | ||
elif tag == 'delete': | ||||
|
r3472 | for i in xrange(alo, ahi): | ||
|
r2869 | yield ('-', a[i]) | ||
elif tag == 'replace': | ||||
|
r3472 | for i in xrange(alo, ahi): | ||
|
r2869 | yield ('-', a[i]) | ||
|
r3472 | for i in xrange(blo, bhi): | ||
|
r2869 | yield ('+', b[i]) | ||
|
r1057 | prev = {} | ||
def display(fn, rev, states, prevstates): | ||||
|
r6134 | datefunc = ui.quiet and util.shortdate or util.datestr | ||
|
r3951 | found = False | ||
|
r1146 | filerevmatches = {} | ||
|
r3951 | r = prev.get(fn, -1) | ||
|
r7131 | if opts.get('all'): | ||
|
r3951 | iter = difflinestates(states, prevstates) | ||
|
r2869 | else: | ||
|
r3951 | iter = [('', l) for l in prevstates] | ||
for change, l in iter: | ||||
|
r2869 | cols = [fn, str(r)] | ||
|
r7131 | if opts.get('line_number'): | ||
|
r1615 | cols.append(str(l.linenum)) | ||
|
r7131 | if opts.get('all'): | ||
|
r1615 | cols.append(change) | ||
|
r7131 | if opts.get('user'): | ||
|
r3650 | cols.append(ui.shortuser(get(r)[1])) | ||
|
r6133 | if opts.get('date'): | ||
|
r6134 | cols.append(datefunc(get(r)[2])) | ||
|
r7131 | if opts.get('files_with_matches'): | ||
|
r3523 | c = (fn, r) | ||
|
r1615 | if c in filerevmatches: | ||
continue | ||||
|
r1146 | filerevmatches[c] = 1 | ||
else: | ||||
cols.append(l.line) | ||||
ui.write(sep.join(cols), eol) | ||||
|
r3951 | found = True | ||
return found | ||||
|
r1057 | |||
fstate = {} | ||||
|
r1145 | skip = {} | ||
|
r6747 | get = util.cachefunc(lambda r: repo[r].changeset()) | ||
|
r3650 | changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) | ||
|
r3951 | found = False | ||
|
r2870 | follow = opts.get('follow') | ||
|
r1146 | for st, rev, fns in changeiter: | ||
|
r1057 | if st == 'window': | ||
matches.clear() | ||||
elif st == 'add': | ||||
|
r6747 | ctx = repo[rev] | ||
|
r1057 | matches[rev] = {} | ||
for fn in fns: | ||||
|
r1615 | if fn in skip: | ||
continue | ||||
|
r1057 | try: | ||
|
r6146 | grepbody(fn, rev, getfile(fn).read(ctx.filenode(fn))) | ||
|
r5105 | fstate.setdefault(fn, []) | ||
|
r2870 | if follow: | ||
|
r6146 | copied = getfile(fn).renamed(ctx.filenode(fn)) | ||
|
r2870 | if copied: | ||
|
r2931 | copies.setdefault(rev, {})[fn] = copied[0] | ||
|
r7633 | except error.LookupError: | ||
|
r1057 | pass | ||
elif st == 'iter': | ||||
|
r8209 | for fn, m in sorted(matches[rev].items()): | ||
|
r2931 | copy = copies.get(rev, {}).get(fn) | ||
|
r1615 | if fn in skip: | ||
|
r2870 | if copy: | ||
skip[copy] = True | ||||
|
r1615 | continue | ||
|
r3951 | if fn in prev or fstate[fn]: | ||
r = display(fn, rev, m, fstate[fn]) | ||||
found = found or r | ||||
|
r7131 | if r and not opts.get('all'): | ||
|
r1145 | skip[fn] = True | ||
|
r2870 | if copy: | ||
skip[copy] = True | ||||
|
r1057 | fstate[fn] = m | ||
|
r2870 | if copy: | ||
fstate[copy] = m | ||||
|
r1057 | prev[fn] = rev | ||
|
r8209 | for fn, state in sorted(fstate.items()): | ||
|
r3950 | if fn in skip: | ||
continue | ||||
if fn not in copies.get(prev[fn], {}): | ||||
|
r3951 | found = display(fn, rev, {}, state) or found | ||
return (not found and 1) or 0 | ||||
|
r1057 | |||
|
r4648 | def heads(ui, repo, *branchrevs, **opts): | ||
"""show current repository heads or show branch heads | ||||
With no arguments, show all repository head changesets. | ||||
|
r8779 | If branch names or revisions are given this will show the heads of | ||
|
r4648 | the specified branches or the branches those revisions are tagged | ||
with. | ||||
Repository "heads" are changesets that don't have child | ||||
|
r1437 | changesets. They are where development generally takes place and | ||
are the usual targets for update and merge operations. | ||||
|
r4648 | |||
Branch heads are changesets that have a given branch tag, but have | ||||
|
r6448 | no child changesets with that tag. They are usually where | ||
|
r8779 | development on a given branch takes place. | ||
|
r1437 | """ | ||
|
r7131 | if opts.get('rev'): | ||
|
r4648 | start = repo.lookup(opts['rev']) | ||
else: | ||||
start = None | ||||
|
r8695 | closed = opts.get('closed') | ||
hideinactive, _heads = opts.get('active'), None | ||||
|
r4648 | if not branchrevs: | ||
# Assume we're looking repo-wide heads if no revs were specified. | ||||
|
r7656 | heads = repo.heads(start, closed=closed) | ||
|
r1550 | else: | ||
|
r8695 | if hideinactive: | ||
_heads = repo.heads(start, closed=closed) | ||||
|
r4648 | heads = [] | ||
|
r8150 | visitedset = set() | ||
|
r4648 | for branchrev in branchrevs: | ||
|
r6747 | branch = repo[branchrev].branch() | ||
|
r4648 | if branch in visitedset: | ||
continue | ||||
visitedset.add(branch) | ||||
|
r7656 | bheads = repo.branchheads(branch, start, closed=closed) | ||
|
r4648 | if not bheads: | ||
if branch != branchrev: | ||||
ui.warn(_("no changes on branch %s containing %s are " | ||||
"reachable from %s\n") | ||||
|
r7131 | % (branch, branchrev, opts.get('rev'))) | ||
|
r4648 | else: | ||
ui.warn(_("no changes on branch %s are reachable from %s\n") | ||||
|
r7131 | % (branch, opts.get('rev'))) | ||
|
r8695 | if hideinactive: | ||
bheads = [bhead for bhead in bheads if bhead in _heads] | ||||
|
r4648 | heads.extend(bheads) | ||
if not heads: | ||||
return 1 | ||||
|
r3643 | displayer = cmdutil.show_changeset(ui, repo, opts) | ||
|
r1550 | for n in heads: | ||
|
r7369 | displayer.show(repo[n]) | ||
|
r221 | |||
|
r3655 | def help_(ui, name=None, with_version=False): | ||
|
r7210 | """show help for a given topic or a help overview | ||
|
r3655 | |||
|
r8779 | With no arguments, print a list of commands with short help messages. | ||
|
r3655 | |||
|
r8004 | Given a topic, extension, or command name, print help for that | ||
topic.""" | ||||
|
r3655 | option_lists = [] | ||
|
r4315 | def addglobalopts(aliases): | ||
if ui.verbose: | ||||
option_lists.append((_("global options:"), globalopts)) | ||||
if name == 'shortlist': | ||||
option_lists.append((_('use "hg help" for the full list ' | ||||
'of commands'), ())) | ||||
else: | ||||
if name == 'shortlist': | ||||
msg = _('use "hg help" for the full list of commands ' | ||||
'or "hg -v" for details') | ||||
elif aliases: | ||||
msg = _('use "hg -v help%s" to show aliases and ' | ||||
'global options') % (name and " " + name or "") | ||||
else: | ||||
msg = _('use "hg -v help %s" to show global options') % name | ||||
option_lists.append((msg, ())) | ||||
|
r3655 | def helpcmd(name): | ||
if with_version: | ||||
version_(ui) | ||||
ui.write('\n') | ||||
|
r6652 | |||
try: | ||||
|
r7213 | aliases, i = cmdutil.findcmd(name, table, False) | ||
|
r7643 | except error.AmbiguousCommand, inst: | ||
|
r6652 | select = lambda c: c.lstrip('^').startswith(inst.args[0]) | ||
helplist(_('list of commands:\n\n'), select) | ||||
return | ||||
|
r3655 | # synopsis | ||
|
r7364 | if len(i) > 2: | ||
if i[2].startswith('hg'): | ||||
ui.write("%s\n" % i[2]) | ||||
else: | ||||
ui.write('hg %s %s\n' % (aliases[0], i[2])) | ||||
else: | ||||
ui.write('hg %s\n' % aliases[0]) | ||||
|
r5783 | |||
# aliases | ||||
if not ui.quiet and len(aliases) > 1: | ||||
ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:])) | ||||
|
r3655 | |||
# description | ||||
|
r7013 | doc = gettext(i[0].__doc__) | ||
|
r3655 | if not doc: | ||
|
r7598 | doc = _("(no help text available)") | ||
|
r3655 | if ui.quiet: | ||
doc = doc.splitlines(0)[0] | ||||
|
r5783 | ui.write("\n%s\n" % doc.rstrip()) | ||
|
r3655 | |||
if not ui.quiet: | ||||
# options | ||||
if i[1]: | ||||
|
r4315 | option_lists.append((_("options:\n"), i[1])) | ||
addglobalopts(False) | ||||
|
r3655 | |||
|
r4950 | def helplist(header, select=None): | ||
|
r3655 | h = {} | ||
cmds = {} | ||||
|
r7622 | for c, e in table.iteritems(): | ||
|
r3655 | f = c.split("|", 1)[0] | ||
if select and not select(f): | ||||
continue | ||||
|
r7197 | if (not select and name != 'shortlist' and | ||
e[0].__module__ != __name__): | ||||
|
r7126 | continue | ||
|
r3655 | if name == "shortlist" and not f.startswith("^"): | ||
continue | ||||
f = f.lstrip("^") | ||||
if not ui.debugflag and f.startswith("debug"): | ||||
continue | ||||
|
r7013 | doc = gettext(e[0].__doc__) | ||
|
r3655 | if not doc: | ||
|
r7598 | doc = _("(no help text available)") | ||
|
r3655 | h[f] = doc.splitlines(0)[0].rstrip() | ||
cmds[f] = c.lstrip("^") | ||||
|
r4950 | if not h: | ||
ui.status(_('no commands defined\n')) | ||||
return | ||||
ui.status(header) | ||||
|
r8209 | fns = sorted(h) | ||
|
r3655 | m = max(map(len, fns)) | ||
for f in fns: | ||||
if ui.verbose: | ||||
commands = cmds[f].replace("|",", ") | ||||
ui.write(" %s:\n %s\n"%(commands, h[f])) | ||||
else: | ||||
ui.write(' %-*s %s\n' % (m, f, h[f])) | ||||
|
r7125 | exts = list(extensions.extensions()) | ||
|
r7197 | if exts and name != 'shortlist': | ||
|
r7125 | ui.write(_('\nenabled extensions:\n\n')) | ||
maxlength = 0 | ||||
exthelps = [] | ||||
for ename, ext in exts: | ||||
|
r8007 | doc = (gettext(ext.__doc__) or _('(no help text available)')) | ||
|
r7125 | ename = ename.split('.')[-1] | ||
maxlength = max(len(ename), maxlength) | ||||
exthelps.append((ename, doc.splitlines(0)[0].strip())) | ||||
for ename, text in exthelps: | ||||
ui.write(_(' %s %s\n') % (ename.ljust(maxlength), text)) | ||||
|
r4315 | if not ui.quiet: | ||
addglobalopts(True) | ||||
|
r3795 | def helptopic(name): | ||
|
r7012 | for names, header, doc in help.helptable: | ||
if name in names: | ||||
break | ||||
else: | ||||
|
r7643 | raise error.UnknownCommand(name) | ||
|
r3795 | |||
# description | ||||
if not doc: | ||||
|
r7598 | doc = _("(no help text available)") | ||
|
r8366 | if hasattr(doc, '__call__'): | ||
|
r3796 | doc = doc() | ||
|
r3795 | |||
ui.write("%s\n" % header) | ||||
ui.write("%s\n" % doc.rstrip()) | ||||
|
r3655 | def helpext(name): | ||
try: | ||||
|
r4544 | mod = extensions.find(name) | ||
|
r3655 | except KeyError: | ||
|
r7643 | raise error.UnknownCommand(name) | ||
|
r3655 | |||
|
r7598 | doc = gettext(mod.__doc__) or _('no help text available') | ||
|
r7013 | doc = doc.splitlines(0) | ||
|
r3655 | ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0])) | ||
for d in doc[1:]: | ||||
ui.write(d, '\n') | ||||
ui.status('\n') | ||||
|
r4009 | |||
try: | ||||
ct = mod.cmdtable | ||||
except AttributeError: | ||||
|
r4950 | ct = {} | ||
|
r8152 | modcmds = set([c.split('|', 1)[0] for c in ct]) | ||
helplist(_('list of commands:\n\n'), modcmds.__contains__) | ||||
|
r3655 | |||
if name and name != 'shortlist': | ||||
|
r3795 | i = None | ||
|
r7449 | for f in (helptopic, helpcmd, helpext): | ||
|
r3795 | try: | ||
f(name) | ||||
i = None | ||||
break | ||||
|
r7643 | except error.UnknownCommand, inst: | ||
|
r3795 | i = inst | ||
if i: | ||||
raise i | ||||
|
r3655 | |||
else: | ||||
# program name | ||||
if ui.verbose or with_version: | ||||
version_(ui) | ||||
else: | ||||
ui.status(_("Mercurial Distributed SCM\n")) | ||||
ui.status('\n') | ||||
# list of commands | ||||
if name == "shortlist": | ||||
|
r4950 | header = _('basic commands:\n\n') | ||
|
r4315 | else: | ||
|
r4950 | header = _('list of commands:\n\n') | ||
helplist(header) | ||||
|
r3655 | |||
# list all option lists | ||||
opt_output = [] | ||||
for title, options in option_lists: | ||||
|
r4315 | opt_output.append(("\n%s" % title, None)) | ||
|
r3655 | for shortopt, longopt, default, desc in options: | ||
if "DEPRECATED" in desc and not ui.verbose: continue | ||||
opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, | ||||
longopt and " --%s" % longopt), | ||||
"%s%s" % (desc, | ||||
default | ||||
and _(" (default: %s)") % default | ||||
or ""))) | ||||
|
r7196 | if not name: | ||
|
r7210 | ui.write(_("\nadditional help topics:\n\n")) | ||
|
r6653 | topics = [] | ||
|
r7012 | for names, header, doc in help.helptable: | ||
|
r7196 | names = [(-len(name), name) for name in names] | ||
names.sort() | ||||
topics.append((names[0][1], header)) | ||||
|
r6653 | topics_len = max([len(s[0]) for s in topics]) | ||
for t, desc in topics: | ||||
ui.write(" %-*s %s\n" % (topics_len, t, desc)) | ||||
|
r3655 | if opt_output: | ||
|
r4315 | opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0]) | ||
|
r3655 | for first, second in opt_output: | ||
if second: | ||||
|
r8039 | # wrap descriptions at 70 characters, just like the | ||
# main help texts | ||||
second = textwrap.wrap(second, width=70 - opts_len - 3) | ||||
pad = '\n' + ' ' * (opts_len + 3) | ||||
ui.write(" %-*s %s\n" % (opts_len, first, pad.join(second))) | ||||
|
r3655 | else: | ||
ui.write("%s\n" % first) | ||||
|
r221 | |||
|
r4671 | def identify(ui, repo, source=None, | ||
rev=None, num=None, id=None, branch=None, tags=None): | ||||
|
r4665 | """identify the working copy or specified revision | ||
|
r8004 | With no revision, print a summary of the current state of the | ||
|
r8027 | repository. | ||
|
r4671 | |||
|
r8779 | Specifying a path to a repository root or Mercurial bundle will | ||
cause lookup to operate on that repository/bundle. | ||||
|
r1437 | |||
|
r8004 | 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, a list of tags for | ||||
this revision and a branch name for non-default branches. | ||||
|
r1437 | """ | ||
|
r4662 | |||
|
r5330 | if not repo and not source: | ||
raise util.Abort(_("There is no Mercurial repository here " | ||||
"(.hg not found)")) | ||||
|
r2966 | hexfunc = ui.debugflag and hex or short | ||
|
r4666 | default = not (num or id or branch or tags) | ||
output = [] | ||||
|
r4664 | |||
|
r7757 | revs = [] | ||
|
r4671 | if source: | ||
|
r5248 | source, revs, checkout = hg.parseurl(ui.expandpath(source), []) | ||
|
r7757 | repo = hg.repository(ui, source) | ||
if not repo.local(): | ||||
|
r4671 | if not rev and revs: | ||
rev = revs[0] | ||||
|
r4667 | if not rev: | ||
rev = "tip" | ||||
if num or branch or tags: | ||||
raise util.Abort( | ||||
"can't query remote revision number, branch, or tags") | ||||
|
r7757 | output = [hexfunc(repo.lookup(rev))] | ||
|
r4667 | elif not rev: | ||
|
r6747 | ctx = repo[None] | ||
|
r4665 | parents = ctx.parents() | ||
|
r4666 | changed = False | ||
if default or id or num: | ||||
changed = ctx.files() + ctx.deleted() | ||||
if default or id: | ||||
output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), | ||||
(changed) and "+" or "")] | ||||
if num: | ||||
output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]), | ||||
(changed) and "+" or "")) | ||||
|
r4665 | else: | ||
|
r6747 | ctx = repo[rev] | ||
|
r4666 | if default or id: | ||
output = [hexfunc(ctx.node())] | ||||
if num: | ||||
output.append(str(ctx.rev())) | ||||
|
r7757 | if repo.local() and default and not ui.quiet: | ||
|
r7948 | b = encoding.tolocal(ctx.branch()) | ||
|
r4666 | if b != 'default': | ||
output.append("(%s)" % b) | ||||
|
r3415 | |||
|
r386 | # multiple tags for a single parent separated by '/' | ||
|
r4666 | t = "/".join(ctx.tags()) | ||
if t: | ||||
output.append(t) | ||||
if branch: | ||||
|
r7948 | output.append(encoding.tolocal(ctx.branch())) | ||
|
r4666 | |||
if tags: | ||||
output.extend(ctx.tags()) | ||||
|
r339 | |||
|
r386 | ui.write("%s\n" % ' '.join(output)) | ||
|
r339 | |||
|
r437 | def import_(ui, repo, patch1, *patches, **opts): | ||
|
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 | ||||
|
r8033 | will abort unless given the -f/--force flag. | ||
|
r1437 | |||
|
r6448 | You can import a patch straight from a mail message. Even patches | ||
|
r8779 | as attachments work (to use the body part, it must have type | ||
text/plain or text/x-patch). From and Subject headers of email | ||||
|
r6448 | message are used as default committer and commit message. All | ||
|
r2515 | text/plain body parts before first diff are added to commit | ||
message. | ||||
|
r2504 | |||
|
r8004 | If the imported patch was generated by hg export, user and | ||
description from patch override values from message headers and | ||||
|
r8033 | body. Values given on command line with -m/--message and -u/--user | ||
override these. | ||||
|
r8004 | |||
If --exact is specified, import will set the working directory to | ||||
the parent of each patch before applying it, and will abort if the | ||||
resulting changeset has a different ID than the one recorded in | ||||
the patch. This may happen due to character set problems or other | ||||
deficiencies in the text patch format. | ||||
|
r4263 | |||
|
r8033 | With -s/--similarity, hg will attempt to discover renames and | ||
copies in the patch in the same way as 'addremove'. | ||||
|
r7402 | |||
|
r8779 | To read a patch from standard input, use "-" as the patch name. | ||
See 'hg help dates' for a list of formats valid for -d/--date. | ||||
|
r1437 | """ | ||
|
r437 | patches = (patch1,) + patches | ||
|
r500 | |||
|
r6139 | date = opts.get('date') | ||
if date: | ||||
opts['date'] = util.parsedate(date) | ||||
|
r7402 | try: | ||
sim = float(opts.get('similarity') or 0) | ||||
except ValueError: | ||||
raise util.Abort(_('similarity must be a number')) | ||||
if sim < 0 or sim > 100: | ||||
raise util.Abort(_('similarity must be between 0 and 100')) | ||||
|
r7131 | if opts.get('exact') or not opts.get('force'): | ||
|
r4549 | cmdutil.bail_if_changed(repo) | ||
|
r966 | |||
|
r437 | d = opts["base"] | ||
strip = opts["strip"] | ||||
|
r4915 | wlock = lock = None | ||
try: | ||||
wlock = repo.wlock() | ||||
lock = repo.lock() | ||||
for p in patches: | ||||
pf = os.path.join(d, p) | ||||
if pf == '-': | ||||
ui.status(_("applying patch from stdin\n")) | ||||
|
r7271 | pf = sys.stdin | ||
|
r2400 | else: | ||
|
r4915 | ui.status(_("applying %s\n") % p) | ||
|
r7271 | pf = url.open(ui, pf) | ||
data = patch.extract(ui, pf) | ||||
|
r4915 | tmpname, message, user, date, branch, nodeid, p1, p2 = data | ||
if tmpname is None: | ||||
raise util.Abort(_('no diffs found')) | ||||
try: | ||||
cmdline_message = cmdutil.logmessage(opts) | ||||
if cmdline_message: | ||||
# pickup the cmdline msg | ||||
message = cmdline_message | ||||
elif message: | ||||
# pickup the patch msg | ||||
message = message.strip() | ||||
else: | ||||
# launch the editor | ||||
message = None | ||||
ui.debug(_('message:\n%s\n') % message) | ||||
|
r6747 | wp = repo.parents() | ||
|
r4915 | if opts.get('exact'): | ||
if not nodeid or not p1: | ||||
|
r8760 | raise util.Abort(_('not a Mercurial patch')) | ||
|
r4264 | p1 = repo.lookup(p1) | ||
|
r4915 | p2 = repo.lookup(p2 or hex(nullid)) | ||
if p1 != wp[0].node(): | ||||
|
r4917 | hg.clean(repo, p1) | ||
|
r4915 | repo.dirstate.setparents(p1, p2) | ||
elif p2: | ||||
try: | ||||
p1 = repo.lookup(p1) | ||||
p2 = repo.lookup(p2) | ||||
if p1 == wp[0].node(): | ||||
repo.dirstate.setparents(p1, p2) | ||||
|
r7637 | except error.RepoError: | ||
|
r4915 | pass | ||
if opts.get('exact') or opts.get('import_branch'): | ||||
repo.dirstate.setbranch(branch or 'default') | ||||
files = {} | ||||
try: | ||||
|
r7874 | patch.patch(tmpname, ui, strip=strip, cwd=repo.root, | ||
files=files) | ||||
|
r4915 | finally: | ||
|
r7402 | files = patch.updatedir(ui, repo, files, similarity=sim/100.) | ||
|
r5936 | if not opts.get('no_commit'): | ||
|
r8704 | m = cmdutil.matchfiles(repo, files or []) | ||
|
r8706 | n = repo.commit(message, opts.get('user') or user, | ||
|
r8704 | opts.get('date') or date, match=m, | ||
|
r8407 | editor=cmdutil.commiteditor) | ||
|
r5936 | if opts.get('exact'): | ||
if hex(n) != nodeid: | ||||
repo.rollback() | ||||
raise util.Abort(_('patch is damaged' | ||||
' or loses information')) | ||||
|
r6001 | # Force a dirstate write so that the next transaction | ||
# backups an up-do-date file. | ||||
repo.dirstate.write() | ||||
|
r3465 | finally: | ||
|
r4915 | os.unlink(tmpname) | ||
finally: | ||||
|
r8109 | release(lock, wlock) | ||
|
r437 | |||
|
r1192 | def incoming(ui, repo, source="default", **opts): | ||
|
r1437 | """show new changesets found in source | ||
|
r1979 | Show new changesets found in the specified path/URL or the default | ||
|
r8779 | pull location. These are the changesets that would have been pulled | ||
if a pull at the time you issued this command. | ||||
|
r8004 | |||
For remote repository, using --bundle avoids downloading the | ||||
changesets twice if the incoming is followed by a pull. | ||||
|
r1979 | |||
See pull for valid source format details. | ||||
|
r1437 | """ | ||
|
r6191 | limit = cmdutil.loglimit(opts) | ||
|
r7131 | source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev')) | ||
|
r8188 | other = hg.repository(cmdutil.remoteui(repo, opts), source) | ||
|
r7270 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | ||
|
r4478 | if revs: | ||
|
r5259 | revs = [other.lookup(rev) for rev in revs] | ||
|
r7415 | common, incoming, rheads = repo.findcommonincoming(other, heads=revs, | ||
force=opts["force"]) | ||||
|
r1944 | if not incoming: | ||
|
r3933 | try: | ||
os.unlink(opts["bundle"]) | ||||
except: | ||||
pass | ||||
|
r1993 | ui.status(_("no changes found\n")) | ||
|
r3931 | return 1 | ||
|
r1944 | |||
cleanup = None | ||||
|
r1974 | try: | ||
fname = opts["bundle"] | ||||
if fname or not other.local(): | ||||
# create a bundle (uncompressed if other repo is not local) | ||||
|
r7415 | |||
if revs is None and other.capable('changegroupsubset'): | ||||
revs = rheads | ||||
|
r4451 | if revs is None: | ||
cg = other.changegroup(incoming, "incoming") | ||||
else: | ||||
cg = other.changegroupsubset(incoming, revs, 'incoming') | ||||
|
r3706 | bundletype = other.local() and "HG10BZ" or "HG10UN" | ||
fname = cleanup = changegroup.writebundle(cg, fname, bundletype) | ||||
|
r1974 | # keep written bundle? | ||
if opts["bundle"]: | ||||
cleanup = None | ||||
if not other.local(): | ||||
# use the created uncompressed bundlerepo | ||||
other = bundlerepo.bundlerepository(ui, repo.root, fname) | ||||
|
r2521 | o = other.changelog.nodesbetween(incoming, revs)[0] | ||
|
r7131 | if opts.get('newest_first'): | ||
|
r1974 | o.reverse() | ||
|
r3643 | displayer = cmdutil.show_changeset(ui, other, opts) | ||
|
r6191 | count = 0 | ||
|
r1974 | for n in o: | ||
|
r6191 | if count >= limit: | ||
break | ||||
|
r1974 | parents = [p for p in other.changelog.parents(n) if p != nullid] | ||
|
r7131 | if opts.get('no_merges') and len(parents) == 2: | ||
|
r1974 | continue | ||
|
r6191 | count += 1 | ||
|
r7369 | displayer.show(other[n]) | ||
|
r1974 | finally: | ||
if hasattr(other, 'close'): | ||||
other.close() | ||||
if cleanup: | ||||
os.unlink(cleanup) | ||||
|
r1944 | |||
|
r2598 | def init(ui, dest=".", **opts): | ||
|
r1437 | """create a new repository in the given directory | ||
|
r6448 | Initialize a new repository in the given directory. If the given | ||
|
r8779 | directory does not exist, it will be created. | ||
|
r1437 | |||
If no directory is given, the current directory is used. | ||||
|
r2590 | |||
It is possible to specify an ssh:// URL as the destination. | ||||
|
r7693 | See 'hg help urls' for more information. | ||
|
r1437 | """ | ||
|
r8188 | hg.repository(cmdutil.remoteui(ui, opts), dest, create=1) | ||
|
r338 | |||
|
r627 | def locate(ui, repo, *pats, **opts): | ||
|
r1437 | """locate files matching specific patterns | ||
|
r8779 | Print files under Mercurial control in the working directory whose | ||
names match the given patterns. | ||||
By default, this command searches all directories in the working | ||||
directory. To search just the current directory and its | ||||
subdirectories, use "--include .". | ||||
If no patterns are given to match, this command prints the names | ||||
of all files under Mercurial control in the working directory. | ||||
|
r1437 | |||
If you want to feed the output of this command into the "xargs" | ||||
|
r8032 | command, use the -0 option to both this command and "xargs". This | ||
will avoid the problem of "xargs" treating single filenames that | ||||
|
r8779 | contain whitespace as multiple filenames. | ||
|
r1437 | """ | ||
|
r7131 | end = opts.get('print0') and '\0' or '\n' | ||
|
r6764 | rev = opts.get('rev') or None | ||
|
r742 | |||
|
r4196 | ret = 1 | ||
|
r6579 | m = cmdutil.match(repo, pats, opts, default='relglob') | ||
|
r6583 | m.bad = lambda x,y: False | ||
|
r6764 | for abs in repo[rev].walk(m): | ||
if not rev and abs not in repo.dirstate: | ||||
|
r4308 | continue | ||
|
r7131 | if opts.get('fullpath'): | ||
|
r7570 | ui.write(repo.wjoin(abs), end) | ||
|
r724 | else: | ||
|
r6584 | ui.write(((pats and m.rel(abs)) or abs), end) | ||
|
r4196 | ret = 0 | ||
return ret | ||||
|
r627 | |||
|
r1031 | def log(ui, repo, *pats, **opts): | ||
|
r1437 | """show revision history of entire repository or files | ||
|
r2741 | Print the revision history of the specified files or the entire | ||
project. | ||||
File history is shown without following rename or copy history of | ||||
|
r8761 | files. Use -f/--follow with a filename to follow history across | ||
renames and copies. --follow without a filename will only show | ||||
|
r2784 | ancestors or descendants of the starting revision. --follow-first | ||
only follows the first parent of merge revisions. | ||||
|
r1437 | |||
|
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. | ||||
|
r6163 | See 'hg help dates' for a list of formats valid for -d/--date. | ||
|
r8779 | By default this command prints revision number and changeset id, | ||
tags, non-trivial parents, user, date and time, and a summary for | ||||
each commit. When the -v/--verbose switch is used, the list of | ||||
changed files and full commit message are shown. | ||||
|
r3822 | |||
|
r8033 | NOTE: log -p/--patch may generate unexpected diff output for merge | ||
|
r7807 | changesets, as it will only compare the merge changeset against | ||
|
r8779 | its first parent. Also, only files different from BOTH parents | ||
will appear in files:. | ||||
|
r1437 | """ | ||
|
r1756 | |||
|
r6747 | get = util.cachefunc(lambda r: repo[r].changeset()) | ||
|
r3650 | changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) | ||
|
r3518 | |||
|
r6190 | limit = cmdutil.loglimit(opts) | ||
|
r1756 | count = 0 | ||
|
r7131 | if opts.get('copies') and opts.get('rev'): | ||
endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1 | ||||
|
r3197 | else: | ||
|
r6750 | endrev = len(repo) | ||
|
r3197 | rcache = {} | ||
ncache = {} | ||||
|
r5811 | def getrenamed(fn, rev): | ||
|
r3197 | '''looks up all renames for a file (up to endrev) the first | ||
time the file is given. It indexes on the changerev and only | ||||
parses the manifest if linkrev != changerev. | ||||
Returns rename info for fn at changerev rev.''' | ||||
if fn not in rcache: | ||||
rcache[fn] = {} | ||||
ncache[fn] = {} | ||||
fl = repo.file(fn) | ||||
|
r6750 | for i in fl: | ||
|
r3197 | node = fl.node(i) | ||
|
r7361 | lr = fl.linkrev(i) | ||
|
r3197 | renamed = fl.renamed(node) | ||
rcache[fn][lr] = renamed | ||||
if renamed: | ||||
ncache[fn][node] = renamed | ||||
if lr >= endrev: | ||||
break | ||||
if rev in rcache[fn]: | ||||
return rcache[fn][rev] | ||||
|
r5811 | |||
# If linkrev != rev (i.e. rev not found in rcache) fallback to | ||||
# filectx logic. | ||||
try: | ||||
|
r6747 | return repo[rev][fn].renamed() | ||
|
r7633 | except error.LookupError: | ||
|
r5811 | pass | ||
|
r3197 | return None | ||
|
r3813 | df = False | ||
if opts["date"]: | ||||
df = util.matchdate(opts["date"]) | ||||
|
r7131 | only_branches = opts.get('only_branch') | ||
|
r6067 | |||
|
r3837 | displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn) | ||
|
r1146 | for st, rev, fns in changeiter: | ||
|
r3645 | if st == 'add': | ||
|
r3578 | parents = [p for p in repo.changelog.parentrevs(rev) | ||
if p != nullrev] | ||||
|
r7131 | if opts.get('no_merges') and len(parents) == 2: | ||
|
r1615 | continue | ||
|
r7131 | if opts.get('only_merges') and len(parents) != 2: | ||
|
r1615 | continue | ||
|
r1435 | |||
|
r6067 | if only_branches: | ||
revbranch = get(rev)[5]['branch'] | ||||
if revbranch not in only_branches: | ||||
continue | ||||
|
r3813 | if df: | ||
changes = get(rev) | ||||
if not df(changes[2][0]): | ||||
continue | ||||
|
r7131 | if opts.get('keyword'): | ||
|
r3650 | changes = get(rev) | ||
|
r1373 | miss = 0 | ||
|
r1404 | for k in [kw.lower() for kw in opts['keyword']]: | ||
|
r1373 | if not (k in changes[1].lower() or | ||
k in changes[4].lower() or | ||||
|
r4322 | k in " ".join(changes[3]).lower()): | ||
|
r1373 | miss = 1 | ||
break | ||||
if miss: | ||||
continue | ||||
|
r7212 | if opts['user']: | ||
changes = get(rev) | ||||
|
r8020 | if not [k for k in opts['user'] if k in changes[1]]: | ||
|
r7212 | continue | ||
|
r7236 | |||
|
r3197 | copies = [] | ||
if opts.get('copies') and rev: | ||||
|
r3650 | for fn in get(rev)[3]: | ||
|
r5811 | rename = getrenamed(fn, rev) | ||
|
r3197 | if rename: | ||
copies.append((fn, rename[0])) | ||||
|
r7369 | displayer.show(context.changectx(repo, rev), copies=copies) | ||
|
r1057 | elif st == 'iter': | ||
|
r1756 | if count == limit: break | ||
|
r3645 | if displayer.flush(rev): | ||
|
r1765 | count += 1 | ||
|
r255 | |||
|
r5155 | def manifest(ui, repo, node=None, rev=None): | ||
|
r3914 | """output the current or given revision of the project manifest | ||
|
r1437 | |||
Print a list of version controlled files for the given revision. | ||||
|
r8041 | If no revision is given, the first parent of the working directory | ||
|
r8779 | is used, or the null revision if no revision is checked out. | ||
With -v, print file permissions, symlink and executable bits. | ||||
With --debug, print file revision hashes. | ||||
|
r1437 | """ | ||
|
r3736 | |||
|
r5155 | if rev and node: | ||
raise util.Abort(_("please specify just one revision")) | ||||
if not node: | ||||
node = rev | ||||
|
r6749 | decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '} | ||
ctx = repo[node] | ||||
for f in ctx: | ||||
|
r3736 | if ui.debugflag: | ||
|
r6749 | ui.write("%40s " % hex(ctx.manifest()[f])) | ||
|
r3736 | if ui.verbose: | ||
|
r6749 | ui.write(decor[ctx.flags(f)]) | ||
|
r3736 | ui.write("%s\n" % f) | ||
|
r255 | |||
|
r8387 | def merge(ui, repo, node=None, **opts): | ||
|
r4014 | """merge working directory with another revision | ||
|
r2019 | |||
|
r8779 | The current working directory is updated with all changes made in | ||
the requested revision since the last common predecessor revision. | ||||
|
r7977 | |||
Files that changed between either parent are marked as changed for | ||||
the next commit and a commit must be performed before any further | ||||
|
r8779 | updates to the repository are allowed. The next commit will have | ||
two parents. | ||||
|
r2915 | |||
If no revision is specified, the working directory's parent is a | ||||
|
r8004 | head revision, and the current branch contains exactly one other | ||
head, the other head is merged with by default. Otherwise, an | ||||
|
r8779 | explicit revision with which to merge with must be provided. | ||
|
r2019 | """ | ||
|
r2806 | |||
|
r8387 | if opts.get('rev') and node: | ||
|
r4450 | raise util.Abort(_("please specify just one revision")) | ||
if not node: | ||||
|
r8387 | node = opts.get('rev') | ||
|
r4450 | |||
|
r3876 | if not node: | ||
|
r6740 | branch = repo.changectx(None).branch() | ||
|
r6844 | bheads = repo.branchheads(branch) | ||
|
r6723 | if len(bheads) > 2: | ||
raise util.Abort(_("branch '%s' has %d heads - " | ||||
"please merge with an explicit rev") % | ||||
(branch, len(bheads))) | ||||
|
r5242 | parent = repo.dirstate.parents()[0] | ||
|
r6723 | if len(bheads) == 1: | ||
if len(repo.heads()) > 1: | ||||
raise util.Abort(_("branch '%s' has one head - " | ||||
"please merge with an explicit rev") % | ||||
branch) | ||||
|
r5242 | msg = _('there is nothing to merge') | ||
|
r6747 | if parent != repo.lookup(repo[None].branch()): | ||
|
r5542 | msg = _('%s - use "hg update" instead') % msg | ||
|
r5242 | raise util.Abort(msg) | ||
|
r6723 | if parent not in bheads: | ||
|
r2915 | raise util.Abort(_('working dir not at a head rev - ' | ||
'use "hg update" or merge with an explicit rev')) | ||||
|
r6723 | node = parent == bheads[0] and bheads[-1] or bheads[0] | ||
|
r8387 | |||
if opts.get('show'): | ||||
p1 = repo['.'] | ||||
p2 = repo[node] | ||||
common = p1.ancestor(p2) | ||||
roots, heads = [common.node()], [p2.node()] | ||||
displayer = cmdutil.show_changeset(ui, repo, opts) | ||||
for node in repo.changelog.nodesbetween(roots=roots, heads=heads)[0]: | ||||
|
r8636 | displayer.show(repo[node]) | ||
|
r8387 | return 0 | ||
return hg.merge(repo, node, force=opts.get('force')) | ||||
|
r2029 | |||
|
r2494 | def outgoing(ui, repo, dest=None, **opts): | ||
|
r1437 | """show changesets not found in destination | ||
|
r8004 | Show changesets not found in the specified destination repository | ||
or the default push location. These are the changesets that would | ||||
be pushed if a push was requested. | ||||
|
r1811 | |||
|
r1979 | See pull for valid destination format details. | ||
|
r1437 | """ | ||
|
r6191 | limit = cmdutil.loglimit(opts) | ||
|
r5248 | dest, revs, checkout = hg.parseurl( | ||
|
r7131 | ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev')) | ||
|
r4478 | if revs: | ||
revs = [repo.lookup(rev) for rev in revs] | ||||
|
r1965 | |||
|
r8188 | other = hg.repository(cmdutil.remoteui(repo, opts), dest) | ||
|
r7270 | ui.status(_('comparing with %s\n') % url.hidepassword(dest)) | ||
|
r7131 | o = repo.findoutgoing(other, force=opts.get('force')) | ||
|
r1994 | if not o: | ||
ui.status(_("no changes found\n")) | ||||
|
r3931 | return 1 | ||
|
r2521 | o = repo.changelog.nodesbetween(o, revs)[0] | ||
|
r7131 | if opts.get('newest_first'): | ||
|
r1439 | o.reverse() | ||
|
r3643 | displayer = cmdutil.show_changeset(ui, repo, opts) | ||
|
r6191 | count = 0 | ||
|
r920 | for n in o: | ||
|
r6191 | if count >= limit: | ||
break | ||||
|
r1435 | parents = [p for p in repo.changelog.parents(n) if p != nullid] | ||
|
r7131 | if opts.get('no_merges') and len(parents) == 2: | ||
|
r1435 | continue | ||
|
r6191 | count += 1 | ||
|
r7369 | displayer.show(repo[n]) | ||
|
r920 | |||
|
r3658 | def parents(ui, repo, file_=None, **opts): | ||
|
r8026 | """show the parents of the working directory or revision | ||
|
r1437 | |||
|
r8004 | Print the working directory's parent revisions. If a revision is | ||
|
r8033 | given via -r/--rev, the parent of that revision will be printed. | ||
|
r8779 | If a file argument is given, the revision in which the file was | ||
last changed (before the working directory revision or the | ||||
argument to --rev if given) is printed. | ||||
|
r1437 | """ | ||
|
r3658 | rev = opts.get('rev') | ||
|
r5298 | if rev: | ||
|
r6747 | ctx = repo[rev] | ||
|
r5298 | else: | ||
|
r6747 | ctx = repo[None] | ||
|
r5298 | |||
|
r4586 | if file_: | ||
|
r6582 | m = cmdutil.match(repo, (file_,), opts) | ||
if m.anypats() or len(m.files()) != 1: | ||||
|
r8761 | raise util.Abort(_('can only specify an explicit filename')) | ||
|
r6582 | file_ = m.files()[0] | ||
|
r5298 | filenodes = [] | ||
for cp in ctx.parents(): | ||||
if not cp: | ||||
continue | ||||
try: | ||||
filenodes.append(cp.filenode(file_)) | ||||
|
r7633 | except error.LookupError: | ||
|
r5298 | pass | ||
if not filenodes: | ||||
raise util.Abort(_("'%s' not found in manifest!") % file_) | ||||
fl = repo.file(file_) | ||||
|
r7361 | p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes] | ||
|
r255 | else: | ||
|
r5298 | p = [cp.node() for cp in ctx.parents()] | ||
|
r255 | |||
|
r3643 | displayer = cmdutil.show_changeset(ui, repo, opts) | ||
|
r255 | for n in p: | ||
|
r1092 | if n != nullid: | ||
|
r7743 | displayer.show(repo[n]) | ||
|
r255 | |||
|
r1858 | def paths(ui, repo, search=None): | ||
|
r7691 | """show aliases for remote repositories | ||
|
r8004 | Show definition of symbolic path name NAME. If no name is given, | ||
|
r8779 | show definition of all available names. | ||
|
r7743 | |||
|
r1437 | Path names are defined in the [paths] section of /etc/mercurial/hgrc | ||
|
r6448 | and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. | ||
|
r7693 | |||
See 'hg help urls' for more information. | ||||
|
r1437 | """ | ||
|
r779 | if search: | ||
for name, path in ui.configitems("paths"): | ||||
if name == search: | ||||
|
r7270 | ui.write("%s\n" % url.hidepassword(path)) | ||
|
r779 | return | ||
|
r1402 | ui.warn(_("not found!\n")) | ||
|
r779 | return 1 | ||
else: | ||||
for name, path in ui.configitems("paths"): | ||||
|
r7270 | ui.write("%s = %s\n" % (name, url.hidepassword(path))) | ||
|
r779 | |||
|
r5224 | def postincoming(ui, repo, modheads, optupdate, checkout): | ||
|
r2019 | if modheads == 0: | ||
return | ||||
if optupdate: | ||||
|
r7372 | if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout: | ||
|
r5224 | return hg.update(repo, checkout) | ||
|
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")) | ||||
|
r2029 | |||
|
r404 | def pull(ui, repo, source="default", **opts): | ||
|
r1437 | """pull changes from the specified source | ||
|
r8779 | Pull changes from a remote repository to a local one. | ||
|
r1437 | |||
This finds all changes from the repository at the specified path | ||||
|
r8779 | or URL and adds them to a local repository (the current one unless | ||
-R is specified). By default, this does not update the copy of the | ||||
project in the working directory. | ||||
Use hg incoming if you want to see what would have been added by a | ||||
pull at the time you issued this command. If you then decide to | ||||
added those changes to the repository, you should use pull -r X | ||||
where X is the last changeset listed by hg incoming. | ||||
|
r7980 | |||
|
r7693 | If SOURCE is omitted, the 'default' path will be used. | ||
See 'hg help urls' for more information. | ||||
|
r1437 | """ | ||
|
r7131 | source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev')) | ||
|
r8188 | other = hg.repository(cmdutil.remoteui(repo, opts), source) | ||
|
r7270 | ui.status(_('pulling from %s\n') % url.hidepassword(source)) | ||
|
r4478 | if revs: | ||
|
r5259 | try: | ||
|
r4478 | revs = [other.lookup(rev) for rev in revs] | ||
|
r7637 | except error.CapabilityError: | ||
err = _("Other repository doesn't support revision lookup, " | ||||
"so a rev cannot be specified.") | ||||
raise util.Abort(err) | ||||
|
r4478 | |||
|
r7131 | modheads = repo.pull(other, heads=revs, force=opts.get('force')) | ||
return postincoming(ui, repo, modheads, opts.get('update'), checkout) | ||||
|
r246 | |||
|
r2494 | def push(ui, repo, dest=None, **opts): | ||
|
r1437 | """push changes to the specified destination | ||
Push changes from the local repository to the given destination. | ||||
|
r7981 | This is the symmetrical operation for pull. It moves 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. | ||||
|
r1437 | |||
By default, push will refuse to run if it detects the result would | ||||
increase the number of remote heads. This generally indicates the | ||||
|
r8779 | user forgot to pull and merge before pushing. | ||
|
r1437 | |||
|
r8033 | If -r/--rev is used, the named revision and all its ancestors will | ||
be pushed to the remote repository. | ||||
|
r7693 | |||
|
r8779 | Please see 'hg help urls' for important details about ssh:// | ||
|
r8004 | URLs. If DESTINATION is omitted, a default path will be used. | ||
|
r7693 | See 'hg help urls' for more information. | ||
|
r1437 | """ | ||
|
r5248 | dest, revs, checkout = hg.parseurl( | ||
|
r7131 | ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev')) | ||
|
r8188 | other = hg.repository(cmdutil.remoteui(repo, opts), dest) | ||
|
r7270 | ui.status(_('pushing to %s\n') % url.hidepassword(dest)) | ||
|
r4478 | if revs: | ||
revs = [repo.lookup(rev) for rev in revs] | ||||
|
r7131 | r = repo.push(other, opts.get('force'), revs=revs) | ||
|
r2019 | return r == 0 | ||
|
r319 | |||
|
r245 | def recover(ui, repo): | ||
|
r1437 | """roll back an interrupted transaction | ||
Recover from an interrupted commit or pull. | ||||
|
r8004 | This command tries to fix the repository status after an | ||
interrupted operation. It should only be necessary when Mercurial | ||||
suggests it. | ||||
|
r1437 | """ | ||
|
r1516 | if repo.recover(): | ||
|
r2778 | return hg.verify(repo) | ||
|
r2057 | return 1 | ||
|
r245 | |||
|
r2179 | def remove(ui, repo, *pats, **opts): | ||
|
r1437 | """remove the specified files on the next commit | ||
Schedule the indicated files for removal from the repository. | ||||
|
r8004 | This only removes files from the current branch, not from the | ||
|
r8033 | entire project history. -A/--after can be used to remove only | ||
files that have already been deleted, -f/--force can be used to | ||||
force deletion, and -Af can be used to remove files from the next | ||||
|
r8779 | revision without deleting them from the working directory. | ||
|
r8004 | |||
The following table details the behavior of remove for different | ||||
file states (columns) and option combinations (rows). The file | ||||
|
r8779 | states are Added [A], Clean [C], Modified [M] and Missing [!] | ||
(as reported by hg status). The actions are Warn, Remove (from | ||||
branch) and Delete (from disk). | ||||
|
r6346 | |||
A C M ! | ||||
none W RD W R | ||||
-f R RD RD R | ||||
-A W W W R | ||||
-Af R R R R | ||||
|
r2309 | |||
|
r3829 | This command schedules the files to be removed at the next commit. | ||
To undo a remove before that, see hg revert. | ||||
|
r1437 | """ | ||
|
r6346 | |||
after, force = opts.get('after'), opts.get('force') | ||||
if not pats and not after: | ||||
|
r2179 | raise util.Abort(_('no files specified')) | ||
|
r6346 | |||
|
r6582 | m = cmdutil.match(repo, pats, opts) | ||
|
r6761 | s = repo.status(match=m, clean=True) | ||
modified, added, deleted, clean = s[0], s[1], s[3], s[6] | ||||
|
r8533 | for f in m.files(): | ||
if f not in repo.dirstate and not os.path.isdir(m.rel(f)): | ||||
ui.warn(_('not removing %s: file is untracked\n') % m.rel(f)) | ||||
|
r6761 | def warn(files, reason): | ||
for f in files: | ||||
ui.warn(_('not removing %s: file %s (use -f to force removal)\n') | ||||
% (m.rel(f), reason)) | ||||
if force: | ||||
remove, forget = modified + deleted + clean, added | ||||
elif after: | ||||
remove, forget = deleted, [] | ||||
warn(modified + added + clean, _('still exists')) | ||||
else: | ||||
remove, forget = deleted + clean, [] | ||||
warn(modified, _('is modified')) | ||||
warn(added, _('has been marked for add')) | ||||
|
r8209 | for f in sorted(remove + forget): | ||
|
r6761 | if ui.verbose or not m.exact(f): | ||
ui.status(_('removing %s\n') % m.rel(f)) | ||||
|
r6346 | |||
|
r2309 | repo.forget(forget) | ||
|
r6346 | repo.remove(remove, unlink=not after) | ||
|
r245 | |||
|
r1253 | def rename(ui, repo, *pats, **opts): | ||
|
r1437 | """rename files; equivalent of copy + remove | ||
|
r8004 | Mark dest as copies of sources; mark sources for deletion. If dest | ||
is a directory, copies are put in that directory. If dest is a | ||||
file, there can only be one source. | ||||
|
r1437 | |||
By default, this command copies the contents of files as they | ||||
|
r8033 | exist in the working directory. If invoked with -A/--after, the | ||
|
r1437 | operation is recorded, but no copying is performed. | ||
|
r7807 | This command takes effect at the next commit. To undo a rename | ||
|
r3829 | before that, see hg revert. | ||
|
r1437 | """ | ||
|
r4914 | wlock = repo.wlock(False) | ||
|
r4915 | try: | ||
|
r5610 | return cmdutil.copy(ui, repo, pats, opts, rename=True) | ||
|
r4915 | finally: | ||
|
r8109 | wlock.release() | ||
|
r1253 | |||
|
r6518 | def resolve(ui, repo, *pats, **opts): | ||
|
r7530 | """retry file merges from a merge or update | ||
This command will cleanly retry unresolved file merges using file | ||||
revisions preserved from the last update or merge. To attempt to | ||||
|
r8033 | resolve all unresolved files, use the -a/--all switch. | ||
|
r7530 | |||
|
r7982 | If a conflict is resolved manually, please note that the changes | ||
|
r8033 | will be overwritten if the merge is retried with resolve. The | ||
-m/--mark switch should be used to mark the file as resolved. | ||||
|
r7530 | |||
|
r8779 | This command also allows listing resolved files and manually | ||
indicating whether or not files are resolved. All files must be | ||||
marked as resolved before a commit is permitted. | ||||
|
r6642 | |||
The codes used to show the status of files are: | ||||
U = unresolved | ||||
R = resolved | ||||
|
r6518 | """ | ||
|
r7527 | all, mark, unmark, show = [opts.get(o) for o in 'all mark unmark list'.split()] | ||
if (show and (mark or unmark)) or (mark and unmark): | ||||
|
r6518 | raise util.Abort(_("too many options specified")) | ||
|
r7527 | if pats and all: | ||
raise util.Abort(_("can't specify --all and patterns")) | ||||
if not (all or pats or show or mark or unmark): | ||||
raise util.Abort(_('no files or directories specified; ' | ||||
'use --all to remerge all files')) | ||||
|
r6518 | |||
ms = merge_.mergestate(repo) | ||||
|
r6594 | m = cmdutil.match(repo, pats, opts) | ||
|
r6518 | |||
for f in ms: | ||||
|
r6594 | if m(f): | ||
|
r7527 | if show: | ||
|
r6518 | ui.write("%s %s\n" % (ms[f].upper(), f)) | ||
|
r7527 | elif mark: | ||
|
r6518 | ms.mark(f, "r") | ||
|
r7527 | elif unmark: | ||
|
r6518 | ms.mark(f, "u") | ||
else: | ||||
|
r6747 | wctx = repo[None] | ||
|
r6518 | mctx = wctx.parents()[-1] | ||
|
r7847 | |||
# backup pre-resolve (merge uses .orig for its own purposes) | ||||
a = repo.wjoin(f) | ||||
util.copyfile(a, a + ".resolve") | ||||
# resolve file | ||||
|
r6518 | ms.resolve(f, wctx, mctx) | ||
|
r7847 | # replace filemerge's .orig file with our resolve file | ||
util.rename(a + ".resolve", a + ".orig") | ||||
|
r1472 | def revert(ui, repo, *pats, **opts): | ||
|
r8026 | """restore individual files or directories to an earlier state | ||
|
r5574 | |||
|
r8287 | (Use update -r to check out earlier revisions, revert does not | ||
change the working directory parents.) | ||||
|
r2204 | |||
|
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 | ||||
|
r3829 | state and unschedules adds, removes, copies, and renames. If the | ||
working directory has two parents, you must explicitly specify the | ||||
revision to revert to. | ||||
|
r1811 | |||
|
r8033 | Using the -r/--rev option, revert the given files or directories | ||
to their contents as of a specific revision. This can be helpful | ||||
to "roll back" some or all of an earlier change. See 'hg help | ||||
dates' for a list of formats valid for -d/--date. | ||||
|
r1811 | |||
|
r6448 | Revert modifies the working directory. It does not commit any | ||
changes, or change the parent of the working directory. If you | ||||
|
r2204 | revert to a revision other than the parent of the working | ||
directory, the reverted files will thus appear modified | ||||
afterwards. | ||||
|
r1437 | |||
|
r8004 | If a file has been deleted, it is restored. If the executable mode | ||
of a file was changed, it is reset. | ||||
|
r1437 | |||
|
r1472 | If names are given, all files matching the names are reverted. | ||
|
r2982 | If no arguments are given, no files are reverted. | ||
|
r5574 | |||
Modified files are saved with a .orig suffix before reverting. | ||||
To disable these backups, use --no-backup. | ||||
|
r1437 | """ | ||
|
r2982 | |||
|
r3814 | if opts["date"]: | ||
if opts["rev"]: | ||||
raise util.Abort(_("you can't specify a revision and a date")) | ||||
opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) | ||||
|
r7131 | if not pats and not opts.get('all'): | ||
|
r3020 | raise util.Abort(_('no files or directories specified; ' | ||
'use --all to revert the whole repo')) | ||||
|
r2982 | |||
|
r2212 | parent, p2 = repo.dirstate.parents() | ||
|
r7131 | if not opts.get('rev') and p2 != nullid: | ||
|
r3132 | raise util.Abort(_('uncommitted merge - please provide a ' | ||
'specific revision')) | ||||
|
r7131 | ctx = repo[opts.get('rev')] | ||
|
r3972 | node = ctx.node() | ||
mf = ctx.manifest() | ||||
|
r2407 | if node == parent: | ||
pmf = mf | ||||
else: | ||||
pmf = None | ||||
|
r2029 | |||
|
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. | ||||
|
r2029 | names = {} | ||
|
r2042 | |||
|
r4915 | wlock = repo.wlock() | ||
try: | ||||
# walk dirstate. | ||||
|
r6579 | |||
m = cmdutil.match(repo, pats, opts) | ||||
|
r6583 | m.bad = lambda x,y: False | ||
|
r6586 | for abs in repo.walk(m): | ||
|
r6584 | names[abs] = m.rel(abs), m.exact(abs) | ||
|
r4915 | |||
# walk target manifest. | ||||
|
r6579 | def badfn(path, msg): | ||
|
r4915 | if path in names: | ||
|
r8679 | return | ||
|
r4915 | path_ = path + '/' | ||
for f in names: | ||||
if f.startswith(path_): | ||||
|
r8679 | return | ||
|
r8615 | ui.warn("%s: %s\n" % (m.rel(path), msg)) | ||
|
r4915 | |||
|
r6579 | m = cmdutil.match(repo, pats, opts) | ||
m.bad = badfn | ||||
|
r6764 | for abs in repo[node].walk(m): | ||
|
r6584 | if abs not in names: | ||
names[abs] = m.rel(abs), m.exact(abs) | ||||
|
r6031 | |||
|
r6599 | m = cmdutil.matchfiles(repo, names) | ||
|
r6603 | changes = repo.status(match=m)[:4] | ||
|
r8152 | modified, added, removed, deleted = map(set, changes) | ||
|
r4915 | |||
|
r5266 | # if f is a rename, also revert the source | ||
cwd = repo.getcwd() | ||||
for f in added: | ||||
src = repo.dirstate.copied(f) | ||||
if src and src not in names and repo.dirstate[src] == 'r': | ||||
|
r8152 | removed.add(src) | ||
|
r5266 | names[src] = (repo.pathto(src, cwd), True) | ||
|
r6109 | def removeforget(abs): | ||
if repo.dirstate[abs] == 'a': | ||||
return _('forgetting %s\n') | ||||
return _('removing %s\n') | ||||
|
r4915 | revert = ([], _('reverting %s\n')) | ||
add = ([], _('adding %s\n')) | ||||
|
r6109 | remove = ([], removeforget) | ||
|
r4915 | undelete = ([], _('undeleting %s\n')) | ||
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), | ||||
|
r6109 | (added, revert, remove, True, False), | ||
|
r4915 | (removed, undelete, None, False, False), | ||
(deleted, revert, remove, False, False), | ||||
) | ||||
|
r8209 | for abs, (rel, exact) in sorted(names.items()): | ||
|
r4915 | mfentry = mf.get(abs) | ||
target = repo.wjoin(abs) | ||||
def handle(xlist, dobackup): | ||||
xlist[0].append(abs) | ||||
|
r7131 | if dobackup and not opts.get('no_backup') and util.lexists(target): | ||
|
r4915 | bakname = "%s.orig" % rel | ||
ui.note(_('saving current version of %s as %s\n') % | ||||
(rel, bakname)) | ||||
if not opts.get('dry_run'): | ||||
util.copyfile(target, bakname) | ||||
if ui.verbose or not exact: | ||||
|
r6109 | msg = xlist[1] | ||
if not isinstance(msg, basestring): | ||||
msg = msg(abs) | ||||
ui.status(msg % rel) | ||||
|
r4915 | for table, hitlist, misslist, backuphit, backupmiss in disptable: | ||
if abs not in table: continue | ||||
# file has changed in dirstate | ||||
if mfentry: | ||||
handle(hitlist, backuphit) | ||||
elif misslist is not None: | ||||
handle(misslist, backupmiss) | ||||
break | ||||
|
r2029 | else: | ||
|
r6031 | if abs not in repo.dirstate: | ||
if mfentry: | ||||
handle(add, True) | ||||
elif exact: | ||||
ui.warn(_('file not managed: %s\n') % rel) | ||||
continue | ||||
|
r4915 | # file has not changed in dirstate | ||
if node == parent: | ||||
if exact: ui.warn(_('no changes needed to %s\n') % rel) | ||||
continue | ||||
if pmf is None: | ||||
# only need parent manifest in this unlikely case, | ||||
# so do not read by default | ||||
|
r6747 | pmf = repo[parent].manifest() | ||
|
r4915 | if abs in pmf: | ||
if mfentry: | ||||
# if version of file is same in parent and target | ||||
# manifests, do nothing | ||||
|
r6030 | if (pmf[abs] != mfentry or | ||
pmf.flags(abs) != mf.flags(abs)): | ||||
|
r4915 | handle(revert, False) | ||
else: | ||||
handle(remove, False) | ||||
if not opts.get('dry_run'): | ||||
|
r6107 | def checkout(f): | ||
fc = ctx[f] | ||||
|
r6743 | repo.wwrite(f, fc.data(), fc.flags()) | ||
|
r6107 | |||
|
r6109 | audit_path = util.path_auditor(repo.root) | ||
for f in remove[0]: | ||||
if repo.dirstate[f] == 'a': | ||||
repo.dirstate.forget(f) | ||||
continue | ||||
audit_path(f) | ||||
try: | ||||
util.unlink(repo.wjoin(f)) | ||||
except OSError: | ||||
pass | ||||
repo.dirstate.remove(f) | ||||
|
r6107 | |||
|
r6299 | normal = None | ||
if node == parent: | ||||
# We're reverting to our parent. If possible, we'd like status | ||||
# to report the file as clean. We have to use normallookup for | ||||
# merges to avoid losing information about merged/dirty files. | ||||
if p2 != nullid: | ||||
normal = repo.dirstate.normallookup | ||||
else: | ||||
normal = repo.dirstate.normal | ||||
|
r6107 | for f in revert[0]: | ||
checkout(f) | ||||
|
r6299 | if normal: | ||
normal(f) | ||||
|
r6107 | |||
|
r4915 | for f in add[0]: | ||
|
r6107 | checkout(f) | ||
|
r4915 | repo.dirstate.add(f) | ||
|
r6107 | |||
|
r6108 | normal = repo.dirstate.normallookup | ||
if node == parent and p2 == nullid: | ||||
normal = repo.dirstate.normal | ||||
|
r4915 | for f in undelete[0]: | ||
|
r6107 | checkout(f) | ||
|
r6108 | normal(f) | ||
|
r6107 | |||
|
r4915 | finally: | ||
|
r8109 | wlock.release() | ||
|
r588 | |||
|
r2227 | def rollback(ui, repo): | ||
|
r5575 | """roll back the last transaction | ||
This command should be used with care. There is only one level of | ||||
rollback, and there is no way to undo a rollback. It will also | ||||
restore the dirstate at the time of the last transaction, losing | ||||
any dirstate changes since that time. | ||||
|
r2227 | |||
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 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. | ||||
""" | ||||
|
r2362 | repo.rollback() | ||
|
r2227 | |||
|
r468 | def root(ui, repo): | ||
|
r8026 | """print the root (top) of the current working directory | ||
|
r1437 | |||
Print the root directory of the current repository. | ||||
""" | ||||
|
r468 | ui.write(repo.root + "\n") | ||
|
r245 | def serve(ui, repo, **opts): | ||
|
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 | ||||
|
r8277 | stderr. Use the -A/--accesslog and -E/--errorlog options to log to | ||
files. | ||||
|
r1437 | """ | ||
|
r624 | |||
if opts["stdio"]: | ||||
|
r2127 | if repo is None: | ||
|
r7637 | raise error.RepoError(_("There is no Mercurial repository here" | ||
|
r6217 | " (.hg not found)")) | ||
|
r2396 | s = sshserver.sshserver(ui, repo) | ||
s.serve_forever() | ||||
|
r2363 | |||
|
r8190 | baseui = repo and repo.baseui or ui | ||
|
r5835 | optlist = ("name templates style address port prefix ipv6" | ||
|
r4860 | " accesslog errorlog webdir_conf certificate") | ||
|
r987 | for o in optlist.split(): | ||
if opts[o]: | ||||
|
r8190 | baseui.setconfig("web", o, str(opts[o])) | ||
if (repo is not None) and (repo.ui != baseui): | ||||
|
r4835 | repo.ui.setconfig("web", o, str(opts[o])) | ||
|
r987 | |||
|
r2127 | if repo is None and not ui.config("web", "webdir_conf"): | ||
|
r7637 | raise error.RepoError(_("There is no Mercurial repository here" | ||
" (.hg not found)")) | ||||
|
r2127 | |||
|
r8778 | class service(object): | ||
|
r4380 | def init(self): | ||
|
r4672 | util.set_signal_handler() | ||
|
r8312 | self.httpd = server.create_server(baseui, repo) | ||
|
r4380 | |||
if not ui.verbose: return | ||||
|
r5970 | if self.httpd.prefix: | ||
prefix = self.httpd.prefix.strip('/') + '/' | ||||
else: | ||||
prefix = '' | ||||
|
r6262 | port = ':%d' % self.httpd.port | ||
if port == ':80': | ||||
port = '' | ||||
|
r6419 | bindaddr = self.httpd.addr | ||
if bindaddr == '0.0.0.0': | ||||
bindaddr = '*' | ||||
elif ':' in bindaddr: # IPv6 | ||||
bindaddr = '[%s]' % bindaddr | ||||
fqaddr = self.httpd.fqaddr | ||||
if ':' in fqaddr: | ||||
fqaddr = '[%s]' % fqaddr | ||||
ui.status(_('listening at http://%s%s/%s (bound to %s:%d)\n') % | ||||
(fqaddr, port, prefix, bindaddr, self.httpd.port)) | ||||
|
r4380 | |||
def run(self): | ||||
self.httpd.serve_forever() | ||||
service = service() | ||||
cmdutil.service(opts, initfn=service.init, runfn=service.run) | ||||
|
r500 | |||
|
r731 | def status(ui, repo, *pats, **opts): | ||
|
r1437 | """show changed files in the working directory | ||
|
r213 | |||
|
r6448 | Show status of files in the repository. If names are given, only | ||
files that match are shown. Files that are clean or ignored or | ||||
|
r8779 | the source of a copy/move operation, are not listed unless | ||
-c/--clean, -i/--ignored, -C/--copies or -A/--all are given. | ||||
Unless options described with "show only ..." are given, the | ||||
options -mardu are used. | ||||
|
r1437 | |||
|
r6201 | Option -q/--quiet hides untracked (unknown and ignored) files | ||
|
r8009 | unless explicitly requested with -u/--unknown or -i/--ignored. | ||
|
r6200 | |||
|
r3822 | NOTE: status may appear to disagree with diff if permissions have | ||
changed or a merge has occurred. The standard diff format does not | ||||
report permission changes and diff only reports changes relative | ||||
to one merge parent. | ||||
|
r3467 | If one revision is given, it is used as the base revision. | ||
|
r8779 | If two revisions are given, the differences between them are | ||
shown. | ||||
|
r3467 | |||
|
r1437 | The codes used to show the status of files are: | ||
|
r746 | M = modified | ||
|
r245 | A = added | ||
R = removed | ||||
|
r2661 | C = clean | ||
|
r8040 | ! = missing (deleted by non-hg command, but still tracked) | ||
|
r842 | ? = not tracked | ||
|
r5998 | I = ignored | ||
|
r8779 | = origin of the previous file listed as A (added) | ||
|
r1437 | """ | ||
|
r312 | |||
|
r3707 | node1, node2 = cmdutil.revpair(repo, opts.get('rev')) | ||
|
r1625 | cwd = (pats and repo.getcwd()) or '' | ||
|
r7131 | end = opts.get('print0') and '\0' or '\n' | ||
|
r6276 | copy = {} | ||
|
r6605 | states = 'modified added removed deleted unknown ignored clean'.split() | ||
|
r7684 | show = [k for k in states if opts.get(k)] | ||
|
r7131 | if opts.get('all'): | ||
|
r6605 | show += ui.quiet and (states[:4] + ['clean']) or states | ||
if not show: | ||||
show = ui.quiet and states[:4] or states[:5] | ||||
stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts), | ||||
'ignored' in show, 'clean' in show, 'unknown' in show) | ||||
changestates = zip(states, 'MAR!?IC', stat) | ||||
|
r7131 | if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'): | ||
|
r6747 | ctxn = repo[nullid] | ||
ctx1 = repo[node1] | ||||
ctx2 = repo[node2] | ||||
|
r6646 | added = stat[1] | ||
if node2 is None: | ||||
added = stat[0] + stat[1] # merged? | ||||
|
r6740 | |||
|
r7622 | for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems(): | ||
|
r6646 | if k in added: | ||
copy[k] = v | ||||
elif v in added: | ||||
|
r6276 | copy[v] = k | ||
|
r6605 | for state, char, files in changestates: | ||
if state in show: | ||||
|
r1966 | format = "%s %%s%s" % (char, end) | ||
|
r7131 | if opts.get('no_status'): | ||
|
r6605 | format = "%%s%s" % end | ||
for f in files: | ||||
ui.write(format % repo.pathto(f, cwd)) | ||||
if f in copy: | ||||
ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end)) | ||||
|
r213 | |||
|
r6321 | def tag(ui, repo, name1, *names, **opts): | ||
"""add one or more tags for the current or given revision | ||||
|
r1437 | |||
Name a particular revision using <name>. | ||||
Tags are used to name particular revisions of the repository and are | ||||
|
r6220 | very useful to compare different revisions, to go back to significant | ||
|
r1437 | earlier versions or to mark branch points as releases, etc. | ||
|
r8004 | If no revision is given, the parent of the working directory is | ||
used, or tip if no revision is checked out. | ||||
|
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 | ||||
|
r6448 | necessary. The file '.hg/localtags' is used for local tags (not | ||
|
r1654 | shared among repositories). | ||
|
r6163 | |||
See 'hg help dates' for a list of formats valid for -d/--date. | ||||
|
r1437 | """ | ||
|
r6321 | |||
|
r6739 | rev_ = "." | ||
|
r6321 | names = (name1,) + names | ||
|
r8152 | if len(names) != len(set(names)): | ||
|
r6321 | raise util.Abort(_('tag names must be unique')) | ||
for n in names: | ||||
if n in ['tip', '.', 'null']: | ||||
raise util.Abort(_('the name \'%s\' is reserved') % n) | ||||
|
r7131 | if opts.get('rev') and opts.get('remove'): | ||
|
r4213 | raise util.Abort(_("--rev and --remove are incompatible")) | ||
|
r7131 | if opts.get('rev'): | ||
|
r1596 | rev_ = opts['rev'] | ||
|
r7131 | message = opts.get('message') | ||
if opts.get('remove'): | ||||
expectedtype = opts.get('local') and 'local' or 'global' | ||||
|
r6321 | for n in names: | ||
if not repo.tagtype(n): | ||||
raise util.Abort(_('tag \'%s\' does not exist') % n) | ||||
if repo.tagtype(n) != expectedtype: | ||||
|
r8008 | if expectedtype == 'global': | ||
raise util.Abort(_('tag \'%s\' is not a global tag') % n) | ||||
else: | ||||
raise util.Abort(_('tag \'%s\' is not a local tag') % n) | ||||
|
r4213 | rev_ = nullid | ||
if not message: | ||||
|
r6321 | message = _('Removed tag %s') % ', '.join(names) | ||
|
r7131 | elif not opts.get('force'): | ||
|
r6321 | for n in names: | ||
if n in repo.tags(): | ||||
raise util.Abort(_('tag \'%s\' already exists ' | ||||
'(use -f to force)') % n) | ||||
|
r3132 | if not rev_ and repo.dirstate.parents()[1] != nullid: | ||
raise util.Abort(_('uncommitted merge - please provide a ' | ||||
'specific revision')) | ||||
|
r6747 | r = repo[rev_].node() | ||
|
r2967 | |||
if not message: | ||||
|
r6321 | message = (_('Added tag %s for changeset %s') % | ||
(', '.join(names), short(r))) | ||||
|
r2967 | |||
|
r6243 | date = opts.get('date') | ||
if date: | ||||
date = util.parsedate(date) | ||||
|
r7131 | repo.tag(names, r, message, opts.get('local'), opts.get('user'), date) | ||
|
r401 | |||
|
r248 | def tags(ui, repo): | ||
|
r1437 | """list repository tags | ||
|
r8004 | This lists both regular and local tags. When the -v/--verbose | ||
switch is used, a third column "local" is printed for local tags. | ||||
|
r1437 | """ | ||
|
r477 | |||
|
r2966 | hexfunc = ui.debugflag and hex or short | ||
|
r5658 | tagtype = "" | ||
|
r8210 | for t, n in reversed(repo.tagslist()): | ||
|
r5658 | if ui.quiet: | ||
ui.write("%s\n" % t) | ||||
continue | ||||
|
r248 | try: | ||
|
r4516 | hn = hexfunc(n) | ||
|
r5658 | r = "%5d:%s" % (repo.changelog.rev(n), hn) | ||
|
r7633 | except error.LookupError: | ||
|
r3930 | r = " ?:%s" % hn | ||
|
r2035 | else: | ||
|
r7948 | spaces = " " * (30 - encoding.colwidth(t)) | ||
|
r5658 | if ui.verbose: | ||
if repo.tagtype(t) == 'local': | ||||
tagtype = " local" | ||||
else: | ||||
tagtype = "" | ||||
ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype)) | ||||
|
r248 | |||
|
r1731 | def tip(ui, repo, **opts): | ||
|
r1437 | """show the tip revision | ||
|
r8779 | The tip revision (usually just called the tip) is the changeset | ||
most recently added to the repository (and therefore the most | ||||
recently changed head). | ||||
|
r6364 | |||
|
r6367 | If you have just made a commit, that commit will be the tip. If | ||
you have just pulled changes from another repository, the tip of | ||||
that repository becomes the current tip. The "tip" tag is special | ||||
and cannot be renamed or assigned to a different changeset. | ||||
|
r1437 | """ | ||
|
r7369 | cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1]) | ||
|
r245 | |||
|
r4699 | def unbundle(ui, repo, fname1, *fnames, **opts): | ||
"""apply one or more changegroup files | ||||
Apply one or more compressed changegroup files generated by the | ||||
bundle command. | ||||
|
r1437 | """ | ||
|
r4699 | fnames = (fname1,) + fnames | ||
|
r6180 | |||
|
r8109 | lock = repo.lock() | ||
|
r6180 | try: | ||
for fname in fnames: | ||||
|
r7271 | f = url.open(ui, fname) | ||
|
r6180 | gen = changegroup.readbundle(f, fname) | ||
modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) | ||||
finally: | ||||
|
r8109 | lock.release() | ||
|
r4699 | |||
|
r7131 | return postincoming(ui, repo, modheads, opts.get('update'), None) | ||
|
r1218 | |||
|
r4450 | def update(ui, repo, node=None, rev=None, clean=False, date=None): | ||
|
r4014 | """update working directory | ||
|
r1437 | |||
|
r8004 | Update the repository's working directory to the specified | ||
revision, or the tip of the current branch if none is specified. | ||||
Use null as the revision to remove the working copy (like 'hg | ||||
clone -U'). | ||||
|
r6375 | |||
|
r8029 | When the working directory contains no uncommitted changes, it | ||
will be replaced by the state of the requested revision from the | ||||
repository. When the requested revision is on a different branch, | ||||
the working directory will additionally be switched to that | ||||
branch. | ||||
|
r7276 | |||
|
r8277 | When there are uncommitted changes, use option -C/--clean to | ||
discard them, forcibly replacing the state of the working | ||||
directory with the requested revision. | ||||
When there are uncommitted changes and option -C/--clean is not | ||||
used, and the parent revision and requested revision are on the | ||||
same branch, and one of them is an ancestor of the other, then the | ||||
new working directory will contain the requested revision merged | ||||
with the uncommitted changes. Otherwise, the update will fail with | ||||
a suggestion to use 'merge' or 'update -C' instead. | ||||
|
r6375 | |||
|
r8004 | If you want to update just one file to an older revision, use | ||
revert. | ||||
|
r6842 | |||
|
r8033 | See 'hg help dates' for a list of formats valid for -d/--date. | ||
|
r1437 | """ | ||
|
r4450 | if rev and node: | ||
raise util.Abort(_("please specify just one revision")) | ||||
if not rev: | ||||
rev = node | ||||
|
r3814 | if date: | ||
|
r4450 | if rev: | ||
|
r3814 | raise util.Abort(_("you can't specify a revision and a date")) | ||
|
r4450 | rev = cmdutil.finddate(ui, repo, date) | ||
|
r3814 | |||
|
r3521 | if clean: | ||
|
r4450 | return hg.clean(repo, rev) | ||
|
r2808 | else: | ||
|
r4450 | return hg.update(repo, rev) | ||
|
r254 | |||
|
r247 | def verify(ui, repo): | ||
|
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. | ||||
""" | ||||
|
r2778 | return hg.verify(repo) | ||
|
r247 | |||
|
r3651 | def version_(ui): | ||
"""output version and copyright information""" | ||||
ui.write(_("Mercurial Distributed SCM (version %s)\n") | ||||
|
r7632 | % util.version()) | ||
|
r3651 | ui.status(_( | ||
|
r7829 | "\nCopyright (C) 2005-2009 Matt Mackall <mpm@selenic.com> and others\n" | ||
|
r3651 | "This is free software; see the source for copying conditions. " | ||
"There is NO\nwarranty; " | ||||
"not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" | ||||
)) | ||||
|
r255 | # Command options and aliases are listed here, alphabetically | ||
|
r3187 | globalopts = [ | ||
('R', 'repository', '', | ||||
_('repository root directory or symbolic path name')), | ||||
('', 'cwd', '', _('change working directory')), | ||||
('y', 'noninteractive', None, | ||||
_('do not prompt, assume \'yes\' for any required answers')), | ||||
('q', 'quiet', None, _('suppress output')), | ||||
('v', 'verbose', None, _('enable additional output')), | ||||
('', 'config', [], _('set/override config option')), | ||||
('', 'debug', None, _('enable debugging output')), | ||||
('', 'debugger', None, _('start debugger')), | ||||
|
r7948 | ('', 'encoding', encoding.encoding, _('set the charset encoding')), | ||
('', 'encodingmode', encoding.encodingmode, | ||||
_('set the charset encoding mode')), | ||||
|
r3187 | ('', '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')), | ||||
] | ||||
|
r3189 | dryrunopts = [('n', 'dry-run', None, | ||
_('do not perform actions, just print output'))] | ||||
|
r3190 | remoteopts = [ | ||
('e', 'ssh', '', _('specify ssh command to use')), | ||||
('', 'remotecmd', '', _('specify hg command to run on the remote side')), | ||||
] | ||||
|
r3188 | walkopts = [ | ||
('I', 'include', [], _('include names matching the given patterns')), | ||||
('X', 'exclude', [], _('exclude names matching the given patterns')), | ||||
] | ||||
|
r3857 | commitopts = [ | ||
('m', 'message', '', _('use <text> as commit message')), | ||||
('l', 'logfile', '', _('read commit message from <file>')), | ||||
] | ||||
|
r5147 | commitopts2 = [ | ||
('d', 'date', '', _('record datecode as commit date')), | ||||
|
r8313 | ('u', 'user', '', _('record the specified user as committer')), | ||
|
r5147 | ] | ||
|
r6192 | templateopts = [ | ||
('', 'style', '', _('display using template map file')), | ||||
('', 'template', '', _('display with template')), | ||||
] | ||||
logopts = [ | ||||
('p', 'patch', None, _('show patch')), | ||||
|
r7763 | ('g', 'git', None, _('use git extended diff format')), | ||
|
r6192 | ('l', 'limit', '', _('limit number of changes displayed')), | ||
('M', 'no-merges', None, _('do not show merges')), | ||||
] + templateopts | ||||
|
r6668 | diffopts = [ | ||
('a', 'text', None, _('treat all files as text')), | ||||
('g', 'git', None, _('use git extended diff format')), | ||||
('', 'nodates', None, _("don't include dates in diff headers")) | ||||
] | ||||
diffopts2 = [ | ||||
('p', 'show-function', None, _('show which function each change is in')), | ||||
('w', 'ignore-all-space', None, | ||||
_('ignore white space when comparing lines')), | ||||
('b', 'ignore-space-change', None, | ||||
_('ignore changes in the amount of white space')), | ||||
('B', 'ignore-blank-lines', None, | ||||
_('ignore changes whose lines are all blank')), | ||||
('U', 'unified', '', _('number of lines of context to show')) | ||||
] | ||||
|
r7402 | similarityopts = [ | ||
('s', 'similarity', '', | ||||
_('guess renamed files by similarity (0<=s<=100)')) | ||||
] | ||||
|
r209 | table = { | ||
|
r7364 | "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')), | ||
|
r2955 | "addremove": | ||
|
r7402 | (addremove, similarityopts + walkopts + dryrunopts, | ||
|
r7364 | _('[OPTION]... [FILE]...')), | ||
|
r6182 | "^annotate|blame": | ||
|
r697 | (annotate, | ||
|
r1437 | [('r', 'rev', '', _('annotate the specified revision')), | ||
|
r3172 | ('f', 'follow', None, _('follow file copies and renames')), | ||
|
r1402 | ('a', 'text', None, _('treat all files as text')), | ||
|
r6134 | ('u', 'user', None, _('list the author (long with -v)')), | ||
('d', 'date', None, _('list the date (short with -q)')), | ||||
|
r1437 | ('n', 'number', None, _('list the revision number (default)')), | ||
('c', 'changeset', None, _('list the changeset')), | ||||
|
r4857 | ('l', 'line-number', None, | ||
_('show line number at the first appearance')) | ||||
|
r3188 | ] + walkopts, | ||
|
r7364 | _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')), | ||
|
r2160 | "archive": | ||
|
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')), | ||||
|
r3188 | ] + walkopts, | ||
|
r7364 | _('[OPTION]... DEST')), | ||
|
r2159 | "backout": | ||
|
r2158 | (backout, | ||
|
r2159 | [('', 'merge', None, | ||
_('merge with old dirstate parent after backout')), | ||||
|
r2614 | ('', 'parent', '', _('parent to choose when backing out merge')), | ||
|
r4450 | ('r', 'rev', '', _('revision to backout')), | ||
|
r5147 | ] + walkopts + commitopts + commitopts2, | ||
|
r7364 | _('[OPTION]... [-r] REV')), | ||
|
r5778 | "bisect": | ||
(bisect, | ||||
[('r', 'reset', False, _('reset bisect state')), | ||||
('g', 'good', False, _('mark changeset good')), | ||||
('b', 'bad', False, _('mark changeset bad')), | ||||
('s', 'skip', False, _('skip testing changeset')), | ||||
|
r7598 | ('c', 'command', '', _('use command to check changeset state')), | ||
|
r5778 | ('U', 'noupdate', False, _('do not update to target'))], | ||
|
r7364 | _("[-gbsr] [-c CMD] [REV]")), | ||
|
r4730 | "branch": | ||
(branch, | ||||
[('f', 'force', None, | ||||
|
r7006 | _('set branch name even if it shadows an existing branch')), | ||
('C', 'clean', None, _('reset branch name to parent branch name'))], | ||||
|
r7364 | _('[-fC] [NAME]')), | ||
|
r4730 | "branches": | ||
(branches, | ||||
[('a', 'active', False, | ||||
_('show only branches that have unmerged heads'))], | ||||
|
r7364 | _('[-a]')), | ||
|
r1218 | "bundle": | ||
(bundle, | ||||
|
r1959 | [('f', 'force', None, | ||
|
r3191 | _('run even when remote repository is unrelated')), | ||
|
r3284 | ('r', 'rev', [], | ||
|
r6304 | _('a changeset up to which you would like to bundle')), | ||
|
r3284 | ('', 'base', [], | ||
_('a base changeset to specify instead of a destination')), | ||||
|
r6570 | ('a', 'all', None, _('bundle all changesets in the repository')), | ||
('t', 'type', 'bzip2', _('bundle compression type to use')), | ||||
|
r3191 | ] + remoteopts, | ||
|
r7364 | _('[-f] [-a] [-r REV]... [--base REV]... FILE [DEST]')), | ||
|
r697 | "cat": | ||
(cat, | ||||
|
r1816 | [('o', 'output', '', _('print output to file with formatted name')), | ||
('r', 'rev', '', _('print the given revision')), | ||||
|
r6094 | ('', 'decode', None, _('apply any matching decode filter')), | ||
|
r3188 | ] + walkopts, | ||
|
r7364 | _('[OPTION]... FILE...')), | ||
|
r697 | "^clone": | ||
(clone, | ||||
|
r6625 | [('U', 'noupdate', None, | ||
_('the clone will only contain a repository (no working copy)')), | ||||
|
r1602 | ('r', 'rev', [], | ||
|
r2764 | _('a changeset you would like to have after cloning')), | ||
|
r1816 | ('', 'pull', None, _('use pull protocol to copy metadata')), | ||
|
r2620 | ('', 'uncompressed', None, | ||
_('use uncompressed transfer (fast over LAN)')), | ||||
|
r3190 | ] + remoteopts, | ||
|
r7364 | _('[OPTION]... SOURCE [DEST]')), | ||
|
r697 | "^commit|ci": | ||
(commit, | ||||
|
r2184 | [('A', 'addremove', None, | ||
_('mark new/missing files as added/removed before committing')), | ||||
|
r7655 | ('', 'close-branch', None, | ||
_('mark a branch as closed, hiding it from the branch list')), | ||||
|
r5147 | ] + walkopts + commitopts + commitopts2, | ||
|
r7364 | _('[OPTION]... [FILE]...')), | ||
|
r1615 | "copy|cp": | ||
(copy, | ||||
|
r1816 | [('A', 'after', None, _('record a copy that has already occurred')), | ||
|
r1615 | ('f', 'force', None, | ||
|
r1816 | _('forcibly copy over an existing managed file')), | ||
|
r3189 | ] + walkopts + dryrunopts, | ||
|
r7364 | _('[OPTION]... [SOURCE]... DEST')), | ||
"debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')), | ||||
"debugcheckstate": (debugcheckstate, []), | ||||
|
r7880 | "debugcommands": (debugcommands, [], _('[COMMAND]')), | ||
|
r2034 | "debugcomplete": | ||
(debugcomplete, | ||||
[('o', 'options', None, _('show the command options'))], | ||||
|
r7364 | _('[-o] CMD')), | ||
|
r5781 | "debugdate": | ||
(debugdate, | ||||
[('e', 'extended', None, _('try extended date formats'))], | ||||
|
r7364 | _('[-e] DATE [RANGE]')), | ||
"debugdata": (debugdata, [], _('FILE REV')), | ||||
"debugfsinfo": (debugfsinfo, [], _('[PATH]')), | ||||
"debugindex": (debugindex, [], _('FILE')), | ||||
"debugindexdot": (debugindexdot, [], _('FILE')), | ||||
"debuginstall": (debuginstall, []), | ||||
|
r1755 | "debugrebuildstate": | ||
(debugrebuildstate, | ||||
|
r1816 | [('r', 'rev', '', _('revision to rebuild to'))], | ||
|
r7364 | _('[-r REV] [REV]')), | ||
|
r4730 | "debugrename": | ||
(debugrename, | ||||
[('r', 'rev', '', _('revision to debug'))], | ||||
|
r7364 | _('[-r REV] FILE')), | ||
|
r5781 | "debugsetparents": | ||
|
r7364 | (debugsetparents, [], _('REV1 [REV2]')), | ||
|
r6296 | "debugstate": | ||
(debugstate, | ||||
[('', 'nodates', None, _('do not display the saved mtime'))], | ||||
|
r7364 | _('[OPTION]...')), | ||
"debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')), | ||||
|
r697 | "^diff": | ||
(diff, | ||||
|
r7628 | [('r', 'rev', [], _('revision')), | ||
('c', 'change', '', _('change made by revision')) | ||||
|
r6668 | ] + diffopts + diffopts2 + walkopts, | ||
|
r7364 | _('[OPTION]... [-r REV1 [-r REV2]] [FILE]...')), | ||
|
r697 | "^export": | ||
(export, | ||||
|
r1615 | [('o', 'output', '', _('print output to file with formatted name')), | ||
|
r6668 | ('', 'switch-parent', None, _('diff against the second parent')) | ||
] + diffopts, | ||||
|
r7364 | _('[OPTION]... [-o OUTFILESPEC] REV...')), | ||
|
r1065 | "grep": | ||
(grep, | ||||
|
r1402 | [('0', 'print0', None, _('end fields with NUL')), | ||
|
r1437 | ('', 'all', None, _('print all revisions that match')), | ||
|
r2870 | ('f', 'follow', None, | ||
_('follow changeset history, or file history across copies and renames')), | ||||
|
r1402 | ('i', 'ignore-case', None, _('ignore case when matching')), | ||
|
r1602 | ('l', 'files-with-matches', None, | ||
|
r8028 | _('print only filenames and revisions that match')), | ||
|
r1437 | ('n', 'line-number', None, _('print matching line numbers')), | ||
('r', 'rev', [], _('search in given revision range')), | ||||
|
r6134 | ('u', 'user', None, _('list the author (long with -v)')), | ||
('d', 'date', None, _('list the date (short with -q)')), | ||||
|
r3188 | ] + walkopts, | ||
|
r7364 | _('[OPTION]... PATTERN [FILE]...')), | ||
|
r905 | "heads": | ||
(heads, | ||||
|
r8031 | [('r', 'rev', '', _('show only heads which are descendants of REV')), | ||
|
r7656 | ('a', 'active', False, | ||
_('show only the active heads from open branches')), | ||||
|
r8695 | ('c', 'closed', False, | ||
_('show normal and closed heads')), | ||||
|
r6192 | ] + templateopts, | ||
|
r7364 | _('[-r REV] [REV]...')), | ||
"help": (help_, [], _('[TOPIC]')), | ||||
|
r4665 | "identify|id": | ||
(identify, | ||||
|
r8028 | [('r', 'rev', '', _('identify the specified revision')), | ||
|
r4666 | ('n', 'num', None, _('show local revision number')), | ||
('i', 'id', None, _('show global revision id')), | ||||
('b', 'branch', None, _('show branch')), | ||||
('t', 'tags', None, _('show tags'))], | ||||
|
r7364 | _('[-nibt] [-r REV] [SOURCE]')), | ||
|
r697 | "import|patch": | ||
(import_, | ||||
|
r1602 | [('p', 'strip', 1, | ||
|
r8038 | _('directory strip option for patch. This has the same ' | ||
|
r2125 | 'meaning as the corresponding patch option')), | ||
|
r3876 | ('b', 'base', '', _('base path')), | ||
|
r1602 | ('f', 'force', None, | ||
|
r4263 | _('skip check for outstanding uncommitted changes')), | ||
|
r5936 | ('', 'no-commit', None, _("don't commit, just update the working directory")), | ||
|
r4263 | ('', 'exact', None, | ||
|
r4592 | _('apply patch to the nodes from which it was generated')), | ||
('', 'import-branch', None, | ||||
|
r8034 | _('use any branch information in patch (implied by --exact)'))] + | ||
|
r7402 | commitopts + commitopts2 + similarityopts, | ||
|
r7364 | _('[OPTION]... PATCH...')), | ||
|
r5778 | "incoming|in": | ||
(incoming, | ||||
|
r6192 | [('f', 'force', None, | ||
|
r1959 | _('run even when remote repository is unrelated')), | ||
|
r1907 | ('n', 'newest-first', None, _('show newest record first')), | ||
|
r1944 | ('', 'bundle', '', _('file to store the bundles into')), | ||
|
r6304 | ('r', 'rev', [], | ||
_('a specific revision up to which you would like to pull')), | ||||
|
r6192 | ] + logopts + remoteopts, | ||
|
r7364 | _('[-p] [-n] [-M] [-f] [-r REV]...' | ||
|
r2544 | ' [--bundle FILENAME] [SOURCE]')), | ||
|
r2598 | "^init": | ||
|
r3885 | (init, | ||
remoteopts, | ||||
|
r7364 | _('[-e CMD] [--remotecmd CMD] [DEST]')), | ||
|
r697 | "locate": | ||
(locate, | ||||
|
r8031 | [('r', 'rev', '', _('search the repository as it stood at REV')), | ||
|
r1602 | ('0', 'print0', None, | ||
_('end filenames with NUL, for use with xargs')), | ||||
('f', 'fullpath', None, | ||||
_('print complete paths from the filesystem root')), | ||||
|
r3188 | ] + walkopts, | ||
|
r7364 | _('[OPTION]... [PATTERN]...')), | ||
|
r697 | "^log|history": | ||
(log, | ||||
|
r3876 | [('f', 'follow', None, | ||
|
r2782 | _('follow changeset history, or file history across copies and renames')), | ||
|
r2784 | ('', 'follow-first', None, | ||
_('only follow the first parent of merge changesets')), | ||||
|
r8028 | ('d', 'date', '', _('show revisions matching date spec')), | ||
|
r3197 | ('C', 'copies', None, _('show copied files')), | ||
|
r4324 | ('k', 'keyword', [], _('do case-insensitive search for a keyword')), | ||
|
r1437 | ('r', 'rev', [], _('show the specified revision or range')), | ||
|
r8028 | ('', 'removed', None, _('include revisions where files were removed')), | ||
|
r1615 | ('m', 'only-merges', None, _('show only merges')), | ||
|
r8028 | ('u', 'user', [], _('revisions committed by user')), | ||
|
r6067 | ('b', 'only-branch', [], | ||
_('show only changesets within the given named branch')), | ||||
|
r2901 | ('P', 'prune', [], _('do not display revision or any of its ancestors')), | ||
|
r6192 | ] + logopts + walkopts, | ||
|
r7364 | _('[OPTION]... [FILE]')), | ||
|
r5778 | "manifest": | ||
(manifest, | ||||
[('r', 'rev', '', _('revision to display'))], | ||||
|
r7364 | _('[-r REV]')), | ||
|
r4014 | "^merge": | ||
|
r2044 | (merge, | ||
|
r4450 | [('f', 'force', None, _('force a merge with outstanding changes')), | ||
('r', 'rev', '', _('revision to merge')), | ||||
|
r8387 | ('S', 'show', None, | ||
_('review revisions to merge (no merge is performed)'))], | ||||
|
r7364 | _('[-f] [[-r] REV]')), | ||
|
r5778 | "outgoing|out": | ||
(outgoing, | ||||
|
r6192 | [('f', 'force', None, | ||
|
r1959 | _('run even when remote repository is unrelated')), | ||
|
r6304 | ('r', 'rev', [], | ||
_('a specific revision up to which you would like to push')), | ||||
|
r1907 | ('n', 'newest-first', None, _('show newest record first')), | ||
|
r6192 | ] + logopts + remoteopts, | ||
|
r7364 | _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')), | ||
|
r1724 | "^parents": | ||
(parents, | ||||
|
r8028 | [('r', 'rev', '', _('show parents from the specified revision')), | ||
|
r6192 | ] + templateopts, | ||
|
r8544 | _('[-r REV] [FILE]')), | ||
|
r7364 | "paths": (paths, [], _('[NAME]')), | ||
|
r697 | "^pull": | ||
(pull, | ||||
|
r1602 | [('u', 'update', None, | ||
|
r3198 | _('update to new tip if changesets were pulled')), | ||
|
r1959 | ('f', 'force', None, | ||
_('run even when remote repository is unrelated')), | ||||
|
r3885 | ('r', 'rev', [], | ||
_('a specific revision up to which you would like to pull')), | ||||
|
r3190 | ] + remoteopts, | ||
|
r7364 | _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')), | ||
|
r818 | "^push": | ||
(push, | ||||
|
r1402 | [('f', 'force', None, _('force push')), | ||
|
r6304 | ('r', 'rev', [], | ||
_('a specific revision up to which you would like to push')), | ||||
|
r3190 | ] + remoteopts, | ||
|
r7364 | _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')), | ||
"recover": (recover, []), | ||||
|
r1615 | "^remove|rm": | ||
(remove, | ||||
|
r6346 | [('A', 'after', None, _('record delete for missing files')), | ||
('f', 'force', None, | ||||
|
r6347 | _('remove (and delete) file even if added or modified')), | ||
|
r3188 | ] + walkopts, | ||
|
r7364 | _('[OPTION]... FILE...')), | ||
|
r1615 | "rename|mv": | ||
(rename, | ||||
|
r1816 | [('A', 'after', None, _('record a rename that has already occurred')), | ||
|
r1615 | ('f', 'force', None, | ||
|
r1816 | _('forcibly copy over an existing managed file')), | ||
|
r3189 | ] + walkopts + dryrunopts, | ||
|
r7364 | _('[OPTION]... SOURCE... DEST')), | ||
|
r6518 | "resolve": | ||
(resolve, | ||||
|
r7527 | [('a', 'all', None, _('remerge all unresolved files')), | ||
('l', 'list', None, _('list state of files needing merge')), | ||||
|
r6518 | ('m', 'mark', None, _('mark files as resolved')), | ||
|
r7765 | ('u', 'unmark', None, _('unmark files as resolved'))] | ||
+ walkopts, | ||||
|
r7364 | _('[OPTION]... [FILE]...')), | ||
|
r5574 | "revert": | ||
|
r697 | (revert, | ||
|
r2983 | [('a', 'all', None, _('revert all changes when no arguments given')), | ||
|
r3814 | ('d', 'date', '', _('tipmost revision matching date')), | ||
|
r2982 | ('r', 'rev', '', _('revision to revert to')), | ||
|
r2029 | ('', 'no-backup', None, _('do not save backup copies of files')), | ||
|
r3189 | ] + walkopts + dryrunopts, | ||
|
r7364 | _('[OPTION]... [-r REV] [NAME]...')), | ||
"rollback": (rollback, []), | ||||
"root": (root, []), | ||||
|
r697 | "^serve": | ||
(serve, | ||||
|
r1437 | [('A', 'accesslog', '', _('name of access log file to write to')), | ||
|
r1740 | ('d', 'daemon', None, _('run server in background')), | ||
|
r1742 | ('', 'daemon-pipefds', '', _('used internally by daemon mode')), | ||
|
r1437 | ('E', 'errorlog', '', _('name of error log file to write to')), | ||
|
r6262 | ('p', 'port', 0, _('port to listen on (default: 8000)')), | ||
('a', 'address', '', _('address to listen on (default: all interfaces)')), | ||||
|
r5835 | ('', 'prefix', '', _('prefix path to serve from (default: server root)')), | ||
|
r1615 | ('n', 'name', '', | ||
|
r8026 | _('name to show in web pages (default: working directory)')), | ||
|
r2124 | ('', 'webdir-conf', '', _('name of the webdir config file' | ||
|
r8027 | ' (serve more than one repository)')), | ||
|
r1740 | ('', 'pid-file', '', _('name of file to write process ID to')), | ||
|
r1402 | ('', 'stdio', None, _('for remote clients')), | ||
|
r1615 | ('t', 'templates', '', _('web templates to use')), | ||
('', 'style', '', _('template style to use')), | ||||
|
r4860 | ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')), | ||
('', 'certificate', '', _('SSL certificate file'))], | ||||
|
r7364 | _('[OPTION]...')), | ||
|
r5781 | "showconfig|debugconfig": | ||
(showconfig, | ||||
[('u', 'untrusted', None, _('show untrusted configuration options'))], | ||||
|
r7364 | _('[-u] [NAME]...')), | ||
|
r1507 | "^status|st": | ||
|
r840 | (status, | ||
|
r2661 | [('A', 'all', None, _('show status of all files')), | ||
('m', 'modified', None, _('show only modified files')), | ||||
|
r1402 | ('a', 'added', None, _('show only added files')), | ||
('r', 'removed', None, _('show only removed files')), | ||||
|
r1619 | ('d', 'deleted', None, _('show only deleted (but tracked) files')), | ||
|
r2661 | ('c', 'clean', None, _('show only files without changes')), | ||
|
r1402 | ('u', 'unknown', None, _('show only unknown (not tracked) files')), | ||
|
r4156 | ('i', 'ignored', None, _('show only ignored files')), | ||
|
r1402 | ('n', 'no-status', None, _('hide status prefix')), | ||
|
r2639 | ('C', 'copies', None, _('show source of copied files')), | ||
|
r1602 | ('0', 'print0', None, | ||
_('end filenames with NUL, for use with xargs')), | ||||
|
r3467 | ('', 'rev', [], _('show difference from revision')), | ||
|
r3188 | ] + walkopts, | ||
|
r7364 | _('[OPTION]... [FILE]...')), | ||
|
r697 | "tag": | ||
(tag, | ||||
|
r4267 | [('f', 'force', None, _('replace existing tag')), | ||
('l', 'local', None, _('make the tag local')), | ||||
|
r4213 | ('r', 'rev', '', _('revision to tag')), | ||
|
r5147 | ('', 'remove', None, _('remove a tag')), | ||
# -l/--local is already there, commitopts cannot be used | ||||
('m', 'message', '', _('use <text> as commit message')), | ||||
] + commitopts2, | ||||
|
r7364 | _('[-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')), | ||
"tags": (tags, []), | ||||
|
r1762 | "tip": | ||
(tip, | ||||
|
r6192 | [('p', 'patch', None, _('show patch')), | ||
|
r7763 | ('g', 'git', None, _('use git extended diff format')), | ||
|
r6192 | ] + templateopts, | ||
|
r7364 | _('[-p]')), | ||
|
r1218 | "unbundle": | ||
(unbundle, | ||||
|
r1601 | [('u', 'update', None, | ||
|
r3198 | _('update to new tip if changesets were unbundled'))], | ||
|
r7364 | _('[-u] FILE...')), | ||
|
r593 | "^update|up|checkout|co": | ||
|
r697 | (update, | ||
|
r6674 | [('C', 'clean', None, _('overwrite locally modified files (no backup)')), | ||
|
r4450 | ('d', 'date', '', _('tipmost revision matching date')), | ||
('r', 'rev', '', _('revision'))], | ||||
|
r7364 | _('[-C] [-d DATE] [[-r] REV]')), | ||
"verify": (verify, []), | ||||
"version": (version_, []), | ||||
|
r1046 | } | ||
|
r209 | |||
|
r7880 | norepo = ("clone init version help debugcommands debugcomplete debugdata" | ||
|
r5741 | " debugindex debugindexdot debugdate debuginstall debugfsinfo") | ||
|
r6189 | optionalrepo = ("identify paths serve showconfig debugancestor") | ||