annotate mercurial/commands.py @ 5124:06154aff2b1a

merge with -stable
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Wed, 08 Aug 2007 23:00:01 +0200
parents f94dbc6c7eaf c80af96943aa
children 13d23d66a6cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
249
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
1 # commands.py - command processing for mercurial
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
2 #
4635
63b9d2deed48 Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4615
diff changeset
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
249
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
4 #
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
5 # This software may be used and distributed according to the terms
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
6 # of the GNU General Public License, incorporated herein by reference.
619e775aa7f9 import and startup cleanups
mpm@selenic.com
parents: 248
diff changeset
7
3886
abaee83ce0a6 Replace demandload with new demandimport
Matt Mackall <mpm@selenic.com>
parents: 3885
diff changeset
8 import demandimport; demandimport.enable()
1092
0a02315976ff commands: use node functions directly
mpm@selenic.com
parents: 1090
diff changeset
9 from node import *
3893
6b4127c7d52a Simplify i18n imports
Matt Mackall <mpm@selenic.com>
parents: 3887
diff changeset
10 from i18n import _
5034
c0417a319e39 commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents: 4967
diff changeset
11 import os, re, sys, urllib
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
12 import ui, hg, util, revlog, bundlerepo, extensions
3886
abaee83ce0a6 Replace demandload with new demandimport
Matt Mackall <mpm@selenic.com>
parents: 3885
diff changeset
13 import difflib, patch, time, help, mdiff, tempfile
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
14 import errno, version, socket
3886
abaee83ce0a6 Replace demandload with new demandimport
Matt Mackall <mpm@selenic.com>
parents: 3885
diff changeset
15 import archival, changegroup, cmdutil, hgweb.server, sshserver
2738
ad4155e757da Kill ui.setconfig_remoteopts
Matt Mackall <mpm@selenic.com>
parents: 2718
diff changeset
16
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
17 # Commands start here, listed alphabetically
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
18
724
1c0c413cccdd Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 723
diff changeset
19 def add(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
20 """add the specified files on the next commit
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
21
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
22 Schedule files to be version controlled and added to the repository.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
23
3831
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
24 The files will be added to the repository at the next commit. To
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
25 undo an add before that, see hg revert.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
26
1568
1d7d0c07e8f3 make all commands be repo-wide by default
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1567
diff changeset
27 If no names are given, add all files in the repository.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
28 """
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
29
724
1c0c413cccdd Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 723
diff changeset
30 names = []
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
31 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts):
942
7eb8cbcca7c4 Modify commands.walk to yield a 4-tuple.
Bryan O'Sullivan <bos@serpentine.com>
parents: 940
diff changeset
32 if exact:
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
33 if ui.verbose:
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
34 ui.status(_('adding %s\n') % rel)
724
1c0c413cccdd Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 723
diff changeset
35 names.append(abs)
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
36 elif abs not in repo.dirstate:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
37 ui.status(_('adding %s\n') % rel)
724
1c0c413cccdd Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 723
diff changeset
38 names.append(abs)
2503
37655f10ced6 Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2494
diff changeset
39 if not opts.get('dry_run'):
2411
734df6333ca4 add: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2410
diff changeset
40 repo.add(names)
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 212
diff changeset
41
766
b444a7e053f1 Get addremove to use new walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 764
diff changeset
42 def addremove(ui, repo, *pats, **opts):
3174
3637d5d17cbc Documentation fixes for addremove.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3165
diff changeset
43 """add all new files, delete all missing files
2181
690da72b0b16 deprecate addremove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2179
diff changeset
44
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
45 Add all new files and remove all missing files from the repository.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
46
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
47 New files are ignored if they match any of the patterns in .hgignore. As
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
48 with add, these changes take effect at the next commit.
2958
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
49
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
50 Use the -s option to detect renamed files. With a parameter > 0,
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
51 this compares every removed file with every added file and records
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
52 those similar enough as renames. This option takes a percentage
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
53 between 0 (disabled) and 100 (files must be identical) as its
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
54 parameter. Detecting renamed files this way can be expensive.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
55 """
4966
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4932
diff changeset
56 try:
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4932
diff changeset
57 sim = float(opts.get('similarity') or 0)
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4932
diff changeset
58 except ValueError:
8d982aef0be1 addremove: print meaningful error message if --similar not numeric
Bryan O'Sullivan <bos@serpentine.com>
parents: 4932
diff changeset
59 raise util.Abort(_('similarity must be a number'))
2958
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
60 if sim < 0 or sim > 100:
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
61 raise util.Abort(_('similarity must be between 0 and 100'))
ff3ea21a981a addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2956
diff changeset
62 return cmdutil.addremove(repo, pats, opts, similarity=sim/100.)
219
8ff4532376a4 hg checkout: refuse to checkout if there are outstanding changes
mpm@selenic.com
parents: 214
diff changeset
63
733
1966c553f652 Convert annotate over to walk interface.
Bryan O'Sullivan <bos@serpentine.com>
parents: 732
diff changeset
64 def annotate(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
65 """show changeset information per file line
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
66
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
67 List changes in files, showing the revision id responsible for each line
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
68
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
69 This command is useful to discover who did a change or when a change took
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
70 place.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
71
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
72 Without the -a option, annotate will avoid processing files it
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
73 detects as binary. With -a, annotate will generate an annotation
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
74 anyway, probably with undesirable results.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
75 """
4847
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
76 getdate = util.cachefunc(lambda x: util.datestr(x[0].date()))
1522
d07d729ce306 Added --date option to annotate.
lupus@debian.org
parents: 1519
diff changeset
77
744
3d88f6dd1ed4 Handle empty file list for annotate
mpm@selenic.com
parents: 743
diff changeset
78 if not pats:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
79 raise util.Abort(_('at least one file name or pattern required'))
744
3d88f6dd1ed4 Handle empty file list for annotate
mpm@selenic.com
parents: 743
diff changeset
80
4847
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
81 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
82 ('number', lambda x: str(x[0].rev())),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
83 ('changeset', lambda x: short(x[0].node())),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
84 ('date', getdate),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
85 ('follow', lambda x: x[0].path()),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
86 ]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
87
3165
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 3159
diff changeset
88 if (not opts['user'] and not opts['changeset'] and not opts['date']
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 3159
diff changeset
89 and not opts['follow']):
714
29fcd195e056 Some cleanups in commands.annotate().
Thomas Arendsen Hein <thomas@intevation.de>
parents: 712
diff changeset
90 opts['number'] = 1
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
91
4847
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
92 linenumber = opts.get('line_number') is not None
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
93 if (linenumber and (not opts['changeset']) and (not opts['number'])):
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
94 raise util.Abort(_('at least one of -n/-c is required for -l'))
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
95
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
96 funcmap = [func for op, func in opmap if opts.get(op)]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
97 if linenumber:
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
98 lastfunc = funcmap[-1]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
99 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
100
3127
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3092
diff changeset
101 ctx = repo.changectx(opts['rev'])
1016
836667830fee Teach annotate about binary files
mpm@selenic.com
parents: 1015
diff changeset
102
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
103 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts,
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
104 node=ctx.node()):
2566
d8560b458f76 Convert hg annotate to context api
Matt Mackall <mpm@selenic.com>
parents: 2565
diff changeset
105 fctx = ctx.filectx(abs)
d8560b458f76 Convert hg annotate to context api
Matt Mackall <mpm@selenic.com>
parents: 2565
diff changeset
106 if not opts['text'] and util.binary(fctx.data()):
1625
e1bcf7fa983f correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1622
diff changeset
107 ui.write(_("%s: binary file\n") % ((pats and rel) or abs))
1016
836667830fee Teach annotate about binary files
mpm@selenic.com
parents: 1015
diff changeset
108 continue
836667830fee Teach annotate about binary files
mpm@selenic.com
parents: 1015
diff changeset
109
4847
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
110 lines = fctx.annotate(follow=opts.get('follow'),
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
111 linenumber=linenumber)
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
112 pieces = []
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
113
4847
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
114 for f in funcmap:
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
115 l = [f(n) for n, dummy in lines]
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
116 if l:
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
117 m = max(map(len, l))
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
118 pieces.append(["%*s" % (m, x) for x in l])
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
119
771
0de223012086 Fixes for annotate
mpm@selenic.com
parents: 770
diff changeset
120 if pieces:
0de223012086 Fixes for annotate
mpm@selenic.com
parents: 770
diff changeset
121 for p, l in zip(zip(*pieces), lines):
0de223012086 Fixes for annotate
mpm@selenic.com
parents: 770
diff changeset
122 ui.write("%s: %s" % (" ".join(p), l[1]))
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
123
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
124 def archive(ui, repo, dest, **opts):
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
125 '''create unversioned archive of a repository revision
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
126
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
127 By default, the revision used is the parent of the working
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
128 directory; use "-r" to specify a different revision.
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
129
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
130 To specify the type of archive to create, use "-t". Valid
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
131 types are:
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
132
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
133 "files" (default): a directory full of files
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
134 "tar": tar archive, uncompressed
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
135 "tbz2": tar archive, compressed using bzip2
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
136 "tgz": tar archive, compressed using gzip
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
137 "uzip": zip archive, uncompressed
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
138 "zip": zip archive, compressed using deflate
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
139
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
140 The exact name of the destination archive or directory is given
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
141 using a format string; see "hg help export" for details.
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
142
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
143 Each member added to an archive file has a directory prefix
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
144 prepended. Use "-p" to specify a format string for the prefix.
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
145 The default is the basename of the archive, with suffixes removed.
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
146 '''
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
147
5061
a49f2a4d5ff7 archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents: 4966
diff changeset
148 ctx = repo.changectx(opts['rev'])
a49f2a4d5ff7 archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents: 4966
diff changeset
149 if not ctx:
a49f2a4d5ff7 archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents: 4966
diff changeset
150 raise util.Abort(_('repository has no revisions'))
a49f2a4d5ff7 archive: abort on empty repository. Fixes #624.
Brendan Cully <brendan@kublai.com>
parents: 4966
diff changeset
151 node = ctx.node()
2873
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2870
diff changeset
152 dest = cmdutil.make_filename(repo, dest, node)
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
153 if os.path.realpath(dest) == repo.root:
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
154 raise util.Abort(_('repository root cannot be destination'))
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
155 dummy, matchfn, dummy = cmdutil.matchpats(repo, [], opts)
2476
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
156 kind = opts.get('type') or 'files'
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
157 prefix = opts['prefix']
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
158 if dest == '-':
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
159 if kind == 'files':
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
160 raise util.Abort(_('cannot archive plain files to stdout'))
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
161 dest = sys.stdout
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
162 if not prefix: prefix = os.path.basename(repo.root) + '-%h'
2873
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2870
diff changeset
163 prefix = cmdutil.make_filename(repo, prefix, node)
2476
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
164 archival.archive(repo, dest, node, kind, not opts['no_decode'],
0f7e4a39d9af archive: make "hg archive -t XXX -" to write to stdout
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2473
diff changeset
165 matchfn, prefix)
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
166
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
167 def backout(ui, repo, node=None, rev=None, **opts):
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
168 '''reverse effect of earlier changeset
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
169
2254
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
170 Commit the backed out changes as a new changeset. The new
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
171 changeset is a child of the backed out changeset.
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
172
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
173 If you back out a changeset other than the tip, a new head is
2254
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
174 created. This head is the parent of the working directory. If
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
175 you back out an old changeset, your working directory will appear
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
176 old after the backout. You should merge the backout changeset
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
177 with another head.
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
178
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
179 The --merge option remembers the parent of the working directory
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
180 before starting the backout, then merges the new head with that
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
181 changeset afterwards. This saves you from doing the merge by
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
182 hand. The result of this merge is not committed, as for a normal
827fcfe88b14 backout command: better help.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2245
diff changeset
183 merge.'''
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
184 if rev and node:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
185 raise util.Abort(_("please specify just one revision"))
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
186
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
187 if not rev:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
188 rev = node
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
189
4726
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4718
diff changeset
190 if not rev:
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4718
diff changeset
191 raise util.Abort(_("please specify a revision to backout"))
f6e961c0155b Fix and test 'hg backout' without or with too many revisions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4718
diff changeset
192
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
193 cmdutil.bail_if_changed(repo)
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
194 op1, op2 = repo.dirstate.parents()
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
195 if op2 != nullid:
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
196 raise util.Abort(_('outstanding uncommitted merge'))
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
197 node = repo.lookup(rev)
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
198 p1, p2 = repo.changelog.parents(node)
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
199 if p1 == nullid:
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
200 raise util.Abort(_('cannot back out a change with no parents'))
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
201 if p2 != nullid:
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
202 if not opts['parent']:
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
203 raise util.Abort(_('cannot back out a merge changeset without '
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
204 '--parent'))
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
205 p = repo.lookup(opts['parent'])
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
206 if p not in (p1, p2):
3679
2956948b81f3 fix warnings generated by pygettext.py.
Marcos Chaves <marcos.nospam@gmail.com>
parents: 3673
diff changeset
207 raise util.Abort(_('%s is not a parent of %s') %
3680
69cf255a55a1 Indentation cleanups for 2956948b81f3.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3679
diff changeset
208 (short(p), short(node)))
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
209 parent = p
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
210 else:
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
211 if opts['parent']:
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
212 raise util.Abort(_('cannot use --parent on non-merge changeset'))
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
213 parent = p1
2822
30f59f4a327e Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents: 2820
diff changeset
214 hg.clean(repo, node, show_stats=False)
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
215 revert_opts = opts.copy()
3818
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
216 revert_opts['date'] = None
2965
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
217 revert_opts['all'] = True
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
218 revert_opts['rev'] = hex(parent)
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
219 revert(ui, repo, **revert_opts)
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
220 commit_opts = opts.copy()
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
221 commit_opts['addremove'] = False
2159
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
222 if not commit_opts['message'] and not commit_opts['logfile']:
4718
934275cd4526 backout: report short hash in commit message
Matt Mackall <mpm@selenic.com>
parents: 4699
diff changeset
223 commit_opts['message'] = _("Backed out changeset %s") % (short(node))
2268
6c9305fbebaf fix coding style of backout editor change.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2267
diff changeset
224 commit_opts['force_editor'] = True
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
225 commit(ui, repo, **commit_opts)
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
226 def nice(node):
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
227 return '%d:%s' % (repo.changelog.rev(node), short(node))
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
228 ui.status(_('changeset %s backs out changeset %s\n') %
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
229 (nice(repo.changelog.tip()), nice(node)))
2493
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
230 if op1 != node:
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
231 if opts['merge']:
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
232 ui.status(_('merging with changeset %s\n') % nice(op1))
3885
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
233 hg.merge(repo, hex(op1))
2493
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
234 else:
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
235 ui.status(_('the backout changeset is a new head - '
9c660e691e90 print message after backout that tells that backout adds new head.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2482
diff changeset
236 'do not forget to merge\n'))
2761
0aa458261901 fix hg backup option recommendation for auto-merge
Christian Ebert <blacktrash@gmx.net>
parents: 2760
diff changeset
237 ui.status(_('(use "backout --merge" '
0aa458261901 fix hg backup option recommendation for auto-merge
Christian Ebert <blacktrash@gmx.net>
parents: 2760
diff changeset
238 'if you want to auto-merge)\n'))
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
239
4197
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4195
diff changeset
240 def branch(ui, repo, label=None, **opts):
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
241 """set or show the current branch name
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
242
4601
e69da61e467e Notify the user that hg branch does not create a branch until commit
Brendan Cully <brendan@kublai.com>
parents: 4593
diff changeset
243 With no argument, show the current branch name. With one argument,
e69da61e467e Notify the user that hg branch does not create a branch until commit
Brendan Cully <brendan@kublai.com>
parents: 4593
diff changeset
244 set the working directory branch name (the branch does not exist in
e69da61e467e Notify the user that hg branch does not create a branch until commit
Brendan Cully <brendan@kublai.com>
parents: 4593
diff changeset
245 the repository until the next commit).
4197
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4195
diff changeset
246
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4195
diff changeset
247 Unless --force is specified, branch will not let you set a
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4195
diff changeset
248 branch name that shadows an existing branch.
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
249 """
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
250
4207
7e1c8a565a4f Move branch read/write to dirstate where it belongs
Matt Mackall <mpm@selenic.com>
parents: 4204
diff changeset
251 if label:
4197
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4195
diff changeset
252 if not opts.get('force') and label in repo.branchtags():
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4195
diff changeset
253 if label not in [p.branch() for p in repo.workingctx().parents()]:
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4195
diff changeset
254 raise util.Abort(_('a branch of the same name already exists'
b2873c587b1a branch: require --force to shadow existing branches
Brendan Cully <brendan@kublai.com>
parents: 4195
diff changeset
255 ' (use --force to override)'))
4207
7e1c8a565a4f Move branch read/write to dirstate where it belongs
Matt Mackall <mpm@selenic.com>
parents: 4204
diff changeset
256 repo.dirstate.setbranch(util.fromlocal(label))
4601
e69da61e467e Notify the user that hg branch does not create a branch until commit
Brendan Cully <brendan@kublai.com>
parents: 4593
diff changeset
257 ui.status(_('marked working directory as branch %s\n') % label)
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
258 else:
4207
7e1c8a565a4f Move branch read/write to dirstate where it belongs
Matt Mackall <mpm@selenic.com>
parents: 4204
diff changeset
259 ui.write("%s\n" % util.tolocal(repo.dirstate.branch()))
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
260
4675
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
261 def branches(ui, repo, active=False):
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
262 """list repository named branches
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
263
4675
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
264 List the repository's named branches, indicating which ones are
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
265 inactive. If active is specified, only show active branches.
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
266
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
267 A branch is considered active if it contains unmerged heads.
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
268 """
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
269 b = repo.branchtags()
4675
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
270 heads = dict.fromkeys(repo.heads(), 1)
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
271 l = [((n in heads), repo.changelog.rev(n), n, t) for t, n in b.items()]
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
272 l.sort()
4675
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
273 l.reverse()
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
274 for ishead, r, n, t in l:
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
275 if active and not ishead:
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
276 # If we're only displaying active branches, abort the loop on
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
277 # encountering the first inactive head
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
278 break
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
279 else:
4675
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
280 hexfunc = ui.debugflag and hex or short
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
281 if ui.quiet:
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
282 ui.write("%s\n" % t)
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
283 else:
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
284 spaces = " " * (30 - util.locallen(t))
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
285 # The code only gets here if inactive branches are being
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
286 # displayed or the branch is active.
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
287 isinactive = ((not ishead) and " (inactive)") or ''
6858a7477a5e Change branches to sort 'active' branches first, and add an option to show only active branches.
Eric Hopper <hopper@omnifarious.org>
parents: 4667
diff changeset
288 ui.write("%s%s %s:%s%s\n" % (t, spaces, r, hexfunc(n), isinactive))
3502
8dc14d630b29 add branch and branches commands
Matt Mackall <mpm@selenic.com>
parents: 3467
diff changeset
289
2494
73ac95671788 push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2493
diff changeset
290 def bundle(ui, repo, fname, dest=None, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
291 """create a changegroup file
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
292
3508
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
293 Generate a compressed changegroup file collecting changesets not
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
294 found in the other repository.
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
295
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
296 If no destination repository is specified the destination is assumed
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
297 to have all the nodes specified by one or more --base parameters.
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
298
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
299 The bundle file can then be transferred using conventional means and
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
300 applied to another repository with the unbundle or pull command.
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
301 This is useful when direct push and pull are not available or when
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
302 exporting an entire repository is undesirable.
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
303
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
304 Applying bundles preserves all changeset contents including
aa8f086cb141 Corrected help text for bundle.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3507
diff changeset
305 permissions, copy/rename information, and revision history.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
306 """
3283
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
307 revs = opts.get('rev') or None
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
308 if revs:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
309 revs = [repo.lookup(rev) for rev in revs]
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
310 base = opts.get('base')
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
311 if base:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
312 if dest:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
313 raise util.Abort(_("--base is incompatible with specifiying "
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
314 "a destination"))
3293
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
315 base = [repo.lookup(rev) for rev in base]
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
316 # create the right base
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
317 # XXX: nodesbetween / changegroup* should be "fixed" instead
3283
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
318 o = []
3656
e50891e461e4 Consolidate brinfo handling
Matt Mackall <mpm@selenic.com>
parents: 3648
diff changeset
319 has = {nullid: None}
3283
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
320 for n in base:
3634
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3632
diff changeset
321 has.update(repo.changelog.reachable(n))
3283
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
322 if revs:
3293
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
323 visit = list(revs)
3283
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
324 else:
3293
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
325 visit = repo.changelog.heads()
3634
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3632
diff changeset
326 seen = {}
3293
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
327 while visit:
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
328 n = visit.pop(0)
3634
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3632
diff changeset
329 parents = [p for p in repo.changelog.parents(n) if p not in has]
3293
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
330 if len(parents) == 0:
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
331 o.insert(0, n)
a225055b3b59 bundle --base: use the right set for the base
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3283
diff changeset
332 else:
3509
630e0b216192 fix graph traversal in commands.bundle (it wasn't O(n))
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3508
diff changeset
333 for p in parents:
630e0b216192 fix graph traversal in commands.bundle (it wasn't O(n))
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3508
diff changeset
334 if p not in seen:
3634
770c4fc03b8e bundle: don't use sets.Set
Matt Mackall <mpm@selenic.com>
parents: 3632
diff changeset
335 seen[p] = 1
3509
630e0b216192 fix graph traversal in commands.bundle (it wasn't O(n))
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3508
diff changeset
336 visit.append(p)
3283
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
337 else:
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
338 cmdutil.setremoteconfig(ui, opts)
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
339 dest, revs = cmdutil.parseurl(
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
340 ui.expandpath(dest or 'default-push', dest or 'default'), revs)
3283
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
341 other = hg.repository(ui, dest)
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
342 o = repo.findoutgoing(other, force=opts['force'])
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
343
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
344 if revs:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
345 cg = repo.changegroupsubset(o, revs, 'bundle')
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
346 else:
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
347 cg = repo.changegroup(o, 'bundle')
3704
9c1737a3e254 fix writebundle for bz2 bundles
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3680
diff changeset
348 changegroup.writebundle(cg, fname, "HG10BZ")
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
349
1254
e6560042b7b8 Switch cat command to use walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1253
diff changeset
350 def cat(ui, repo, file1, *pats, **opts):
3913
283ee8971570 doc string fix: hg cat and manifest default to current parent revision.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3900
diff changeset
351 """output the current or given revision of files
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
352
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
353 Print the specified files as they were at the given revision.
3914
3c82ab166eea doc fix: hg tags defaults to current parent revision, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3913
diff changeset
354 If no revision is given, the parent of the working directory is used,
3c82ab166eea doc fix: hg tags defaults to current parent revision, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3913
diff changeset
355 or tip if no revision is checked out.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
356
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
357 Output may be to a file, in which case the name of the file is
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
358 given using a format string. The formatting rules are the same as
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
359 for the export command, with the following additions:
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
360
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
361 %s basename of file being printed
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
362 %d dirname of file being printed, or '.' if in repo root
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
363 %p root-relative path name of file being printed
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
364 """
3127
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3092
diff changeset
365 ctx = repo.changectx(opts['rev'])
4697
5b2d986de0f8 cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents: 4692
diff changeset
366 err = 1
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
367 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts,
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
368 ctx.node()):
2873
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2870
diff changeset
369 fp = cmdutil.make_file(repo, opts['output'], ctx.node(), pathname=abs)
2565
7f78ca2c7977 convert hg cat to new context api
Matt Mackall <mpm@selenic.com>
parents: 2562
diff changeset
370 fp.write(ctx.filectx(abs).data())
4697
5b2d986de0f8 cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents: 4692
diff changeset
371 err = 0
5b2d986de0f8 cat: return an error on failure
Matt Mackall <mpm@selenic.com>
parents: 4692
diff changeset
372 return err
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
373
698
df78d8ccac4c Use python function instead of external 'cp' command when cloning repos.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 697
diff changeset
374 def clone(ui, source, dest=None, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
375 """make a copy of an existing repository
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
376
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
377 Create a copy of an existing repository in a new directory.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
378
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
379 If no destination directory name is specified, it defaults to the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
380 basename of the source.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
381
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
382 The location of the source is added to the new repository's
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
383 .hg/hgrc file, as the default to be used for future pulls.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
384
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
385 For efficiency, hardlinks are used for cloning whenever the source
2762
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
386 and destination are on the same filesystem (note this applies only
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
387 to the repository data, not to the checked out files). Some
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
388 filesystems, such as AFS, implement hardlinking incorrectly, but
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
389 do not report errors. In these cases, use the --pull option to
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
390 avoid hardlinking.
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
391
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
392 You can safely clone repositories and checked out files using full
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
393 hardlinks with
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
394
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
395 $ cp -al REPO REPOCLONE
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
396
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
397 which is the fastest way to clone. However, the operation is not
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
398 atomic (making sure REPO is not modified during the operation is
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
399 up to you) and you have to make sure your editor breaks hardlinks
2df98f616645 Expand clone help with hardlink information
Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
parents: 2761
diff changeset
400 (Emacs and most Linux Kernel tools do so).
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
401
2764
71029a3247cb clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2763
diff changeset
402 If you use the -r option to clone up to a specific revision, no
71029a3247cb clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2763
diff changeset
403 subsequent revisions will be present in the cloned repository.
71029a3247cb clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2763
diff changeset
404 This option implies --pull, even on local repositories.
71029a3247cb clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2763
diff changeset
405
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
406 See pull for valid source format details.
2590
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
407
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
408 It is possible to specify an ssh:// URL as the destination, but no
3583
8ee579885d23 doc: clone doesn't create a working directory in remote repos
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3578
diff changeset
409 .hg/hgrc and working directory will be created on the remote side.
8ee579885d23 doc: clone doesn't create a working directory in remote repos
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3578
diff changeset
410 Look at the help text for the pull command for important details
8ee579885d23 doc: clone doesn't create a working directory in remote repos
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3578
diff changeset
411 about ssh:// URLs.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
412 """
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
413 cmdutil.setremoteconfig(ui, opts)
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
414 hg.clone(ui, source, dest,
2597
5ba8be56fa8f clone: move code into hg module. make doc better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2590
diff changeset
415 pull=opts['pull'],
2620
de82749d3a71 clone: change name of --stream to --uncompressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2618
diff changeset
416 stream=opts['uncompressed'],
2597
5ba8be56fa8f clone: move code into hg module. make doc better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2590
diff changeset
417 rev=opts['rev'],
5ba8be56fa8f clone: move code into hg module. make doc better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2590
diff changeset
418 update=not opts['noupdate'])
515
03f27b1381f9 Whitespace cleanups
mpm@selenic.com
parents: 513
diff changeset
419
813
80fd2958235a Adapt commit to use file matching code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 812
diff changeset
420 def commit(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
421 """commit the specified files or all outstanding changes
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
422
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
423 Commit changes to the given files into the repository.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
424
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
425 If a list of files is omitted, all changes reported by "hg status"
1995
2da2d46862fb Spelling fix: "commited" -> "committed"
mcmillen@cs.cmu.edu
parents: 1994
diff changeset
426 will be committed.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
427
1996
4c70b10f0418 Don't mention deprecated HGEDITOR variable in the help text of commit.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1995
diff changeset
428 If no commit message is specified, the editor configured in your hgrc
4c70b10f0418 Don't mention deprecated HGEDITOR variable in the help text of commit.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1995
diff changeset
429 or in the EDITOR environment variable is started to enter a message.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
430 """
5034
c0417a319e39 commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents: 4967
diff changeset
431 def commitfunc(ui, repo, files, message, match, opts):
c0417a319e39 commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents: 4967
diff changeset
432 return repo.commit(files, message, opts['user'], opts['date'], match,
c0417a319e39 commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents: 4967
diff changeset
433 force_editor=opts.get('force_editor'))
c0417a319e39 commands: move commit to cmdutil as wrapper for commit-like functions
Bryan O'Sullivan <bos@serpentine.com>
parents: 4967
diff changeset
434 cmdutil.commit(ui, repo, commitfunc, pats, opts)
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
435
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
436 def docopy(ui, repo, pats, opts):
1822
64df4220b349 copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents: 1812
diff changeset
437 # called with the repo lock held
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
438 #
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
439 # hgsep => pathname that uses "/" to separate directories
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
440 # ossep => pathname that uses os.sep to separate directories
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
441 cwd = repo.getcwd()
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
442 errors = 0
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
443 copied = []
1514
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
444 targets = {}
1249
a5355fa5e33a Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents: 1247
diff changeset
445
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
446 # abs: hgsep
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
447 # rel: ossep
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
448 # return: hgsep
1249
a5355fa5e33a Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents: 1247
diff changeset
449 def okaytocopy(abs, rel, exact):
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
450 reasons = {'?': _('is not managed'),
1634
f49f602fae92 copy & rename can ignore removed source files
Robin Farine <robin.farine@terminus.org>
parents: 1633
diff changeset
451 'r': _('has been marked for remove')}
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
452 state = repo.dirstate[abs]
1747
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
453 reason = reasons.get(state)
1249
a5355fa5e33a Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents: 1247
diff changeset
454 if reason:
4777
44e17f5029d0 Make hg add foo; hg mv foo bar work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4738
diff changeset
455 if exact:
44e17f5029d0 Make hg add foo; hg mv foo bar work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4738
diff changeset
456 ui.warn(_('%s: not copying - file %s\n') % (rel, reason))
44e17f5029d0 Make hg add foo; hg mv foo bar work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4738
diff changeset
457 else:
1747
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
458 if state == 'a':
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
459 origsrc = repo.dirstate.copied(abs)
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
460 if origsrc is not None:
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
461 return origsrc
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
462 return abs
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
463
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
464 # origsrc: hgsep
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
465 # abssrc: hgsep
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
466 # relsrc: ossep
4523
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
467 # otarget: ossep
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
468 def copy(origsrc, abssrc, relsrc, otarget, exact):
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
469 abstarget = util.canonpath(repo.root, cwd, otarget)
4525
78b6add1f966 Add dirstate.pathto and localrepo.pathto.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4524
diff changeset
470 reltarget = repo.pathto(abstarget, cwd)
1514
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
471 prevsrc = targets.get(abstarget)
4523
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
472 src = repo.wjoin(abssrc)
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
473 target = repo.wjoin(abstarget)
1514
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
474 if prevsrc is not None:
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
475 ui.warn(_('%s: not overwriting - %s collides with %s\n') %
4526
cbabc9ac7424 docopy: use repo.pathto to format paths for printing
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4525
diff changeset
476 (reltarget, repo.pathto(abssrc, cwd),
cbabc9ac7424 docopy: use repo.pathto to format paths for printing
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4525
diff changeset
477 repo.pathto(prevsrc, cwd)))
1514
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
478 return
4523
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
479 if (not opts['after'] and os.path.exists(target) or
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
480 opts['after'] and repo.dirstate[abstarget] in 'mn'):
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
481 if not opts['force']:
1513
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
482 ui.warn(_('%s: not overwriting - file exists\n') %
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
483 reltarget)
5c3b93b244aa copy & rename don't overwrite unless --force is specified
Robin Farine <robin.farine@terminus.org>
parents: 1512
diff changeset
484 return
2503
37655f10ced6 Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2494
diff changeset
485 if not opts['after'] and not opts.get('dry_run'):
4523
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
486 os.unlink(target)
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
487 if opts['after']:
4523
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
488 if not os.path.exists(target):
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
489 return
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
490 else:
4523
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
491 targetdir = os.path.dirname(target) or '.'
2503
37655f10ced6 Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2494
diff changeset
492 if not os.path.isdir(targetdir) and not opts.get('dry_run'):
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
493 os.makedirs(targetdir)
1249
a5355fa5e33a Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents: 1247
diff changeset
494 try:
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
495 restore = repo.dirstate[abstarget] == 'r'
2503
37655f10ced6 Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2494
diff changeset
496 if restore and not opts.get('dry_run'):
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
497 repo.undelete([abstarget])
1822
64df4220b349 copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents: 1812
diff changeset
498 try:
2503
37655f10ced6 Don't require opts['dry_run'] to be set to fix external tools like tailor.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2494
diff changeset
499 if not opts.get('dry_run'):
4523
b9d311928caf Use absolute paths in docopy.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4516
diff changeset
500 util.copyfile(src, target)
1822
64df4220b349 copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents: 1812
diff changeset
501 restore = False
64df4220b349 copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents: 1812
diff changeset
502 finally:
64df4220b349 copy/rename to a removed destination file
Robin Farine <robin.farine@terminus.org>
parents: 1812
diff changeset
503 if restore:
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
504 repo.remove([abstarget])
1249
a5355fa5e33a Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents: 1247
diff changeset
505 except IOError, inst:
a5355fa5e33a Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents: 1247
diff changeset
506 if inst.errno == errno.ENOENT:
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
507 ui.warn(_('%s: deleted in working copy\n') % relsrc)
1249
a5355fa5e33a Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents: 1247
diff changeset
508 else:
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
509 ui.warn(_('%s: cannot copy - %s\n') %
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
510 (relsrc, inst.strerror))
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
511 errors += 1
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
512 return
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
513 if ui.verbose or not exact:
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
514 ui.status(_('copying %s to %s\n') % (relsrc, reltarget))
1514
faf46d810a85 avoid to copy more than one file to the same destination file
Robin Farine <robin.farine@terminus.org>
parents: 1513
diff changeset
515 targets[abstarget] = abssrc
4777
44e17f5029d0 Make hg add foo; hg mv foo bar work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4738
diff changeset
516 if abstarget != origsrc:
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
517 if repo.dirstate[origsrc] == 'a':
4864
fc8b3e7cbf6b improve warning for hg add foo; hg mv foo bar
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4803
diff changeset
518 if not ui.quiet:
fc8b3e7cbf6b improve warning for hg add foo; hg mv foo bar
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4803
diff changeset
519 ui.warn(_("%s has not been committed yet, so no copy "
fc8b3e7cbf6b improve warning for hg add foo; hg mv foo bar
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4803
diff changeset
520 "data will be stored for %s.\n")
fc8b3e7cbf6b improve warning for hg add foo; hg mv foo bar
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4803
diff changeset
521 % (repo.pathto(origsrc, cwd), reltarget))
4777
44e17f5029d0 Make hg add foo; hg mv foo bar work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4738
diff changeset
522 if abstarget not in repo.dirstate and not opts.get('dry_run'):
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
523 repo.add([abstarget])
4777
44e17f5029d0 Make hg add foo; hg mv foo bar work.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4738
diff changeset
524 elif not opts.get('dry_run'):
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
525 repo.copy(origsrc, abstarget)
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
526 copied.append((abssrc, relsrc, exact))
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
527
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
528 # pat: ossep
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
529 # dest ossep
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
530 # srcs: list of (hgsep, hgsep, ossep, bool)
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
531 # return: function that takes hgsep and returns ossep
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
532 def targetpathfn(pat, dest, srcs):
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
533 if os.path.isdir(pat):
1633
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
534 abspfx = util.canonpath(repo.root, cwd, pat)
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
535 abspfx = util.localpath(abspfx)
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
536 if destdirexists:
1633
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
537 striplen = len(os.path.split(abspfx)[0])
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
538 else:
1633
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
539 striplen = len(abspfx)
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
540 if striplen:
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
541 striplen += len(os.sep)
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
542 res = lambda p: os.path.join(dest, util.localpath(p)[striplen:])
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
543 elif destdirexists:
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
544 res = lambda p: os.path.join(dest,
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
545 os.path.basename(util.localpath(p)))
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
546 else:
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
547 res = lambda p: dest
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
548 return res
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
549
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
550 # pat: ossep
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
551 # dest ossep
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
552 # srcs: list of (hgsep, hgsep, ossep, bool)
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
553 # return: function that takes hgsep and returns ossep
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
554 def targetpathafterfn(pat, dest, srcs):
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
555 if util.patkind(pat, None)[0]:
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
556 # a mercurial pattern
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
557 res = lambda p: os.path.join(dest,
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
558 os.path.basename(util.localpath(p)))
1633
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
559 else:
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
560 abspfx = util.canonpath(repo.root, cwd, pat)
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
561 if len(abspfx) < len(srcs[0][0]):
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
562 # A directory. Either the target path contains the last
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
563 # component of the source path or it does not.
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
564 def evalpath(striplen):
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
565 score = 0
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
566 for s in srcs:
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
567 t = os.path.join(dest, util.localpath(s[0])[striplen:])
1633
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
568 if os.path.exists(t):
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
569 score += 1
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
570 return score
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
571
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
572 abspfx = util.localpath(abspfx)
1633
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
573 striplen = len(abspfx)
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
574 if striplen:
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
575 striplen += len(os.sep)
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
576 if os.path.isdir(os.path.join(dest, os.path.split(abspfx)[1])):
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
577 score = evalpath(striplen)
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
578 striplen1 = len(os.path.split(abspfx)[0])
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
579 if striplen1:
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
580 striplen1 += len(os.sep)
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
581 if evalpath(striplen1) > score:
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
582 striplen = striplen1
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
583 res = lambda p: os.path.join(dest,
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
584 util.localpath(p)[striplen:])
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
585 else:
1633
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
586 # a file
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
587 if destdirexists:
3652
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
588 res = lambda p: os.path.join(dest,
d2d8d23944a9 commands.docopy: pay attention on whether paths use "/" or os.sep
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3648
diff changeset
589 os.path.basename(util.localpath(p)))
1633
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
590 else:
94c179a92f4a copy/rename '.' or '..' correctly
Robin Farine <robin.farine@terminus.org>
parents: 1626
diff changeset
591 res = lambda p: dest
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
592 return res
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
593
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
594
4055
e37786b29bed docopy: deal with globs on windows in a better way
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4053
diff changeset
595 pats = util.expand_glob(pats)
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
596 if not pats:
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
597 raise util.Abort(_('no source or destination specified'))
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
598 if len(pats) == 1:
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
599 raise util.Abort(_('no destination specified'))
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
600 dest = pats.pop()
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
601 destdirexists = os.path.isdir(dest)
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
602 if (len(pats) > 1 or util.patkind(pats[0], None)[0]) and not destdirexists:
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
603 raise util.Abort(_('with multiple sources, destination must be an '
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
604 'existing directory'))
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
605 if opts['after']:
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
606 tfn = targetpathafterfn
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
607 else:
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
608 tfn = targetpathfn
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
609 copylist = []
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
610 for pat in pats:
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
611 srcs = []
4055
e37786b29bed docopy: deal with globs on windows in a better way
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4053
diff changeset
612 for tag, abssrc, relsrc, exact in cmdutil.walk(repo, [pat], opts,
e37786b29bed docopy: deal with globs on windows in a better way
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4053
diff changeset
613 globbed=True):
1747
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
614 origsrc = okaytocopy(abssrc, relsrc, exact)
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
615 if origsrc:
91c56c427171 transitive copy/rename
Robin Farine <robin.farine@terminus.org>
parents: 1743
diff changeset
616 srcs.append((origsrc, abssrc, relsrc, exact))
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
617 if not srcs:
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
618 continue
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
619 copylist.append((tfn(pat, dest, srcs), srcs))
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
620 if not copylist:
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
621 raise util.Abort(_('no files to copy'))
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1561
diff changeset
622
2414
86e07466bcfc remove: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2413
diff changeset
623 for targetpath, srcs in copylist:
86e07466bcfc remove: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2413
diff changeset
624 for origsrc, abssrc, relsrc, exact in srcs:
86e07466bcfc remove: add -n/--dry-run option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2413
diff changeset
625 copy(origsrc, abssrc, relsrc, targetpath(abssrc), exact)
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
626
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
627 if errors:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
628 ui.warn(_('(consider using --after)\n'))
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents: 1507
diff changeset
629 return errors, copied
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
630
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
631 def copy(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
632 """mark files as copied for the next commit
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
633
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
634 Mark dest as having copies of source files. If dest is a
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
635 directory, copies are put in that directory. If dest is a file,
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
636 there can only be one source.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
637
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
638 By default, this command copies the contents of files as they
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
639 stand in the working directory. If invoked with --after, the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
640 operation is recorded, but no copying is performed.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
641
3831
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
642 This command takes effect in the next commit. To undo a copy
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
643 before that, see hg revert.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
644 """
4958
9a2a73ea6135 repo locks: use True/False
Matt Mackall <mpm@selenic.com>
parents: 4950
diff changeset
645 wlock = repo.wlock(False)
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
646 try:
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
647 errs, copied = docopy(ui, repo, pats, opts)
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
648 finally:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
649 del wlock
1249
a5355fa5e33a Fix up copy command to behave more like regular "cp".
Bryan O'Sullivan <bos@serpentine.com>
parents: 1247
diff changeset
650 return errs
363
ae96b7e1318d Add hg copy
mpm@selenic.com
parents: 355
diff changeset
651
1262
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
652 def debugancestor(ui, index, rev1, rev2):
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
653 """find the ancestor revision of two revisions in a given index"""
4267
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4266
diff changeset
654 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
1262
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
655 a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
656 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
325c07fd2ebd Add debugancestor command
mpm@selenic.com
parents: 1257
diff changeset
657
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
658 def debugcomplete(ui, cmd='', **opts):
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1875
diff changeset
659 """returns the completion list associated with the given command"""
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
660
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
661 if opts['options']:
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
662 options = []
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
663 otables = [globalopts]
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
664 if cmd:
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
665 aliases, entry = cmdutil.findcmd(ui, cmd)
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
666 otables.append(entry[1])
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
667 for t in otables:
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
668 for o in t:
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
669 if o[0]:
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
670 options.append('-%s' % o[0])
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
671 options.append('--%s' % o[1])
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
672 ui.write("%s\n" % "\n".join(options))
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
673 return
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
674
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
675 clist = cmdutil.findpossible(ui, cmd).keys()
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1875
diff changeset
676 clist.sort()
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
677 ui.write("%s\n" % "\n".join(clist))
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1875
diff changeset
678
3972
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
679 def debugrebuildstate(ui, repo, rev=""):
1755
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
680 """rebuild the dirstate as it would look like for the given revision"""
3972
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
681 if rev == "":
1755
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
682 rev = repo.changelog.tip()
3972
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
683 ctx = repo.changectx(rev)
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
684 files = ctx.manifest()
1760
13f8e068d13c fix typo in debugrebuildstate
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1755
diff changeset
685 wlock = repo.wlock()
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
686 try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
687 repo.dirstate.rebuild(rev, files)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
688 finally:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
689 del wlock
1755
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
690
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
691 def debugcheckstate(ui, repo):
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
692 """validate the correctness of the current dirstate"""
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
693 parent1, parent2 = repo.dirstate.parents()
3972
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
694 m1 = repo.changectx(parent1).manifest()
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
695 m2 = repo.changectx(parent2).manifest()
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
696 errors = 0
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
697 for f in repo.dirstate:
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
698 state = repo.dirstate[f]
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
699 if state in "nr" and f not in m1:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
700 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
701 errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
702 if state in "a" and f in m1:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
703 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
704 errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
705 if state in "m" and f not in m1 and f not in m2:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
706 ui.warn(_("%s in state %s, but not in either manifest\n") %
582
df8a5a0098d4 Remove all remaining print statements
mpm@selenic.com
parents: 580
diff changeset
707 (f, state))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
708 errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
709 for f in m1:
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
710 state = repo.dirstate[f]
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
711 if state not in "nrm":
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
712 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
713 errors += 1
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
714 if errors:
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
715 error = _(".hg/dirstate inconsistent with current parent's manifest")
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
716 raise util.Abort(error)
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
717
3539
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3524
diff changeset
718 def showconfig(ui, repo, *values, **opts):
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
719 """show combined config settings from all hgrc files
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
720
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
721 With no args, print names and values of all config items.
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
722
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
723 With one arg of the form section.name, print just the value of
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
724 that config item.
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
725
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
726 With multiple args, print names and values of all config items
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
727 with matching section names."""
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
728
3539
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3524
diff changeset
729 untrusted = bool(opts.get('untrusted'))
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
730 if values:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
731 if len([v for v in values if '.' in v]) > 1:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
732 raise util.Abort(_('only one config item permitted'))
3539
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3524
diff changeset
733 for section, name, value in ui.walkconfig(untrusted=untrusted):
2410
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
734 sectname = section + '.' + name
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
735 if values:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
736 for v in values:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
737 if v == section:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
738 ui.write('%s=%s\n' % (sectname, value))
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
739 elif v == sectname:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
740 ui.write(value, '\n')
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
741 else:
1e80d47b8581 debugconfig: allow to print by section and exact item name
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2407
diff changeset
742 ui.write('%s=%s\n' % (sectname, value))
1028
25e7ea0f2cff Add commands.debugconfig.
Bryan O'Sullivan <bos@serpentine.com>
parents: 989
diff changeset
743
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
744 def debugsetparents(ui, repo, rev1, rev2=None):
1470
fb9b84c91222 minor fix on command help docstrings
TK Soh <teekaysoh@yahoo.com>
parents: 1469
diff changeset
745 """manually set the parents of the current working directory
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
746
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
747 This is useful for writing repository conversion tools, but should
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
748 be used with care.
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
749 """
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
750
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
751 if not rev2:
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
752 rev2 = hex(nullid)
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
753
4249
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
754 wlock = repo.wlock()
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
755 try:
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
756 repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
89075f106414 debugsetparents: wlock the repo before updating the dirstate
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4231
diff changeset
757 finally:
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
758 del wlock
1395
c2eb204917f8 Add debugsetparents command
Matt Mackall <mpm@selenic.com>
parents: 1390
diff changeset
759
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
760 def debugstate(ui, repo):
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
761 """show the contents of the current dirstate"""
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
762 dc = repo.dirstate._map
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
763 k = dc.keys()
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
764 k.sort()
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
765 for file_ in k:
4053
994fec0ee900 mtime can be -1 after a merge and cause tracebacks on win32.
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4043
diff changeset
766 if dc[file_][3] == -1:
994fec0ee900 mtime can be -1 after a merge and cause tracebacks on win32.
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4043
diff changeset
767 # Pad or slice to locale representation
994fec0ee900 mtime can be -1 after a merge and cause tracebacks on win32.
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4043
diff changeset
768 locale_len = len(time.strftime("%x %X", time.localtime(0)))
994fec0ee900 mtime can be -1 after a merge and cause tracebacks on win32.
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4043
diff changeset
769 timestr = 'unset'
994fec0ee900 mtime can be -1 after a merge and cause tracebacks on win32.
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4043
diff changeset
770 timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr))
994fec0ee900 mtime can be -1 after a merge and cause tracebacks on win32.
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4043
diff changeset
771 else:
994fec0ee900 mtime can be -1 after a merge and cause tracebacks on win32.
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4043
diff changeset
772 timestr = time.strftime("%x %X", time.localtime(dc[file_][3]))
791
040655ea0cc4 Show all dirstate info for 'hg debugstate'.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 770
diff changeset
773 ui.write("%c %3o %10d %s %s\n"
040655ea0cc4 Show all dirstate info for 'hg debugstate'.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 770
diff changeset
774 % (dc[file_][0], dc[file_][1] & 0777, dc[file_][2],
4053
994fec0ee900 mtime can be -1 after a merge and cause tracebacks on win32.
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4043
diff changeset
775 timestr, file_))
3159
e43fd1623fe1 fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3146
diff changeset
776 for f in repo.dirstate.copies():
e43fd1623fe1 fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3146
diff changeset
777 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
460
6409d9a0df43 add dirstate debugging commands
mpm@selenic.com
parents: 452
diff changeset
778
1039
4296754ba7b4 Add debugdata for dumping revlog revision data
mpm@selenic.com
parents: 1037
diff changeset
779 def debugdata(ui, file_, rev):
4267
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4266
diff changeset
780 """dump the contents of a data file revision"""
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4266
diff changeset
781 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
1313
1cc7c0cbc30b Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents: 1312
diff changeset
782 try:
1cc7c0cbc30b Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents: 1312
diff changeset
783 ui.write(r.revision(r.lookup(rev)))
1cc7c0cbc30b Fix traceback during invalid rev identifier for debugdata
Anupam Kapoor<anupam.kapoor@gmail.com>
parents: 1312
diff changeset
784 except KeyError:
3069
bc3fe3b5b785 Never apply string formatting to generated errors with util.Abort.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3068
diff changeset
785 raise util.Abort(_('invalid revision identifier %s') % rev)
1039
4296754ba7b4 Add debugdata for dumping revlog revision data
mpm@selenic.com
parents: 1037
diff changeset
786
3815
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3807
diff changeset
787 def debugdate(ui, date, range=None, **opts):
3807
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
788 """parse and display a date"""
3815
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3807
diff changeset
789 if opts["extended"]:
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3807
diff changeset
790 d = util.parsedate(date, util.extendeddateformats)
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3807
diff changeset
791 else:
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3807
diff changeset
792 d = util.parsedate(date)
3807
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
793 ui.write("internal: %s %s\n" % d)
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
794 ui.write("standard: %s\n" % util.datestr(d))
3815
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3807
diff changeset
795 if range:
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3807
diff changeset
796 m = util.matchdate(range)
bf6ab30559e6 Add date matching support
Matt Mackall <mpm@selenic.com>
parents: 3807
diff changeset
797 ui.write("match: %s\n" % m(d[0]))
3807
299d6cce6c0b add debugdate command
Matt Mackall <mpm@selenic.com>
parents: 3804
diff changeset
798
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
799 def debugindex(ui, file_):
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
800 """dump the contents of an index file"""
4267
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4266
diff changeset
801 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
582
df8a5a0098d4 Remove all remaining print statements
mpm@selenic.com
parents: 580
diff changeset
802 ui.write(" rev offset length base linkrev" +
989
1b6eb272b238 Reformat debugindex output
mpm@selenic.com
parents: 988
diff changeset
803 " nodeid p1 p2\n")
3467
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3466
diff changeset
804 for i in xrange(r.count()):
2072
74d3f5336b66 Implement revlogng.
mason@suse.com
parents: 2042
diff changeset
805 node = r.node(i)
74d3f5336b66 Implement revlogng.
mason@suse.com
parents: 2042
diff changeset
806 pp = r.parents(node)
989
1b6eb272b238 Reformat debugindex output
mpm@selenic.com
parents: 988
diff changeset
807 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2072
74d3f5336b66 Implement revlogng.
mason@suse.com
parents: 2042
diff changeset
808 i, r.start(i), r.length(i), r.base(i), r.linkrev(node),
74d3f5336b66 Implement revlogng.
mason@suse.com
parents: 2042
diff changeset
809 short(node), short(pp[0]), short(pp[1])))
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
810
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
811 def debugindexdot(ui, file_):
596
9a8daeff0ffa A bunch of parsing/help updates
mpm@selenic.com
parents: 593
diff changeset
812 """dump an index DAG as a .dot file"""
4267
b11a2fb59cf5 revlog: simplify revlog version handling
Matt Mackall <mpm@selenic.com>
parents: 4266
diff changeset
813 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
582
df8a5a0098d4 Remove all remaining print statements
mpm@selenic.com
parents: 580
diff changeset
814 ui.write("digraph G {\n")
3467
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3466
diff changeset
815 for i in xrange(r.count()):
2287
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
816 node = r.node(i)
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
817 pp = r.parents(node)
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
818 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
819 if pp[1] != nullid:
3f18d1eea370 Update debugindexdot to work with RevlogNG.
Samuel Masham <samuel.masham@gmail.com>
parents: 2283
diff changeset
820 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
582
df8a5a0098d4 Remove all remaining print statements
mpm@selenic.com
parents: 580
diff changeset
821 ui.write("}\n")
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
822
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
823 def debuginstall(ui):
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
824 '''test Mercurial installation'''
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
825
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
826 def writetemp(contents):
4836
035489f60842 Use a prefix for debuginstall tempfiles.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4819
diff changeset
827 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
828 f = os.fdopen(fd, "wb")
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
829 f.write(contents)
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
830 f.close()
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
831 return name
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
832
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
833 problems = 0
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
834
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
835 # encoding
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
836 ui.status(_("Checking encoding (%s)...\n") % util._encoding)
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
837 try:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
838 util.fromlocal("test")
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
839 except util.Abort, inst:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
840 ui.write(" %s\n" % inst)
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
841 ui.write(_(" (check that your locale is properly set)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
842 problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
843
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
844 # compiled modules
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
845 ui.status(_("Checking extensions...\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
846 try:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
847 import bdiff, mpatch, base85
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
848 except Exception, inst:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
849 ui.write(" %s\n" % inst)
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
850 ui.write(_(" One or more extensions could not be found"))
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
851 ui.write(_(" (check that you compiled the extensions)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
852 problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
853
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
854 # templates
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
855 ui.status(_("Checking templates...\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
856 try:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
857 import templater
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
858 t = templater.templater(templater.templatepath("map-cmdline.default"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
859 except Exception, inst:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
860 ui.write(" %s\n" % inst)
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
861 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
862 problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
863
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
864 # patch
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
865 ui.status(_("Checking patch...\n"))
4435
aac150af09e8 Add ui.patch option.
Patrick Mezard <pmezard@gmail.com>
parents: 4394
diff changeset
866 patcher = ui.config('ui', 'patch')
4482
62019c4427e3 Introduce find_exe. Use instead of find_in_path for programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4438
diff changeset
867 patcher = ((patcher and util.find_exe(patcher)) or
62019c4427e3 Introduce find_exe. Use instead of find_in_path for programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4438
diff changeset
868 util.find_exe('gpatch') or
62019c4427e3 Introduce find_exe. Use instead of find_in_path for programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4438
diff changeset
869 util.find_exe('patch'))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
870 if not patcher:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
871 ui.write(_(" Can't find patch or gpatch in PATH\n"))
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
872 ui.write(_(" (specify a patch utility in your .hgrc file)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
873 problems += 1
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
874 else:
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
875 # actually attempt a patch here
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
876 a = "1\n2\n3\n4\n"
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
877 b = "1\n2\n3\ninsert\n4\n"
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
878 fa = writetemp(a)
4382
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
879 d = mdiff.unidiff(a, None, b, None, os.path.basename(fa))
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
880 fd = writetemp(d)
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4505
diff changeset
881
4382
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
882 files = {}
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
883 try:
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
884 patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files)
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
885 except util.Abort, e:
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
886 ui.write(_(" patch call failed:\n"))
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
887 ui.write(" " + str(e) + "\n")
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
888 problems += 1
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4505
diff changeset
889 else:
4382
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
890 if list(files) != [os.path.basename(fa)]:
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
891 ui.write(_(" unexpected patch output!"))
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
892 ui.write(_(" (you may have an incompatible version of patch)\n"))
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
893 problems += 1
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
894 a = file(fa).read()
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
895 if a != b:
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
896 ui.write(_(" patch test failed!"))
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
897 ui.write(_(" (you may have an incompatible version of patch)\n"))
caaba589d9c7 Use patch.patch() when checking for patch availability.
Patrick Mezard <pmezard@gmail.com>
parents: 4381
diff changeset
898 problems += 1
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4505
diff changeset
899
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
900 os.unlink(fa)
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
901 os.unlink(fd)
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
902
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
903 # merge helper
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
904 ui.status(_("Checking merge helper...\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
905 cmd = (os.environ.get("HGMERGE") or ui.config("ui", "merge")
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
906 or "hgmerge")
4482
62019c4427e3 Introduce find_exe. Use instead of find_in_path for programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4438
diff changeset
907 cmdpath = util.find_exe(cmd) or util.find_exe(cmd.split()[0])
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
908 if not cmdpath:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
909 if cmd == 'hgmerge':
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
910 ui.write(_(" No merge helper set and can't find default"
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
911 " hgmerge script in PATH\n"))
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
912 ui.write(_(" (specify a merge helper in your .hgrc file)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
913 else:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
914 ui.write(_(" Can't find merge helper '%s' in PATH\n") % cmd)
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
915 ui.write(_(" (specify a merge helper in your .hgrc file)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
916 problems += 1
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
917 else:
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
918 # actually attempt a patch here
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
919 fa = writetemp("1\n2\n3\n4\n")
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
920 fl = writetemp("1\n2\n3\ninsert\n4\n")
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
921 fr = writetemp("begin\n1\n2\n3\n4\n")
4798
452d171a1b39 Fixed calling the merge script and reporting errors in debuginstall (issue617)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4777
diff changeset
922 r = util.system('%s "%s" "%s" "%s"' % (cmd, fl, fa, fr))
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
923 if r:
4798
452d171a1b39 Fixed calling the merge script and reporting errors in debuginstall (issue617)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4777
diff changeset
924 ui.write(_(" Got unexpected merge error %d!\n") % r)
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
925 problems += 1
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
926 m = file(fl).read()
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
927 if m != "begin\n1\n2\n3\ninsert\n4\n":
4798
452d171a1b39 Fixed calling the merge script and reporting errors in debuginstall (issue617)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4777
diff changeset
928 ui.write(_(" Got unexpected merge results!\n"))
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
929 ui.write(_(" (your merge helper may have the"
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
930 " wrong argument order)\n"))
4798
452d171a1b39 Fixed calling the merge script and reporting errors in debuginstall (issue617)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4777
diff changeset
931 ui.write(_(" Result: %r\n") % m)
452d171a1b39 Fixed calling the merge script and reporting errors in debuginstall (issue617)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4777
diff changeset
932 problems += 1
3846
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
933 os.unlink(fa)
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
934 os.unlink(fl)
18855084b922 Make debuginstall actually attempt to use external patch and merge
Matt Mackall <mpm@selenic.com>
parents: 3844
diff changeset
935 os.unlink(fr)
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
936
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
937 # editor
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
938 ui.status(_("Checking commit editor...\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
939 editor = (os.environ.get("HGEDITOR") or
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
940 ui.config("ui", "editor") or
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
941 os.environ.get("EDITOR", "vi"))
4482
62019c4427e3 Introduce find_exe. Use instead of find_in_path for programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4438
diff changeset
942 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
943 if not cmdpath:
3855
b9cdd6f2aa43 debuginstall: fix a copy/paste error
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3848
diff changeset
944 if editor == 'vi':
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
945 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
946 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
947 else:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
948 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
949 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
950 problems += 1
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
951
3848
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
952 # check username
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
953 ui.status(_("Checking username...\n"))
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
954 user = os.environ.get("HGUSER")
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
955 if user is None:
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
956 user = ui.config("ui", "username")
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
957 if user is None:
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
958 user = os.environ.get("EMAIL")
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
959 if not user:
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
960 ui.warn(" ")
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
961 ui.username()
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
962 ui.write(_(" (specify a username in your .hgrc file)\n"))
8cbf060f637e Add some remedies and a username check to debuginstall
Matt Mackall <mpm@selenic.com>
parents: 3846
diff changeset
963
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
964 if not problems:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
965 ui.status(_("No problems detected\n"))
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
966 else:
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
967 ui.write(_("%s problems detected,"
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
968 " please check your install!\n") % problems)
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
969
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
970 return problems
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
971
3659
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
972 def debugrename(ui, repo, file1, *pats, **opts):
1194
c165cbf56bb1 Add doc string for debugrename.
bos@serpentine.internal.keyresearch.com
parents: 1193
diff changeset
973 """dump rename information"""
3659
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
974
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
975 ctx = repo.changectx(opts.get('rev', 'tip'))
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
976 for src, abs, rel, exact in cmdutil.walk(repo, (file1,) + pats, opts,
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
977 ctx.node()):
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
978 m = ctx.filectx(abs).renamed()
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
979 if m:
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
980 ui.write(_("%s renamed from %s:%s\n") % (rel, m[0], hex(m[1])))
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
981 else:
f4dece0f7016 refactor debugrenamed
Matt Mackall <mpm@selenic.com>
parents: 3658
diff changeset
982 ui.write(_("%s not renamed\n") % rel)
1116
0cdd73b0767c Add some rename debugging support
mpm@selenic.com
parents: 1114
diff changeset
983
820
89985a1b3427 Clean up walk and changes code to use normalised names properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 815
diff changeset
984 def debugwalk(ui, repo, *pats, **opts):
1053
1539ca091d86 Added missing doc strings for two new debug commmands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1052
diff changeset
985 """show how files match on given patterns"""
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
986 items = list(cmdutil.walk(repo, pats, opts))
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
987 if not items:
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
988 return
1309
332f225b835c Make debugwalk strip trailing spaces and remove these from test-walk.out
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1285
diff changeset
989 fmt = '%%s %%-%ds %%-%ds %%s' % (
942
7eb8cbcca7c4 Modify commands.walk to yield a 4-tuple.
Bryan O'Sullivan <bos@serpentine.com>
parents: 940
diff changeset
990 max([len(abs) for (src, abs, rel, exact) in items]),
7eb8cbcca7c4 Modify commands.walk to yield a 4-tuple.
Bryan O'Sullivan <bos@serpentine.com>
parents: 940
diff changeset
991 max([len(rel) for (src, abs, rel, exact) in items]))
7eb8cbcca7c4 Modify commands.walk to yield a 4-tuple.
Bryan O'Sullivan <bos@serpentine.com>
parents: 940
diff changeset
992 for src, abs, rel, exact in items:
1309
332f225b835c Make debugwalk strip trailing spaces and remove these from test-walk.out
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1285
diff changeset
993 line = fmt % (src, abs, rel, exact and 'exact' or '')
332f225b835c Make debugwalk strip trailing spaces and remove these from test-walk.out
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1285
diff changeset
994 ui.write("%s\n" % line.rstrip())
820
89985a1b3427 Clean up walk and changes code to use normalised names properly.
Bryan O'Sullivan <bos@serpentine.com>
parents: 815
diff changeset
995
732
ba0b6d17a6de Convert diff command over to using walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 731
diff changeset
996 def diff(ui, repo, *pats, **opts):
1568
1d7d0c07e8f3 make all commands be repo-wide by default
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1567
diff changeset
997 """diff repository (or selected files)
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
998
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
999 Show differences between revisions for the specified files.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1000
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1001 Differences between files are shown using the unified diff format.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1002
3828
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1003 NOTE: diff may generate unexpected results for merges, as it will
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1004 default to comparing against the working directory's first parent
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1005 changeset if no revisions are specified.
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1006
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1007 When two revision arguments are given, then changes are shown
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1008 between those revisions. If only one revision is specified then
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1009 that revision is compared to the working directory, and, when no
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1010 revisions are specified, the working directory files are compared
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1011 to its parent.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1012
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1013 Without the -a option, diff will avoid generating diffs of files
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1014 it detects as binary. With -a, diff will generate a diff anyway,
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1015 probably with undesirable results.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1016 """
3707
67f44b825784 Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3706
diff changeset
1017 node1, node2 = cmdutil.revpair(repo, opts['rev'])
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
1018
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
1019 fns, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
1014
e37cd99fa909 Clean up argument passing for dodiff
mpm@selenic.com
parents: 989
diff changeset
1020
2873
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2870
diff changeset
1021 patch.diff(repo, node1, node2, fns, match=matchfn,
2908
3848488244fc Move ui.diffopts to patch.diffopts where it belongs
Matt Mackall <mpm@selenic.com>
parents: 2882
diff changeset
1022 opts=patch.diffopts(ui, opts))
396
8f8bb77d560e Show revisions in diffs like CVS, based on a patch from Goffredo Baroncelli.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 395
diff changeset
1023
580
353a2ce50423 [PATCH] New export patch
mpm@selenic.com
parents: 577
diff changeset
1024 def export(ui, repo, *changesets, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1025 """dump the header and diffs for one or more changesets
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1026
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1027 Print the changeset header and diffs for one or more revisions.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1028
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1029 The information shown in the changeset header is: author,
3828
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1030 changeset hash, parent(s) and commit comment.
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1031
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1032 NOTE: export may generate unexpected diff output for merge changesets,
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1033 as it will compare the merge changeset against its first parent only.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1034
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1035 Output may be to a file, in which case the name of the file is
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1036 given using a format string. The formatting rules are as follows:
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1037
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1038 %% literal "%" character
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1039 %H changeset hash (40 bytes of hexadecimal)
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1040 %N number of patches being generated
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1041 %R changeset revision number
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1042 %b basename of the exporting repository
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1043 %h short-form changeset hash (12 bytes of hexadecimal)
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1044 %n zero-padded sequence number, starting at 1
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1045 %r zero-padded changeset revision number
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1046
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1047 Without the -a option, export will avoid generating diffs of files
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1048 it detects as binary. With -a, export will generate a diff anyway,
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1049 probably with undesirable results.
1571
bcdc030c59f8 add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1570
diff changeset
1050
bcdc030c59f8 add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1570
diff changeset
1051 With the --switch-parent option, the diff will be against the second
bcdc030c59f8 add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1570
diff changeset
1052 parent. It can be useful to review a merge.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1053 """
610
4c02464cb9f0 check export options for changeset before running
shaleh@speakeasy.net
parents: 609
diff changeset
1054 if not changesets:
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
1055 raise util.Abort(_("export requires at least one changeset"))
3707
67f44b825784 Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3706
diff changeset
1056 revs = cmdutil.revrange(repo, changesets)
2873
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2870
diff changeset
1057 if len(revs) > 1:
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2870
diff changeset
1058 ui.note(_('exporting patches:\n'))
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2870
diff changeset
1059 else:
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2870
diff changeset
1060 ui.note(_('exporting patch:\n'))
3900
2b3175acb653 Don't use node length for calculating revision number length.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3883
diff changeset
1061 patch.export(repo, revs, template=opts['output'],
2908
3848488244fc Move ui.diffopts to patch.diffopts where it belongs
Matt Mackall <mpm@selenic.com>
parents: 2882
diff changeset
1062 switch_parent=opts['switch_parent'],
3848488244fc Move ui.diffopts to patch.diffopts where it belongs
Matt Mackall <mpm@selenic.com>
parents: 2882
diff changeset
1063 opts=patch.diffopts(ui, opts))
246
96cde50a746f Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents: 245
diff changeset
1064
1108
7a75d8fbbdaf Remove some options from 'hg grep':
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1106
diff changeset
1065 def grep(ui, repo, pattern, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1066 """search for a pattern in specified files and revisions
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1067
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1068 Search revisions of files for a regular expression.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1069
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1070 This command behaves differently than Unix grep. It only accepts
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1071 Python/Perl regexps. It searches repository history, not the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1072 working directory. It always prints the revision number in which
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1073 a match appears.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1074
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1075 By default, grep only prints output for the first revision of a
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1076 file in which it finds a match. To get it to print every revision
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1077 that contains a change in match status ("-" for a match that
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1078 becomes a non-match, or "+" for a non-match that becomes a match),
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1079 use the --all flag.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1080 """
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1081 reflags = 0
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
1082 if opts['ignore_case']:
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
1083 reflags |= re.I
4877
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4866
diff changeset
1084 try:
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4866
diff changeset
1085 regexp = re.compile(pattern, reflags)
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4866
diff changeset
1086 except Exception, inst:
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4866
diff changeset
1087 ui.warn(_("grep: invalid match pattern: %s!\n") % inst)
242026115e6a hg grep: handle re.compile errors & update tests/test-grep
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4866
diff changeset
1088 return None
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1089 sep, eol = ':', '\n'
1108
7a75d8fbbdaf Remove some options from 'hg grep':
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1106
diff changeset
1090 if opts['print0']:
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1091 sep = eol = '\0'
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1092
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1093 fcache = {}
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1094 def getfile(fn):
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1095 if fn not in fcache:
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1096 fcache[fn] = repo.file(fn)
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1097 return fcache[fn]
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1098
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1099 def matchlines(body):
1059
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1100 begin = 0
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1101 linenum = 0
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1102 while True:
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1103 match = regexp.search(body, begin)
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
1104 if not match:
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
1105 break
1059
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1106 mstart, mend = match.span()
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1107 linenum += body.count('\n', begin, mstart) + 1
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1108 lstart = body.rfind('\n', begin, mstart) + 1 or begin
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1109 lend = body.find('\n', mend)
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1110 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
4eab07ef66e2 grep: speed up matching, and only return one match per line.
bos@serpentine.internal.keyresearch.com
parents: 1058
diff changeset
1111 begin = lend + 1
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1112
1559
59b3639df0a9 Convert all classes to new-style classes by deriving them from object.
Eric Hopper <hopper@omnifarious.org>
parents: 1552
diff changeset
1113 class linestate(object):
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1114 def __init__(self, line, linenum, colstart, colend):
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1115 self.line = line
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1116 self.linenum = linenum
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1117 self.colstart = colstart
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1118 self.colend = colend
2868
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1119
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
1120 def __eq__(self, other):
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
1121 return self.line == other.line
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1122
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1123 matches = {}
2869
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1124 copies = {}
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1125 def grepbody(fn, rev, body):
2868
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1126 matches[rev].setdefault(fn, [])
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1127 m = matches[rev][fn]
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1128 for lnum, cstart, cend, line in matchlines(body):
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1129 s = linestate(line, lnum, cstart, cend)
2868
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1130 m.append(s)
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1131
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1132 def difflinestates(a, b):
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1133 sm = difflib.SequenceMatcher(None, a, b)
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1134 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1135 if tag == 'insert':
3467
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3466
diff changeset
1136 for i in xrange(blo, bhi):
2868
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1137 yield ('+', b[i])
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1138 elif tag == 'delete':
3467
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3466
diff changeset
1139 for i in xrange(alo, ahi):
2868
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1140 yield ('-', a[i])
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1141 elif tag == 'replace':
3467
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3466
diff changeset
1142 for i in xrange(alo, ahi):
2868
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1143 yield ('-', a[i])
3467
df7202f6887c use xrange instead of range
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3466
diff changeset
1144 for i in xrange(blo, bhi):
2868
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1145 yield ('+', b[i])
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1146
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1147 prev = {}
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1148 def display(fn, rev, states, prevstates):
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1149 found = False
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1150 filerevmatches = {}
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1151 r = prev.get(fn, -1)
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1152 if opts['all']:
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1153 iter = difflinestates(states, prevstates)
2868
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1154 else:
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1155 iter = [('', l) for l in prevstates]
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1156 for change, l in iter:
2868
81f351c5264d grep: display correct user/revision for --all in reverse.
Brendan Cully <brendan@kublai.com>
parents: 2842
diff changeset
1157 cols = [fn, str(r)]
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1158 if opts['line_number']:
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1159 cols.append(str(l.linenum))
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1160 if opts['all']:
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1161 cols.append(change)
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1162 if opts['user']:
3657
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3656
diff changeset
1163 cols.append(ui.shortuser(get(r)[1]))
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1164 if opts['files_with_matches']:
3554
7ed86c28f1ae Fixups for hg grep
Matt Mackall <mpm@selenic.com>
parents: 3524
diff changeset
1165 c = (fn, r)
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1166 if c in filerevmatches:
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1167 continue
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1168 filerevmatches[c] = 1
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1169 else:
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1170 cols.append(l.line)
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1171 ui.write(sep.join(cols), eol)
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1172 found = True
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1173 return found
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1174
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1175 fstate = {}
1145
bd917e1a26dd grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1116
diff changeset
1176 skip = {}
3673
eb0b4a2d70a9 white space and line break cleanups
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3672
diff changeset
1177 get = util.cachefunc(lambda r: repo.changectx(r).changeset())
3657
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3656
diff changeset
1178 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1179 found = False
2869
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1180 follow = opts.get('follow')
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1181 for st, rev, fns in changeiter:
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1182 if st == 'window':
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1183 matches.clear()
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1184 elif st == 'add':
3561
cd2216599c99 minor hg grep simplification
Matt Mackall <mpm@selenic.com>
parents: 3558
diff changeset
1185 mf = repo.changectx(rev).manifest()
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1186 matches[rev] = {}
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1187 for fn in fns:
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1188 if fn in skip:
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1189 continue
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1190 fstate.setdefault(fn, {})
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1191 try:
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1192 grepbody(fn, rev, getfile(fn).read(mf[fn]))
2869
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1193 if follow:
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1194 copied = getfile(fn).renamed(mf[fn])
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1195 if copied:
2931
0843bd53dcff Fix bug #345.
Brendan Cully <brendan@kublai.com>
parents: 2922
diff changeset
1196 copies.setdefault(rev, {})[fn] = copied[0]
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1197 except KeyError:
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1198 pass
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1199 elif st == 'iter':
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1200 states = matches[rev].items()
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1201 states.sort()
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1202 for fn, m in states:
2931
0843bd53dcff Fix bug #345.
Brendan Cully <brendan@kublai.com>
parents: 2922
diff changeset
1203 copy = copies.get(rev, {}).get(fn)
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1204 if fn in skip:
2869
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1205 if copy:
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1206 skip[copy] = True
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1207 continue
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1208 if fn in prev or fstate[fn]:
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1209 r = display(fn, rev, m, fstate[fn])
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1210 found = found or r
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1211 if r and not opts['all']:
1145
bd917e1a26dd grep: change default to printing first matching rev.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1116
diff changeset
1212 skip[fn] = True
2869
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1213 if copy:
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1214 skip[copy] = True
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1215 fstate[fn] = m
2869
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1216 if copy:
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
1217 fstate[copy] = m
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1218 prev[fn] = rev
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1219
3950
3d3007064a17 grep: incrementing is always False during 'iter'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3940
diff changeset
1220 fstate = fstate.items()
3d3007064a17 grep: incrementing is always False during 'iter'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3940
diff changeset
1221 fstate.sort()
3d3007064a17 grep: incrementing is always False during 'iter'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3940
diff changeset
1222 for fn, state in fstate:
3d3007064a17 grep: incrementing is always False during 'iter'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3940
diff changeset
1223 if fn in skip:
3d3007064a17 grep: incrementing is always False during 'iter'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3940
diff changeset
1224 continue
3d3007064a17 grep: incrementing is always False during 'iter'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3940
diff changeset
1225 if fn not in copies.get(prev[fn], {}):
3951
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1226 found = display(fn, rev, {}, state) or found
cb66641cdee3 grep: remove count handling, simplify, fix issue337
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3950
diff changeset
1227 return (not found and 1) or 0
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1228
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1229 def heads(ui, repo, *branchrevs, **opts):
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1230 """show current repository heads or show branch heads
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1231
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1232 With no arguments, show all repository head changesets.
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1233
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1234 If branch or revisions names are given this will show the heads of
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1235 the specified branches or the branches those revisions are tagged
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1236 with.
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1237
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1238 Repository "heads" are changesets that don't have child
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1239 changesets. They are where development generally takes place and
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1240 are the usual targets for update and merge operations.
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1241
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1242 Branch heads are changesets that have a given branch tag, but have
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1243 no child changesets with that tag. They are usually where
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1244 development on the given branch takes place.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1245 """
1550
ccb9b62de892 add a -r/--rev option to heads to show only heads descendant from rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1547
diff changeset
1246 if opts['rev']:
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1247 start = repo.lookup(opts['rev'])
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1248 else:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1249 start = None
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1250 if not branchrevs:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1251 # Assume we're looking repo-wide heads if no revs were specified.
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1252 heads = repo.heads(start)
1550
ccb9b62de892 add a -r/--rev option to heads to show only heads descendant from rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1547
diff changeset
1253 else:
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1254 heads = []
4649
52259d5fb76d Small fixes for 8e503fa54d2d (hg heads branch)
Brendan Cully <brendan@kublai.com>
parents: 4648
diff changeset
1255 visitedset = util.set()
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1256 for branchrev in branchrevs:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1257 branch = repo.changectx(branchrev).branch()
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1258 if branch in visitedset:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1259 continue
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1260 visitedset.add(branch)
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1261 bheads = repo.branchheads(branch, start)
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1262 if not bheads:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1263 if branch != branchrev:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1264 ui.warn(_("no changes on branch %s containing %s are "
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1265 "reachable from %s\n")
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1266 % (branch, branchrev, opts['rev']))
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1267 else:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1268 ui.warn(_("no changes on branch %s are reachable from %s\n")
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1269 % (branch, opts['rev']))
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1270 heads.extend(bheads)
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1271 if not heads:
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
1272 return 1
3646
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3634
diff changeset
1273 displayer = cmdutil.show_changeset(ui, repo, opts)
1550
ccb9b62de892 add a -r/--rev option to heads to show only heads descendant from rev
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1547
diff changeset
1274 for n in heads:
3656
e50891e461e4 Consolidate brinfo handling
Matt Mackall <mpm@selenic.com>
parents: 3648
diff changeset
1275 displayer.show(changenode=n)
221
2bfe525ef6ca Beginning of multi-head support
mpm@selenic.com
parents: 220
diff changeset
1276
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1277 def help_(ui, name=None, with_version=False):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1278 """show help for a command, extension, or list of commands
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1279
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1280 With no arguments, print a list of commands and short help.
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1281
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1282 Given a command name, print help for that command.
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1283
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1284 Given an extension name, print help for that extension, and the
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1285 commands it provides."""
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1286 option_lists = []
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1287
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1288 def addglobalopts(aliases):
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1289 if ui.verbose:
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1290 option_lists.append((_("global options:"), globalopts))
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1291 if name == 'shortlist':
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1292 option_lists.append((_('use "hg help" for the full list '
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1293 'of commands'), ()))
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1294 else:
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1295 if name == 'shortlist':
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1296 msg = _('use "hg help" for the full list of commands '
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1297 'or "hg -v" for details')
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1298 elif aliases:
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1299 msg = _('use "hg -v help%s" to show aliases and '
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1300 'global options') % (name and " " + name or "")
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1301 else:
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1302 msg = _('use "hg -v help %s" to show global options') % name
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1303 option_lists.append((msg, ()))
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1304
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1305 def helpcmd(name):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1306 if with_version:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1307 version_(ui)
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1308 ui.write('\n')
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
1309 aliases, i = cmdutil.findcmd(ui, name)
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1310 # synopsis
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1311 ui.write("%s\n\n" % i[2])
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1312
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1313 # description
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1314 doc = i[0].__doc__
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1315 if not doc:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1316 doc = _("(No help text available)")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1317 if ui.quiet:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1318 doc = doc.splitlines(0)[0]
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1319 ui.write("%s\n" % doc.rstrip())
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1320
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1321 if not ui.quiet:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1322 # aliases
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1323 if len(aliases) > 1:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1324 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1325
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1326 # options
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1327 if i[1]:
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1328 option_lists.append((_("options:\n"), i[1]))
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1329
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1330 addglobalopts(False)
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1331
4932
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1332 def helplist(header, select=None):
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1333 h = {}
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1334 cmds = {}
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1335 for c, e in table.items():
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1336 f = c.split("|", 1)[0]
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1337 if select and not select(f):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1338 continue
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1339 if name == "shortlist" and not f.startswith("^"):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1340 continue
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1341 f = f.lstrip("^")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1342 if not ui.debugflag and f.startswith("debug"):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1343 continue
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1344 doc = e[0].__doc__
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1345 if not doc:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1346 doc = _("(No help text available)")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1347 h[f] = doc.splitlines(0)[0].rstrip()
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1348 cmds[f] = c.lstrip("^")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1349
4932
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1350 if not h:
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1351 ui.status(_('no commands defined\n'))
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1352 return
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1353
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1354 ui.status(header)
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1355 fns = h.keys()
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1356 fns.sort()
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1357 m = max(map(len, fns))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1358 for f in fns:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1359 if ui.verbose:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1360 commands = cmds[f].replace("|",", ")
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1361 ui.write(" %s:\n %s\n"%(commands, h[f]))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1362 else:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1363 ui.write(' %-*s %s\n' % (m, f, h[f]))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1364
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1365 if not ui.quiet:
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1366 addglobalopts(True)
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1367
3798
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1368 def helptopic(name):
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1369 v = None
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1370 for i in help.helptable:
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1371 l = i.split('|')
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1372 if name in l:
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1373 v = i
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1374 header = l[-1]
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1375 if not v:
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
1376 raise cmdutil.UnknownCommand(name)
3798
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1377
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1378 # description
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1379 doc = help.helptable[v]
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1380 if not doc:
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1381 doc = _("(No help text available)")
3799
58133ba5847d Allow topics to be callables
Matt Mackall <mpm@selenic.com>
parents: 3798
diff changeset
1382 if callable(doc):
58133ba5847d Allow topics to be callables
Matt Mackall <mpm@selenic.com>
parents: 3798
diff changeset
1383 doc = doc()
3798
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1384
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1385 ui.write("%s\n" % header)
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1386 ui.write("%s\n" % doc.rstrip())
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1387
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1388 def helpext(name):
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1389 try:
4544
930ed513c864 Create a separate module for managing extensions
Matt Mackall <mpm@selenic.com>
parents: 4543
diff changeset
1390 mod = extensions.find(name)
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1391 except KeyError:
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
1392 raise cmdutil.UnknownCommand(name)
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1393
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1394 doc = (mod.__doc__ or _('No help text available')).splitlines(0)
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1395 ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0]))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1396 for d in doc[1:]:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1397 ui.write(d, '\n')
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1398
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1399 ui.status('\n')
4009
86098ec4b77a fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3914
diff changeset
1400
86098ec4b77a fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3914
diff changeset
1401 try:
86098ec4b77a fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3914
diff changeset
1402 ct = mod.cmdtable
86098ec4b77a fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3914
diff changeset
1403 except AttributeError:
4932
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1404 ct = {}
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1405
4009
86098ec4b77a fix hg help <ext> for extension that do not define any command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3914
diff changeset
1406 modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct])
4932
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1407 helplist(_('list of commands:\n\n'), modcmds.has_key)
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1408
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1409 if name and name != 'shortlist':
3798
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1410 i = None
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1411 for f in (helpcmd, helptopic, helpext):
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1412 try:
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1413 f(name)
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1414 i = None
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1415 break
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
1416 except cmdutil.UnknownCommand, inst:
3798
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1417 i = inst
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1418 if i:
17a11f4ff260 Add basic support for help topics and a dates topic
Matt Mackall <mpm@selenic.com>
parents: 3787
diff changeset
1419 raise i
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1420
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1421 else:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1422 # program name
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1423 if ui.verbose or with_version:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1424 version_(ui)
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1425 else:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1426 ui.status(_("Mercurial Distributed SCM\n"))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1427 ui.status('\n')
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1428
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1429 # list of commands
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1430 if name == "shortlist":
4932
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1431 header = _('basic commands:\n\n')
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1432 else:
4932
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1433 header = _('list of commands:\n\n')
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1434
93b7e2fa7ee3 help: avoid traceback if an extension has only debug commands
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4924
diff changeset
1435 helplist(header)
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1436
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1437 # list all option lists
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1438 opt_output = []
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1439 for title, options in option_lists:
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1440 opt_output.append(("\n%s" % title, None))
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1441 for shortopt, longopt, default, desc in options:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1442 if "DEPRECATED" in desc and not ui.verbose: continue
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1443 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1444 longopt and " --%s" % longopt),
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1445 "%s%s" % (desc,
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1446 default
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1447 and _(" (default: %s)") % default
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1448 or "")))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1449
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1450 if opt_output:
4315
bc6f5a1d8b7b Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4273
diff changeset
1451 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
3662
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1452 for first, second in opt_output:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1453 if second:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1454 ui.write(" %-*s %s\n" % (opts_len, first, second))
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1455 else:
da361aa7a118 alphabetize help_ in commands
Matt Mackall <mpm@selenic.com>
parents: 3661
diff changeset
1456 ui.write("%s\n" % first)
221
2bfe525ef6ca Beginning of multi-head support
mpm@selenic.com
parents: 220
diff changeset
1457
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1458 def identify(ui, repo, source=None,
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1459 rev=None, num=None, id=None, branch=None, tags=None):
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
1460 """identify the working copy or specified revision
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
1461
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1462 With no revision, print a summary of the current state of the repo.
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1463
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1464 With a path, do a lookup in another repository.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1465
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1466 This summary identifies the repository state using one or two parent
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1467 hash identifiers, followed by a "+" if there are uncommitted changes
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
1468 in the working directory, a list of tags for this revision and a branch
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
1469 name for non-default branches.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1470 """
4662
f9b8ea362b49 identify: show nullid for empty repo
Matt Mackall <mpm@selenic.com>
parents: 4659
diff changeset
1471
2973
fb493241d7f6 Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents: 2963
diff changeset
1472 hexfunc = ui.debugflag and hex or short
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1473 default = not (num or id or branch or tags)
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1474 output = []
4664
dedb8abfd0e1 identify: use contexts
Matt Mackall <mpm@selenic.com>
parents: 4662
diff changeset
1475
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1476 if source:
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1477 source, revs = cmdutil.parseurl(ui.expandpath(source), [])
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1478 srepo = hg.repository(ui, source)
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1479 if not rev and revs:
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1480 rev = revs[0]
4667
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
1481 if not rev:
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
1482 rev = "tip"
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
1483 if num or branch or tags:
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
1484 raise util.Abort(
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
1485 "can't query remote revision number, branch, or tags")
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1486 output = [hexfunc(srepo.lookup(rev))]
4667
c7a81e3ae80f identify: work with remote repos
Matt Mackall <mpm@selenic.com>
parents: 4666
diff changeset
1487 elif not rev:
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
1488 ctx = repo.workingctx()
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
1489 parents = ctx.parents()
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1490 changed = False
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1491 if default or id or num:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1492 changed = ctx.files() + ctx.deleted()
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1493 if default or id:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1494 output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1495 (changed) and "+" or "")]
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1496 if num:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1497 output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1498 (changed) and "+" or ""))
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
1499 else:
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
1500 ctx = repo.changectx(rev)
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1501 if default or id:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1502 output = [hexfunc(ctx.node())]
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1503 if num:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1504 output.append(str(ctx.rev()))
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1505
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
1506 if not source and default and not ui.quiet:
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1507 b = util.tolocal(ctx.branch())
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1508 if b != 'default':
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1509 output.append("(%s)" % b)
3430
9a6491770b04 Report branch for hg id
Matt Mackall <mpm@selenic.com>
parents: 3429
diff changeset
1510
386
494c8e3f47f3 Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 371
diff changeset
1511 # multiple tags for a single parent separated by '/'
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1512 t = "/".join(ctx.tags())
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1513 if t:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1514 output.append(t)
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1515
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1516 if branch:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1517 output.append(util.tolocal(ctx.branch()))
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1518
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1519 if tags:
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
1520 output.extend(ctx.tags())
339
a76fc9c4b67b added hg identify|id (based on a patch from Andrew Thompson)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 338
diff changeset
1521
386
494c8e3f47f3 Improvements for hg identify:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 371
diff changeset
1522 ui.write("%s\n" % ' '.join(output))
339
a76fc9c4b67b added hg identify|id (based on a patch from Andrew Thompson)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 338
diff changeset
1523
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
1524 def import_(ui, repo, patch1, *patches, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1525 """import an ordered set of patches
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1526
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1527 Import a list of patches and commit them individually.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1528
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1529 If there are outstanding changes in the working directory, import
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1530 will abort unless given the -f flag.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1531
2504
158d3d2ae070 import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2494
diff changeset
1532 You can import a patch straight from a mail message. Even patches
158d3d2ae070 import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2494
diff changeset
1533 as attachments work (body part must be type text/plain or
2515
a6700c222314 import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2513
diff changeset
1534 text/x-patch to be used). From and Subject headers of email
a6700c222314 import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2513
diff changeset
1535 message are used as default committer and commit message. All
a6700c222314 import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2513
diff changeset
1536 text/plain body parts before first diff are added to commit
a6700c222314 import: make help clearer. suggested by asak.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2513
diff changeset
1537 message.
2504
158d3d2ae070 import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2494
diff changeset
1538
4258
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
1539 If the imported patch was generated by hg export, user and description
2504
158d3d2ae070 import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2494
diff changeset
1540 from patch override values from message headers and body. Values
158d3d2ae070 import: parse email messages
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2494
diff changeset
1541 given on command line with -m and -u override these.
2400
2e90024e1471 import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2397
diff changeset
1542
4258
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
1543 If --exact is specified, import will set the working directory
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
1544 to the parent of each patch before applying it, and will abort
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
1545 if the resulting changeset has a different ID than the one
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
1546 recorded in the patch. This may happen due to character set
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
1547 problems or other deficiencies in the text patch format.
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
1548
2400
2e90024e1471 import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2397
diff changeset
1549 To read a patch from standard input, use patch name "-".
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1550 """
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
1551 patches = (patch1,) + patches
500
ebc4714a7632 [PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents: 499
diff changeset
1552
4258
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
1553 if opts.get('exact') or not opts['force']:
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
1554 cmdutil.bail_if_changed(repo)
966
022bcc738389 hg import: abort with uncommitted changes, override with --force
mpm@selenic.com
parents: 965
diff changeset
1555
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
1556 d = opts["base"]
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
1557 strip = opts["strip"]
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1558 wlock = lock = None
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1559 try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1560 wlock = repo.wlock()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1561 lock = repo.lock()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1562 for p in patches:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1563 pf = os.path.join(d, p)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1564
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1565 if pf == '-':
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1566 ui.status(_("applying patch from stdin\n"))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1567 data = patch.extract(ui, sys.stdin)
2400
2e90024e1471 import: allow to import stdin with file name "-"
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2397
diff changeset
1568 else:
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1569 ui.status(_("applying %s\n") % p)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1570 data = patch.extract(ui, file(pf, 'rb'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1571
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1572 tmpname, message, user, date, branch, nodeid, p1, p2 = data
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1573
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1574 if tmpname is None:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1575 raise util.Abort(_('no diffs found'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1576
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1577 try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1578 cmdline_message = cmdutil.logmessage(opts)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1579 if cmdline_message:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1580 # pickup the cmdline msg
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1581 message = cmdline_message
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1582 elif message:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1583 # pickup the patch msg
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1584 message = message.strip()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1585 else:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1586 # launch the editor
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1587 message = None
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1588 ui.debug(_('message:\n%s\n') % message)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1589
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1590 wp = repo.workingctx().parents()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1591 if opts.get('exact'):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1592 if not nodeid or not p1:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1593 raise util.Abort(_('not a mercurial patch'))
4259
bda63383d529 Make import opportunistically use merge information
Brendan Cully <brendan@kublai.com>
parents: 4258
diff changeset
1594 p1 = repo.lookup(p1)
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1595 p2 = repo.lookup(p2 or hex(nullid))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1596
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1597 if p1 != wp[0].node():
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
1598 hg.clean(repo, p1)
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1599 repo.dirstate.setparents(p1, p2)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1600 elif p2:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1601 try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1602 p1 = repo.lookup(p1)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1603 p2 = repo.lookup(p2)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1604 if p1 == wp[0].node():
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1605 repo.dirstate.setparents(p1, p2)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1606 except hg.RepoError:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1607 pass
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1608 if opts.get('exact') or opts.get('import_branch'):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1609 repo.dirstate.setbranch(branch or 'default')
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1610
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1611 files = {}
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1612 try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1613 fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1614 files=files)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1615 finally:
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
1616 files = patch.updatedir(ui, repo, files)
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
1617 n = repo.commit(files, message, user, date)
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1618 if opts.get('exact'):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1619 if hex(n) != nodeid:
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
1620 repo.rollback()
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1621 raise util.Abort(_('patch is damaged' +
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1622 ' or loses information'))
3460
2d35a8d2b32d patch: return list of modified files even when an exception is raised
Brendan Cully <brendan@kublai.com>
parents: 3455
diff changeset
1623 finally:
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1624 os.unlink(tmpname)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
1625 finally:
5053
47a8ea1eb2c3 del transaction before lock before wlock
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5034
diff changeset
1626 del lock, wlock
437
5b38a5af4019 Commands cleanup
mpm@selenic.com
parents: 429
diff changeset
1627
1192
6e165de907c5 Add -p to incoming and outgoing commands to show patch
TK Soh <teekaysoh@yahoo.com>
parents: 1191
diff changeset
1628 def incoming(ui, repo, source="default", **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1629 """show new changesets found in source
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1630
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
1631 Show new changesets found in the specified path/URL or the default
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
1632 pull location. These are the changesets that would be pulled if a pull
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1633 was requested.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1634
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
1635 For remote repository, using --bundle avoids downloading the changesets
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
1636 twice if the incoming is followed by a pull.
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
1637
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
1638 See pull for valid source format details.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1639 """
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
1640 source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev'])
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
1641 cmdutil.setremoteconfig(ui, opts)
1965
62aa1b90414f add remotecmd/ssh option support to incoming/outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1959
diff changeset
1642
927
5a830d7bea52 Add hg incoming command for local repositories
mpm@selenic.com
parents: 924
diff changeset
1643 other = hg.repository(ui, source)
4162
b2d9e553cdc8 incoming/outgoing: print the name of the other repo
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4158
diff changeset
1644 ui.status(_('comparing with %s\n') % source)
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
1645 if revs:
4473
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1646 if 'lookup' in other.capabilities:
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
1647 revs = [other.lookup(rev) for rev in revs]
4473
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1648 else:
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1649 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1650 raise util.Abort(error)
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1651 incoming = repo.findincoming(other, heads=revs, force=opts["force"])
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
1652 if not incoming:
3940
7997c0e01bfc hg in: if no incoming csets, remove existing bundle
Matt Mackall <mpm@selenic.com>
parents: 3931
diff changeset
1653 try:
7997c0e01bfc hg in: if no incoming csets, remove existing bundle
Matt Mackall <mpm@selenic.com>
parents: 3931
diff changeset
1654 os.unlink(opts["bundle"])
7997c0e01bfc hg in: if no incoming csets, remove existing bundle
Matt Mackall <mpm@selenic.com>
parents: 3931
diff changeset
1655 except:
7997c0e01bfc hg in: if no incoming csets, remove existing bundle
Matt Mackall <mpm@selenic.com>
parents: 3931
diff changeset
1656 pass
1993
fb6ca9801d04 show message if no changes found on incoming
TK Soh <teekaysoh@yahoo.com>
parents: 1981
diff changeset
1657 ui.status(_("no changes found\n"))
3931
f2cbcf1e98b2 incoming/outgoing: return failure if no changes found
Matt Mackall <mpm@selenic.com>
parents: 3930
diff changeset
1658 return 1
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
1659
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
1660 cleanup = None
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1661 try:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1662 fname = opts["bundle"]
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1663 if fname or not other.local():
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1664 # create a bundle (uncompressed if other repo is not local)
4473
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1665 if revs is None:
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1666 cg = other.changegroup(incoming, "incoming")
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1667 else:
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1668 if 'changegroupsubset' not in other.capabilities:
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1669 raise util.Abort(_("Partial incoming cannot be done because other repository doesn't support changegroupsubset."))
671158f060cc Make "hg incoming -r revision_number" work for remote repos (issue566)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4324
diff changeset
1670 cg = other.changegroupsubset(incoming, revs, 'incoming')
3706
0d810798acb1 Use 'bundletype' instead of 'type' to not shadow built-in function.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3704
diff changeset
1671 bundletype = other.local() and "HG10BZ" or "HG10UN"
0d810798acb1 Use 'bundletype' instead of 'type' to not shadow built-in function.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3704
diff changeset
1672 fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1673 # keep written bundle?
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1674 if opts["bundle"]:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1675 cleanup = None
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1676 if not other.local():
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1677 # use the created uncompressed bundlerepo
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1678 other = bundlerepo.bundlerepository(ui, repo.root, fname)
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1679
2521
9cceb439048b add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2515
diff changeset
1680 o = other.changelog.nodesbetween(incoming, revs)[0]
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1681 if opts['newest_first']:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1682 o.reverse()
3646
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3634
diff changeset
1683 displayer = cmdutil.show_changeset(ui, other, opts)
1974
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1684 for n in o:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1685 parents = [p for p in other.changelog.parents(n) if p != nullid]
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1686 if opts['no_merges'] and len(parents) == 2:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1687 continue
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1688 displayer.show(changenode=n)
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1689 finally:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1690 if hasattr(other, 'close'):
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1691 other.close()
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1692 if cleanup:
0d54675cd566 Delete bundle file of hg incoming in case of errors, preserve existing files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1973
diff changeset
1693 os.unlink(cleanup)
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
1694
2598
b898afee9d0d Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2597
diff changeset
1695 def init(ui, dest=".", **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1696 """create a new repository in the given directory
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1697
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1698 Initialize a new repository in the given directory. If the given
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1699 directory does not exist, it is created.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1700
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1701 If no directory is given, the current directory is used.
2590
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
1702
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
1703 It is possible to specify an ssh:// URL as the destination.
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
1704 Look at the help text for the pull command for important details
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
1705 about ssh:// URLs.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1706 """
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
1707 cmdutil.setremoteconfig(ui, opts)
907
652507dc9fce Modify init command to take an optional directory to set up.
Bryan O'Sullivan <bos@serpentine.com>
parents: 906
diff changeset
1708 hg.repository(ui, dest, create=1)
338
1e091b3293d5 default path support with .hg/hgrc
mpm@selenic.com
parents: 335
diff changeset
1709
627
b6c42714d900 Add locate command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 625
diff changeset
1710 def locate(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1711 """locate files matching specific patterns
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1712
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1713 Print all files under Mercurial control whose names match the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1714 given patterns.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1715
4190
e8ee8fdeddb1 change locate to use relglobs by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4175
diff changeset
1716 This command searches the entire repository by default. To search
4692
c135c6cddbec Command in doc comment is now on a single line, fixed
paul sorenson <sf@metrak.com>
parents: 4684
diff changeset
1717 just the current directory and its subdirectories, use
c135c6cddbec Command in doc comment is now on a single line, fixed
paul sorenson <sf@metrak.com>
parents: 4684
diff changeset
1718 "--include .".
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1719
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1720 If no patterns are given to match, this command prints all file
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1721 names.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1722
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1723 If you want to feed the output of this command into the "xargs"
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1724 command, use the "-0" option to both this command and "xargs".
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1725 This will avoid the problem of "xargs" treating single filenames
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1726 that contain white space as multiple filenames.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1727 """
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
1728 end = opts['print0'] and '\0' or '\n'
1622
5e9168401a68 fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1619
diff changeset
1729 rev = opts['rev']
5e9168401a68 fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1619
diff changeset
1730 if rev:
5e9168401a68 fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1619
diff changeset
1731 node = repo.lookup(rev)
5e9168401a68 fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1619
diff changeset
1732 else:
5e9168401a68 fix locate broken since 63799b01985c
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1619
diff changeset
1733 node = None
742
092937de2ad7 Refactor matchpats and walk
mpm@selenic.com
parents: 740
diff changeset
1734
4191
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4190
diff changeset
1735 ret = 1
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
1736 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
4305
a5cde03cd019 locate: don't print "file not found" messages.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4252
diff changeset
1737 badmatch=util.always,
4190
e8ee8fdeddb1 change locate to use relglobs by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4175
diff changeset
1738 default='relglob'):
4305
a5cde03cd019 locate: don't print "file not found" messages.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4252
diff changeset
1739 if src == 'b':
a5cde03cd019 locate: don't print "file not found" messages.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4252
diff changeset
1740 continue
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
1741 if not node and abs not in repo.dirstate:
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
1742 continue
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
1743 if opts['fullpath']:
724
1c0c413cccdd Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 723
diff changeset
1744 ui.write(os.path.join(repo.root, abs), end)
1c0c413cccdd Get add and locate to use new repo and dirstate walk code.
Bryan O'Sullivan <bos@serpentine.com>
parents: 723
diff changeset
1745 else:
1625
e1bcf7fa983f correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1622
diff changeset
1746 ui.write(((pats and rel) or abs), end)
4191
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4190
diff changeset
1747 ret = 0
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4190
diff changeset
1748
1c69c73d85d9 locate: exit(1) if we didn't print any file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4190
diff changeset
1749 return ret
627
b6c42714d900 Add locate command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 625
diff changeset
1750
1031
503aaf19a040 Rewrite log command. New version is faster and more featureful.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1030
diff changeset
1751 def log(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1752 """show revision history of entire repository or files
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1753
2741
ae5ce3454ef5 log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2739
diff changeset
1754 Print the revision history of the specified files or the entire
ae5ce3454ef5 log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2739
diff changeset
1755 project.
ae5ce3454ef5 log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2739
diff changeset
1756
ae5ce3454ef5 log: add -f/--follow option, to follow rename/copy
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2739
diff changeset
1757 File history is shown without following rename or copy history of
2777
21e571c21a6b Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents: 2764
diff changeset
1758 files. Use -f/--follow with a file name to follow history across
21e571c21a6b Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents: 2764
diff changeset
1759 renames and copies. --follow without a file name will only show
2779
12a7bfcafd8f Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents: 2778
diff changeset
1760 ancestors or descendants of the starting revision. --follow-first
12a7bfcafd8f Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents: 2778
diff changeset
1761 only follows the first parent of merge revisions.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1762
2778
2e0cd25fe4ac Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents: 2777
diff changeset
1763 If no revision range is specified, the default is tip:0 unless
2e0cd25fe4ac Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents: 2777
diff changeset
1764 --follow is set, in which case the working directory parent is
2e0cd25fe4ac Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents: 2777
diff changeset
1765 used as the starting revision.
2e0cd25fe4ac Make log --follow revision range start default to working dir parent.
Brendan Cully <brendan@kublai.com>
parents: 2777
diff changeset
1766
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1767 By default this command outputs: changeset id and hash, tags,
1557
f7d9823e65df Updated help text for 'hg log'.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1552
diff changeset
1768 non-trivial parents, user, date and time, and a summary for each
f7d9823e65df Updated help text for 'hg log'.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1552
diff changeset
1769 commit. When the -v/--verbose switch is used, the list of changed
f7d9823e65df Updated help text for 'hg log'.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1552
diff changeset
1770 files and full commit message is shown.
3828
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1771
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1772 NOTE: log -p may generate unexpected diff output for merge
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1773 changesets, as it will compare the merge changeset against its
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1774 first parent only. Also, the files: list will only reflect files
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1775 that are different from BOTH parents.
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
1776
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1777 """
1756
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1778
3673
eb0b4a2d70a9 white space and line break cleanups
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3672
diff changeset
1779 get = util.cachefunc(lambda r: repo.changectx(r).changeset())
3657
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3656
diff changeset
1780 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
3521
467d923e4e3d Fix excessive complaining from hg log -b
Matt Mackall <mpm@selenic.com>
parents: 3520
diff changeset
1781
1756
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1782 if opts['limit']:
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1783 try:
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1784 limit = int(opts['limit'])
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1785 except ValueError:
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1786 raise util.Abort(_('limit must be a positive integer'))
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1787 if limit <= 0: raise util.Abort(_('limit must be positive'))
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1788 else:
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1789 limit = sys.maxint
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1790 count = 0
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1791
3190
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1792 if opts['copies'] and opts['rev']:
3707
67f44b825784 Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3706
diff changeset
1793 endrev = max(cmdutil.revrange(repo, opts['rev'])) + 1
3190
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1794 else:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1795 endrev = repo.changelog.count()
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1796 rcache = {}
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1797 ncache = {}
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1798 dcache = []
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1799 def getrenamed(fn, rev, man):
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1800 '''looks up all renames for a file (up to endrev) the first
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1801 time the file is given. It indexes on the changerev and only
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1802 parses the manifest if linkrev != changerev.
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1803 Returns rename info for fn at changerev rev.'''
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1804 if fn not in rcache:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1805 rcache[fn] = {}
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1806 ncache[fn] = {}
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1807 fl = repo.file(fn)
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1808 for i in xrange(fl.count()):
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1809 node = fl.node(i)
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1810 lr = fl.linkrev(node)
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1811 renamed = fl.renamed(node)
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1812 rcache[fn][lr] = renamed
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1813 if renamed:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1814 ncache[fn][node] = renamed
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1815 if lr >= endrev:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1816 break
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1817 if rev in rcache[fn]:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1818 return rcache[fn][rev]
3385
55476ce8e59c Use manifest rev instead of changelog rev for linear manifest test
Brendan Cully <brendan@kublai.com>
parents: 3383
diff changeset
1819 mr = repo.manifest.rev(man)
3578
3b4e00cba57a Define and use nullrev (revision of nullid) instead of -1.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3576
diff changeset
1820 if repo.manifest.parentrevs(mr) != (mr - 1, nullrev):
3383
5e6c19919741 log --copies: use manifest.find instead of delta when manifest parent is not rev-1
Brendan Cully <brendan@kublai.com>
parents: 3346
diff changeset
1821 return ncache[fn].get(repo.manifest.find(man, fn)[0])
3190
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1822 if not dcache or dcache[0] != man:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1823 dcache[:] = [man, repo.manifest.readdelta(man)]
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1824 if fn in dcache[1]:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1825 return ncache[fn].get(dcache[1][fn])
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1826 return None
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1827
3816
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
1828 df = False
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
1829 if opts["date"]:
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
1830 df = util.matchdate(opts["date"])
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
1831
3837
7df171ea50cd Fix log regression where log -p file showed diffs for other files
Matt Mackall <mpm@selenic.com>
parents: 3833
diff changeset
1832 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
1146
9061f79c6c6f grep: extend functionality, add man page entry, add unit test.
bos@serpentine.internal.keyresearch.com
parents: 1145
diff changeset
1833 for st, rev, fns in changeiter:
3648
b984dcb1df71 Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents: 3646
diff changeset
1834 if st == 'add':
1435
22b44fd9a166 add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1431
diff changeset
1835 changenode = repo.changelog.node(rev)
3578
3b4e00cba57a Define and use nullrev (revision of nullid) instead of -1.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3576
diff changeset
1836 parents = [p for p in repo.changelog.parentrevs(rev)
3b4e00cba57a Define and use nullrev (revision of nullid) instead of -1.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3576
diff changeset
1837 if p != nullrev]
1435
22b44fd9a166 add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1431
diff changeset
1838 if opts['no_merges'] and len(parents) == 2:
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1839 continue
1436
db6d7b4005ba add --only-merges (-m) log
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1435
diff changeset
1840 if opts['only_merges'] and len(parents) != 2:
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
1841 continue
1435
22b44fd9a166 add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1431
diff changeset
1842
3816
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
1843 if df:
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
1844 changes = get(rev)
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
1845 if not df(changes[2][0]):
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
1846 continue
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
1847
1373
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
1848 if opts['keyword']:
3657
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3656
diff changeset
1849 changes = get(rev)
1373
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
1850 miss = 0
1404
67e20e27d8df log: make keyword search truly case-insensitive
TK Soh <teekaysoh@yahoo.com>
parents: 1402
diff changeset
1851 for k in [kw.lower() for kw in opts['keyword']]:
1373
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
1852 if not (k in changes[1].lower() or
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
1853 k in changes[4].lower() or
4322
38922a13101e log: expand keyword search to full list of files
TK Soh <teekaysoh@yahoo.com>
parents: 4315
diff changeset
1854 k in " ".join(changes[3]).lower()):
1373
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
1855 miss = 1
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
1856 break
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
1857 if miss:
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
1858 continue
965d1db5c95d hg log: add -k for keyword searching
Matt Mackall <mpm@selenic.com>
parents: 1366
diff changeset
1859
3190
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1860 copies = []
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1861 if opts.get('copies') and rev:
3657
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3656
diff changeset
1862 mf = get(rev)[0]
731e739b8659 move walkchangerevs to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3656
diff changeset
1863 for fn in get(rev)[3]:
3190
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1864 rename = getrenamed(fn, rev, mf)
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1865 if rename:
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
1866 copies.append((fn, rename[0]))
3656
e50891e461e4 Consolidate brinfo handling
Matt Mackall <mpm@selenic.com>
parents: 3648
diff changeset
1867 displayer.show(rev, changenode, copies=copies)
1057
2fd15d743b3b Add grep command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1042
diff changeset
1868 elif st == 'iter':
1756
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
1869 if count == limit: break
3648
b984dcb1df71 Refactor log ui buffering and patch display
Matt Mackall <mpm@selenic.com>
parents: 3646
diff changeset
1870 if displayer.flush(rev):
1765
b9fac31f34c9 hg log --limit shouldn't count unprinted revisions (found by TK Soh)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1764
diff changeset
1871 count += 1
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1872
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
1873 def manifest(ui, repo, rev=None):
3913
283ee8971570 doc string fix: hg cat and manifest default to current parent revision.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3900
diff changeset
1874 """output the current or given revision of the project manifest
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1875
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1876 Print a list of version controlled files for the given revision.
3914
3c82ab166eea doc fix: hg tags defaults to current parent revision, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3913
diff changeset
1877 If no revision is given, the parent of the working directory is used,
3c82ab166eea doc fix: hg tags defaults to current parent revision, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3913
diff changeset
1878 or tip if no revision is checked out.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1879
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1880 The manifest is the list of files being version controlled. If no revision
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1881 is given then the first parent of the working directory is used.
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1882
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1883 With -v flag, print file permissions. With --debug flag, print
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1884 file revision hashes.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1885 """
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1886
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1887 m = repo.changectx(rev).manifest()
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1888 files = m.keys()
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1889 files.sort()
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1890
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1891 for f in files:
3736
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1892 if ui.debugflag:
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1893 ui.write("%40s " % hex(m[f]))
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1894 if ui.verbose:
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1895 ui.write("%3s " % (m.execf(f) and "755" or "644"))
ad3d5b4367cb make manifest friendlier
Matt Mackall <mpm@selenic.com>
parents: 3707
diff changeset
1896 ui.write("%s\n" % f)
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1897
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
1898 def merge(ui, repo, node=None, force=None, rev=None):
4014
509342f95564 various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4013
diff changeset
1899 """merge working directory with another revision
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
1900
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
1901 Merge the contents of the current working directory and the
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
1902 requested revision. Files that changed between either parent are
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
1903 marked as changed for the next commit and a commit must be
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
1904 performed before any further updates are allowed.
2903
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1905
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1906 If no revision is specified, the working directory's parent is a
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1907 head revision, and the repository contains exactly one other head,
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1908 the other head is merged with by default. Otherwise, an explicit
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1909 revision to merge with must be provided.
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
1910 """
2820
0bf22c109cc3 Factor doupdate into _lookup + hg.update
Matt Mackall <mpm@selenic.com>
parents: 2803
diff changeset
1911
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
1912 if rev and node:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
1913 raise util.Abort(_("please specify just one revision"))
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
1914
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
1915 if not node:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
1916 node = rev
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
1917
3885
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
1918 if not node:
2903
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1919 heads = repo.heads()
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1920 if len(heads) > 2:
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1921 raise util.Abort(_('repo has %d heads - '
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1922 'please merge with an explicit rev') %
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1923 len(heads))
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1924 if len(heads) == 1:
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1925 raise util.Abort(_('there is nothing to merge - '
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1926 'use "hg update" instead'))
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1927 parent = repo.dirstate.parents()[0]
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1928 if parent not in heads:
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1929 raise util.Abort(_('working dir not at a head rev - '
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1930 'use "hg update" or merge with an explicit rev'))
013921c753bd merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2896
diff changeset
1931 node = parent == heads[0] and heads[-1] or heads[0]
2822
30f59f4a327e Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents: 2820
diff changeset
1932 return hg.merge(repo, node, force=force)
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
1933
2494
73ac95671788 push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2493
diff changeset
1934 def outgoing(ui, repo, dest=None, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1935 """show changesets not found in destination
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1936
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
1937 Show changesets not found in the specified destination repository or
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
1938 the default push location. These are the changesets that would be pushed
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1939 if a push was requested.
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
1940
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
1941 See pull for valid destination format details.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1942 """
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
1943 dest, revs = cmdutil.parseurl(
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
1944 ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
1945 cmdutil.setremoteconfig(ui, opts)
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
1946 if revs:
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
1947 revs = [repo.lookup(rev) for rev in revs]
1965
62aa1b90414f add remotecmd/ssh option support to incoming/outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1959
diff changeset
1948
920
270756aa29d5 Add hg outgoing command
mpm@selenic.com
parents: 918
diff changeset
1949 other = hg.repository(ui, dest)
4162
b2d9e553cdc8 incoming/outgoing: print the name of the other repo
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4158
diff changeset
1950 ui.status(_('comparing with %s\n') % dest)
1959
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
1951 o = repo.findoutgoing(other, force=opts['force'])
1994
78ef83c9e9e1 show message if no changes found on outgoing
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1993
diff changeset
1952 if not o:
78ef83c9e9e1 show message if no changes found on outgoing
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1993
diff changeset
1953 ui.status(_("no changes found\n"))
3931
f2cbcf1e98b2 incoming/outgoing: return failure if no changes found
Matt Mackall <mpm@selenic.com>
parents: 3930
diff changeset
1954 return 1
2521
9cceb439048b add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2515
diff changeset
1955 o = repo.changelog.nodesbetween(o, revs)[0]
1439
65cbe22b03fa allow 'hg out' / 'hg in' to show newest commit first
Michal Kvasnica <kvasnica@gmail.com>
parents: 1437
diff changeset
1956 if opts['newest_first']:
65cbe22b03fa allow 'hg out' / 'hg in' to show newest commit first
Michal Kvasnica <kvasnica@gmail.com>
parents: 1437
diff changeset
1957 o.reverse()
3646
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3634
diff changeset
1958 displayer = cmdutil.show_changeset(ui, repo, opts)
920
270756aa29d5 Add hg outgoing command
mpm@selenic.com
parents: 918
diff changeset
1959 for n in o:
1435
22b44fd9a166 add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1431
diff changeset
1960 parents = [p for p in repo.changelog.parents(n) if p != nullid]
22b44fd9a166 add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1431
diff changeset
1961 if opts['no_merges'] and len(parents) == 2:
22b44fd9a166 add --no-merges (-M) for log, outgoing, incoming
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1431
diff changeset
1962 continue
1907
7718885070b1 let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1800
diff changeset
1963 displayer.show(changenode=n)
920
270756aa29d5 Add hg outgoing command
mpm@selenic.com
parents: 918
diff changeset
1964
3665
d12c8668b102 remove legacy hg parents REV syntax
Matt Mackall <mpm@selenic.com>
parents: 3664
diff changeset
1965 def parents(ui, repo, file_=None, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1966 """show the parents of the working dir or revision
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1967
4586
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1968 Print the working directory's parent revisions. If a
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1969 revision is given via --rev, the parent of that revision
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1970 will be printed. If a file argument is given, revision in
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1971 which the file was last changed (before the working directory
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1972 revision or the argument to --rev if given) is printed.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1973 """
3665
d12c8668b102 remove legacy hg parents REV syntax
Matt Mackall <mpm@selenic.com>
parents: 3664
diff changeset
1974 rev = opts.get('rev')
4586
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1975 if file_:
4894
be5dc5e3ab2d hg parents: don't pass an OS-specific path to repo.filectx
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4877
diff changeset
1976 files, match, anypats = cmdutil.matchpats(repo, (file_,), opts)
be5dc5e3ab2d hg parents: don't pass an OS-specific path to repo.filectx
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4877
diff changeset
1977 if anypats or len(files) != 1:
be5dc5e3ab2d hg parents: don't pass an OS-specific path to repo.filectx
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4877
diff changeset
1978 raise util.Abort(_('can only specify an explicit file name'))
be5dc5e3ab2d hg parents: don't pass an OS-specific path to repo.filectx
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4877
diff changeset
1979 ctx = repo.filectx(files[0], changeid=rev)
4586
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1980 elif rev:
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1981 ctx = repo.changectx(rev)
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1982 else:
4586
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1983 ctx = repo.workingctx()
1fcc076fcb17 Make parents with a file but not a revision use working directory revision.
Brendan Cully <brendan@kublai.com>
parents: 4473
diff changeset
1984 p = [cp.node() for cp in ctx.parents()]
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1985
3646
b4ad640a3bcf templates: move changeset templating bits to cmdutils
Matt Mackall <mpm@selenic.com>
parents: 3634
diff changeset
1986 displayer = cmdutil.show_changeset(ui, repo, opts)
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1987 for n in p:
1092
0a02315976ff commands: use node functions directly
mpm@selenic.com
parents: 1090
diff changeset
1988 if n != nullid:
3656
e50891e461e4 Consolidate brinfo handling
Matt Mackall <mpm@selenic.com>
parents: 3648
diff changeset
1989 displayer.show(changenode=n)
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
1990
1858
9fab6e903bae Make hg paths and hg debugconfig work with -R/--repository option.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1857
diff changeset
1991 def paths(ui, repo, search=None):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1992 """show definition of symbolic path names
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1993
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1994 Show definition of symbolic path name NAME. If no name is given, show
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1995 definition of available names.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1996
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1997 Path names are defined in the [paths] section of /etc/mercurial/hgrc
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1998 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
1999 """
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2000 if search:
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2001 for name, path in ui.configitems("paths"):
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2002 if name == search:
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2003 ui.write("%s\n" % path)
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2004 return
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2005 ui.warn(_("not found!\n"))
779
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2006 return 1
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2007 else:
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2008 for name, path in ui.configitems("paths"):
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2009 ui.write("%s = %s\n" % (name, path))
b3c7cb74d325 Add paths command
TK Soh <teekaysoh@yahoo.com>
parents: 778
diff changeset
2010
4923
e8c0b52c363c Better fix for issue 622 than we had in c4dd58af0fc8.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4912
diff changeset
2011 def postincoming(ui, repo, modheads, optupdate):
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2012 if modheads == 0:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2013 return
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2014 if optupdate:
5097
73fdc8bd3ed8 Update on pull -u when heads were closed (fixes issue666).
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5067
diff changeset
2015 if modheads <= 1:
4924
b8076522e889 Simplify update.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4923
diff changeset
2016 return hg.update(repo, None)
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2017 else:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2018 ui.status(_("not updating, since new heads added\n"))
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2019 if modheads > 1:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2020 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2021 else:
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2022 ui.status(_("(run 'hg update' to get a working copy)\n"))
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
2023
404
a1ecef497721 [PATCH] Unintuive use
mpm@selenic.com
parents: 403
diff changeset
2024 def pull(ui, repo, source="default", **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2025 """pull changes from the specified source
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2026
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2027 Pull changes from a remote repository to a local one.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2028
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2029 This finds all changes from the repository at the specified path
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2030 or URL and adds them to the local repository. By default, this
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2031 does not update the copy of the project in the working directory.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2032
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2033 Valid URLs are of the form:
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2034
3549
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2035 local/filesystem/path (or file://local/filesystem/path)
2589
dc63db82b530 disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents: 2580
diff changeset
2036 http://[user@]host[:port]/[path]
dc63db82b530 disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents: 2580
diff changeset
2037 https://[user@]host[:port]/[path]
dc63db82b530 disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents: 2580
diff changeset
2038 ssh://[user@]host[:port]/[path]
3549
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2039 static-http://host[:port]/[path]
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2040
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2041 Paths in the local filesystem can either point to Mercurial
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2042 repositories or to bundle files (as created by 'hg bundle' or
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2043 'hg incoming --bundle'). The static-http:// protocol, albeit slow,
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2044 allows access to a Mercurial repository where you simply use a web
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2045 server to publish the .hg directory as static content.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2046
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2047 An optional identifier after # indicates a particular branch, tag,
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2048 or changeset to pull.
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2049
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2050 Some notes about using SSH with Mercurial:
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2051 - SSH requires an accessible shell account on the destination machine
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2052 and a copy of hg in the remote path or specified with as remotecmd.
2589
dc63db82b530 disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents: 2580
diff changeset
2053 - path is relative to the remote user's home directory by default.
2590
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
2054 Use an extra slash at the start of a path to specify an absolute path:
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
2055 ssh://example.com//tmp/repository
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2056 - Mercurial doesn't use its own compression via SSH; the right thing
3466
be2bf7263276 Corrected SSH configuration example in pull help.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3462
diff changeset
2057 to do is to configure it in your ~/.ssh/config, e.g.:
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2058 Host *.mylocalnetwork.example.com
3466
be2bf7263276 Corrected SSH configuration example in pull help.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3462
diff changeset
2059 Compression no
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2060 Host *
3466
be2bf7263276 Corrected SSH configuration example in pull help.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3462
diff changeset
2061 Compression yes
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2062 Alternatively specify "ssh -C" as your ssh command in your hgrc or
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2063 with the --ssh command line option.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2064 """
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2065 source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev'])
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
2066 cmdutil.setremoteconfig(ui, opts)
963
84355e3e4493 Add -e and --remotecmd for clone and pull too
mpm@selenic.com
parents: 961
diff changeset
2067
246
96cde50a746f Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents: 245
diff changeset
2068 other = hg.repository(ui, source)
2473
30c267cb4c2f change some repo messages in small ways.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2461
diff changeset
2069 ui.status(_('pulling from %s\n') % (source))
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2070 if revs:
3448
6ca49c5fe268 Stop erroring out pull -r and clone -r if repository isn't local.
Eric Hopper <hopper@omnifarious.org>
parents: 3436
diff changeset
2071 if 'lookup' in other.capabilities:
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2072 revs = [other.lookup(rev) for rev in revs]
3448
6ca49c5fe268 Stop erroring out pull -r and clone -r if repository isn't local.
Eric Hopper <hopper@omnifarious.org>
parents: 3436
diff changeset
2073 else:
6ca49c5fe268 Stop erroring out pull -r and clone -r if repository isn't local.
Eric Hopper <hopper@omnifarious.org>
parents: 3436
diff changeset
2074 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
6ca49c5fe268 Stop erroring out pull -r and clone -r if repository isn't local.
Eric Hopper <hopper@omnifarious.org>
parents: 3436
diff changeset
2075 raise util.Abort(error)
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2076
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2077 modheads = repo.pull(other, heads=revs, force=opts['force'])
4923
e8c0b52c363c Better fix for issue 622 than we had in c4dd58af0fc8.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4912
diff changeset
2078 return postincoming(ui, repo, modheads, opts['update'])
246
96cde50a746f Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents: 245
diff changeset
2079
2494
73ac95671788 push, outgoing, bundle: fall back to "default" if "default-push" not defined
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2493
diff changeset
2080 def push(ui, repo, dest=None, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2081 """push changes to the specified destination
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2082
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2083 Push changes from the local repository to the given destination.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2084
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2085 This is the symmetrical operation for pull. It helps to move
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2086 changes from the current repository to a different one. If the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2087 destination is local this is identical to a pull in that directory
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2088 from the current one.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2089
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2090 By default, push will refuse to run if it detects the result would
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2091 increase the number of remote heads. This generally indicates the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2092 the client has forgotten to sync and merge before pushing.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2093
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2094 Valid URLs are of the form:
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2095
3549
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2096 local/filesystem/path (or file://local/filesystem/path)
2589
dc63db82b530 disambiguate help about url syntax
"Aurelien Jacobs <aurel@gnuage.org>"
parents: 2580
diff changeset
2097 ssh://[user@]host[:port]/[path]
3549
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2098 http://[user@]host[:port]/[path]
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2099 https://[user@]host[:port]/[path]
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2100
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2101 An optional identifier after # indicates a particular branch, tag,
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2102 or changeset to push.
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2103
1979
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2104 Look at the help text for the pull command for important details
d545fa1426b9 More detailed documentation about ssh:// URLs; fixes issue170.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1974
diff changeset
2105 about ssh:// URLs.
2590
911b56853fdd Additional information about URLs in pull/push/clone/init:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2589
diff changeset
2106
3549
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2107 Pushing to http:// and https:// URLs is only possible, if this
db946221a58a Some clarifications for pull/push protocols:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3539
diff changeset
2108 feature is explicitly enabled on the remote Mercurial server.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2109 """
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2110 dest, revs = cmdutil.parseurl(
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2111 ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
2112 cmdutil.setremoteconfig(ui, opts)
961
3e11d5038649 Add --ssh and --remotecmd to push
mpm@selenic.com
parents: 955
diff changeset
2113
640
b48b91d3fb4a Switch push over to the new scheme
Matt Mackall <mpm@selenic.com>
parents: 639
diff changeset
2114 other = hg.repository(ui, dest)
2473
30c267cb4c2f change some repo messages in small ways.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2461
diff changeset
2115 ui.status('pushing to %s\n' % (dest))
4478
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2116 if revs:
b2b55acbacdd Add support for url#id syntax
Matt Mackall <mpm@selenic.com>
parents: 4474
diff changeset
2117 revs = [repo.lookup(rev) for rev in revs]
1781
284fc722c342 add an optional argument to push only the specified revisions (push -r)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1712
diff changeset
2118 r = repo.push(other, opts['force'], revs=revs)
2019
ced2d3620f95 add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1996
diff changeset
2119 return r == 0
319
9ab17e83bce3 stopgap hg push support
mpm@selenic.com
parents: 317
diff changeset
2120
3660
d793e09e1b71 refactor rawcommit
Matt Mackall <mpm@selenic.com>
parents: 3659
diff changeset
2121 def rawcommit(ui, repo, *pats, **opts):
1812
a81f99dfaa2a fix the synopsis of some commands, mark rawcommit as deprecated in short help
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1811
diff changeset
2122 """raw commit interface (DEPRECATED)
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
2123
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
2124 (DEPRECATED)
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2125 Lowlevel commit, for use in helper scripts.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2126
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2127 This command is not intended to be used by normal users, as it is
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2128 primarily useful for importing from other SCMs.
1657
dbb8bba48510 deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents: 1654
diff changeset
2129
dbb8bba48510 deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents: 1654
diff changeset
2130 This command is now deprecated and will be removed in a future
dbb8bba48510 deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents: 1654
diff changeset
2131 release, please use debugsetparents and commit instead.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2132 """
1657
dbb8bba48510 deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents: 1654
diff changeset
2133
dbb8bba48510 deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents: 1654
diff changeset
2134 ui.warn(_("(the rawcommit command is deprecated)\n"))
dbb8bba48510 deprecate the rawcommit command
Matt Mackall <mpm@selenic.com>
parents: 1654
diff changeset
2135
4549
0c61124ad877 dispatch: move dispatching code to cmdutil
Matt Mackall <mpm@selenic.com>
parents: 4548
diff changeset
2136 message = cmdutil.logmessage(opts)
3660
d793e09e1b71 refactor rawcommit
Matt Mackall <mpm@selenic.com>
parents: 3659
diff changeset
2137
d793e09e1b71 refactor rawcommit
Matt Mackall <mpm@selenic.com>
parents: 3659
diff changeset
2138 files, match, anypats = cmdutil.matchpats(repo, pats, opts)
d793e09e1b71 refactor rawcommit
Matt Mackall <mpm@selenic.com>
parents: 3659
diff changeset
2139 if opts['files']:
d793e09e1b71 refactor rawcommit
Matt Mackall <mpm@selenic.com>
parents: 3659
diff changeset
2140 files += open(opts['files']).read().splitlines()
d793e09e1b71 refactor rawcommit
Matt Mackall <mpm@selenic.com>
parents: 3659
diff changeset
2141
d793e09e1b71 refactor rawcommit
Matt Mackall <mpm@selenic.com>
parents: 3659
diff changeset
2142 parents = [repo.lookup(p) for p in opts['parent']]
500
ebc4714a7632 [PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents: 499
diff changeset
2143
1202
71111d796e40 Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1194
diff changeset
2144 try:
3666
025f68f22ae2 move write_bundle to changegroup.py
Matt Mackall <mpm@selenic.com>
parents: 3665
diff changeset
2145 repo.rawcommit(files, message, opts['user'], opts['date'], *parents)
1202
71111d796e40 Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1194
diff changeset
2146 except ValueError, inst:
71111d796e40 Commit date validation: more stringent checks, more useful error messages.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1194
diff changeset
2147 raise util.Abort(str(inst))
500
ebc4714a7632 [PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents: 499
diff changeset
2148
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
2149 def recover(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2150 """roll back an interrupted transaction
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2151
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2152 Recover from an interrupted commit or pull.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2153
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2154 This command tries to fix the repository status after an interrupted
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2155 operation. It should only be necessary when Mercurial suggests it.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2156 """
1516
0b1b029b4de3 Automatically run "verify" whenever we run "recover"
Matt Mackall <mpm@selenic.com>
parents: 1514
diff changeset
2157 if repo.recover():
2802
fdc232d8a193 Move repo.verify
Matt Mackall <mpm@selenic.com>
parents: 2800
diff changeset
2158 return hg.verify(repo)
2057
fef2d653beaf Never exit directly from commands.dispatch(), but pass return code to caller.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2056
diff changeset
2159 return 1
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
2160
2179
520dd3d28e9b add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2175
diff changeset
2161 def remove(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2162 """remove the specified files on the next commit
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2163
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2164 Schedule the indicated files for removal from the repository.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2165
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2166 This only removes files from the current branch, not from the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2167 entire project history. If the files still exist in the working
2179
520dd3d28e9b add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2175
diff changeset
2168 directory, they will be deleted from it. If invoked with --after,
4392
9770d260a405 Make rm --after simply mark files as removed, unless --force is also given
Brendan Cully <brendan@kublai.com>
parents: 4382
diff changeset
2169 files are marked as removed, but not actually unlinked unless --force
4394
a6436e9333db Also restore old rm -A behavior for inexact patterns
Brendan Cully <brendan@kublai.com>
parents: 4393
diff changeset
2170 is also given. Without exact file names, --after will only mark
4393
cf5f35ec4720 Fix rm -A with no patterns, which I just broke.
Brendan Cully <brendan@kublai.com>
parents: 4392
diff changeset
2171 files as removed if they are no longer in the working directory.
2309
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2172
3831
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
2173 This command schedules the files to be removed at the next commit.
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
2174 To undo a remove before that, see hg revert.
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
2175
2309
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2176 Modified files and added files are not removed by default. To
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2177 remove them, use the -f/--force option.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2178 """
2179
520dd3d28e9b add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2175
diff changeset
2179 if not opts['after'] and not pats:
520dd3d28e9b add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2175
diff changeset
2180 raise util.Abort(_('no files specified'))
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
2181 files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
2309
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2182 exact = dict.fromkeys(files)
2874
3d6efcbbd1c9 remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2873
diff changeset
2183 mardu = map(dict.fromkeys, repo.status(files=files, match=matchfn))[:5]
2309
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2184 modified, added, removed, deleted, unknown = mardu
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2185 remove, forget = [], []
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
2186 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts):
1189
4cbcc54695b2 Make removal check more complete and informative.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1188
diff changeset
2187 reason = None
4392
9770d260a405 Make rm --after simply mark files as removed, unless --force is also given
Brendan Cully <brendan@kublai.com>
parents: 4382
diff changeset
2188 if abs in modified and not opts['force']:
2309
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2189 reason = _('is modified (use -f to force removal)')
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2190 elif abs in added:
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2191 if opts['force']:
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2192 forget.append(abs)
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2193 continue
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2194 reason = _('has been marked for add (use -f to force removal)')
4950
30847b8af7ca dirstate: add __contains__ and make __getitem__ more useful
Matt Mackall <mpm@selenic.com>
parents: 4948
diff changeset
2195 elif abs not in repo.dirstate:
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2196 reason = _('is not managed')
4394
a6436e9333db Also restore old rm -A behavior for inexact patterns
Brendan Cully <brendan@kublai.com>
parents: 4393
diff changeset
2197 elif opts['after'] and not exact and abs not in deleted:
4393
cf5f35ec4720 Fix rm -A with no patterns, which I just broke.
Brendan Cully <brendan@kublai.com>
parents: 4392
diff changeset
2198 continue
2309
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2199 elif abs in removed:
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2200 continue
1255
e825dfea3823 Get all commands that operate on files to honour --verbose and --quiet.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1254
diff changeset
2201 if reason:
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2202 if exact:
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2203 ui.warn(_('not removing %s: file %s\n') % (rel, reason))
1189
4cbcc54695b2 Make removal check more complete and informative.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1188
diff changeset
2204 else:
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2205 if ui.verbose or not exact:
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2206 ui.status(_('removing %s\n') % rel)
2309
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2207 remove.append(abs)
b2f37c7026ca remove: rewrite to be ~400x faster, bit more friendly
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2301
diff changeset
2208 repo.forget(forget)
4392
9770d260a405 Make rm --after simply mark files as removed, unless --force is also given
Brendan Cully <brendan@kublai.com>
parents: 4382
diff changeset
2209 repo.remove(remove, unlink=opts['force'] or not opts['after'])
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
2210
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
2211 def rename(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2212 """rename files; equivalent of copy + remove
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2213
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2214 Mark dest as copies of sources; mark sources for deletion. If
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2215 dest is a directory, copies are put in that directory. If dest is
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2216 a file, there can only be one source.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2217
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2218 By default, this command copies the contents of files as they
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2219 stand in the working directory. If invoked with --after, the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2220 operation is recorded, but no copying is performed.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2221
3831
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
2222 This command takes effect in the next commit. To undo a rename
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
2223 before that, see hg revert.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2224 """
4958
9a2a73ea6135 repo locks: use True/False
Matt Mackall <mpm@selenic.com>
parents: 4950
diff changeset
2225 wlock = repo.wlock(False)
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2226 try:
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
2227 errs, copied = docopy(ui, repo, pats, opts)
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2228 names = []
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2229 for abs, rel, exact in copied:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2230 if ui.verbose or not exact:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2231 ui.status(_('removing %s\n') % rel)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2232 names.append(abs)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2233 if not opts.get('dry_run'):
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
2234 repo.remove(names, True)
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2235 return errs
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2236 finally:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2237 del wlock
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
2238
1472
3c909a747d7f make revert use standard matcher
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1470
diff changeset
2239 def revert(ui, repo, *pats, **opts):
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2240 """revert files or dirs to their states as of some revision
2204
eb5fa83ffcfa fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2189
diff changeset
2241
2212
8164e3f31638 revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2204
diff changeset
2242 With no revision specified, revert the named files or directories
8164e3f31638 revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2204
diff changeset
2243 to the contents they had in the parent of the working directory.
8164e3f31638 revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2204
diff changeset
2244 This restores the contents of the affected files to an unmodified
3831
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
2245 state and unschedules adds, removes, copies, and renames. If the
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
2246 working directory has two parents, you must explicitly specify the
531c116b2028 Add doc notes about revert and hg status vs diff
Matt Mackall <mpm@selenic.com>
parents: 3828
diff changeset
2247 revision to revert to.
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
2248
2036
c9226bcc288d Don't abort when backup files already exist. Don't allow alternative names.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2029
diff changeset
2249 Modified files are saved with a .orig suffix before reverting.
c9226bcc288d Don't abort when backup files already exist. Don't allow alternative names.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2029
diff changeset
2250 To disable these backups, use --no-backup.
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
2251
3013
2b255c3478dc minor docstring fix for revert
TK Soh <teekaysoh@yahoo.com>
parents: 3011
diff changeset
2252 Using the -r option, revert the given files or directories to their
2b255c3478dc minor docstring fix for revert
TK Soh <teekaysoh@yahoo.com>
parents: 3011
diff changeset
2253 contents as of a specific revision. This can be helpful to "roll
1811
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
2254 back" some or all of a change that should not have been committed.
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
2255
6cb548cffdf5 resync commands.py docstrings with hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1804
diff changeset
2256 Revert modifies the working directory. It does not commit any
2204
eb5fa83ffcfa fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2189
diff changeset
2257 changes, or change the parent of the working directory. If you
eb5fa83ffcfa fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2189
diff changeset
2258 revert to a revision other than the parent of the working
eb5fa83ffcfa fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2189
diff changeset
2259 directory, the reverted files will thus appear modified
eb5fa83ffcfa fix doc comments for revert command. people found them confusing.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2189
diff changeset
2260 afterwards.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2261
4803
7db38bfb307e Fix issue589 wording problem
Patrick Mezard <pmezard@gmail.com>
parents: 4798
diff changeset
2262 If a file has been deleted, it is restored. If the executable
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2263 mode of a file was changed, it is reset.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2264
1472
3c909a747d7f make revert use standard matcher
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1470
diff changeset
2265 If names are given, all files matching the names are reverted.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2266
2965
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
2267 If no arguments are given, no files are reverted.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2268 """
2965
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
2269
3818
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
2270 if opts["date"]:
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
2271 if opts["rev"]:
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
2272 raise util.Abort(_("you can't specify a revision and a date"))
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
2273 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
2274
2965
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
2275 if not pats and not opts['all']:
3017
ea2a9c13afc6 Add a hint for revert --all when aborting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3013
diff changeset
2276 raise util.Abort(_('no files or directories specified; '
ea2a9c13afc6 Add a hint for revert --all when aborting
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3013
diff changeset
2277 'use --all to revert the whole repo'))
2965
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
2278
2212
8164e3f31638 revert: require explicit revision when working dir has two parents.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2204
diff changeset
2279 parent, p2 = repo.dirstate.parents()
3127
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3092
diff changeset
2280 if not opts['rev'] and p2 != nullid:
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3092
diff changeset
2281 raise util.Abort(_('uncommitted merge - please provide a '
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3092
diff changeset
2282 'specific revision'))
3972
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
2283 ctx = repo.changectx(opts['rev'])
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
2284 node = ctx.node()
356e20d46b34 commands.py: use contexts in various places (debug*state, revert)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3951
diff changeset
2285 mf = ctx.manifest()
2407
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
2286 if node == parent:
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
2287 pmf = mf
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
2288 else:
8fe3d60b7f19 revert: better fix for not printing 'reverting' message
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2406
diff changeset
2289 pmf = None
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
2290
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
2291 # need all matching names in dirstate and manifest of target rev,
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
2292 # so have to walk both. do not print errors if files exist in one
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
2293 # but not other.
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
2294
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
2295 names = {}
2042
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
2296 target_only = {}
a514c7509fa9 small changes to revert command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2037
diff changeset
2297
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2298 wlock = repo.wlock()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2299 try:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2300 # walk dirstate.
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2301 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts,
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2302 badmatch=mf.has_key):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2303 names[abs] = (rel, exact)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2304 if src == 'b':
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2305 target_only[abs] = True
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2306
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2307 # walk target manifest.
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2308
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2309 def badmatch(path):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2310 if path in names:
4225
281f9f8f1bd4 Fix confusing message from hg revert (issue332)
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4217
diff changeset
2311 return True
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2312 path_ = path + '/'
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2313 for f in names:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2314 if f.startswith(path_):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2315 return True
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2316 return False
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2317
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2318 for src, abs, rel, exact in cmdutil.walk(repo, pats, opts, node=node,
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2319 badmatch=badmatch):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2320 if abs in names or src == 'b':
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2321 continue
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2322 names[abs] = (rel, exact)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2323 target_only[abs] = True
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2324
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
2325 changes = repo.status(match=names.has_key)[:5]
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2326 modified, added, removed, deleted, unknown = map(dict.fromkeys, changes)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2327
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2328 revert = ([], _('reverting %s\n'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2329 add = ([], _('adding %s\n'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2330 remove = ([], _('removing %s\n'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2331 forget = ([], _('forgetting %s\n'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2332 undelete = ([], _('undeleting %s\n'))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2333 update = {}
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2334
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2335 disptable = (
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2336 # dispatch table:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2337 # file state
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2338 # action if in target manifest
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2339 # action if not in target manifest
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2340 # make backup if in target manifest
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2341 # make backup if not in target manifest
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2342 (modified, revert, remove, True, True),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2343 (added, revert, forget, True, False),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2344 (removed, undelete, None, False, False),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2345 (deleted, revert, remove, False, False),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2346 (unknown, add, None, True, False),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2347 (target_only, add, None, False, False),
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2348 )
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2349
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2350 entries = names.items()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2351 entries.sort()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2352
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2353 for abs, (rel, exact) in entries:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2354 mfentry = mf.get(abs)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2355 target = repo.wjoin(abs)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2356 def handle(xlist, dobackup):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2357 xlist[0].append(abs)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2358 update[abs] = 1
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2359 if dobackup and not opts['no_backup'] and util.lexists(target):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2360 bakname = "%s.orig" % rel
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2361 ui.note(_('saving current version of %s as %s\n') %
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2362 (rel, bakname))
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2363 if not opts.get('dry_run'):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2364 util.copyfile(target, bakname)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2365 if ui.verbose or not exact:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2366 ui.status(xlist[1] % rel)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2367 for table, hitlist, misslist, backuphit, backupmiss in disptable:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2368 if abs not in table: continue
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2369 # file has changed in dirstate
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2370 if mfentry:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2371 handle(hitlist, backuphit)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2372 elif misslist is not None:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2373 handle(misslist, backupmiss)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2374 else:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2375 if exact: ui.warn(_('file not managed: %s\n') % rel)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2376 break
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
2377 else:
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2378 # file has not changed in dirstate
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2379 if node == parent:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2380 if exact: ui.warn(_('no changes needed to %s\n') % rel)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2381 continue
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2382 if pmf is None:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2383 # only need parent manifest in this unlikely case,
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2384 # so do not read by default
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2385 pmf = repo.changectx(parent).manifest()
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2386 if abs in pmf:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2387 if mfentry:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2388 # if version of file is same in parent and target
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2389 # manifests, do nothing
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2390 if pmf[abs] != mfentry:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2391 handle(revert, False)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2392 else:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2393 handle(remove, False)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2394
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2395 if not opts.get('dry_run'):
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2396 for f in forget[0]:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2397 repo.dirstate.forget(f)
4961
126f527b3ba3 Make repo locks recursive, eliminate all passing of lock/wlock
Matt Mackall <mpm@selenic.com>
parents: 4959
diff changeset
2398 r = hg.revert(repo, node, update.has_key)
4959
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2399 for f in add[0]:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2400 repo.dirstate.add(f)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2401 for f in undelete[0]:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2402 repo.dirstate.normal(f)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2403 for f in remove[0]:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2404 repo.dirstate.remove(f)
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2405 return r
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2406 finally:
97b734fb9c6f Use try/finally pattern to cleanup locks and transactions
Matt Mackall <mpm@selenic.com>
parents: 4958
diff changeset
2407 del wlock
588
0c3bae18403b [PATCH] hg revert
mpm@selenic.com
parents: 582
diff changeset
2408
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2409 def rollback(ui, repo):
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2410 """roll back the last transaction in this repository
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2411
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2412 Roll back the last transaction in this repository, restoring the
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2413 project to its state prior to the transaction.
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2414
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2415 Transactions are used to encapsulate the effects of all commands
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2416 that create new changesets or propagate existing changesets into a
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2417 repository. For example, the following commands are transactional,
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2418 and their effects can be rolled back:
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2419
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2420 commit
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2421 import
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2422 pull
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2423 push (with this repository as destination)
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2424 unbundle
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2425
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2426 This command should be used with care. There is only one level of
4682
51ec5e069505 rollback: update help for issue316
Matt Mackall <mpm@selenic.com>
parents: 4676
diff changeset
2427 rollback, and there is no way to undo a rollback. It will also
51ec5e069505 rollback: update help for issue316
Matt Mackall <mpm@selenic.com>
parents: 4676
diff changeset
2428 restore the dirstate at the time of the last transaction, which
51ec5e069505 rollback: update help for issue316
Matt Mackall <mpm@selenic.com>
parents: 4676
diff changeset
2429 may lose subsequent dirstate changes.
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2430
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2431 This command is not intended for use on public repositories. Once
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2432 changes are visible for pull by other users, rolling a transaction
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2433 back locally is ineffective (someone else may already have pulled
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2434 the changes). Furthermore, a race is possible with readers of the
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2435 repository; for example an in-progress pull from the repository
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2436 may fail if a rollback is performed.
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2437 """
2362
482d3fb47d80 Renamed localrepo.undo() to rollback() and talk about "rollback information".
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2356
diff changeset
2438 repo.rollback()
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
2439
468
157675add351 [PATCH] add "root" command
mpm@selenic.com
parents: 467
diff changeset
2440 def root(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2441 """print the root (top) of the current working dir
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2442
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2443 Print the root directory of the current repository.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2444 """
468
157675add351 [PATCH] add "root" command
mpm@selenic.com
parents: 467
diff changeset
2445 ui.write(repo.root + "\n")
157675add351 [PATCH] add "root" command
mpm@selenic.com
parents: 467
diff changeset
2446
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
2447 def serve(ui, repo, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2448 """export the repository via HTTP
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2449
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2450 Start a local HTTP repository browser and pull server.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2451
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2452 By default, the server logs accesses to stdout and errors to
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2453 stderr. Use the "-A" and "-E" options to log to files.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2454 """
624
876333a295ff Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents: 618
diff changeset
2455
876333a295ff Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents: 618
diff changeset
2456 if opts["stdio"]:
2127
8a85dbbadddf Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2125
diff changeset
2457 if repo is None:
3076
4c9fcb5e3b82 If local repository is missing, make error message clearer.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3069
diff changeset
2458 raise hg.RepoError(_("There is no Mercurial repository here"
4c9fcb5e3b82 If local repository is missing, make error message clearer.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3069
diff changeset
2459 " (.hg not found)"))
2396
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2392
diff changeset
2460 s = sshserver.sshserver(ui, repo)
8d44649df03b refactor ssh server.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2392
diff changeset
2461 s.serve_forever()
2363
fa4c11751367 Give a response to unknown SSH commands
Matt Mackall <mpm@selenic.com>
parents: 2362
diff changeset
2462
4078
ff08cebcd116 hg serve: call setconfig on the parentui
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4064
diff changeset
2463 parentui = ui.parentui or ui
2125
3610d9468b1e Use string literal concatenation for optlist and import -p option
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2124
diff changeset
2464 optlist = ("name templates style address port ipv6"
4850
f3802f9f1840 Add SSL support to hg serve, activated via --certificate option
Brendan Cully <brendan@kublai.com>
parents: 4847
diff changeset
2465 " accesslog errorlog webdir_conf certificate")
987
bfe12654764d hgweb: change startup argument processing
mpm@selenic.com
parents: 981
diff changeset
2466 for o in optlist.split():
bfe12654764d hgweb: change startup argument processing
mpm@selenic.com
parents: 981
diff changeset
2467 if opts[o]:
4078
ff08cebcd116 hg serve: call setconfig on the parentui
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4064
diff changeset
2468 parentui.setconfig("web", o, str(opts[o]))
5123
f94dbc6c7eaf Fix hgwebdir after 9858477ed74cce9dc8f4069f9453a1bda0e13ba1 broke it.
Eric Hopper <hopper@omnifarious.org>
parents: 5097
diff changeset
2469 if (repo is not None) and (repo.ui != parentui):
4866
9858477ed74c serve: respect settings from .hg/hgrc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4864
diff changeset
2470 repo.ui.setconfig("web", o, str(opts[o]))
987
bfe12654764d hgweb: change startup argument processing
mpm@selenic.com
parents: 981
diff changeset
2471
2127
8a85dbbadddf Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2125
diff changeset
2472 if repo is None and not ui.config("web", "webdir_conf"):
3076
4c9fcb5e3b82 If local repository is missing, make error message clearer.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3069
diff changeset
2473 raise hg.RepoError(_("There is no Mercurial repository here"
4c9fcb5e3b82 If local repository is missing, make error message clearer.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3069
diff changeset
2474 " (.hg not found)"))
2127
8a85dbbadddf Allow 'hg serve --webdir-conf foo' to be run outside a repository.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2125
diff changeset
2475
4378
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2476 class service:
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2477 def init(self):
4672
272c0a09b203 Handle CTRL+C in serve under Windows.
Marcos Chaves <marcos.nospam@gmail.com>
parents: 4659
diff changeset
2478 util.set_signal_handler()
4378
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2479 try:
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2480 self.httpd = hgweb.server.create_server(parentui, repo)
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2481 except socket.error, inst:
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2482 raise util.Abort(_('cannot start server: ') + inst.args[1])
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2483
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2484 if not ui.verbose: return
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2485
4505
0ca5ef554987 Fix bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents: 4488
diff changeset
2486 if self.httpd.port != 80:
4378
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2487 ui.status(_('listening at http://%s:%d/\n') %
4505
0ca5ef554987 Fix bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents: 4488
diff changeset
2488 (self.httpd.addr, self.httpd.port))
4378
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2489 else:
4505
0ca5ef554987 Fix bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents: 4488
diff changeset
2490 ui.status(_('listening at http://%s/\n') % self.httpd.addr)
4378
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2491
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2492 def run(self):
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2493 self.httpd.serve_forever()
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2494
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2495 service = service()
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2496
e89f9afc462b Refactor commands.serve to allow other commands to run as services.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4374
diff changeset
2497 cmdutil.service(opts, initfn=service.init, runfn=service.run)
500
ebc4714a7632 [PATCH] Clean up destination directory if a clone fails.
mpm@selenic.com
parents: 499
diff changeset
2498
731
91ca3afab8e8 Add name matching to status command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 729
diff changeset
2499 def status(ui, repo, *pats, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2500 """show changed files in the working directory
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 212
diff changeset
2501
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2502 Show status of files in the repository. If names are given, only
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2503 files that match are shown. Files that are clean or ignored, are
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2504 not listed unless -c (clean), -i (ignored) or -A is given.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2505
3828
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
2506 NOTE: status may appear to disagree with diff if permissions have
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
2507 changed or a merge has occurred. The standard diff format does not
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
2508 report permission changes and diff only reports changes relative
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
2509 to one merge parent.
28134d82db9b Add notes about diff/merge asymmetry to export, diff, and log
Matt Mackall <mpm@selenic.com>
parents: 3819
diff changeset
2510
3462
2b3b703b3a2b Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents: 3460
diff changeset
2511 If one revision is given, it is used as the base revision.
2b3b703b3a2b Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents: 3460
diff changeset
2512 If two revisions are given, the difference between them is shown.
2b3b703b3a2b Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents: 3460
diff changeset
2513
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2514 The codes used to show the status of files are:
746
9095e3456ea7 Change C to M in status
mpm@selenic.com
parents: 745
diff changeset
2515 M = modified
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
2516 A = added
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
2517 R = removed
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2518 C = clean
1619
1ba0d7041ac4 Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1618
diff changeset
2519 ! = deleted, but still tracked
842
8fb488773063 Rewritten change type selection for hg status.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 841
diff changeset
2520 ? = not tracked
2022
a59da8cc35e4 New option -i/--ignored for 'hg status' to show ignored files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2020
diff changeset
2521 I = ignored (not shown by default)
2639
001703ec311d Add an option '-C|--copies' to hg status to show the source of copied files.
Brendan Cully <brendan@kublai.com>
parents: 2630
diff changeset
2522 = the previous added file was copied from here
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2523 """
312
09375250eb31 Optimize diff and status in subdirectories
mpm@selenic.com
parents: 310
diff changeset
2524
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2525 all = opts['all']
3707
67f44b825784 Removed unused ui parameter from revpair/revrange and fix its users.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3706
diff changeset
2526 node1, node2 = cmdutil.revpair(repo, opts.get('rev'))
3215
53e843840349 Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3204
diff changeset
2527
2881
cf98cd70d2c4 move walk and matchpats from commands to cmdutil.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2877
diff changeset
2528 files, matchfn, anypats = cmdutil.matchpats(repo, pats, opts)
1625
e1bcf7fa983f correct the relative path when walking from a subdir
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1622
diff changeset
2529 cwd = (pats and repo.getcwd()) or ''
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2530 modified, added, removed, deleted, unknown, ignored, clean = [
4043
31047b6f7ec1 Copied files sources were not shown by status -C under Win32.
Patrick Mezard <pmezard@gmail.com>
parents: 4014
diff changeset
2531 n for n in repo.status(node1=node1, node2=node2, files=files,
3462
2b3b703b3a2b Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents: 3460
diff changeset
2532 match=matchfn,
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2533 list_ignored=all or opts['ignored'],
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2534 list_clean=all or opts['clean'])]
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2535
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2536 changetypes = (('modified', 'M', modified),
1966
f8b0e73e320f hg status cleanups: Don't translate long options, remove stray semicolon.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1965
diff changeset
2537 ('added', 'A', added),
f8b0e73e320f hg status cleanups: Don't translate long options, remove stray semicolon.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1965
diff changeset
2538 ('removed', 'R', removed),
f8b0e73e320f hg status cleanups: Don't translate long options, remove stray semicolon.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1965
diff changeset
2539 ('deleted', '!', deleted),
2022
a59da8cc35e4 New option -i/--ignored for 'hg status' to show ignored files.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2020
diff changeset
2540 ('unknown', '?', unknown),
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2541 ('ignored', 'I', ignored))
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2542
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2543 explicit_changetypes = changetypes + (('clean', 'C', clean),)
842
8fb488773063 Rewritten change type selection for hg status.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 841
diff changeset
2544
1085
6f94688b81b6 status: added option -p and -0 to assist xargs
TK Soh <teekaysoh@yahoo.com>
parents: 1081
diff changeset
2545 end = opts['print0'] and '\0' or '\n'
1106
95a044b73bd5 Whitespace cleanup.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1105
diff changeset
2546
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2547 for opt, char, changes in ([ct for ct in explicit_changetypes
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2548 if all or opts[ct[0]]]
842
8fb488773063 Rewritten change type selection for hg status.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 841
diff changeset
2549 or changetypes):
1105
a906b018eaef Replaced hg status -p/--strip with -n/--no-status to not confuse with patch.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1085
diff changeset
2550 if opts['no_status']:
1085
6f94688b81b6 status: added option -p and -0 to assist xargs
TK Soh <teekaysoh@yahoo.com>
parents: 1081
diff changeset
2551 format = "%%s%s" % end
6f94688b81b6 status: added option -p and -0 to assist xargs
TK Soh <teekaysoh@yahoo.com>
parents: 1081
diff changeset
2552 else:
1966
f8b0e73e320f hg status cleanups: Don't translate long options, remove stray semicolon.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1965
diff changeset
2553 format = "%s %%s%s" % (char, end)
1106
95a044b73bd5 Whitespace cleanup.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1105
diff changeset
2554
842
8fb488773063 Rewritten change type selection for hg status.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 841
diff changeset
2555 for f in changes:
4525
78b6add1f966 Add dirstate.pathto and localrepo.pathto.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4524
diff changeset
2556 ui.write(format % repo.pathto(f, cwd))
3256
7c114915fbdb Make status -C work with merge+rename
Matt Mackall <mpm@selenic.com>
parents: 3215
diff changeset
2557 if ((all or opts.get('copies')) and not opts.get('no_status')):
3159
e43fd1623fe1 fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3146
diff changeset
2558 copied = repo.dirstate.copied(f)
e43fd1623fe1 fix users of dirstate.copies broken by b1f10d3223c1
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3146
diff changeset
2559 if copied:
4525
78b6add1f966 Add dirstate.pathto and localrepo.pathto.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4524
diff changeset
2560 ui.write(' %s%s' % (repo.pathto(copied, cwd), end))
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 212
diff changeset
2561
1596
41366b7d6709 fix 'hg tag <tagname> <revision>
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1589
diff changeset
2562 def tag(ui, repo, name, rev_=None, **opts):
3914
3c82ab166eea doc fix: hg tags defaults to current parent revision, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3913
diff changeset
2563 """add a tag for the current or given revision
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2564
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2565 Name a particular revision using <name>.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2566
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2567 Tags are used to name particular revisions of the repository and are
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2568 very useful to compare different revision, to go back to significant
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2569 earlier versions or to mark branch points as releases, etc.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2570
3914
3c82ab166eea doc fix: hg tags defaults to current parent revision, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3913
diff changeset
2571 If no revision is given, the parent of the working directory is used,
3c82ab166eea doc fix: hg tags defaults to current parent revision, too.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3913
diff changeset
2572 or tip if no revision is checked out.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2573
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2574 To facilitate version control, distribution, and merging of tags,
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2575 they are stored as a file named ".hgtags" which is managed
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2576 similarly to other project files and can be hand-edited if
1654
b7fc961507db deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1648
diff changeset
2577 necessary. The file '.hg/localtags' is used for local tags (not
b7fc961507db deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1648
diff changeset
2578 shared among repositories).
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2579 """
3795
bd7011246fab Add "null" pseudo-tag pointing to nullid
Brendan Cully <brendan@kublai.com>
parents: 3787
diff changeset
2580 if name in ['tip', '.', 'null']:
2784
e3564699409c Add '.' as a shortcut revision name for the working directory parent.
Brendan Cully <brendan@kublai.com>
parents: 2779
diff changeset
2581 raise util.Abort(_("the name '%s' is reserved") % name)
1654
b7fc961507db deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1648
diff changeset
2582 if rev_ is not None:
b7fc961507db deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1648
diff changeset
2583 ui.warn(_("use of 'hg tag NAME [REV]' is deprecated, "
1661
b11507d6d16d Added missing quote in warning text.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1657
diff changeset
2584 "please use 'hg tag [-r REV] NAME' instead\n"))
1654
b7fc961507db deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1648
diff changeset
2585 if opts['rev']:
b7fc961507db deprecate the use of 'hg tag NAME [REV]'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1648
diff changeset
2586 raise util.Abort(_("use only one form to specify the revision"))
4217
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4207
diff changeset
2587 if opts['rev'] and opts['remove']:
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4207
diff changeset
2588 raise util.Abort(_("--rev and --remove are incompatible"))
1596
41366b7d6709 fix 'hg tag <tagname> <revision>
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1589
diff changeset
2589 if opts['rev']:
41366b7d6709 fix 'hg tag <tagname> <revision>
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1589
diff changeset
2590 rev_ = opts['rev']
4217
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4207
diff changeset
2591 message = opts['message']
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4207
diff changeset
2592 if opts['remove']:
4659
7a7d4937272b Kill trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4650
diff changeset
2593 if not name in repo.tags():
4650
15e22b483adc tag: abort when trying to remove nonexistent tags
TK Soh <teekaysoh@yahoo.com>
parents: 4649
diff changeset
2594 raise util.Abort(_('tag %s does not exist') % name)
4217
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4207
diff changeset
2595 rev_ = nullid
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4207
diff changeset
2596 if not message:
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4207
diff changeset
2597 message = _('Removed tag %s') % name
4273
8185a1ca8628 tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents: 4249
diff changeset
2598 elif name in repo.tags() and not opts['force']:
8185a1ca8628 tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents: 4249
diff changeset
2599 raise util.Abort(_('a tag named %s already exists (use -f to force)')
8185a1ca8628 tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents: 4249
diff changeset
2600 % name)
3127
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3092
diff changeset
2601 if not rev_ and repo.dirstate.parents()[1] != nullid:
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3092
diff changeset
2602 raise util.Abort(_('uncommitted merge - please provide a '
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3092
diff changeset
2603 'specific revision'))
81da3c45aabd Move defaultrev into changectx
Brendan Cully <brendan@kublai.com>
parents: 3092
diff changeset
2604 r = repo.changectx(rev_).node()
2974
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2973
diff changeset
2605
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2973
diff changeset
2606 if not message:
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2973
diff changeset
2607 message = _('Added tag %s for changeset %s') % (name, short(r))
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2973
diff changeset
2608
eef469259745 tag: shorten hash in default commit message
Matt Mackall <mpm@selenic.com>
parents: 2973
diff changeset
2609 repo.tag(name, r, message, opts['local'], opts['user'], opts['date'])
401
af4848f83e68 From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl>
mpm@selenic.com
parents: 396
diff changeset
2610
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
2611 def tags(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2612 """list repository tags
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2613
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2614 List the repository tags.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2615
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2616 This lists both regular and local tags.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2617 """
477
520540fd6b64 Handle errors in .hgtags or hgrc [tags] section more gracefully.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 470
diff changeset
2618
343
d7df759d0e97 rework all code using tags
mpm@selenic.com
parents: 340
diff changeset
2619 l = repo.tagslist()
d7df759d0e97 rework all code using tags
mpm@selenic.com
parents: 340
diff changeset
2620 l.reverse()
2973
fb493241d7f6 Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents: 2963
diff changeset
2621 hexfunc = ui.debugflag and hex or short
477
520540fd6b64 Handle errors in .hgtags or hgrc [tags] section more gracefully.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 470
diff changeset
2622 for t, n in l:
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
2623 try:
4516
96d8a56d4ef9 Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4505
diff changeset
2624 hn = hexfunc(n)
2973
fb493241d7f6 Only show long hashes with --debug, not --verbose
Matt Mackall <mpm@selenic.com>
parents: 2963
diff changeset
2625 r = "%5d:%s" % (repo.changelog.rev(n), hexfunc(n))
3930
01d98d68d697 Add revlog.LookupError exception, and use it instead of RevlogError.
Brendan Cully <brendan@kublai.com>
parents: 3919
diff changeset
2626 except revlog.LookupError:
01d98d68d697 Add revlog.LookupError exception, and use it instead of RevlogError.
Brendan Cully <brendan@kublai.com>
parents: 3919
diff changeset
2627 r = " ?:%s" % hn
2035
107dc72880f8 Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2034
diff changeset
2628 if ui.quiet:
107dc72880f8 Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2034
diff changeset
2629 ui.write("%s\n" % t)
107dc72880f8 Make 'hg tags -q' only list tag names without revision numbers and hashes,
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2034
diff changeset
2630 else:
4143
26314500a5e1 Don't truncate tag and branch names after 30 chars (introduced 73860ffbe798)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4078
diff changeset
2631 spaces = " " * (30 - util.locallen(t))
26314500a5e1 Don't truncate tag and branch names after 30 chars (introduced 73860ffbe798)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4078
diff changeset
2632 ui.write("%s%s %s\n" % (t, spaces, r))
248
b7645b3c86ff migrate remaining commands
mpm@selenic.com
parents: 247
diff changeset
2633
1731
251729df9cc6 add -p option to tip. for issue 64.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1728
diff changeset
2634 def tip(ui, repo, **opts):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2635 """show the tip revision
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2636
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2637 Show the tip revision.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2638 """
3671
86d3f966201d Use nullrev+count instead of count-1 in a newly introduced expression.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3670
diff changeset
2639 cmdutil.show_changeset(ui, repo, opts).show(nullrev+repo.changelog.count())
245
fef0f8e041aa big heap of command clean-up work
mpm@selenic.com
parents: 241
diff changeset
2640
4699
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2641 def unbundle(ui, repo, fname1, *fnames, **opts):
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2642 """apply one or more changegroup files
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2643
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2644 Apply one or more compressed changegroup files generated by the
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2645 bundle command.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2646 """
4699
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2647 fnames = (fname1,) + fnames
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2648 for fname in fnames:
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2649 if os.path.exists(fname):
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2650 f = open(fname, "rb")
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2651 else:
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2652 f = urllib.urlopen(fname)
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2653 gen = changegroup.readbundle(f, fname)
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2654 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
2655
4923
e8c0b52c363c Better fix for issue 622 than we had in c4dd58af0fc8.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4912
diff changeset
2656 return postincoming(ui, repo, modheads, opts['update'])
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
2657
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2658 def update(ui, repo, node=None, rev=None, clean=False, date=None):
4014
509342f95564 various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4013
diff changeset
2659 """update working directory
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2660
4200
7ca05d29c1f0 Clarify update help text for update without an explicit revision
Brendan Cully <brendan@kublai.com>
parents: 4199
diff changeset
2661 Update the working directory to the specified revision, or the
7ca05d29c1f0 Clarify update help text for update without an explicit revision
Brendan Cully <brendan@kublai.com>
parents: 4199
diff changeset
2662 tip of the current branch if none is specified.
254
c03f58e5fd2d unify checkout and resolve into update
mpm@selenic.com
parents: 252
diff changeset
2663
c03f58e5fd2d unify checkout and resolve into update
mpm@selenic.com
parents: 252
diff changeset
2664 If there are no outstanding changes in the working directory and
c03f58e5fd2d unify checkout and resolve into update
mpm@selenic.com
parents: 252
diff changeset
2665 there is a linear relationship between the current version and the
c03f58e5fd2d unify checkout and resolve into update
mpm@selenic.com
parents: 252
diff changeset
2666 requested version, the result is the requested version.
c03f58e5fd2d unify checkout and resolve into update
mpm@selenic.com
parents: 252
diff changeset
2667
2283
e506c14382fd deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
2668 To merge the working directory with another revision, use the
e506c14382fd deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2272
diff changeset
2669 merge command.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2670
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2671 By default, update will refuse to run if doing so would require
4014
509342f95564 various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4013
diff changeset
2672 discarding local changes.
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2673 """
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2674 if rev and node:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2675 raise util.Abort(_("please specify just one revision"))
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2676
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2677 if not rev:
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2678 rev = node
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2679
3818
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
2680 if date:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2681 if rev:
3818
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
2682 raise util.Abort(_("you can't specify a revision and a date"))
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2683 rev = cmdutil.finddate(ui, repo, date)
3818
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
2684
3524
ba94e80e5540 Remove update -m, deprecated for 0.9.1
Matt Mackall <mpm@selenic.com>
parents: 3523
diff changeset
2685 if clean:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2686 return hg.clean(repo, rev)
2822
30f59f4a327e Introduce update helper functions: update, merge, clean, and revert
Matt Mackall <mpm@selenic.com>
parents: 2820
diff changeset
2687 else:
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2688 return hg.update(repo, rev)
254
c03f58e5fd2d unify checkout and resolve into update
mpm@selenic.com
parents: 252
diff changeset
2689
247
863b508c5b36 migrate verify
mpm@selenic.com
parents: 246
diff changeset
2690 def verify(ui, repo):
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2691 """verify the integrity of the repository
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2692
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2693 Verify the integrity of the current repository.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2694
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2695 This will perform an extensive check of the repository's
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2696 integrity, validating the hashes and checksums of each entry in
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2697 the changelog, manifest, and tracked files, as well as the
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2698 integrity of their crosslinks and indices.
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2699 """
2802
fdc232d8a193 Move repo.verify
Matt Mackall <mpm@selenic.com>
parents: 2800
diff changeset
2700 return hg.verify(repo)
247
863b508c5b36 migrate verify
mpm@selenic.com
parents: 246
diff changeset
2701
3658
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2702 def version_(ui):
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2703 """output version and copyright information"""
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2704 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2705 % version.get_version())
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2706 ui.status(_(
4635
63b9d2deed48 Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4615
diff changeset
2707 "\nCopyright (C) 2005-2007 Matt Mackall <mpm@selenic.com> and others\n"
3658
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2708 "This is free software; see the source for copying conditions. "
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2709 "There is NO\nwarranty; "
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2710 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2711 ))
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
2712
255
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
2713 # Command options and aliases are listed here, alphabetically
20a44c82795f hg help: use docstrings only
mpm@selenic.com
parents: 254
diff changeset
2714
3180
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2715 globalopts = [
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2716 ('R', 'repository', '',
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2717 _('repository root directory or symbolic path name')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2718 ('', 'cwd', '', _('change working directory')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2719 ('y', 'noninteractive', None,
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2720 _('do not prompt, assume \'yes\' for any required answers')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2721 ('q', 'quiet', None, _('suppress output')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2722 ('v', 'verbose', None, _('enable additional output')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2723 ('', 'config', [], _('set/override config option')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2724 ('', 'debug', None, _('enable debugging output')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2725 ('', 'debugger', None, _('start debugger')),
3775
a88e02081a88 Add global options for setting encoding and encodingmode
Matt Mackall <mpm@selenic.com>
parents: 3774
diff changeset
2726 ('', 'encoding', util._encoding, _('set the charset encoding')),
a88e02081a88 Add global options for setting encoding and encodingmode
Matt Mackall <mpm@selenic.com>
parents: 3774
diff changeset
2727 ('', 'encodingmode', util._encodingmode, _('set the charset encoding mode')),
3180
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2728 ('', 'lsprof', None, _('print improved command execution profile')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2729 ('', 'traceback', None, _('print traceback on exception')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2730 ('', 'time', None, _('time how long the command takes')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2731 ('', 'profile', None, _('print command execution profile')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2732 ('', 'version', None, _('output version information and exit')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2733 ('h', 'help', None, _('display help and exit')),
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2734 ]
fca5ddbaa12a factor opts: move globalopts to a more logical place
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3174
diff changeset
2735
3182
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
2736 dryrunopts = [('n', 'dry-run', None,
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
2737 _('do not perform actions, just print output'))]
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
2738
3183
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
2739 remoteopts = [
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
2740 ('e', 'ssh', '', _('specify ssh command to use')),
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
2741 ('', 'remotecmd', '', _('specify hg command to run on the remote side')),
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
2742 ]
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
2743
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2744 walkopts = [
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2745 ('I', 'include', [], _('include names matching the given patterns')),
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2746 ('X', 'exclude', [], _('exclude names matching the given patterns')),
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2747 ]
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2748
3857
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
2749 commitopts = [
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
2750 ('m', 'message', '', _('use <text> as commit message')),
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
2751 ('l', 'logfile', '', _('read commit message from <file>')),
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
2752 ]
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
2753
5122
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
2754 commitopts2 = [
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
2755 ('d', 'date', '', _('record datecode as commit date')),
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
2756 ('u', 'user', '', _('record user as committer')),
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
2757 ]
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
2758
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
2759 table = {
3821
2631b506e93d Fixed indentation, spacing and a typo (debugdata->debugdate) in commands.table.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3819
diff changeset
2760 "^add": (add, walkopts + dryrunopts, _('hg add [OPTION]... [FILE]...')),
2955
9d1c3529ebbc addremove: do not deprecate.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
2761 "addremove":
841
03cc2ba291d1 Realigned command table again.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 840
diff changeset
2762 (addremove,
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2763 [('s', 'similarity', '',
3182
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
2764 _('guess renamed files by similarity (0<=s<=100)')),
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
2765 ] + walkopts + dryrunopts,
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2766 _('hg addremove [OPTION]... [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2767 "^annotate":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2768 (annotate,
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2769 [('r', 'rev', '', _('annotate the specified revision')),
3165
5c93dd0ae413 Refactor annotate copy support.
Brendan Cully <brendan@kublai.com>
parents: 3159
diff changeset
2770 ('f', 'follow', None, _('follow file copies and renames')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2771 ('a', 'text', None, _('treat all files as text')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2772 ('u', 'user', None, _('list the author')),
1522
d07d729ce306 Added --date option to annotate.
lupus@debian.org
parents: 1519
diff changeset
2773 ('d', 'date', None, _('list the date')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2774 ('n', 'number', None, _('list the revision number (default)')),
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2775 ('c', 'changeset', None, _('list the changeset')),
4847
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
2776 ('l', 'line-number', None,
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
2777 _('show line number at the first appearance'))
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2778 ] + walkopts,
4847
2192001e4bb4 Add --line-number option to hg annotate (issue506)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4836
diff changeset
2779 _('hg annotate [-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')),
2160
858df1f354c1 Cleanup archive command: Don't overwrite gettext, quoting in cmd table entry.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2159
diff changeset
2780 "archive":
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
2781 (archive,
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
2782 [('', 'no-decode', None, _('do not pass files through decoders')),
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
2783 ('p', 'prefix', '', _('directory prefix for files in archive')),
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
2784 ('r', 'rev', '', _('revision to distribute')),
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
2785 ('t', 'type', '', _('type of distribution to create')),
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2786 ] + walkopts,
2112
2b03c6733efa add "archive" command, like "cvs export" only better.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2092
diff changeset
2787 _('hg archive [OPTION]... DEST')),
2159
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
2788 "backout":
2158
ec96c4518236 add backout command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2153
diff changeset
2789 (backout,
2159
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
2790 [('', 'merge', None,
5c34b98ad6b1 Small cleanups to backout command:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2158
diff changeset
2791 _('merge with old dirstate parent after backout')),
2614
8ba1c31f6864 backout: allow backout of merge changeset with --parent option.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2613
diff changeset
2792 ('', 'parent', '', _('parent to choose when backing out merge')),
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2793 ('r', 'rev', '', _('revision to backout')),
5122
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
2794 ] + walkopts + commitopts + commitopts2,
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2795 _('hg backout [OPTION]... [-r] REV')),
4730
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2796 "branch":
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2797 (branch,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2798 [('f', 'force', None,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2799 _('set branch name even if it shadows an existing branch'))],
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2800 _('hg branch [NAME]')),
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2801 "branches":
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2802 (branches,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2803 [('a', 'active', False,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2804 _('show only branches that have unmerged heads'))],
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2805 _('hg branches [-a]')),
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
2806 "bundle":
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
2807 (bundle,
1959
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
2808 [('f', 'force', None,
3184
545b6d718593 add remoteopts to bundle command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3183
diff changeset
2809 _('run even when remote repository is unrelated')),
3283
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
2810 ('r', 'rev', [],
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
2811 _('a changeset you would like to bundle')),
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
2812 ('', 'base', [],
d89e98840b08 add -r/--rev and --base option to bundle
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3277
diff changeset
2813 _('a base changeset to specify instead of a destination')),
3184
545b6d718593 add remoteopts to bundle command
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3183
diff changeset
2814 ] + remoteopts,
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
2815 _('hg bundle [-f] [-r REV]... [--base REV]... FILE [DEST]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2816 "cat":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2817 (cat,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
2818 [('o', 'output', '', _('print output to file with formatted name')),
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
2819 ('r', 'rev', '', _('print the given revision')),
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2820 ] + walkopts,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2821 _('hg cat [OPTION]... FILE...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2822 "^clone":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2823 (clone,
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2824 [('U', 'noupdate', None, _('do not update the new working directory')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
2825 ('r', 'rev', [],
2764
71029a3247cb clone: replace long help string of inaky with doc comment.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2763
diff changeset
2826 _('a changeset you would like to have after cloning')),
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
2827 ('', 'pull', None, _('use pull protocol to copy metadata')),
2620
de82749d3a71 clone: change name of --stream to --uncompressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2618
diff changeset
2828 ('', 'uncompressed', None,
de82749d3a71 clone: change name of --stream to --uncompressed.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2618
diff changeset
2829 _('use uncompressed transfer (fast over LAN)')),
3183
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
2830 ] + remoteopts,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2831 _('hg clone [OPTION]... SOURCE [DEST]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2832 "^commit|ci":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2833 (commit,
2184
2477a7183a6f Add debugaddremove alias to addremove, so it doesn't show up in 'hg help'.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2181
diff changeset
2834 [('A', 'addremove', None,
2477a7183a6f Add debugaddremove alias to addremove, so it doesn't show up in 'hg help'.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2181
diff changeset
2835 _('mark new/missing files as added/removed before committing')),
5122
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
2836 ] + walkopts + commitopts + commitopts2,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2837 _('hg commit [OPTION]... [FILE]...')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2838 "copy|cp":
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2839 (copy,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
2840 [('A', 'after', None, _('record a copy that has already occurred')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2841 ('f', 'force', None,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
2842 _('forcibly copy over an existing managed file')),
3182
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
2843 ] + walkopts + dryrunopts,
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2844 _('hg copy [OPTION]... [SOURCE]... DEST')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2845 "debugancestor": (debugancestor, [], _('debugancestor INDEX REV1 REV2')),
2034
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
2846 "debugcomplete":
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
2847 (debugcomplete,
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
2848 [('o', 'options', None, _('show the command options'))],
5e7aff1b6ae1 add --options to debugcomplete and change bash_completion to use it
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 2033
diff changeset
2849 _('debugcomplete [-o] CMD')),
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
2850 "debuginstall": (debuginstall, [], _('debuginstall')),
1755
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
2851 "debugrebuildstate":
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
2852 (debugrebuildstate,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
2853 [('r', 'rev', '', _('revision to rebuild to'))],
1755
a8f7791e3680 add 'debugrebuildstate' to rebuild the dirstate from a given revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1754
diff changeset
2854 _('debugrebuildstate [-r REV] [REV]')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2855 "debugcheckstate": (debugcheckstate, [], _('debugcheckstate')),
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2856 "debugsetparents": (debugsetparents, [], _('debugsetparents REV1 [REV2]')),
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2857 "debugstate": (debugstate, [], _('debugstate')),
3821
2631b506e93d Fixed indentation, spacing and a typo (debugdata->debugdate) in commands.table.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3819
diff changeset
2858 "debugdate":
2631b506e93d Fixed indentation, spacing and a typo (debugdata->debugdate) in commands.table.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3819
diff changeset
2859 (debugdate,
2631b506e93d Fixed indentation, spacing and a typo (debugdata->debugdate) in commands.table.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3819
diff changeset
2860 [('e', 'extended', None, _('try extended date formats'))],
2631b506e93d Fixed indentation, spacing and a typo (debugdata->debugdate) in commands.table.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3819
diff changeset
2861 _('debugdate [-e] DATE [RANGE]')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2862 "debugdata": (debugdata, [], _('debugdata FILE REV')),
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2863 "debugindex": (debugindex, [], _('debugindex FILE')),
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2864 "debugindexdot": (debugindexdot, [], _('debugindexdot FILE')),
4730
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2865 "debugrename":
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2866 (debugrename,
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2867 [('r', 'rev', '', _('revision to debug'))],
eadfaa9ec487 Updated command tables in commands.py and hgext extensions.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4726
diff changeset
2868 _('debugrename [-r REV] FILE')),
3821
2631b506e93d Fixed indentation, spacing and a typo (debugdata->debugdate) in commands.table.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3819
diff changeset
2869 "debugwalk": (debugwalk, walkopts, _('debugwalk [OPTION]... [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2870 "^diff":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2871 (diff,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2872 [('r', 'rev', [], _('revision')),
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2873 ('a', 'text', None, _('treat all files as text')),
1728
9b92b71d5dd7 add -w and -p options to diff. this is for issue 126.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1720
diff changeset
2874 ('p', 'show-function', None,
9b92b71d5dd7 add -w and -p options to diff. this is for issue 126.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1720
diff changeset
2875 _('show which function each change is in')),
2892
8b02af865990 Add diff --git option
Brendan Cully <brendan@kublai.com>
parents: 2886
diff changeset
2876 ('g', 'git', None, _('use git extended diff format')),
3193
367a009c2acb Remove single character equivalent of --nodates (was -D)
Stephen Darnell <stephen@darnell.plus.com>
parents: 3192
diff changeset
2877 ('', 'nodates', None, _("don't include dates in diff headers")),
1728
9b92b71d5dd7 add -w and -p options to diff. this is for issue 126.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1720
diff changeset
2878 ('w', 'ignore-all-space', None,
9b92b71d5dd7 add -w and -p options to diff. this is for issue 126.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1720
diff changeset
2879 _('ignore white space when comparing lines')),
2580
a20a1bb0c396 diff: add -b/-B options
Haakon Riiser <haakon.riiser@fys.uio.no>
parents: 2579
diff changeset
2880 ('b', 'ignore-space-change', None,
a20a1bb0c396 diff: add -b/-B options
Haakon Riiser <haakon.riiser@fys.uio.no>
parents: 2579
diff changeset
2881 _('ignore changes in the amount of white space')),
a20a1bb0c396 diff: add -b/-B options
Haakon Riiser <haakon.riiser@fys.uio.no>
parents: 2579
diff changeset
2882 ('B', 'ignore-blank-lines', None,
a20a1bb0c396 diff: add -b/-B options
Haakon Riiser <haakon.riiser@fys.uio.no>
parents: 2579
diff changeset
2883 _('ignore changes whose lines are all blank')),
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2884 ] + walkopts,
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
2885 _('hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2886 "^export":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2887 (export,
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2888 [('o', 'output', '', _('print output to file with formatted name')),
1571
bcdc030c59f8 add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1570
diff changeset
2889 ('a', 'text', None, _('treat all files as text')),
3026
d161e6f39557 Add --git to hg export
Brendan Cully <brendan@kublai.com>
parents: 3017
diff changeset
2890 ('g', 'git', None, _('use git extended diff format')),
3193
367a009c2acb Remove single character equivalent of --nodates (was -D)
Stephen Darnell <stephen@darnell.plus.com>
parents: 3192
diff changeset
2891 ('', 'nodates', None, _("don't include dates in diff headers")),
1571
bcdc030c59f8 add a --switch-parent option to export against the other parent
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1570
diff changeset
2892 ('', 'switch-parent', None, _('diff against the second parent'))],
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
2893 _('hg export [OPTION]... [-o OUTFILESPEC] REV...')),
1065
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
2894 "grep":
6e94c0365d98 Cleanups to commands.py
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1062
diff changeset
2895 (grep,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2896 [('0', 'print0', None, _('end fields with NUL')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2897 ('', 'all', None, _('print all revisions that match')),
2869
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
2898 ('f', 'follow', None,
8eaaf1321bfe grep: add --follow support.
Brendan Cully <brendan@kublai.com>
parents: 2868
diff changeset
2899 _('follow changeset history, or file history across copies and renames')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2900 ('i', 'ignore-case', None, _('ignore case when matching')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
2901 ('l', 'files-with-matches', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
2902 _('print only filenames and revs that match')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2903 ('n', 'line-number', None, _('print matching line numbers')),
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2904 ('r', 'rev', [], _('search in given revision range')),
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
2905 ('u', 'user', None, _('print user who committed change')),
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2906 ] + walkopts,
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2907 _('hg grep [OPTION]... PATTERN [FILE]...')),
905
65763ff9fa53 Update online help of hg heads for new --branches option.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 904
diff changeset
2908 "heads":
65763ff9fa53 Update online help of hg heads for new --branches option.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 904
diff changeset
2909 (heads,
3885
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
2910 [('', 'style', '', _('display using template map file')),
1907
7718885070b1 let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1800
diff changeset
2911 ('r', 'rev', '', _('show only heads which are descendants of rev')),
1913
74cf2b2f43d4 fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1910
diff changeset
2912 ('', 'template', '', _('display with template'))],
4648
8e503fa54d2d Add option to heads to show only heads for current branch.
Eric Hopper <hopper@omnifarious.org>
parents: 4646
diff changeset
2913 _('hg heads [-r REV] [REV]...')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2914 "help": (help_, [], _('hg help [COMMAND]')),
4665
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
2915 "identify|id":
091c9e54d306 identify: accept a revision argument
Matt Mackall <mpm@selenic.com>
parents: 4664
diff changeset
2916 (identify,
4666
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
2917 [('r', 'rev', '', _('identify the specified rev')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
2918 ('n', 'num', None, _('show local revision number')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
2919 ('i', 'id', None, _('show global revision id')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
2920 ('b', 'branch', None, _('show branch')),
48c94bffdb28 identify: add support for output flags
Matt Mackall <mpm@selenic.com>
parents: 4665
diff changeset
2921 ('t', 'tags', None, _('show tags'))],
4671
150afe6becf6 identify: take a path to a remote repo
Matt Mackall <mpm@selenic.com>
parents: 4667
diff changeset
2922 _('hg identify [-nibt] [-r REV] [SOURCE]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2923 "import|patch":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2924 (import_,
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
2925 [('p', 'strip', 1,
2125
3610d9468b1e Use string literal concatenation for optlist and import -p option
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2124
diff changeset
2926 _('directory strip option for patch. This has the same\n'
3610d9468b1e Use string literal concatenation for optlist and import -p option
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2124
diff changeset
2927 'meaning as the corresponding patch option')),
3885
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
2928 ('b', 'base', '', _('base path')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
2929 ('f', 'force', None,
4258
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
2930 _('skip check for outstanding uncommitted changes')),
47ba52121433 Add import --exact.
Brendan Cully <brendan@kublai.com>
parents: 4256
diff changeset
2931 ('', 'exact', None,
4592
5243cece3d97 Add --import-branch option to hg import to pull in branch information without --exact
Eric Hopper <hopper@omnifarious.org>
parents: 4587
diff changeset
2932 _('apply patch to the nodes from which it was generated')),
5243cece3d97 Add --import-branch option to hg import to pull in branch information without --exact
Eric Hopper <hopper@omnifarious.org>
parents: 4587
diff changeset
2933 ('', 'import-branch', None,
5243cece3d97 Add --import-branch option to hg import to pull in branch information without --exact
Eric Hopper <hopper@omnifarious.org>
parents: 4587
diff changeset
2934 _('Use any branch information in patch (implied by --exact)'))] + commitopts,
3520
b0dc459cd06c Remove some more deprecated options from help syntax summaries
Matt Mackall <mpm@selenic.com>
parents: 3519
diff changeset
2935 _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')),
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
2936 "incoming|in": (incoming,
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2937 [('M', 'no-merges', None, _('do not show merges')),
1959
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
2938 ('f', 'force', None,
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
2939 _('run even when remote repository is unrelated')),
1913
74cf2b2f43d4 fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1910
diff changeset
2940 ('', 'style', '', _('display using template map file')),
1907
7718885070b1 let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1800
diff changeset
2941 ('n', 'newest-first', None, _('show newest record first')),
1944
fdf40c9b3306 incoming: add support for remote repo using bundlerepo
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1943
diff changeset
2942 ('', 'bundle', '', _('file to store the bundles into')),
1439
65cbe22b03fa allow 'hg out' / 'hg in' to show newest commit first
Michal Kvasnica <kvasnica@gmail.com>
parents: 1437
diff changeset
2943 ('p', 'patch', None, _('show patch')),
2877
982c3237c63d Make clear that hg pull -r REV pulls "up to" a revision.
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 2874
diff changeset
2944 ('r', 'rev', [], _('a specific revision up to which you would like to pull')),
1965
62aa1b90414f add remotecmd/ssh option support to incoming/outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1959
diff changeset
2945 ('', 'template', '', _('display with template')),
3183
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
2946 ] + remoteopts,
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
2947 _('hg incoming [-p] [-n] [-M] [-f] [-r REV]...'
2544
0ab63318bc36 Added missing space in continued string.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2521
diff changeset
2948 ' [--bundle FILENAME] [SOURCE]')),
2598
b898afee9d0d Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2597
diff changeset
2949 "^init":
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
2950 (init,
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
2951 remoteopts,
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
2952 _('hg init [-e CMD] [--remotecmd CMD] [DEST]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2953 "locate":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2954 (locate,
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2955 [('r', 'rev', '', _('search the repository as it stood at rev')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
2956 ('0', 'print0', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
2957 _('end filenames with NUL, for use with xargs')),
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
2958 ('f', 'fullpath', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
2959 _('print complete paths from the filesystem root')),
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2960 ] + walkopts,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2961 _('hg locate [OPTION]... [PATTERN]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2962 "^log|history":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
2963 (log,
3885
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
2964 [('f', 'follow', None,
2777
21e571c21a6b Make log --follow without a file list follow a single head.
Brendan Cully <brendan@kublai.com>
parents: 2764
diff changeset
2965 _('follow changeset history, or file history across copies and renames')),
2779
12a7bfcafd8f Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents: 2778
diff changeset
2966 ('', 'follow-first', None,
12a7bfcafd8f Add log option --follow-first to follow only the first parent of
Brendan Cully <brendan@kublai.com>
parents: 2778
diff changeset
2967 _('only follow the first parent of merge changesets')),
3816
fc5ba0ab7f45 Add --date support to log
Matt Mackall <mpm@selenic.com>
parents: 3815
diff changeset
2968 ('d', 'date', '', _('show revs matching date spec')),
3190
e18c3d08528d Show copies in hg log.
Brendan Cully <brendan@kublai.com>
parents: 3187
diff changeset
2969 ('C', 'copies', None, _('show copied files')),
4324
cd650cd61b06 help: log --keyword is case-insensitive
TK Soh <teekaysoh@yahoo.com>
parents: 4322
diff changeset
2970 ('k', 'keyword', [], _('do case-insensitive search for a keyword')),
1756
f29857aaa053 add -l,--limit to log command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1747
diff changeset
2971 ('l', 'limit', '', _('limit number of changes displayed')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
2972 ('r', 'rev', [], _('show the specified revision or range')),
3664
4d988b7412f2 add log --removed
Matt Mackall <mpm@selenic.com>
parents: 3663
diff changeset
2973 ('', 'removed', None, _('include revs where files were removed')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2974 ('M', 'no-merges', None, _('do not show merges')),
1913
74cf2b2f43d4 fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1910
diff changeset
2975 ('', 'style', '', _('display using template map file')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2976 ('m', 'only-merges', None, _('show only merges')),
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
2977 ('p', 'patch', None, _('show patch')),
2886
9826af4841ef Test for log --prune.
Brendan Cully <brendan@kublai.com>
parents: 2882
diff changeset
2978 ('P', 'prune', [], _('do not display revision or any of its ancestors')),
1920
b7cc0f323a4c merge with crew.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1917 1894
diff changeset
2979 ('', 'template', '', _('display with template')),
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
2980 ] + walkopts,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
2981 _('hg log [OPTION]... [FILE]')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
2982 "manifest": (manifest, [], _('hg manifest [REV]')),
4014
509342f95564 various doc fixes
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 4013
diff changeset
2983 "^merge":
2044
b343e7d454b4 Don't allow --style and --template for hg update and hg merge.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2043
diff changeset
2984 (merge,
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2985 [('f', 'force', None, _('force a merge with outstanding changes')),
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2986 ('r', 'rev', '', _('revision to merge')),
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2987 ],
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
2988 _('hg merge [-f] [[-r] REV]')),
1253
a45e717c61a8 Add rename/mv command.
Bryan O'Sullivan <bos@serpentine.com>
parents: 1250
diff changeset
2989 "outgoing|out": (outgoing,
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
2990 [('M', 'no-merges', None, _('do not show merges')),
1959
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
2991 ('f', 'force', None,
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
2992 _('run even when remote repository is unrelated')),
1439
65cbe22b03fa allow 'hg out' / 'hg in' to show newest commit first
Michal Kvasnica <kvasnica@gmail.com>
parents: 1437
diff changeset
2993 ('p', 'patch', None, _('show patch')),
1913
74cf2b2f43d4 fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1910
diff changeset
2994 ('', 'style', '', _('display using template map file')),
2521
9cceb439048b add -r/--rev arguments to incoming and outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 2515
diff changeset
2995 ('r', 'rev', [], _('a specific revision you would like to push')),
1907
7718885070b1 let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1800
diff changeset
2996 ('n', 'newest-first', None, _('show newest record first')),
1965
62aa1b90414f add remotecmd/ssh option support to incoming/outgoing
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1959
diff changeset
2997 ('', 'template', '', _('display with template')),
3183
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
2998 ] + remoteopts,
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
2999 _('hg outgoing [-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
1724
5a36609f73a7 add a -b/--branch option to 'hg parents'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1720
diff changeset
3000 "^parents":
5a36609f73a7 add a -b/--branch option to 'hg parents'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1720
diff changeset
3001 (parents,
3885
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
3002 [('r', 'rev', '', _('show parents from the specified rev')),
1913
74cf2b2f43d4 fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1910
diff changeset
3003 ('', 'style', '', _('display using template map file')),
74cf2b2f43d4 fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1910
diff changeset
3004 ('', 'template', '', _('display with template'))],
3504
f4ab58d4ccd4 Remove [-b] options from help syntax lines
Matt Mackall <mpm@selenic.com>
parents: 3503
diff changeset
3005 _('hg parents [-r REV] [FILE]')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3006 "paths": (paths, [], _('hg paths [NAME]')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3007 "^pull":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3008 (pull,
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
3009 [('u', 'update', None,
3191
a32f65549b9e Documentation clarification for --update option to pull and unbundle
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3190
diff changeset
3010 _('update to new tip if changesets were pulled')),
1959
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
3011 ('f', 'force', None,
d53a18f592be add -f/--force to pull, incoming, outgoing, to work on unrelated repo.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1948
diff changeset
3012 _('run even when remote repository is unrelated')),
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
3013 ('r', 'rev', [],
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
3014 _('a specific revision up to which you would like to pull')),
3183
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
3015 ] + remoteopts,
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
3016 _('hg pull [-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
818
eef752151556 Actually implement the -f switch for push
mpm@selenic.com
parents: 815
diff changeset
3017 "^push":
eef752151556 Actually implement the -f switch for push
mpm@selenic.com
parents: 815
diff changeset
3018 (push,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3019 [('f', 'force', None, _('force push')),
1781
284fc722c342 add an optional argument to push only the specified revisions (push -r)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1712
diff changeset
3020 ('r', 'rev', [], _('a specific revision you would like to push')),
3183
37b53487c341 factor opts: remote repo access options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3182
diff changeset
3021 ] + remoteopts,
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
3022 _('hg push [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
1818
9bbc7b304c34 Make the deprecated rawcommit an alias of debugrawcommit.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1816
diff changeset
3023 "debugrawcommit|rawcommit":
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3024 (rawcommit,
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3025 [('p', 'parent', [], _('parent')),
3857
f6f16f871049 Uniformisation of commit help for -m and -l.
Mathieu Clabaut <mathieu.clabaut@gmail.com>
parents: 3855
diff changeset
3026 ('F', 'files', '', _('file list'))
5122
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
3027 ] + commitopts + commitopts2,
1818
9bbc7b304c34 Make the deprecated rawcommit an alias of debugrawcommit.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1816
diff changeset
3028 _('hg debugrawcommit [OPTION]... [FILE]...')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3029 "recover": (recover, [], _('hg recover')),
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3030 "^remove|rm":
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3031 (remove,
2245
d2118a0926bd Added -A as an alias for --after to hg remove, like for other commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 2241
diff changeset
3032 [('A', 'after', None, _('record remove that has already occurred')),
2179
520dd3d28e9b add --after option to remove command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2175
diff changeset
3033 ('f', 'force', None, _('remove file even if modified')),
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
3034 ] + walkopts,
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3035 _('hg remove [OPTION]... FILE...')),
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3036 "rename|mv":
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3037 (rename,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
3038 [('A', 'after', None, _('record a rename that has already occurred')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3039 ('f', 'force', None,
1816
08f4398bdb1a Updated help synopsises and reordered some options. Dropped [-n] from revert.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1812
diff changeset
3040 _('forcibly copy over an existing managed file')),
3182
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
3041 ] + walkopts + dryrunopts,
1869
42c76ec7a8d4 Reordered options for remove, fixed synopsis for rename.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1867
diff changeset
3042 _('hg rename [OPTION]... SOURCE... DEST')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3043 "^revert":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3044 (revert,
2966
3b7626b861f8 revert: add -a as alias for --all
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2965
diff changeset
3045 [('a', 'all', None, _('revert all changes when no arguments given')),
3818
120be84f33de Add --date support to update and revert
Matt Mackall <mpm@selenic.com>
parents: 3816
diff changeset
3046 ('d', 'date', '', _('tipmost revision matching date')),
2965
890e285c52a1 revert: require --all to revert all files.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2963
diff changeset
3047 ('r', 'rev', '', _('revision to revert to')),
2029
d436b21b20dc rewrite revert command. fix issues 93, 123, 147.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2022
diff changeset
3048 ('', 'no-backup', None, _('do not save backup copies of files')),
3182
a73a785ea8e1 factor opts: --dry-run option
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3181
diff changeset
3049 ] + walkopts + dryrunopts,
3883
6081b4c68baf Corrected synopsis for many commands.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3862
diff changeset
3050 _('hg revert [OPTION]... [-r REV] [NAME]...')),
2227
4f072bb06e89 deprecate undo command, replace with rollback command.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2212
diff changeset
3051 "rollback": (rollback, [], _('hg rollback')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3052 "root": (root, [], _('hg root')),
3539
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3524
diff changeset
3053 "showconfig|debugconfig":
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3524
diff changeset
3054 (showconfig,
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3524
diff changeset
3055 [('u', 'untrusted', None, _('show untrusted configuration options'))],
e1508621e9ef add --untrusted to showconfig
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3524
diff changeset
3056 _('showconfig [-u] [NAME]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3057 "^serve":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3058 (serve,
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
3059 [('A', 'accesslog', '', _('name of access log file to write to')),
1740
f95654385065 add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1736
diff changeset
3060 ('d', 'daemon', None, _('run server in background')),
1742
1e5bb6c929cd Added help string for --daemon-pipefds
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1741
diff changeset
3061 ('', 'daemon-pipefds', '', _('used internally by daemon mode')),
1437
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
3062 ('E', 'errorlog', '', _('name of error log file to write to')),
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
3063 ('p', 'port', 0, _('port to use (default: 8000)')),
ea51d296085f import docstring from doc/hg.1.txt
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1436
diff changeset
3064 ('a', 'address', '', _('address to use')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3065 ('n', 'name', '',
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
3066 _('name to show in web pages (default: working dir)')),
2124
27fd8b7a6c51 Cleaned trailing whitespace in hgweb.py, removed command line shortcut for webdir-conf.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2122
diff changeset
3067 ('', 'webdir-conf', '', _('name of the webdir config file'
27fd8b7a6c51 Cleaned trailing whitespace in hgweb.py, removed command line shortcut for webdir-conf.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2122
diff changeset
3068 ' (serve more than one repo)')),
1740
f95654385065 add --daemon option to serve command. for issue 45.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1736
diff changeset
3069 ('', 'pid-file', '', _('name of file to write process ID to')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3070 ('', 'stdio', None, _('for remote clients')),
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3071 ('t', 'templates', '', _('web templates to use')),
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3072 ('', 'style', '', _('template style to use')),
4850
f3802f9f1840 Add SSL support to hg serve, activated via --certificate option
Brendan Cully <brendan@kublai.com>
parents: 4847
diff changeset
3073 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
f3802f9f1840 Add SSL support to hg serve, activated via --certificate option
Brendan Cully <brendan@kublai.com>
parents: 4847
diff changeset
3074 ('', 'certificate', '', _('SSL certificate file'))],
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3075 _('hg serve [OPTION]...')),
1507
cd8fadd8c689 Add explicit 'st' alias for status
Matt Mackall <mpm@selenic.com>
parents: 1506
diff changeset
3076 "^status|st":
840
141744605b51 hg status: added options to select files by status.
tksoh@users.sourceforge.net
parents: 839
diff changeset
3077 (status,
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
3078 [('A', 'all', None, _('show status of all files')),
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
3079 ('m', 'modified', None, _('show only modified files')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3080 ('a', 'added', None, _('show only added files')),
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3081 ('r', 'removed', None, _('show only removed files')),
1619
1ba0d7041ac4 Distinguish removed and deleted files. Tests are not fixed yet.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1618
diff changeset
3082 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
2661
5c10b7ed3411 status: add -c (clean) and -A (all files) options
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2639
diff changeset
3083 ('c', 'clean', None, _('show only files without changes')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3084 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4156
30857b5779f8 Fix help text for hg status -i
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4143
diff changeset
3085 ('i', 'ignored', None, _('show only ignored files')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3086 ('n', 'no-status', None, _('hide status prefix')),
2639
001703ec311d Add an option '-C|--copies' to hg status to show the source of copied files.
Brendan Cully <brendan@kublai.com>
parents: 2630
diff changeset
3087 ('C', 'copies', None, _('show source of copied files')),
1602
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
3088 ('0', 'print0', None,
fb4149eebdd4 strictly adher to 80 chars per line
Muli Ben-Yehuda <mulix@mulix.org>
parents: 1601
diff changeset
3089 _('end filenames with NUL, for use with xargs')),
3462
2b3b703b3a2b Add --rev option to status
Brendan Cully <brendan@kublai.com>
parents: 3460
diff changeset
3090 ('', 'rev', [], _('show difference from revision')),
3181
725e3d3145d8 factor opts: walk options
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3180
diff changeset
3091 ] + walkopts,
1615
83238c1db6de Cleanup of indentation, spacing, newlines, strings and line length
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1607
diff changeset
3092 _('hg status [OPTION]... [FILE]...')),
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3093 "tag":
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3094 (tag,
4273
8185a1ca8628 tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents: 4249
diff changeset
3095 [('f', 'force', None, _('replace existing tag')),
8185a1ca8628 tags: require -f to replace an existing tag
Matt Mackall <mpm@selenic.com>
parents: 4249
diff changeset
3096 ('l', 'local', None, _('make the tag local')),
4217
3be4785f8994 tags: add --remove
Matt Mackall <mpm@selenic.com>
parents: 4207
diff changeset
3097 ('r', 'rev', '', _('revision to tag')),
5122
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
3098 ('', 'remove', None, _('remove a tag')),
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
3099 # -l/--local is already there, commitopts cannot be used
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
3100 ('m', 'message', '', _('use <text> as commit message')),
c80af96943aa refactor options from cmdtable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 5098
diff changeset
3101 ] + commitopts2,
1812
a81f99dfaa2a fix the synopsis of some commands, mark rawcommit as deprecated in short help
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1811
diff changeset
3102 _('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3103 "tags": (tags, [], _('hg tags')),
1762
8eaa8e06a364 Add option -b/--branch to hg tip (as done for hg parents).
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1761
diff changeset
3104 "tip":
8eaa8e06a364 Add option -b/--branch to hg tip (as done for hg parents).
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1761
diff changeset
3105 (tip,
3885
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
3106 [('', 'style', '', _('display using template map file')),
1907
7718885070b1 let commands that show changesets use templates.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1800
diff changeset
3107 ('p', 'patch', None, _('show patch')),
1913
74cf2b2f43d4 fix some things people wanted to be cleaner.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 1910
diff changeset
3108 ('', 'template', '', _('display with template'))],
3504
f4ab58d4ccd4 Remove [-b] options from help syntax lines
Matt Mackall <mpm@selenic.com>
parents: 3503
diff changeset
3109 _('hg tip [-p]')),
1218
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
3110 "unbundle":
cde6818e082a Add preliminary support for the bundle and unbundle commands
mpm@selenic.com
parents: 1215
diff changeset
3111 (unbundle,
1601
a1b25fb2e764 Error handling for unbundle, fix option line wrapping
Matt Mackall <mpm@selenic.com>
parents: 1600
diff changeset
3112 [('u', 'update', None,
3191
a32f65549b9e Documentation clarification for --update option to pull and unbundle
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3190
diff changeset
3113 _('update to new tip if changesets were unbundled'))],
4699
a6b62584d0b2 unbundle: accept multiple file arguments
Giorgos Keramidas <keramida@ceid.upatras.gr>
parents: 4697
diff changeset
3114 _('hg unbundle [-u] FILE...')),
593
ca3c499e94c6 Shorten help
mpm@selenic.com
parents: 592
diff changeset
3115 "^update|up|checkout|co":
697
cb1be2327220 Multiple cleanups of things detected by pylint.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 696
diff changeset
3116 (update,
3885
1e0b94cfba0e Remove deprecated old-style branch support
Matt Mackall <mpm@selenic.com>
parents: 3862
diff changeset
3117 [('C', 'clean', None, _('overwrite locally modified files')),
4450
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
3118 ('d', 'date', '', _('tipmost revision matching date')),
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
3119 ('r', 'rev', '', _('revision'))],
8fa54b9c6c5a accept -r REV in more places
Daniel Holth <dholth@fastmail.fm>
parents: 4442
diff changeset
3120 _('hg update [-C] [-d DATE] [[-r] REV]')),
1402
9d2c2e6b32b5 i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1400
diff changeset
3121 "verify": (verify, [], _('hg verify')),
3658
6389205291c6 move show_version to version_
Matt Mackall <mpm@selenic.com>
parents: 3657
diff changeset
3122 "version": (version_, [], _('hg version')),
1046
772507daaa17 Sort global options by topic: directories, ui, timing, other
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1044
diff changeset
3123 }
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
3124
4819
616a5adbf402 extensions: untangle some recursive dependencies
Matt Mackall <mpm@selenic.com>
parents: 4803
diff changeset
3125 extensions.commandtable = table
616a5adbf402 extensions: untangle some recursive dependencies
Matt Mackall <mpm@selenic.com>
parents: 4803
diff changeset
3126
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1875
diff changeset
3127 norepo = ("clone init version help debugancestor debugcomplete debugdata"
3844
3ba82c3f4bc3 Add debuginstall command to do basic install tests
Matt Mackall <mpm@selenic.com>
parents: 3840
diff changeset
3128 " debugindex debugindexdot debugdate debuginstall")
3267
bb057b6ce3cf Un-debugify debugconfig to showconfig. (issue 317)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 3256
diff changeset
3129 optionalrepo = ("paths serve showconfig")
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents:
diff changeset
3130
5067
3d35c8cb5eb4 Simplify/correct finding the hg executable (fixes issue644)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5061
diff changeset
3131 def dispatch(args):
293
11d64332a1cb hg help improvements
mpm@selenic.com
parents: 290
diff changeset
3132 try:
4558
a73d80d6385a Revive commands.dispatch as a simple way to call hg from other pythons scripts.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4549
diff changeset
3133 u = ui.ui(traceback='--traceback' in args)
2943
8e59010158ce refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2842
diff changeset
3134 except util.Abort, inst:
8e59010158ce refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2842
diff changeset
3135 sys.stderr.write(_("abort: %s\n") % inst)
8e59010158ce refactor extension loading.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2842
diff changeset
3136 return -1
5067
3d35c8cb5eb4 Simplify/correct finding the hg executable (fixes issue644)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5061
diff changeset
3137 return cmdutil.runcatch(u, args)
4558
a73d80d6385a Revive commands.dispatch as a simple way to call hg from other pythons scripts.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4549
diff changeset
3138
a73d80d6385a Revive commands.dispatch as a simple way to call hg from other pythons scripts.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4549
diff changeset
3139 def run():
5067
3d35c8cb5eb4 Simplify/correct finding the hg executable (fixes issue644)
Thomas Arendsen Hein <thomas@intevation.de>
parents: 5061
diff changeset
3140 sys.exit(dispatch(sys.argv[1:]))