##// END OF EJS Templates
debugbuilddag: use memctx for speed...
Peter Arrenbrecht -
r14163:38184a72 default
parent child Browse files
Show More
@@ -1,4884 +1,4901 b''
1 # commands.py - command processing for mercurial
1 # commands.py - command processing for mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from node import hex, bin, nullid, nullrev, short
8 from node import hex, bin, nullid, nullrev, short
9 from lock import release
9 from lock import release
10 from i18n import _, gettext
10 from i18n import _, gettext
11 import os, re, sys, difflib, time, tempfile
11 import os, re, sys, difflib, time, tempfile
12 import hg, scmutil, util, revlog, extensions, copies, error, bookmarks
12 import hg, scmutil, util, revlog, extensions, copies, error, bookmarks
13 import patch, help, url, encoding, templatekw, discovery
13 import patch, help, url, encoding, templatekw, discovery
14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server
14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server
15 import merge as mergemod
15 import merge as mergemod
16 import minirst, revset, templatefilters
16 import minirst, revset, templatefilters
17 import dagparser
17 import dagparser, context, simplemerge
18
18
19 # Commands start here, listed alphabetically
19 # Commands start here, listed alphabetically
20
20
21 def add(ui, repo, *pats, **opts):
21 def add(ui, repo, *pats, **opts):
22 """add the specified files on the next commit
22 """add the specified files on the next commit
23
23
24 Schedule files to be version controlled and added to the
24 Schedule files to be version controlled and added to the
25 repository.
25 repository.
26
26
27 The files will be added to the repository at the next commit. To
27 The files will be added to the repository at the next commit. To
28 undo an add before that, see :hg:`forget`.
28 undo an add before that, see :hg:`forget`.
29
29
30 If no names are given, add all files to the repository.
30 If no names are given, add all files to the repository.
31
31
32 .. container:: verbose
32 .. container:: verbose
33
33
34 An example showing how new (unknown) files are added
34 An example showing how new (unknown) files are added
35 automatically by :hg:`add`::
35 automatically by :hg:`add`::
36
36
37 $ ls
37 $ ls
38 foo.c
38 foo.c
39 $ hg status
39 $ hg status
40 ? foo.c
40 ? foo.c
41 $ hg add
41 $ hg add
42 adding foo.c
42 adding foo.c
43 $ hg status
43 $ hg status
44 A foo.c
44 A foo.c
45
45
46 Returns 0 if all files are successfully added.
46 Returns 0 if all files are successfully added.
47 """
47 """
48
48
49 m = cmdutil.match(repo, pats, opts)
49 m = cmdutil.match(repo, pats, opts)
50 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
50 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
51 opts.get('subrepos'), prefix="")
51 opts.get('subrepos'), prefix="")
52 return rejected and 1 or 0
52 return rejected and 1 or 0
53
53
54 def addremove(ui, repo, *pats, **opts):
54 def addremove(ui, repo, *pats, **opts):
55 """add all new files, delete all missing files
55 """add all new files, delete all missing files
56
56
57 Add all new files and remove all missing files from the
57 Add all new files and remove all missing files from the
58 repository.
58 repository.
59
59
60 New files are ignored if they match any of the patterns in
60 New files are ignored if they match any of the patterns in
61 ``.hgignore``. As with add, these changes take effect at the next
61 ``.hgignore``. As with add, these changes take effect at the next
62 commit.
62 commit.
63
63
64 Use the -s/--similarity option to detect renamed files. With a
64 Use the -s/--similarity option to detect renamed files. With a
65 parameter greater than 0, this compares every removed file with
65 parameter greater than 0, this compares every removed file with
66 every added file and records those similar enough as renames. This
66 every added file and records those similar enough as renames. This
67 option takes a percentage between 0 (disabled) and 100 (files must
67 option takes a percentage between 0 (disabled) and 100 (files must
68 be identical) as its parameter. Detecting renamed files this way
68 be identical) as its parameter. Detecting renamed files this way
69 can be expensive. After using this option, :hg:`status -C` can be
69 can be expensive. After using this option, :hg:`status -C` can be
70 used to check which files were identified as moved or renamed.
70 used to check which files were identified as moved or renamed.
71
71
72 Returns 0 if all files are successfully added.
72 Returns 0 if all files are successfully added.
73 """
73 """
74 try:
74 try:
75 sim = float(opts.get('similarity') or 100)
75 sim = float(opts.get('similarity') or 100)
76 except ValueError:
76 except ValueError:
77 raise util.Abort(_('similarity must be a number'))
77 raise util.Abort(_('similarity must be a number'))
78 if sim < 0 or sim > 100:
78 if sim < 0 or sim > 100:
79 raise util.Abort(_('similarity must be between 0 and 100'))
79 raise util.Abort(_('similarity must be between 0 and 100'))
80 return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0)
80 return cmdutil.addremove(repo, pats, opts, similarity=sim / 100.0)
81
81
82 def annotate(ui, repo, *pats, **opts):
82 def annotate(ui, repo, *pats, **opts):
83 """show changeset information by line for each file
83 """show changeset information by line for each file
84
84
85 List changes in files, showing the revision id responsible for
85 List changes in files, showing the revision id responsible for
86 each line
86 each line
87
87
88 This command is useful for discovering when a change was made and
88 This command is useful for discovering when a change was made and
89 by whom.
89 by whom.
90
90
91 Without the -a/--text option, annotate will avoid processing files
91 Without the -a/--text option, annotate will avoid processing files
92 it detects as binary. With -a, annotate will annotate the file
92 it detects as binary. With -a, annotate will annotate the file
93 anyway, although the results will probably be neither useful
93 anyway, although the results will probably be neither useful
94 nor desirable.
94 nor desirable.
95
95
96 Returns 0 on success.
96 Returns 0 on success.
97 """
97 """
98 if opts.get('follow'):
98 if opts.get('follow'):
99 # --follow is deprecated and now just an alias for -f/--file
99 # --follow is deprecated and now just an alias for -f/--file
100 # to mimic the behavior of Mercurial before version 1.5
100 # to mimic the behavior of Mercurial before version 1.5
101 opts['file'] = 1
101 opts['file'] = 1
102
102
103 datefunc = ui.quiet and util.shortdate or util.datestr
103 datefunc = ui.quiet and util.shortdate or util.datestr
104 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
104 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
105
105
106 if not pats:
106 if not pats:
107 raise util.Abort(_('at least one filename or pattern is required'))
107 raise util.Abort(_('at least one filename or pattern is required'))
108
108
109 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
109 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
110 ('number', lambda x: str(x[0].rev())),
110 ('number', lambda x: str(x[0].rev())),
111 ('changeset', lambda x: short(x[0].node())),
111 ('changeset', lambda x: short(x[0].node())),
112 ('date', getdate),
112 ('date', getdate),
113 ('file', lambda x: x[0].path()),
113 ('file', lambda x: x[0].path()),
114 ]
114 ]
115
115
116 if (not opts.get('user') and not opts.get('changeset')
116 if (not opts.get('user') and not opts.get('changeset')
117 and not opts.get('date') and not opts.get('file')):
117 and not opts.get('date') and not opts.get('file')):
118 opts['number'] = 1
118 opts['number'] = 1
119
119
120 linenumber = opts.get('line_number') is not None
120 linenumber = opts.get('line_number') is not None
121 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
121 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
122 raise util.Abort(_('at least one of -n/-c is required for -l'))
122 raise util.Abort(_('at least one of -n/-c is required for -l'))
123
123
124 funcmap = [func for op, func in opmap if opts.get(op)]
124 funcmap = [func for op, func in opmap if opts.get(op)]
125 if linenumber:
125 if linenumber:
126 lastfunc = funcmap[-1]
126 lastfunc = funcmap[-1]
127 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
127 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
128
128
129 def bad(x, y):
129 def bad(x, y):
130 raise util.Abort("%s: %s" % (x, y))
130 raise util.Abort("%s: %s" % (x, y))
131
131
132 ctx = cmdutil.revsingle(repo, opts.get('rev'))
132 ctx = cmdutil.revsingle(repo, opts.get('rev'))
133 m = cmdutil.match(repo, pats, opts)
133 m = cmdutil.match(repo, pats, opts)
134 m.bad = bad
134 m.bad = bad
135 follow = not opts.get('no_follow')
135 follow = not opts.get('no_follow')
136 for abs in ctx.walk(m):
136 for abs in ctx.walk(m):
137 fctx = ctx[abs]
137 fctx = ctx[abs]
138 if not opts.get('text') and util.binary(fctx.data()):
138 if not opts.get('text') and util.binary(fctx.data()):
139 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
139 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
140 continue
140 continue
141
141
142 lines = fctx.annotate(follow=follow, linenumber=linenumber)
142 lines = fctx.annotate(follow=follow, linenumber=linenumber)
143 pieces = []
143 pieces = []
144
144
145 for f in funcmap:
145 for f in funcmap:
146 l = [f(n) for n, dummy in lines]
146 l = [f(n) for n, dummy in lines]
147 if l:
147 if l:
148 sized = [(x, encoding.colwidth(x)) for x in l]
148 sized = [(x, encoding.colwidth(x)) for x in l]
149 ml = max([w for x, w in sized])
149 ml = max([w for x, w in sized])
150 pieces.append(["%s%s" % (' ' * (ml - w), x) for x, w in sized])
150 pieces.append(["%s%s" % (' ' * (ml - w), x) for x, w in sized])
151
151
152 if pieces:
152 if pieces:
153 for p, l in zip(zip(*pieces), lines):
153 for p, l in zip(zip(*pieces), lines):
154 ui.write("%s: %s" % (" ".join(p), l[1]))
154 ui.write("%s: %s" % (" ".join(p), l[1]))
155
155
156 def archive(ui, repo, dest, **opts):
156 def archive(ui, repo, dest, **opts):
157 '''create an unversioned archive of a repository revision
157 '''create an unversioned archive of a repository revision
158
158
159 By default, the revision used is the parent of the working
159 By default, the revision used is the parent of the working
160 directory; use -r/--rev to specify a different revision.
160 directory; use -r/--rev to specify a different revision.
161
161
162 The archive type is automatically detected based on file
162 The archive type is automatically detected based on file
163 extension (or override using -t/--type).
163 extension (or override using -t/--type).
164
164
165 Valid types are:
165 Valid types are:
166
166
167 :``files``: a directory full of files (default)
167 :``files``: a directory full of files (default)
168 :``tar``: tar archive, uncompressed
168 :``tar``: tar archive, uncompressed
169 :``tbz2``: tar archive, compressed using bzip2
169 :``tbz2``: tar archive, compressed using bzip2
170 :``tgz``: tar archive, compressed using gzip
170 :``tgz``: tar archive, compressed using gzip
171 :``uzip``: zip archive, uncompressed
171 :``uzip``: zip archive, uncompressed
172 :``zip``: zip archive, compressed using deflate
172 :``zip``: zip archive, compressed using deflate
173
173
174 The exact name of the destination archive or directory is given
174 The exact name of the destination archive or directory is given
175 using a format string; see :hg:`help export` for details.
175 using a format string; see :hg:`help export` for details.
176
176
177 Each member added to an archive file has a directory prefix
177 Each member added to an archive file has a directory prefix
178 prepended. Use -p/--prefix to specify a format string for the
178 prepended. Use -p/--prefix to specify a format string for the
179 prefix. The default is the basename of the archive, with suffixes
179 prefix. The default is the basename of the archive, with suffixes
180 removed.
180 removed.
181
181
182 Returns 0 on success.
182 Returns 0 on success.
183 '''
183 '''
184
184
185 ctx = cmdutil.revsingle(repo, opts.get('rev'))
185 ctx = cmdutil.revsingle(repo, opts.get('rev'))
186 if not ctx:
186 if not ctx:
187 raise util.Abort(_('no working directory: please specify a revision'))
187 raise util.Abort(_('no working directory: please specify a revision'))
188 node = ctx.node()
188 node = ctx.node()
189 dest = cmdutil.make_filename(repo, dest, node)
189 dest = cmdutil.make_filename(repo, dest, node)
190 if os.path.realpath(dest) == repo.root:
190 if os.path.realpath(dest) == repo.root:
191 raise util.Abort(_('repository root cannot be destination'))
191 raise util.Abort(_('repository root cannot be destination'))
192
192
193 kind = opts.get('type') or archival.guesskind(dest) or 'files'
193 kind = opts.get('type') or archival.guesskind(dest) or 'files'
194 prefix = opts.get('prefix')
194 prefix = opts.get('prefix')
195
195
196 if dest == '-':
196 if dest == '-':
197 if kind == 'files':
197 if kind == 'files':
198 raise util.Abort(_('cannot archive plain files to stdout'))
198 raise util.Abort(_('cannot archive plain files to stdout'))
199 dest = sys.stdout
199 dest = sys.stdout
200 if not prefix:
200 if not prefix:
201 prefix = os.path.basename(repo.root) + '-%h'
201 prefix = os.path.basename(repo.root) + '-%h'
202
202
203 prefix = cmdutil.make_filename(repo, prefix, node)
203 prefix = cmdutil.make_filename(repo, prefix, node)
204 matchfn = cmdutil.match(repo, [], opts)
204 matchfn = cmdutil.match(repo, [], opts)
205 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
205 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
206 matchfn, prefix, subrepos=opts.get('subrepos'))
206 matchfn, prefix, subrepos=opts.get('subrepos'))
207
207
208 def backout(ui, repo, node=None, rev=None, **opts):
208 def backout(ui, repo, node=None, rev=None, **opts):
209 '''reverse effect of earlier changeset
209 '''reverse effect of earlier changeset
210
210
211 Prepare a new changeset with the effect of REV undone in the
211 Prepare a new changeset with the effect of REV undone in the
212 current working directory.
212 current working directory.
213
213
214 If REV is the parent of the working directory, then this new changeset
214 If REV is the parent of the working directory, then this new changeset
215 is committed automatically. Otherwise, hg needs to merge the
215 is committed automatically. Otherwise, hg needs to merge the
216 changes and the merged result is left uncommitted.
216 changes and the merged result is left uncommitted.
217
217
218 By default, the pending changeset will have one parent,
218 By default, the pending changeset will have one parent,
219 maintaining a linear history. With --merge, the pending changeset
219 maintaining a linear history. With --merge, the pending changeset
220 will instead have two parents: the old parent of the working
220 will instead have two parents: the old parent of the working
221 directory and a new child of REV that simply undoes REV.
221 directory and a new child of REV that simply undoes REV.
222
222
223 Before version 1.7, the behavior without --merge was equivalent to
223 Before version 1.7, the behavior without --merge was equivalent to
224 specifying --merge followed by :hg:`update --clean .` to cancel
224 specifying --merge followed by :hg:`update --clean .` to cancel
225 the merge and leave the child of REV as a head to be merged
225 the merge and leave the child of REV as a head to be merged
226 separately.
226 separately.
227
227
228 See :hg:`help dates` for a list of formats valid for -d/--date.
228 See :hg:`help dates` for a list of formats valid for -d/--date.
229
229
230 Returns 0 on success.
230 Returns 0 on success.
231 '''
231 '''
232 if rev and node:
232 if rev and node:
233 raise util.Abort(_("please specify just one revision"))
233 raise util.Abort(_("please specify just one revision"))
234
234
235 if not rev:
235 if not rev:
236 rev = node
236 rev = node
237
237
238 if not rev:
238 if not rev:
239 raise util.Abort(_("please specify a revision to backout"))
239 raise util.Abort(_("please specify a revision to backout"))
240
240
241 date = opts.get('date')
241 date = opts.get('date')
242 if date:
242 if date:
243 opts['date'] = util.parsedate(date)
243 opts['date'] = util.parsedate(date)
244
244
245 cmdutil.bail_if_changed(repo)
245 cmdutil.bail_if_changed(repo)
246 node = cmdutil.revsingle(repo, rev).node()
246 node = cmdutil.revsingle(repo, rev).node()
247
247
248 op1, op2 = repo.dirstate.parents()
248 op1, op2 = repo.dirstate.parents()
249 a = repo.changelog.ancestor(op1, node)
249 a = repo.changelog.ancestor(op1, node)
250 if a != node:
250 if a != node:
251 raise util.Abort(_('cannot backout change on a different branch'))
251 raise util.Abort(_('cannot backout change on a different branch'))
252
252
253 p1, p2 = repo.changelog.parents(node)
253 p1, p2 = repo.changelog.parents(node)
254 if p1 == nullid:
254 if p1 == nullid:
255 raise util.Abort(_('cannot backout a change with no parents'))
255 raise util.Abort(_('cannot backout a change with no parents'))
256 if p2 != nullid:
256 if p2 != nullid:
257 if not opts.get('parent'):
257 if not opts.get('parent'):
258 raise util.Abort(_('cannot backout a merge changeset without '
258 raise util.Abort(_('cannot backout a merge changeset without '
259 '--parent'))
259 '--parent'))
260 p = repo.lookup(opts['parent'])
260 p = repo.lookup(opts['parent'])
261 if p not in (p1, p2):
261 if p not in (p1, p2):
262 raise util.Abort(_('%s is not a parent of %s') %
262 raise util.Abort(_('%s is not a parent of %s') %
263 (short(p), short(node)))
263 (short(p), short(node)))
264 parent = p
264 parent = p
265 else:
265 else:
266 if opts.get('parent'):
266 if opts.get('parent'):
267 raise util.Abort(_('cannot use --parent on non-merge changeset'))
267 raise util.Abort(_('cannot use --parent on non-merge changeset'))
268 parent = p1
268 parent = p1
269
269
270 # the backout should appear on the same branch
270 # the backout should appear on the same branch
271 branch = repo.dirstate.branch()
271 branch = repo.dirstate.branch()
272 hg.clean(repo, node, show_stats=False)
272 hg.clean(repo, node, show_stats=False)
273 repo.dirstate.setbranch(branch)
273 repo.dirstate.setbranch(branch)
274 revert_opts = opts.copy()
274 revert_opts = opts.copy()
275 revert_opts['date'] = None
275 revert_opts['date'] = None
276 revert_opts['all'] = True
276 revert_opts['all'] = True
277 revert_opts['rev'] = hex(parent)
277 revert_opts['rev'] = hex(parent)
278 revert_opts['no_backup'] = None
278 revert_opts['no_backup'] = None
279 revert(ui, repo, **revert_opts)
279 revert(ui, repo, **revert_opts)
280 if not opts.get('merge') and op1 != node:
280 if not opts.get('merge') and op1 != node:
281 try:
281 try:
282 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
282 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
283 return hg.update(repo, op1)
283 return hg.update(repo, op1)
284 finally:
284 finally:
285 ui.setconfig('ui', 'forcemerge', '')
285 ui.setconfig('ui', 'forcemerge', '')
286
286
287 commit_opts = opts.copy()
287 commit_opts = opts.copy()
288 commit_opts['addremove'] = False
288 commit_opts['addremove'] = False
289 if not commit_opts['message'] and not commit_opts['logfile']:
289 if not commit_opts['message'] and not commit_opts['logfile']:
290 # we don't translate commit messages
290 # we don't translate commit messages
291 commit_opts['message'] = "Backed out changeset %s" % short(node)
291 commit_opts['message'] = "Backed out changeset %s" % short(node)
292 commit_opts['force_editor'] = True
292 commit_opts['force_editor'] = True
293 commit(ui, repo, **commit_opts)
293 commit(ui, repo, **commit_opts)
294 def nice(node):
294 def nice(node):
295 return '%d:%s' % (repo.changelog.rev(node), short(node))
295 return '%d:%s' % (repo.changelog.rev(node), short(node))
296 ui.status(_('changeset %s backs out changeset %s\n') %
296 ui.status(_('changeset %s backs out changeset %s\n') %
297 (nice(repo.changelog.tip()), nice(node)))
297 (nice(repo.changelog.tip()), nice(node)))
298 if opts.get('merge') and op1 != node:
298 if opts.get('merge') and op1 != node:
299 hg.clean(repo, op1, show_stats=False)
299 hg.clean(repo, op1, show_stats=False)
300 ui.status(_('merging with changeset %s\n')
300 ui.status(_('merging with changeset %s\n')
301 % nice(repo.changelog.tip()))
301 % nice(repo.changelog.tip()))
302 try:
302 try:
303 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
303 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
304 return hg.merge(repo, hex(repo.changelog.tip()))
304 return hg.merge(repo, hex(repo.changelog.tip()))
305 finally:
305 finally:
306 ui.setconfig('ui', 'forcemerge', '')
306 ui.setconfig('ui', 'forcemerge', '')
307 return 0
307 return 0
308
308
309 def bisect(ui, repo, rev=None, extra=None, command=None,
309 def bisect(ui, repo, rev=None, extra=None, command=None,
310 reset=None, good=None, bad=None, skip=None, extend=None,
310 reset=None, good=None, bad=None, skip=None, extend=None,
311 noupdate=None):
311 noupdate=None):
312 """subdivision search of changesets
312 """subdivision search of changesets
313
313
314 This command helps to find changesets which introduce problems. To
314 This command helps to find changesets which introduce problems. To
315 use, mark the earliest changeset you know exhibits the problem as
315 use, mark the earliest changeset you know exhibits the problem as
316 bad, then mark the latest changeset which is free from the problem
316 bad, then mark the latest changeset which is free from the problem
317 as good. Bisect will update your working directory to a revision
317 as good. Bisect will update your working directory to a revision
318 for testing (unless the -U/--noupdate option is specified). Once
318 for testing (unless the -U/--noupdate option is specified). Once
319 you have performed tests, mark the working directory as good or
319 you have performed tests, mark the working directory as good or
320 bad, and bisect will either update to another candidate changeset
320 bad, and bisect will either update to another candidate changeset
321 or announce that it has found the bad revision.
321 or announce that it has found the bad revision.
322
322
323 As a shortcut, you can also use the revision argument to mark a
323 As a shortcut, you can also use the revision argument to mark a
324 revision as good or bad without checking it out first.
324 revision as good or bad without checking it out first.
325
325
326 If you supply a command, it will be used for automatic bisection.
326 If you supply a command, it will be used for automatic bisection.
327 Its exit status will be used to mark revisions as good or bad:
327 Its exit status will be used to mark revisions as good or bad:
328 status 0 means good, 125 means to skip the revision, 127
328 status 0 means good, 125 means to skip the revision, 127
329 (command not found) will abort the bisection, and any other
329 (command not found) will abort the bisection, and any other
330 non-zero exit status means the revision is bad.
330 non-zero exit status means the revision is bad.
331
331
332 Returns 0 on success.
332 Returns 0 on success.
333 """
333 """
334 def extendbisectrange(nodes, good):
334 def extendbisectrange(nodes, good):
335 # bisect is incomplete when it ends on a merge node and
335 # bisect is incomplete when it ends on a merge node and
336 # one of the parent was not checked.
336 # one of the parent was not checked.
337 parents = repo[nodes[0]].parents()
337 parents = repo[nodes[0]].parents()
338 if len(parents) > 1:
338 if len(parents) > 1:
339 side = good and state['bad'] or state['good']
339 side = good and state['bad'] or state['good']
340 num = len(set(i.node() for i in parents) & set(side))
340 num = len(set(i.node() for i in parents) & set(side))
341 if num == 1:
341 if num == 1:
342 return parents[0].ancestor(parents[1])
342 return parents[0].ancestor(parents[1])
343 return None
343 return None
344
344
345 def print_result(nodes, good):
345 def print_result(nodes, good):
346 displayer = cmdutil.show_changeset(ui, repo, {})
346 displayer = cmdutil.show_changeset(ui, repo, {})
347 if len(nodes) == 1:
347 if len(nodes) == 1:
348 # narrowed it down to a single revision
348 # narrowed it down to a single revision
349 if good:
349 if good:
350 ui.write(_("The first good revision is:\n"))
350 ui.write(_("The first good revision is:\n"))
351 else:
351 else:
352 ui.write(_("The first bad revision is:\n"))
352 ui.write(_("The first bad revision is:\n"))
353 displayer.show(repo[nodes[0]])
353 displayer.show(repo[nodes[0]])
354 extendnode = extendbisectrange(nodes, good)
354 extendnode = extendbisectrange(nodes, good)
355 if extendnode is not None:
355 if extendnode is not None:
356 ui.write(_('Not all ancestors of this changeset have been'
356 ui.write(_('Not all ancestors of this changeset have been'
357 ' checked.\nUse bisect --extend to continue the '
357 ' checked.\nUse bisect --extend to continue the '
358 'bisection from\nthe common ancestor, %s.\n')
358 'bisection from\nthe common ancestor, %s.\n')
359 % extendnode)
359 % extendnode)
360 else:
360 else:
361 # multiple possible revisions
361 # multiple possible revisions
362 if good:
362 if good:
363 ui.write(_("Due to skipped revisions, the first "
363 ui.write(_("Due to skipped revisions, the first "
364 "good revision could be any of:\n"))
364 "good revision could be any of:\n"))
365 else:
365 else:
366 ui.write(_("Due to skipped revisions, the first "
366 ui.write(_("Due to skipped revisions, the first "
367 "bad revision could be any of:\n"))
367 "bad revision could be any of:\n"))
368 for n in nodes:
368 for n in nodes:
369 displayer.show(repo[n])
369 displayer.show(repo[n])
370 displayer.close()
370 displayer.close()
371
371
372 def check_state(state, interactive=True):
372 def check_state(state, interactive=True):
373 if not state['good'] or not state['bad']:
373 if not state['good'] or not state['bad']:
374 if (good or bad or skip or reset) and interactive:
374 if (good or bad or skip or reset) and interactive:
375 return
375 return
376 if not state['good']:
376 if not state['good']:
377 raise util.Abort(_('cannot bisect (no known good revisions)'))
377 raise util.Abort(_('cannot bisect (no known good revisions)'))
378 else:
378 else:
379 raise util.Abort(_('cannot bisect (no known bad revisions)'))
379 raise util.Abort(_('cannot bisect (no known bad revisions)'))
380 return True
380 return True
381
381
382 # backward compatibility
382 # backward compatibility
383 if rev in "good bad reset init".split():
383 if rev in "good bad reset init".split():
384 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
384 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
385 cmd, rev, extra = rev, extra, None
385 cmd, rev, extra = rev, extra, None
386 if cmd == "good":
386 if cmd == "good":
387 good = True
387 good = True
388 elif cmd == "bad":
388 elif cmd == "bad":
389 bad = True
389 bad = True
390 else:
390 else:
391 reset = True
391 reset = True
392 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
392 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
393 raise util.Abort(_('incompatible arguments'))
393 raise util.Abort(_('incompatible arguments'))
394
394
395 if reset:
395 if reset:
396 p = repo.join("bisect.state")
396 p = repo.join("bisect.state")
397 if os.path.exists(p):
397 if os.path.exists(p):
398 os.unlink(p)
398 os.unlink(p)
399 return
399 return
400
400
401 state = hbisect.load_state(repo)
401 state = hbisect.load_state(repo)
402
402
403 if command:
403 if command:
404 changesets = 1
404 changesets = 1
405 try:
405 try:
406 while changesets:
406 while changesets:
407 # update state
407 # update state
408 status = util.system(command)
408 status = util.system(command)
409 if status == 125:
409 if status == 125:
410 transition = "skip"
410 transition = "skip"
411 elif status == 0:
411 elif status == 0:
412 transition = "good"
412 transition = "good"
413 # status < 0 means process was killed
413 # status < 0 means process was killed
414 elif status == 127:
414 elif status == 127:
415 raise util.Abort(_("failed to execute %s") % command)
415 raise util.Abort(_("failed to execute %s") % command)
416 elif status < 0:
416 elif status < 0:
417 raise util.Abort(_("%s killed") % command)
417 raise util.Abort(_("%s killed") % command)
418 else:
418 else:
419 transition = "bad"
419 transition = "bad"
420 ctx = cmdutil.revsingle(repo, rev)
420 ctx = cmdutil.revsingle(repo, rev)
421 rev = None # clear for future iterations
421 rev = None # clear for future iterations
422 state[transition].append(ctx.node())
422 state[transition].append(ctx.node())
423 ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition))
423 ui.status(_('Changeset %d:%s: %s\n') % (ctx, ctx, transition))
424 check_state(state, interactive=False)
424 check_state(state, interactive=False)
425 # bisect
425 # bisect
426 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
426 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
427 # update to next check
427 # update to next check
428 cmdutil.bail_if_changed(repo)
428 cmdutil.bail_if_changed(repo)
429 hg.clean(repo, nodes[0], show_stats=False)
429 hg.clean(repo, nodes[0], show_stats=False)
430 finally:
430 finally:
431 hbisect.save_state(repo, state)
431 hbisect.save_state(repo, state)
432 print_result(nodes, good)
432 print_result(nodes, good)
433 return
433 return
434
434
435 # update state
435 # update state
436
436
437 if rev:
437 if rev:
438 nodes = [repo.lookup(i) for i in cmdutil.revrange(repo, [rev])]
438 nodes = [repo.lookup(i) for i in cmdutil.revrange(repo, [rev])]
439 else:
439 else:
440 nodes = [repo.lookup('.')]
440 nodes = [repo.lookup('.')]
441
441
442 if good or bad or skip:
442 if good or bad or skip:
443 if good:
443 if good:
444 state['good'] += nodes
444 state['good'] += nodes
445 elif bad:
445 elif bad:
446 state['bad'] += nodes
446 state['bad'] += nodes
447 elif skip:
447 elif skip:
448 state['skip'] += nodes
448 state['skip'] += nodes
449 hbisect.save_state(repo, state)
449 hbisect.save_state(repo, state)
450
450
451 if not check_state(state):
451 if not check_state(state):
452 return
452 return
453
453
454 # actually bisect
454 # actually bisect
455 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
455 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
456 if extend:
456 if extend:
457 if not changesets:
457 if not changesets:
458 extendnode = extendbisectrange(nodes, good)
458 extendnode = extendbisectrange(nodes, good)
459 if extendnode is not None:
459 if extendnode is not None:
460 ui.write(_("Extending search to changeset %d:%s\n"
460 ui.write(_("Extending search to changeset %d:%s\n"
461 % (extendnode.rev(), extendnode)))
461 % (extendnode.rev(), extendnode)))
462 if noupdate:
462 if noupdate:
463 return
463 return
464 cmdutil.bail_if_changed(repo)
464 cmdutil.bail_if_changed(repo)
465 return hg.clean(repo, extendnode.node())
465 return hg.clean(repo, extendnode.node())
466 raise util.Abort(_("nothing to extend"))
466 raise util.Abort(_("nothing to extend"))
467
467
468 if changesets == 0:
468 if changesets == 0:
469 print_result(nodes, good)
469 print_result(nodes, good)
470 else:
470 else:
471 assert len(nodes) == 1 # only a single node can be tested next
471 assert len(nodes) == 1 # only a single node can be tested next
472 node = nodes[0]
472 node = nodes[0]
473 # compute the approximate number of remaining tests
473 # compute the approximate number of remaining tests
474 tests, size = 0, 2
474 tests, size = 0, 2
475 while size <= changesets:
475 while size <= changesets:
476 tests, size = tests + 1, size * 2
476 tests, size = tests + 1, size * 2
477 rev = repo.changelog.rev(node)
477 rev = repo.changelog.rev(node)
478 ui.write(_("Testing changeset %d:%s "
478 ui.write(_("Testing changeset %d:%s "
479 "(%d changesets remaining, ~%d tests)\n")
479 "(%d changesets remaining, ~%d tests)\n")
480 % (rev, short(node), changesets, tests))
480 % (rev, short(node), changesets, tests))
481 if not noupdate:
481 if not noupdate:
482 cmdutil.bail_if_changed(repo)
482 cmdutil.bail_if_changed(repo)
483 return hg.clean(repo, node)
483 return hg.clean(repo, node)
484
484
485 def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False, rename=None):
485 def bookmark(ui, repo, mark=None, rev=None, force=False, delete=False, rename=None):
486 '''track a line of development with movable markers
486 '''track a line of development with movable markers
487
487
488 Bookmarks are pointers to certain commits that move when
488 Bookmarks are pointers to certain commits that move when
489 committing. Bookmarks are local. They can be renamed, copied and
489 committing. Bookmarks are local. They can be renamed, copied and
490 deleted. It is possible to use bookmark names in :hg:`merge` and
490 deleted. It is possible to use bookmark names in :hg:`merge` and
491 :hg:`update` to merge and update respectively to a given bookmark.
491 :hg:`update` to merge and update respectively to a given bookmark.
492
492
493 You can use :hg:`bookmark NAME` to set a bookmark on the working
493 You can use :hg:`bookmark NAME` to set a bookmark on the working
494 directory's parent revision with the given name. If you specify
494 directory's parent revision with the given name. If you specify
495 a revision using -r REV (where REV may be an existing bookmark),
495 a revision using -r REV (where REV may be an existing bookmark),
496 the bookmark is assigned to that revision.
496 the bookmark is assigned to that revision.
497
497
498 Bookmarks can be pushed and pulled between repositories (see :hg:`help
498 Bookmarks can be pushed and pulled between repositories (see :hg:`help
499 push` and :hg:`help pull`). This requires both the local and remote
499 push` and :hg:`help pull`). This requires both the local and remote
500 repositories to support bookmarks. For versions prior to 1.8, this means
500 repositories to support bookmarks. For versions prior to 1.8, this means
501 the bookmarks extension must be enabled.
501 the bookmarks extension must be enabled.
502 '''
502 '''
503 hexfn = ui.debugflag and hex or short
503 hexfn = ui.debugflag and hex or short
504 marks = repo._bookmarks
504 marks = repo._bookmarks
505 cur = repo.changectx('.').node()
505 cur = repo.changectx('.').node()
506
506
507 if rename:
507 if rename:
508 if rename not in marks:
508 if rename not in marks:
509 raise util.Abort(_("bookmark '%s' does not exist") % rename)
509 raise util.Abort(_("bookmark '%s' does not exist") % rename)
510 if mark in marks and not force:
510 if mark in marks and not force:
511 raise util.Abort(_("bookmark '%s' already exists "
511 raise util.Abort(_("bookmark '%s' already exists "
512 "(use -f to force)") % mark)
512 "(use -f to force)") % mark)
513 if mark is None:
513 if mark is None:
514 raise util.Abort(_("new bookmark name required"))
514 raise util.Abort(_("new bookmark name required"))
515 marks[mark] = marks[rename]
515 marks[mark] = marks[rename]
516 if repo._bookmarkcurrent == rename:
516 if repo._bookmarkcurrent == rename:
517 bookmarks.setcurrent(repo, mark)
517 bookmarks.setcurrent(repo, mark)
518 del marks[rename]
518 del marks[rename]
519 bookmarks.write(repo)
519 bookmarks.write(repo)
520 return
520 return
521
521
522 if delete:
522 if delete:
523 if mark is None:
523 if mark is None:
524 raise util.Abort(_("bookmark name required"))
524 raise util.Abort(_("bookmark name required"))
525 if mark not in marks:
525 if mark not in marks:
526 raise util.Abort(_("bookmark '%s' does not exist") % mark)
526 raise util.Abort(_("bookmark '%s' does not exist") % mark)
527 if mark == repo._bookmarkcurrent:
527 if mark == repo._bookmarkcurrent:
528 bookmarks.setcurrent(repo, None)
528 bookmarks.setcurrent(repo, None)
529 del marks[mark]
529 del marks[mark]
530 bookmarks.write(repo)
530 bookmarks.write(repo)
531 return
531 return
532
532
533 if mark is not None:
533 if mark is not None:
534 if "\n" in mark:
534 if "\n" in mark:
535 raise util.Abort(_("bookmark name cannot contain newlines"))
535 raise util.Abort(_("bookmark name cannot contain newlines"))
536 mark = mark.strip()
536 mark = mark.strip()
537 if not mark:
537 if not mark:
538 raise util.Abort(_("bookmark names cannot consist entirely of "
538 raise util.Abort(_("bookmark names cannot consist entirely of "
539 "whitespace"))
539 "whitespace"))
540 if mark in marks and not force:
540 if mark in marks and not force:
541 raise util.Abort(_("bookmark '%s' already exists "
541 raise util.Abort(_("bookmark '%s' already exists "
542 "(use -f to force)") % mark)
542 "(use -f to force)") % mark)
543 if ((mark in repo.branchtags() or mark == repo.dirstate.branch())
543 if ((mark in repo.branchtags() or mark == repo.dirstate.branch())
544 and not force):
544 and not force):
545 raise util.Abort(
545 raise util.Abort(
546 _("a bookmark cannot have the name of an existing branch"))
546 _("a bookmark cannot have the name of an existing branch"))
547 if rev:
547 if rev:
548 marks[mark] = repo.lookup(rev)
548 marks[mark] = repo.lookup(rev)
549 else:
549 else:
550 marks[mark] = repo.changectx('.').node()
550 marks[mark] = repo.changectx('.').node()
551 if repo.changectx('.').node() == marks[mark]:
551 if repo.changectx('.').node() == marks[mark]:
552 bookmarks.setcurrent(repo, mark)
552 bookmarks.setcurrent(repo, mark)
553 bookmarks.write(repo)
553 bookmarks.write(repo)
554 return
554 return
555
555
556 if mark is None:
556 if mark is None:
557 if rev:
557 if rev:
558 raise util.Abort(_("bookmark name required"))
558 raise util.Abort(_("bookmark name required"))
559 if len(marks) == 0:
559 if len(marks) == 0:
560 ui.status(_("no bookmarks set\n"))
560 ui.status(_("no bookmarks set\n"))
561 else:
561 else:
562 for bmark, n in sorted(marks.iteritems()):
562 for bmark, n in sorted(marks.iteritems()):
563 current = repo._bookmarkcurrent
563 current = repo._bookmarkcurrent
564 if bmark == current and n == cur:
564 if bmark == current and n == cur:
565 prefix, label = '*', 'bookmarks.current'
565 prefix, label = '*', 'bookmarks.current'
566 else:
566 else:
567 prefix, label = ' ', ''
567 prefix, label = ' ', ''
568
568
569 if ui.quiet:
569 if ui.quiet:
570 ui.write("%s\n" % bmark, label=label)
570 ui.write("%s\n" % bmark, label=label)
571 else:
571 else:
572 ui.write(" %s %-25s %d:%s\n" % (
572 ui.write(" %s %-25s %d:%s\n" % (
573 prefix, bmark, repo.changelog.rev(n), hexfn(n)),
573 prefix, bmark, repo.changelog.rev(n), hexfn(n)),
574 label=label)
574 label=label)
575 return
575 return
576
576
577 def branch(ui, repo, label=None, **opts):
577 def branch(ui, repo, label=None, **opts):
578 """set or show the current branch name
578 """set or show the current branch name
579
579
580 With no argument, show the current branch name. With one argument,
580 With no argument, show the current branch name. With one argument,
581 set the working directory branch name (the branch will not exist
581 set the working directory branch name (the branch will not exist
582 in the repository until the next commit). Standard practice
582 in the repository until the next commit). Standard practice
583 recommends that primary development take place on the 'default'
583 recommends that primary development take place on the 'default'
584 branch.
584 branch.
585
585
586 Unless -f/--force is specified, branch will not let you set a
586 Unless -f/--force is specified, branch will not let you set a
587 branch name that already exists, even if it's inactive.
587 branch name that already exists, even if it's inactive.
588
588
589 Use -C/--clean to reset the working directory branch to that of
589 Use -C/--clean to reset the working directory branch to that of
590 the parent of the working directory, negating a previous branch
590 the parent of the working directory, negating a previous branch
591 change.
591 change.
592
592
593 Use the command :hg:`update` to switch to an existing branch. Use
593 Use the command :hg:`update` to switch to an existing branch. Use
594 :hg:`commit --close-branch` to mark this branch as closed.
594 :hg:`commit --close-branch` to mark this branch as closed.
595
595
596 Returns 0 on success.
596 Returns 0 on success.
597 """
597 """
598
598
599 if opts.get('clean'):
599 if opts.get('clean'):
600 label = repo[None].p1().branch()
600 label = repo[None].p1().branch()
601 repo.dirstate.setbranch(label)
601 repo.dirstate.setbranch(label)
602 ui.status(_('reset working directory to branch %s\n') % label)
602 ui.status(_('reset working directory to branch %s\n') % label)
603 elif label:
603 elif label:
604 if not opts.get('force') and label in repo.branchtags():
604 if not opts.get('force') and label in repo.branchtags():
605 if label not in [p.branch() for p in repo.parents()]:
605 if label not in [p.branch() for p in repo.parents()]:
606 raise util.Abort(_('a branch of the same name already exists'
606 raise util.Abort(_('a branch of the same name already exists'
607 " (use 'hg update' to switch to it)"))
607 " (use 'hg update' to switch to it)"))
608 repo.dirstate.setbranch(label)
608 repo.dirstate.setbranch(label)
609 ui.status(_('marked working directory as branch %s\n') % label)
609 ui.status(_('marked working directory as branch %s\n') % label)
610 else:
610 else:
611 ui.write("%s\n" % repo.dirstate.branch())
611 ui.write("%s\n" % repo.dirstate.branch())
612
612
613 def branches(ui, repo, active=False, closed=False):
613 def branches(ui, repo, active=False, closed=False):
614 """list repository named branches
614 """list repository named branches
615
615
616 List the repository's named branches, indicating which ones are
616 List the repository's named branches, indicating which ones are
617 inactive. If -c/--closed is specified, also list branches which have
617 inactive. If -c/--closed is specified, also list branches which have
618 been marked closed (see :hg:`commit --close-branch`).
618 been marked closed (see :hg:`commit --close-branch`).
619
619
620 If -a/--active is specified, only show active branches. A branch
620 If -a/--active is specified, only show active branches. A branch
621 is considered active if it contains repository heads.
621 is considered active if it contains repository heads.
622
622
623 Use the command :hg:`update` to switch to an existing branch.
623 Use the command :hg:`update` to switch to an existing branch.
624
624
625 Returns 0.
625 Returns 0.
626 """
626 """
627
627
628 hexfunc = ui.debugflag and hex or short
628 hexfunc = ui.debugflag and hex or short
629 activebranches = [repo[n].branch() for n in repo.heads()]
629 activebranches = [repo[n].branch() for n in repo.heads()]
630 def testactive(tag, node):
630 def testactive(tag, node):
631 realhead = tag in activebranches
631 realhead = tag in activebranches
632 open = node in repo.branchheads(tag, closed=False)
632 open = node in repo.branchheads(tag, closed=False)
633 return realhead and open
633 return realhead and open
634 branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag)
634 branches = sorted([(testactive(tag, node), repo.changelog.rev(node), tag)
635 for tag, node in repo.branchtags().items()],
635 for tag, node in repo.branchtags().items()],
636 reverse=True)
636 reverse=True)
637
637
638 for isactive, node, tag in branches:
638 for isactive, node, tag in branches:
639 if (not active) or isactive:
639 if (not active) or isactive:
640 if ui.quiet:
640 if ui.quiet:
641 ui.write("%s\n" % tag)
641 ui.write("%s\n" % tag)
642 else:
642 else:
643 hn = repo.lookup(node)
643 hn = repo.lookup(node)
644 if isactive:
644 if isactive:
645 label = 'branches.active'
645 label = 'branches.active'
646 notice = ''
646 notice = ''
647 elif hn not in repo.branchheads(tag, closed=False):
647 elif hn not in repo.branchheads(tag, closed=False):
648 if not closed:
648 if not closed:
649 continue
649 continue
650 label = 'branches.closed'
650 label = 'branches.closed'
651 notice = _(' (closed)')
651 notice = _(' (closed)')
652 else:
652 else:
653 label = 'branches.inactive'
653 label = 'branches.inactive'
654 notice = _(' (inactive)')
654 notice = _(' (inactive)')
655 if tag == repo.dirstate.branch():
655 if tag == repo.dirstate.branch():
656 label = 'branches.current'
656 label = 'branches.current'
657 rev = str(node).rjust(31 - encoding.colwidth(tag))
657 rev = str(node).rjust(31 - encoding.colwidth(tag))
658 rev = ui.label('%s:%s' % (rev, hexfunc(hn)), 'log.changeset')
658 rev = ui.label('%s:%s' % (rev, hexfunc(hn)), 'log.changeset')
659 tag = ui.label(tag, label)
659 tag = ui.label(tag, label)
660 ui.write("%s %s%s\n" % (tag, rev, notice))
660 ui.write("%s %s%s\n" % (tag, rev, notice))
661
661
662 def bundle(ui, repo, fname, dest=None, **opts):
662 def bundle(ui, repo, fname, dest=None, **opts):
663 """create a changegroup file
663 """create a changegroup file
664
664
665 Generate a compressed changegroup file collecting changesets not
665 Generate a compressed changegroup file collecting changesets not
666 known to be in another repository.
666 known to be in another repository.
667
667
668 If you omit the destination repository, then hg assumes the
668 If you omit the destination repository, then hg assumes the
669 destination will have all the nodes you specify with --base
669 destination will have all the nodes you specify with --base
670 parameters. To create a bundle containing all changesets, use
670 parameters. To create a bundle containing all changesets, use
671 -a/--all (or --base null).
671 -a/--all (or --base null).
672
672
673 You can change compression method with the -t/--type option.
673 You can change compression method with the -t/--type option.
674 The available compression methods are: none, bzip2, and
674 The available compression methods are: none, bzip2, and
675 gzip (by default, bundles are compressed using bzip2).
675 gzip (by default, bundles are compressed using bzip2).
676
676
677 The bundle file can then be transferred using conventional means
677 The bundle file can then be transferred using conventional means
678 and applied to another repository with the unbundle or pull
678 and applied to another repository with the unbundle or pull
679 command. This is useful when direct push and pull are not
679 command. This is useful when direct push and pull are not
680 available or when exporting an entire repository is undesirable.
680 available or when exporting an entire repository is undesirable.
681
681
682 Applying bundles preserves all changeset contents including
682 Applying bundles preserves all changeset contents including
683 permissions, copy/rename information, and revision history.
683 permissions, copy/rename information, and revision history.
684
684
685 Returns 0 on success, 1 if no changes found.
685 Returns 0 on success, 1 if no changes found.
686 """
686 """
687 revs = None
687 revs = None
688 if 'rev' in opts:
688 if 'rev' in opts:
689 revs = cmdutil.revrange(repo, opts['rev'])
689 revs = cmdutil.revrange(repo, opts['rev'])
690
690
691 if opts.get('all'):
691 if opts.get('all'):
692 base = ['null']
692 base = ['null']
693 else:
693 else:
694 base = cmdutil.revrange(repo, opts.get('base'))
694 base = cmdutil.revrange(repo, opts.get('base'))
695 if base:
695 if base:
696 if dest:
696 if dest:
697 raise util.Abort(_("--base is incompatible with specifying "
697 raise util.Abort(_("--base is incompatible with specifying "
698 "a destination"))
698 "a destination"))
699 common = [repo.lookup(rev) for rev in base]
699 common = [repo.lookup(rev) for rev in base]
700 else:
700 else:
701 dest = ui.expandpath(dest or 'default-push', dest or 'default')
701 dest = ui.expandpath(dest or 'default-push', dest or 'default')
702 dest, branches = hg.parseurl(dest, opts.get('branch'))
702 dest, branches = hg.parseurl(dest, opts.get('branch'))
703 other = hg.repository(hg.remoteui(repo, opts), dest)
703 other = hg.repository(hg.remoteui(repo, opts), dest)
704 revs, checkout = hg.addbranchrevs(repo, other, branches, revs)
704 revs, checkout = hg.addbranchrevs(repo, other, branches, revs)
705 inc = discovery.findcommonincoming(repo, other, force=opts.get('force'))
705 inc = discovery.findcommonincoming(repo, other, force=opts.get('force'))
706 common, _anyinc, _heads = inc
706 common, _anyinc, _heads = inc
707
707
708 nodes = revs and map(repo.lookup, revs) or revs
708 nodes = revs and map(repo.lookup, revs) or revs
709 cg = repo.getbundle('bundle', common=common, heads=nodes)
709 cg = repo.getbundle('bundle', common=common, heads=nodes)
710 if not cg:
710 if not cg:
711 ui.status(_("no changes found\n"))
711 ui.status(_("no changes found\n"))
712 return 1
712 return 1
713
713
714 bundletype = opts.get('type', 'bzip2').lower()
714 bundletype = opts.get('type', 'bzip2').lower()
715 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
715 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
716 bundletype = btypes.get(bundletype)
716 bundletype = btypes.get(bundletype)
717 if bundletype not in changegroup.bundletypes:
717 if bundletype not in changegroup.bundletypes:
718 raise util.Abort(_('unknown bundle type specified with --type'))
718 raise util.Abort(_('unknown bundle type specified with --type'))
719
719
720 changegroup.writebundle(cg, fname, bundletype)
720 changegroup.writebundle(cg, fname, bundletype)
721
721
722 def cat(ui, repo, file1, *pats, **opts):
722 def cat(ui, repo, file1, *pats, **opts):
723 """output the current or given revision of files
723 """output the current or given revision of files
724
724
725 Print the specified files as they were at the given revision. If
725 Print the specified files as they were at the given revision. If
726 no revision is given, the parent of the working directory is used,
726 no revision is given, the parent of the working directory is used,
727 or tip if no revision is checked out.
727 or tip if no revision is checked out.
728
728
729 Output may be to a file, in which case the name of the file is
729 Output may be to a file, in which case the name of the file is
730 given using a format string. The formatting rules are the same as
730 given using a format string. The formatting rules are the same as
731 for the export command, with the following additions:
731 for the export command, with the following additions:
732
732
733 :``%s``: basename of file being printed
733 :``%s``: basename of file being printed
734 :``%d``: dirname of file being printed, or '.' if in repository root
734 :``%d``: dirname of file being printed, or '.' if in repository root
735 :``%p``: root-relative path name of file being printed
735 :``%p``: root-relative path name of file being printed
736
736
737 Returns 0 on success.
737 Returns 0 on success.
738 """
738 """
739 ctx = cmdutil.revsingle(repo, opts.get('rev'))
739 ctx = cmdutil.revsingle(repo, opts.get('rev'))
740 err = 1
740 err = 1
741 m = cmdutil.match(repo, (file1,) + pats, opts)
741 m = cmdutil.match(repo, (file1,) + pats, opts)
742 for abs in ctx.walk(m):
742 for abs in ctx.walk(m):
743 fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs)
743 fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs)
744 data = ctx[abs].data()
744 data = ctx[abs].data()
745 if opts.get('decode'):
745 if opts.get('decode'):
746 data = repo.wwritedata(abs, data)
746 data = repo.wwritedata(abs, data)
747 fp.write(data)
747 fp.write(data)
748 fp.close()
748 fp.close()
749 err = 0
749 err = 0
750 return err
750 return err
751
751
752 def clone(ui, source, dest=None, **opts):
752 def clone(ui, source, dest=None, **opts):
753 """make a copy of an existing repository
753 """make a copy of an existing repository
754
754
755 Create a copy of an existing repository in a new directory.
755 Create a copy of an existing repository in a new directory.
756
756
757 If no destination directory name is specified, it defaults to the
757 If no destination directory name is specified, it defaults to the
758 basename of the source.
758 basename of the source.
759
759
760 The location of the source is added to the new repository's
760 The location of the source is added to the new repository's
761 ``.hg/hgrc`` file, as the default to be used for future pulls.
761 ``.hg/hgrc`` file, as the default to be used for future pulls.
762
762
763 See :hg:`help urls` for valid source format details.
763 See :hg:`help urls` for valid source format details.
764
764
765 It is possible to specify an ``ssh://`` URL as the destination, but no
765 It is possible to specify an ``ssh://`` URL as the destination, but no
766 ``.hg/hgrc`` and working directory will be created on the remote side.
766 ``.hg/hgrc`` and working directory will be created on the remote side.
767 Please see :hg:`help urls` for important details about ``ssh://`` URLs.
767 Please see :hg:`help urls` for important details about ``ssh://`` URLs.
768
768
769 A set of changesets (tags, or branch names) to pull may be specified
769 A set of changesets (tags, or branch names) to pull may be specified
770 by listing each changeset (tag, or branch name) with -r/--rev.
770 by listing each changeset (tag, or branch name) with -r/--rev.
771 If -r/--rev is used, the cloned repository will contain only a subset
771 If -r/--rev is used, the cloned repository will contain only a subset
772 of the changesets of the source repository. Only the set of changesets
772 of the changesets of the source repository. Only the set of changesets
773 defined by all -r/--rev options (including all their ancestors)
773 defined by all -r/--rev options (including all their ancestors)
774 will be pulled into the destination repository.
774 will be pulled into the destination repository.
775 No subsequent changesets (including subsequent tags) will be present
775 No subsequent changesets (including subsequent tags) will be present
776 in the destination.
776 in the destination.
777
777
778 Using -r/--rev (or 'clone src#rev dest') implies --pull, even for
778 Using -r/--rev (or 'clone src#rev dest') implies --pull, even for
779 local source repositories.
779 local source repositories.
780
780
781 For efficiency, hardlinks are used for cloning whenever the source
781 For efficiency, hardlinks are used for cloning whenever the source
782 and destination are on the same filesystem (note this applies only
782 and destination are on the same filesystem (note this applies only
783 to the repository data, not to the working directory). Some
783 to the repository data, not to the working directory). Some
784 filesystems, such as AFS, implement hardlinking incorrectly, but
784 filesystems, such as AFS, implement hardlinking incorrectly, but
785 do not report errors. In these cases, use the --pull option to
785 do not report errors. In these cases, use the --pull option to
786 avoid hardlinking.
786 avoid hardlinking.
787
787
788 In some cases, you can clone repositories and the working directory
788 In some cases, you can clone repositories and the working directory
789 using full hardlinks with ::
789 using full hardlinks with ::
790
790
791 $ cp -al REPO REPOCLONE
791 $ cp -al REPO REPOCLONE
792
792
793 This is the fastest way to clone, but it is not always safe. The
793 This is the fastest way to clone, but it is not always safe. The
794 operation is not atomic (making sure REPO is not modified during
794 operation is not atomic (making sure REPO is not modified during
795 the operation is up to you) and you have to make sure your editor
795 the operation is up to you) and you have to make sure your editor
796 breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
796 breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
797 this is not compatible with certain extensions that place their
797 this is not compatible with certain extensions that place their
798 metadata under the .hg directory, such as mq.
798 metadata under the .hg directory, such as mq.
799
799
800 Mercurial will update the working directory to the first applicable
800 Mercurial will update the working directory to the first applicable
801 revision from this list:
801 revision from this list:
802
802
803 a) null if -U or the source repository has no changesets
803 a) null if -U or the source repository has no changesets
804 b) if -u . and the source repository is local, the first parent of
804 b) if -u . and the source repository is local, the first parent of
805 the source repository's working directory
805 the source repository's working directory
806 c) the changeset specified with -u (if a branch name, this means the
806 c) the changeset specified with -u (if a branch name, this means the
807 latest head of that branch)
807 latest head of that branch)
808 d) the changeset specified with -r
808 d) the changeset specified with -r
809 e) the tipmost head specified with -b
809 e) the tipmost head specified with -b
810 f) the tipmost head specified with the url#branch source syntax
810 f) the tipmost head specified with the url#branch source syntax
811 g) the tipmost head of the default branch
811 g) the tipmost head of the default branch
812 h) tip
812 h) tip
813
813
814 Returns 0 on success.
814 Returns 0 on success.
815 """
815 """
816 if opts.get('noupdate') and opts.get('updaterev'):
816 if opts.get('noupdate') and opts.get('updaterev'):
817 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
817 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
818
818
819 r = hg.clone(hg.remoteui(ui, opts), source, dest,
819 r = hg.clone(hg.remoteui(ui, opts), source, dest,
820 pull=opts.get('pull'),
820 pull=opts.get('pull'),
821 stream=opts.get('uncompressed'),
821 stream=opts.get('uncompressed'),
822 rev=opts.get('rev'),
822 rev=opts.get('rev'),
823 update=opts.get('updaterev') or not opts.get('noupdate'),
823 update=opts.get('updaterev') or not opts.get('noupdate'),
824 branch=opts.get('branch'))
824 branch=opts.get('branch'))
825
825
826 return r is None
826 return r is None
827
827
828 def commit(ui, repo, *pats, **opts):
828 def commit(ui, repo, *pats, **opts):
829 """commit the specified files or all outstanding changes
829 """commit the specified files or all outstanding changes
830
830
831 Commit changes to the given files into the repository. Unlike a
831 Commit changes to the given files into the repository. Unlike a
832 centralized SCM, this operation is a local operation. See
832 centralized SCM, this operation is a local operation. See
833 :hg:`push` for a way to actively distribute your changes.
833 :hg:`push` for a way to actively distribute your changes.
834
834
835 If a list of files is omitted, all changes reported by :hg:`status`
835 If a list of files is omitted, all changes reported by :hg:`status`
836 will be committed.
836 will be committed.
837
837
838 If you are committing the result of a merge, do not provide any
838 If you are committing the result of a merge, do not provide any
839 filenames or -I/-X filters.
839 filenames or -I/-X filters.
840
840
841 If no commit message is specified, Mercurial starts your
841 If no commit message is specified, Mercurial starts your
842 configured editor where you can enter a message. In case your
842 configured editor where you can enter a message. In case your
843 commit fails, you will find a backup of your message in
843 commit fails, you will find a backup of your message in
844 ``.hg/last-message.txt``.
844 ``.hg/last-message.txt``.
845
845
846 See :hg:`help dates` for a list of formats valid for -d/--date.
846 See :hg:`help dates` for a list of formats valid for -d/--date.
847
847
848 Returns 0 on success, 1 if nothing changed.
848 Returns 0 on success, 1 if nothing changed.
849 """
849 """
850 extra = {}
850 extra = {}
851 if opts.get('close_branch'):
851 if opts.get('close_branch'):
852 if repo['.'].node() not in repo.branchheads():
852 if repo['.'].node() not in repo.branchheads():
853 # The topo heads set is included in the branch heads set of the
853 # The topo heads set is included in the branch heads set of the
854 # current branch, so it's sufficient to test branchheads
854 # current branch, so it's sufficient to test branchheads
855 raise util.Abort(_('can only close branch heads'))
855 raise util.Abort(_('can only close branch heads'))
856 extra['close'] = 1
856 extra['close'] = 1
857 e = cmdutil.commiteditor
857 e = cmdutil.commiteditor
858 if opts.get('force_editor'):
858 if opts.get('force_editor'):
859 e = cmdutil.commitforceeditor
859 e = cmdutil.commitforceeditor
860
860
861 def commitfunc(ui, repo, message, match, opts):
861 def commitfunc(ui, repo, message, match, opts):
862 return repo.commit(message, opts.get('user'), opts.get('date'), match,
862 return repo.commit(message, opts.get('user'), opts.get('date'), match,
863 editor=e, extra=extra)
863 editor=e, extra=extra)
864
864
865 branch = repo[None].branch()
865 branch = repo[None].branch()
866 bheads = repo.branchheads(branch)
866 bheads = repo.branchheads(branch)
867
867
868 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
868 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
869 if not node:
869 if not node:
870 stat = repo.status(match=cmdutil.match(repo, pats, opts))
870 stat = repo.status(match=cmdutil.match(repo, pats, opts))
871 if stat[3]:
871 if stat[3]:
872 ui.status(_("nothing changed (%d missing files, see 'hg status')\n")
872 ui.status(_("nothing changed (%d missing files, see 'hg status')\n")
873 % len(stat[3]))
873 % len(stat[3]))
874 else:
874 else:
875 ui.status(_("nothing changed\n"))
875 ui.status(_("nothing changed\n"))
876 return 1
876 return 1
877
877
878 ctx = repo[node]
878 ctx = repo[node]
879 parents = ctx.parents()
879 parents = ctx.parents()
880
880
881 if bheads and not [x for x in parents
881 if bheads and not [x for x in parents
882 if x.node() in bheads and x.branch() == branch]:
882 if x.node() in bheads and x.branch() == branch]:
883 ui.status(_('created new head\n'))
883 ui.status(_('created new head\n'))
884 # The message is not printed for initial roots. For the other
884 # The message is not printed for initial roots. For the other
885 # changesets, it is printed in the following situations:
885 # changesets, it is printed in the following situations:
886 #
886 #
887 # Par column: for the 2 parents with ...
887 # Par column: for the 2 parents with ...
888 # N: null or no parent
888 # N: null or no parent
889 # B: parent is on another named branch
889 # B: parent is on another named branch
890 # C: parent is a regular non head changeset
890 # C: parent is a regular non head changeset
891 # H: parent was a branch head of the current branch
891 # H: parent was a branch head of the current branch
892 # Msg column: whether we print "created new head" message
892 # Msg column: whether we print "created new head" message
893 # In the following, it is assumed that there already exists some
893 # In the following, it is assumed that there already exists some
894 # initial branch heads of the current branch, otherwise nothing is
894 # initial branch heads of the current branch, otherwise nothing is
895 # printed anyway.
895 # printed anyway.
896 #
896 #
897 # Par Msg Comment
897 # Par Msg Comment
898 # NN y additional topo root
898 # NN y additional topo root
899 #
899 #
900 # BN y additional branch root
900 # BN y additional branch root
901 # CN y additional topo head
901 # CN y additional topo head
902 # HN n usual case
902 # HN n usual case
903 #
903 #
904 # BB y weird additional branch root
904 # BB y weird additional branch root
905 # CB y branch merge
905 # CB y branch merge
906 # HB n merge with named branch
906 # HB n merge with named branch
907 #
907 #
908 # CC y additional head from merge
908 # CC y additional head from merge
909 # CH n merge with a head
909 # CH n merge with a head
910 #
910 #
911 # HH n head merge: head count decreases
911 # HH n head merge: head count decreases
912
912
913 if not opts.get('close_branch'):
913 if not opts.get('close_branch'):
914 for r in parents:
914 for r in parents:
915 if r.extra().get('close') and r.branch() == branch:
915 if r.extra().get('close') and r.branch() == branch:
916 ui.status(_('reopening closed branch head %d\n') % r)
916 ui.status(_('reopening closed branch head %d\n') % r)
917
917
918 if ui.debugflag:
918 if ui.debugflag:
919 ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex()))
919 ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx.hex()))
920 elif ui.verbose:
920 elif ui.verbose:
921 ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx))
921 ui.write(_('committed changeset %d:%s\n') % (int(ctx), ctx))
922
922
923 def copy(ui, repo, *pats, **opts):
923 def copy(ui, repo, *pats, **opts):
924 """mark files as copied for the next commit
924 """mark files as copied for the next commit
925
925
926 Mark dest as having copies of source files. If dest is a
926 Mark dest as having copies of source files. If dest is a
927 directory, copies are put in that directory. If dest is a file,
927 directory, copies are put in that directory. If dest is a file,
928 the source must be a single file.
928 the source must be a single file.
929
929
930 By default, this command copies the contents of files as they
930 By default, this command copies the contents of files as they
931 exist in the working directory. If invoked with -A/--after, the
931 exist in the working directory. If invoked with -A/--after, the
932 operation is recorded, but no copying is performed.
932 operation is recorded, but no copying is performed.
933
933
934 This command takes effect with the next commit. To undo a copy
934 This command takes effect with the next commit. To undo a copy
935 before that, see :hg:`revert`.
935 before that, see :hg:`revert`.
936
936
937 Returns 0 on success, 1 if errors are encountered.
937 Returns 0 on success, 1 if errors are encountered.
938 """
938 """
939 wlock = repo.wlock(False)
939 wlock = repo.wlock(False)
940 try:
940 try:
941 return cmdutil.copy(ui, repo, pats, opts)
941 return cmdutil.copy(ui, repo, pats, opts)
942 finally:
942 finally:
943 wlock.release()
943 wlock.release()
944
944
945 def debugancestor(ui, repo, *args):
945 def debugancestor(ui, repo, *args):
946 """find the ancestor revision of two revisions in a given index"""
946 """find the ancestor revision of two revisions in a given index"""
947 if len(args) == 3:
947 if len(args) == 3:
948 index, rev1, rev2 = args
948 index, rev1, rev2 = args
949 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
949 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
950 lookup = r.lookup
950 lookup = r.lookup
951 elif len(args) == 2:
951 elif len(args) == 2:
952 if not repo:
952 if not repo:
953 raise util.Abort(_("there is no Mercurial repository here "
953 raise util.Abort(_("there is no Mercurial repository here "
954 "(.hg not found)"))
954 "(.hg not found)"))
955 rev1, rev2 = args
955 rev1, rev2 = args
956 r = repo.changelog
956 r = repo.changelog
957 lookup = repo.lookup
957 lookup = repo.lookup
958 else:
958 else:
959 raise util.Abort(_('either two or three arguments required'))
959 raise util.Abort(_('either two or three arguments required'))
960 a = r.ancestor(lookup(rev1), lookup(rev2))
960 a = r.ancestor(lookup(rev1), lookup(rev2))
961 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
961 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
962
962
963 def debugbuilddag(ui, repo, text,
963 def debugbuilddag(ui, repo, text,
964 mergeable_file=False,
964 mergeable_file=False,
965 appended_file=False,
966 overwritten_file=False,
965 overwritten_file=False,
967 new_file=False):
966 new_file=False):
968 """builds a repo with a given dag from scratch in the current empty repo
967 """builds a repo with a given dag from scratch in the current empty repo
969
968
970 Elements:
969 Elements:
971
970
972 - "+n" is a linear run of n nodes based on the current default parent
971 - "+n" is a linear run of n nodes based on the current default parent
973 - "." is a single node based on the current default parent
972 - "." is a single node based on the current default parent
974 - "$" resets the default parent to null (implied at the start);
973 - "$" resets the default parent to null (implied at the start);
975 otherwise the default parent is always the last node created
974 otherwise the default parent is always the last node created
976 - "<p" sets the default parent to the backref p
975 - "<p" sets the default parent to the backref p
977 - "*p" is a fork at parent p, which is a backref
976 - "*p" is a fork at parent p, which is a backref
978 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
977 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
979 - "/p2" is a merge of the preceding node and p2
978 - "/p2" is a merge of the preceding node and p2
980 - ":tag" defines a local tag for the preceding node
979 - ":tag" defines a local tag for the preceding node
981 - "@branch" sets the named branch for subsequent nodes
980 - "@branch" sets the named branch for subsequent nodes
982 - "!command" runs the command using your shell
983 - "!!my command\\n" is like "!", but to the end of the line
984 - "#...\\n" is a comment up to the end of the line
981 - "#...\\n" is a comment up to the end of the line
985
982
986 Whitespace between the above elements is ignored.
983 Whitespace between the above elements is ignored.
987
984
988 A backref is either
985 A backref is either
989
986
990 - a number n, which references the node curr-n, where curr is the current
987 - a number n, which references the node curr-n, where curr is the current
991 node, or
988 node, or
992 - the name of a local tag you placed earlier using ":tag", or
989 - the name of a local tag you placed earlier using ":tag", or
993 - empty to denote the default parent.
990 - empty to denote the default parent.
994
991
995 All string valued-elements are either strictly alphanumeric, or must
992 All string valued-elements are either strictly alphanumeric, or must
996 be enclosed in double quotes ("..."), with "\\" as escape character.
993 be enclosed in double quotes ("..."), with "\\" as escape character.
997
998 Note that the --overwritten-file and --appended-file options imply the
999 use of "HGMERGE=internal:local" during DAG buildup.
1000 """
994 """
1001
995
1002 if not (mergeable_file or appended_file or overwritten_file or new_file):
996 cl = repo.changelog
1003 raise util.Abort(_('need at least one of -m, -a, -o, -n'))
997 if len(cl) > 0:
1004
1005 if len(repo.changelog) > 0:
1006 raise util.Abort(_('repository is not empty'))
998 raise util.Abort(_('repository is not empty'))
1007
999
1008 if overwritten_file or appended_file:
1009 # we don't want to fail in merges during buildup
1010 os.environ['HGMERGE'] = 'internal:local'
1011
1012 def writefile(fname, text, fmode="wb"):
1013 f = open(fname, fmode)
1014 try:
1015 f.write(text)
1016 finally:
1017 f.close()
1018
1019 if mergeable_file:
1000 if mergeable_file:
1020 linesperrev = 2
1001 linesperrev = 2
1021 # determine number of revs in DAG
1002 # determine number of revs in DAG
1022 n = 0
1003 n = 0
1023 for type, data in dagparser.parsedag(text):
1004 for type, data in dagparser.parsedag(text):
1024 if type == 'n':
1005 if type == 'n':
1025 n += 1
1006 n += 1
1026 # make a file with k lines per rev
1007 # make a file with k lines per rev
1027 writefile("mf", "\n".join(str(i) for i in xrange(0, n * linesperrev))
1008 initialmergedlines = [str(i) for i in xrange(0, n * linesperrev)]
1028 + "\n")
1009 initialmergedlines.append("")
1029
1010
1030 at = -1
1011 tags = []
1031 atbranch = 'default'
1012
1032 for type, data in dagparser.parsedag(text):
1013 tr = repo.transaction("builddag")
1033 if type == 'n':
1014 try:
1034 ui.status('node %s\n' % str(data))
1015
1035 id, ps = data
1016 at = -1
1036 p1 = ps[0]
1017 atbranch = 'default'
1037 if p1 != at:
1018 nodeids = []
1038 update(ui, repo, node=str(p1), clean=True)
1019 for type, data in dagparser.parsedag(text):
1039 at = p1
1020 if type == 'n':
1040 if repo.dirstate.branch() != atbranch:
1021 ui.note('node %s\n' % str(data))
1041 branch(ui, repo, atbranch, force=True)
1022 id, ps = data
1042 if len(ps) > 1:
1023
1043 p2 = ps[1]
1024 files = []
1044 merge(ui, repo, node=p2)
1025 fctxs = {}
1045
1026
1046 if mergeable_file:
1027 p2 = None
1047 f = open("mf", "rb+")
1028 if mergeable_file:
1048 try:
1029 fn = "mf"
1049 lines = f.read().split("\n")
1030 p1 = repo[ps[0]]
1050 lines[id * linesperrev] += " r%i" % id
1031 if len(ps) > 1:
1051 f.seek(0)
1032 p2 = repo[ps[1]]
1052 f.write("\n".join(lines))
1033 pa = p1.ancestor(p2)
1053 finally:
1034 base, local, other = [x[fn].data() for x in pa, p1, p2]
1054 f.close()
1035 m3 = simplemerge.Merge3Text(base, local, other)
1055
1036 ml = [l.strip() for l in m3.merge_lines()]
1056 if appended_file:
1037 ml.append("")
1057 writefile("af", "r%i\n" % id, "ab")
1038 elif at > 0:
1058
1039 ml = p1[fn].data().split("\n")
1059 if overwritten_file:
1040 else:
1060 writefile("of", "r%i\n" % id)
1041 ml = initialmergedlines
1061
1042 ml[id * linesperrev] += " r%i" % id
1062 if new_file:
1043 mergedtext = "\n".join(ml)
1063 writefile("nf%i" % id, "r%i\n" % id)
1044 files.append(fn)
1064
1045 fctxs[fn] = context.memfilectx(fn, mergedtext)
1065 commit(ui, repo, addremove=True, message="r%i" % id, date=(id, 0))
1046
1066 at = id
1047 if overwritten_file:
1067 elif type == 'l':
1048 fn = "of"
1068 id, name = data
1049 files.append(fn)
1069 ui.status('tag %s\n' % name)
1050 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1070 tag(ui, repo, name, local=True)
1051
1071 elif type == 'a':
1052 if new_file:
1072 ui.status('branch %s\n' % data)
1053 fn = "nf%i" % id
1073 atbranch = data
1054 files.append(fn)
1074 elif type in 'cC':
1055 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1075 r = util.system(data, cwd=repo.root)
1056 if len(ps) > 1:
1076 if r:
1057 if not p2:
1077 desc, r = util.explain_exit(r)
1058 p2 = repo[ps[1]]
1078 raise util.Abort(_('%s command %s') % (data, desc))
1059 for fn in p2:
1060 if fn.startswith("nf"):
1061 files.append(fn)
1062 fctxs[fn] = p2[fn]
1063
1064 def fctxfn(repo, cx, path):
1065 return fctxs.get(path)
1066
1067 if len(ps) == 0 or ps[0] < 0:
1068 pars = [None, None]
1069 elif len(ps) == 1:
1070 pars = [nodeids[ps[0]], None]
1071 else:
1072 pars = [nodeids[p] for p in ps]
1073 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1074 date=(id, 0),
1075 user="debugbuilddag",
1076 extra={'branch': atbranch})
1077 nodeid = repo.commitctx(cx)
1078 nodeids.append(nodeid)
1079 at = id
1080 elif type == 'l':
1081 id, name = data
1082 ui.note('tag %s\n' % name)
1083 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1084 elif type == 'a':
1085 ui.note('branch %s\n' % data)
1086 atbranch = data
1087 tr.close()
1088 finally:
1089 tr.release()
1090
1091 if tags:
1092 tagsf = repo.opener("localtags", "w")
1093 try:
1094 tagsf.write("".join(tags))
1095 finally:
1096 tagsf.close()
1079
1097
1080 def debugcommands(ui, cmd='', *args):
1098 def debugcommands(ui, cmd='', *args):
1081 """list all available commands and options"""
1099 """list all available commands and options"""
1082 for cmd, vals in sorted(table.iteritems()):
1100 for cmd, vals in sorted(table.iteritems()):
1083 cmd = cmd.split('|')[0].strip('^')
1101 cmd = cmd.split('|')[0].strip('^')
1084 opts = ', '.join([i[1] for i in vals[1]])
1102 opts = ', '.join([i[1] for i in vals[1]])
1085 ui.write('%s: %s\n' % (cmd, opts))
1103 ui.write('%s: %s\n' % (cmd, opts))
1086
1104
1087 def debugcomplete(ui, cmd='', **opts):
1105 def debugcomplete(ui, cmd='', **opts):
1088 """returns the completion list associated with the given command"""
1106 """returns the completion list associated with the given command"""
1089
1107
1090 if opts.get('options'):
1108 if opts.get('options'):
1091 options = []
1109 options = []
1092 otables = [globalopts]
1110 otables = [globalopts]
1093 if cmd:
1111 if cmd:
1094 aliases, entry = cmdutil.findcmd(cmd, table, False)
1112 aliases, entry = cmdutil.findcmd(cmd, table, False)
1095 otables.append(entry[1])
1113 otables.append(entry[1])
1096 for t in otables:
1114 for t in otables:
1097 for o in t:
1115 for o in t:
1098 if "(DEPRECATED)" in o[3]:
1116 if "(DEPRECATED)" in o[3]:
1099 continue
1117 continue
1100 if o[0]:
1118 if o[0]:
1101 options.append('-%s' % o[0])
1119 options.append('-%s' % o[0])
1102 options.append('--%s' % o[1])
1120 options.append('--%s' % o[1])
1103 ui.write("%s\n" % "\n".join(options))
1121 ui.write("%s\n" % "\n".join(options))
1104 return
1122 return
1105
1123
1106 cmdlist = cmdutil.findpossible(cmd, table)
1124 cmdlist = cmdutil.findpossible(cmd, table)
1107 if ui.verbose:
1125 if ui.verbose:
1108 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1126 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1109 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1127 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1110
1128
1111 def debugfsinfo(ui, path = "."):
1129 def debugfsinfo(ui, path = "."):
1112 """show information detected about current filesystem"""
1130 """show information detected about current filesystem"""
1113 open('.debugfsinfo', 'w').write('')
1131 open('.debugfsinfo', 'w').write('')
1114 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
1132 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
1115 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
1133 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
1116 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
1134 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
1117 and 'yes' or 'no'))
1135 and 'yes' or 'no'))
1118 os.unlink('.debugfsinfo')
1136 os.unlink('.debugfsinfo')
1119
1137
1120 def debugrebuildstate(ui, repo, rev="tip"):
1138 def debugrebuildstate(ui, repo, rev="tip"):
1121 """rebuild the dirstate as it would look like for the given revision"""
1139 """rebuild the dirstate as it would look like for the given revision"""
1122 ctx = cmdutil.revsingle(repo, rev)
1140 ctx = cmdutil.revsingle(repo, rev)
1123 wlock = repo.wlock()
1141 wlock = repo.wlock()
1124 try:
1142 try:
1125 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
1143 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
1126 finally:
1144 finally:
1127 wlock.release()
1145 wlock.release()
1128
1146
1129 def debugcheckstate(ui, repo):
1147 def debugcheckstate(ui, repo):
1130 """validate the correctness of the current dirstate"""
1148 """validate the correctness of the current dirstate"""
1131 parent1, parent2 = repo.dirstate.parents()
1149 parent1, parent2 = repo.dirstate.parents()
1132 m1 = repo[parent1].manifest()
1150 m1 = repo[parent1].manifest()
1133 m2 = repo[parent2].manifest()
1151 m2 = repo[parent2].manifest()
1134 errors = 0
1152 errors = 0
1135 for f in repo.dirstate:
1153 for f in repo.dirstate:
1136 state = repo.dirstate[f]
1154 state = repo.dirstate[f]
1137 if state in "nr" and f not in m1:
1155 if state in "nr" and f not in m1:
1138 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1156 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1139 errors += 1
1157 errors += 1
1140 if state in "a" and f in m1:
1158 if state in "a" and f in m1:
1141 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1159 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1142 errors += 1
1160 errors += 1
1143 if state in "m" and f not in m1 and f not in m2:
1161 if state in "m" and f not in m1 and f not in m2:
1144 ui.warn(_("%s in state %s, but not in either manifest\n") %
1162 ui.warn(_("%s in state %s, but not in either manifest\n") %
1145 (f, state))
1163 (f, state))
1146 errors += 1
1164 errors += 1
1147 for f in m1:
1165 for f in m1:
1148 state = repo.dirstate[f]
1166 state = repo.dirstate[f]
1149 if state not in "nrm":
1167 if state not in "nrm":
1150 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1168 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1151 errors += 1
1169 errors += 1
1152 if errors:
1170 if errors:
1153 error = _(".hg/dirstate inconsistent with current parent's manifest")
1171 error = _(".hg/dirstate inconsistent with current parent's manifest")
1154 raise util.Abort(error)
1172 raise util.Abort(error)
1155
1173
1156 def showconfig(ui, repo, *values, **opts):
1174 def showconfig(ui, repo, *values, **opts):
1157 """show combined config settings from all hgrc files
1175 """show combined config settings from all hgrc files
1158
1176
1159 With no arguments, print names and values of all config items.
1177 With no arguments, print names and values of all config items.
1160
1178
1161 With one argument of the form section.name, print just the value
1179 With one argument of the form section.name, print just the value
1162 of that config item.
1180 of that config item.
1163
1181
1164 With multiple arguments, print names and values of all config
1182 With multiple arguments, print names and values of all config
1165 items with matching section names.
1183 items with matching section names.
1166
1184
1167 With --debug, the source (filename and line number) is printed
1185 With --debug, the source (filename and line number) is printed
1168 for each config item.
1186 for each config item.
1169
1187
1170 Returns 0 on success.
1188 Returns 0 on success.
1171 """
1189 """
1172
1190
1173 for f in scmutil.rcpath():
1191 for f in scmutil.rcpath():
1174 ui.debug(_('read config from: %s\n') % f)
1192 ui.debug(_('read config from: %s\n') % f)
1175 untrusted = bool(opts.get('untrusted'))
1193 untrusted = bool(opts.get('untrusted'))
1176 if values:
1194 if values:
1177 sections = [v for v in values if '.' not in v]
1195 sections = [v for v in values if '.' not in v]
1178 items = [v for v in values if '.' in v]
1196 items = [v for v in values if '.' in v]
1179 if len(items) > 1 or items and sections:
1197 if len(items) > 1 or items and sections:
1180 raise util.Abort(_('only one config item permitted'))
1198 raise util.Abort(_('only one config item permitted'))
1181 for section, name, value in ui.walkconfig(untrusted=untrusted):
1199 for section, name, value in ui.walkconfig(untrusted=untrusted):
1182 value = str(value).replace('\n', '\\n')
1200 value = str(value).replace('\n', '\\n')
1183 sectname = section + '.' + name
1201 sectname = section + '.' + name
1184 if values:
1202 if values:
1185 for v in values:
1203 for v in values:
1186 if v == section:
1204 if v == section:
1187 ui.debug('%s: ' %
1205 ui.debug('%s: ' %
1188 ui.configsource(section, name, untrusted))
1206 ui.configsource(section, name, untrusted))
1189 ui.write('%s=%s\n' % (sectname, value))
1207 ui.write('%s=%s\n' % (sectname, value))
1190 elif v == sectname:
1208 elif v == sectname:
1191 ui.debug('%s: ' %
1209 ui.debug('%s: ' %
1192 ui.configsource(section, name, untrusted))
1210 ui.configsource(section, name, untrusted))
1193 ui.write(value, '\n')
1211 ui.write(value, '\n')
1194 else:
1212 else:
1195 ui.debug('%s: ' %
1213 ui.debug('%s: ' %
1196 ui.configsource(section, name, untrusted))
1214 ui.configsource(section, name, untrusted))
1197 ui.write('%s=%s\n' % (sectname, value))
1215 ui.write('%s=%s\n' % (sectname, value))
1198
1216
1199 def debugknown(ui, repopath, *ids, **opts):
1217 def debugknown(ui, repopath, *ids, **opts):
1200 """test whether node ids are known to a repo
1218 """test whether node ids are known to a repo
1201
1219
1202 Every ID must be a full-length hex node id string. Returns a list of 0s and 1s
1220 Every ID must be a full-length hex node id string. Returns a list of 0s and 1s
1203 indicating unknown/known.
1221 indicating unknown/known.
1204 """
1222 """
1205 repo = hg.repository(ui, repopath)
1223 repo = hg.repository(ui, repopath)
1206 if not repo.capable('known'):
1224 if not repo.capable('known'):
1207 raise util.Abort("known() not supported by target repository")
1225 raise util.Abort("known() not supported by target repository")
1208 flags = repo.known([bin(s) for s in ids])
1226 flags = repo.known([bin(s) for s in ids])
1209 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
1227 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
1210
1228
1211 def debugbundle(ui, bundlepath, all=None, **opts):
1229 def debugbundle(ui, bundlepath, all=None, **opts):
1212 """lists the contents of a bundle"""
1230 """lists the contents of a bundle"""
1213 f = url.open(ui, bundlepath)
1231 f = url.open(ui, bundlepath)
1214 try:
1232 try:
1215 gen = changegroup.readbundle(f, bundlepath)
1233 gen = changegroup.readbundle(f, bundlepath)
1216 if all:
1234 if all:
1217 ui.write("format: id, p1, p2, cset, delta base, len(delta)\n")
1235 ui.write("format: id, p1, p2, cset, delta base, len(delta)\n")
1218
1236
1219 def showchunks(named):
1237 def showchunks(named):
1220 ui.write("\n%s\n" % named)
1238 ui.write("\n%s\n" % named)
1221 chain = None
1239 chain = None
1222 while 1:
1240 while 1:
1223 chunkdata = gen.deltachunk(chain)
1241 chunkdata = gen.deltachunk(chain)
1224 if not chunkdata:
1242 if not chunkdata:
1225 break
1243 break
1226 node = chunkdata['node']
1244 node = chunkdata['node']
1227 p1 = chunkdata['p1']
1245 p1 = chunkdata['p1']
1228 p2 = chunkdata['p2']
1246 p2 = chunkdata['p2']
1229 cs = chunkdata['cs']
1247 cs = chunkdata['cs']
1230 deltabase = chunkdata['deltabase']
1248 deltabase = chunkdata['deltabase']
1231 delta = chunkdata['delta']
1249 delta = chunkdata['delta']
1232 ui.write("%s %s %s %s %s %s\n" %
1250 ui.write("%s %s %s %s %s %s\n" %
1233 (hex(node), hex(p1), hex(p2),
1251 (hex(node), hex(p1), hex(p2),
1234 hex(cs), hex(deltabase), len(delta)))
1252 hex(cs), hex(deltabase), len(delta)))
1235 chain = node
1253 chain = node
1236
1254
1237 chunkdata = gen.changelogheader()
1255 chunkdata = gen.changelogheader()
1238 showchunks("changelog")
1256 showchunks("changelog")
1239 chunkdata = gen.manifestheader()
1257 chunkdata = gen.manifestheader()
1240 showchunks("manifest")
1258 showchunks("manifest")
1241 while 1:
1259 while 1:
1242 chunkdata = gen.filelogheader()
1260 chunkdata = gen.filelogheader()
1243 if not chunkdata:
1261 if not chunkdata:
1244 break
1262 break
1245 fname = chunkdata['filename']
1263 fname = chunkdata['filename']
1246 showchunks(fname)
1264 showchunks(fname)
1247 else:
1265 else:
1248 chunkdata = gen.changelogheader()
1266 chunkdata = gen.changelogheader()
1249 chain = None
1267 chain = None
1250 while 1:
1268 while 1:
1251 chunkdata = gen.deltachunk(chain)
1269 chunkdata = gen.deltachunk(chain)
1252 if not chunkdata:
1270 if not chunkdata:
1253 break
1271 break
1254 node = chunkdata['node']
1272 node = chunkdata['node']
1255 ui.write("%s\n" % hex(node))
1273 ui.write("%s\n" % hex(node))
1256 chain = node
1274 chain = node
1257 finally:
1275 finally:
1258 f.close()
1276 f.close()
1259
1277
1260 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
1278 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
1261 """retrieves a bundle from a repo
1279 """retrieves a bundle from a repo
1262
1280
1263 Every ID must be a full-length hex node id string. Saves the bundle to the
1281 Every ID must be a full-length hex node id string. Saves the bundle to the
1264 given file.
1282 given file.
1265 """
1283 """
1266 repo = hg.repository(ui, repopath)
1284 repo = hg.repository(ui, repopath)
1267 if not repo.capable('getbundle'):
1285 if not repo.capable('getbundle'):
1268 raise util.Abort("getbundle() not supported by target repository")
1286 raise util.Abort("getbundle() not supported by target repository")
1269 args = {}
1287 args = {}
1270 if common:
1288 if common:
1271 args['common'] = [bin(s) for s in common]
1289 args['common'] = [bin(s) for s in common]
1272 if head:
1290 if head:
1273 args['heads'] = [bin(s) for s in head]
1291 args['heads'] = [bin(s) for s in head]
1274 bundle = repo.getbundle('debug', **args)
1292 bundle = repo.getbundle('debug', **args)
1275
1293
1276 bundletype = opts.get('type', 'bzip2').lower()
1294 bundletype = opts.get('type', 'bzip2').lower()
1277 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1295 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1278 bundletype = btypes.get(bundletype)
1296 bundletype = btypes.get(bundletype)
1279 if bundletype not in changegroup.bundletypes:
1297 if bundletype not in changegroup.bundletypes:
1280 raise util.Abort(_('unknown bundle type specified with --type'))
1298 raise util.Abort(_('unknown bundle type specified with --type'))
1281 changegroup.writebundle(bundle, bundlepath, bundletype)
1299 changegroup.writebundle(bundle, bundlepath, bundletype)
1282
1300
1283 def debugpushkey(ui, repopath, namespace, *keyinfo):
1301 def debugpushkey(ui, repopath, namespace, *keyinfo):
1284 '''access the pushkey key/value protocol
1302 '''access the pushkey key/value protocol
1285
1303
1286 With two args, list the keys in the given namespace.
1304 With two args, list the keys in the given namespace.
1287
1305
1288 With five args, set a key to new if it currently is set to old.
1306 With five args, set a key to new if it currently is set to old.
1289 Reports success or failure.
1307 Reports success or failure.
1290 '''
1308 '''
1291
1309
1292 target = hg.repository(ui, repopath)
1310 target = hg.repository(ui, repopath)
1293 if keyinfo:
1311 if keyinfo:
1294 key, old, new = keyinfo
1312 key, old, new = keyinfo
1295 r = target.pushkey(namespace, key, old, new)
1313 r = target.pushkey(namespace, key, old, new)
1296 ui.status(str(r) + '\n')
1314 ui.status(str(r) + '\n')
1297 return not r
1315 return not r
1298 else:
1316 else:
1299 for k, v in target.listkeys(namespace).iteritems():
1317 for k, v in target.listkeys(namespace).iteritems():
1300 ui.write("%s\t%s\n" % (k.encode('string-escape'),
1318 ui.write("%s\t%s\n" % (k.encode('string-escape'),
1301 v.encode('string-escape')))
1319 v.encode('string-escape')))
1302
1320
1303 def debugrevspec(ui, repo, expr):
1321 def debugrevspec(ui, repo, expr):
1304 '''parse and apply a revision specification'''
1322 '''parse and apply a revision specification'''
1305 if ui.verbose:
1323 if ui.verbose:
1306 tree = revset.parse(expr)[0]
1324 tree = revset.parse(expr)[0]
1307 ui.note(tree, "\n")
1325 ui.note(tree, "\n")
1308 newtree = revset.findaliases(ui, tree)
1326 newtree = revset.findaliases(ui, tree)
1309 if newtree != tree:
1327 if newtree != tree:
1310 ui.note(newtree, "\n")
1328 ui.note(newtree, "\n")
1311 func = revset.match(ui, expr)
1329 func = revset.match(ui, expr)
1312 for c in func(repo, range(len(repo))):
1330 for c in func(repo, range(len(repo))):
1313 ui.write("%s\n" % c)
1331 ui.write("%s\n" % c)
1314
1332
1315 def debugsetparents(ui, repo, rev1, rev2=None):
1333 def debugsetparents(ui, repo, rev1, rev2=None):
1316 """manually set the parents of the current working directory
1334 """manually set the parents of the current working directory
1317
1335
1318 This is useful for writing repository conversion tools, but should
1336 This is useful for writing repository conversion tools, but should
1319 be used with care.
1337 be used with care.
1320
1338
1321 Returns 0 on success.
1339 Returns 0 on success.
1322 """
1340 """
1323
1341
1324 r1 = cmdutil.revsingle(repo, rev1).node()
1342 r1 = cmdutil.revsingle(repo, rev1).node()
1325 r2 = cmdutil.revsingle(repo, rev2, 'null').node()
1343 r2 = cmdutil.revsingle(repo, rev2, 'null').node()
1326
1344
1327 wlock = repo.wlock()
1345 wlock = repo.wlock()
1328 try:
1346 try:
1329 repo.dirstate.setparents(r1, r2)
1347 repo.dirstate.setparents(r1, r2)
1330 finally:
1348 finally:
1331 wlock.release()
1349 wlock.release()
1332
1350
1333 def debugstate(ui, repo, nodates=None, datesort=None):
1351 def debugstate(ui, repo, nodates=None, datesort=None):
1334 """show the contents of the current dirstate"""
1352 """show the contents of the current dirstate"""
1335 timestr = ""
1353 timestr = ""
1336 showdate = not nodates
1354 showdate = not nodates
1337 if datesort:
1355 if datesort:
1338 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
1356 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
1339 else:
1357 else:
1340 keyfunc = None # sort by filename
1358 keyfunc = None # sort by filename
1341 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
1359 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
1342 if showdate:
1360 if showdate:
1343 if ent[3] == -1:
1361 if ent[3] == -1:
1344 # Pad or slice to locale representation
1362 # Pad or slice to locale representation
1345 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
1363 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
1346 time.localtime(0)))
1364 time.localtime(0)))
1347 timestr = 'unset'
1365 timestr = 'unset'
1348 timestr = (timestr[:locale_len] +
1366 timestr = (timestr[:locale_len] +
1349 ' ' * (locale_len - len(timestr)))
1367 ' ' * (locale_len - len(timestr)))
1350 else:
1368 else:
1351 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
1369 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
1352 time.localtime(ent[3]))
1370 time.localtime(ent[3]))
1353 if ent[1] & 020000:
1371 if ent[1] & 020000:
1354 mode = 'lnk'
1372 mode = 'lnk'
1355 else:
1373 else:
1356 mode = '%3o' % (ent[1] & 0777)
1374 mode = '%3o' % (ent[1] & 0777)
1357 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
1375 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
1358 for f in repo.dirstate.copies():
1376 for f in repo.dirstate.copies():
1359 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
1377 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
1360
1378
1361 def debugsub(ui, repo, rev=None):
1379 def debugsub(ui, repo, rev=None):
1362 ctx = cmdutil.revsingle(repo, rev, None)
1380 ctx = cmdutil.revsingle(repo, rev, None)
1363 for k, v in sorted(ctx.substate.items()):
1381 for k, v in sorted(ctx.substate.items()):
1364 ui.write('path %s\n' % k)
1382 ui.write('path %s\n' % k)
1365 ui.write(' source %s\n' % v[0])
1383 ui.write(' source %s\n' % v[0])
1366 ui.write(' revision %s\n' % v[1])
1384 ui.write(' revision %s\n' % v[1])
1367
1385
1368 def debugdag(ui, repo, file_=None, *revs, **opts):
1386 def debugdag(ui, repo, file_=None, *revs, **opts):
1369 """format the changelog or an index DAG as a concise textual description
1387 """format the changelog or an index DAG as a concise textual description
1370
1388
1371 If you pass a revlog index, the revlog's DAG is emitted. If you list
1389 If you pass a revlog index, the revlog's DAG is emitted. If you list
1372 revision numbers, they get labelled in the output as rN.
1390 revision numbers, they get labelled in the output as rN.
1373
1391
1374 Otherwise, the changelog DAG of the current repo is emitted.
1392 Otherwise, the changelog DAG of the current repo is emitted.
1375 """
1393 """
1376 spaces = opts.get('spaces')
1394 spaces = opts.get('spaces')
1377 dots = opts.get('dots')
1395 dots = opts.get('dots')
1378 if file_:
1396 if file_:
1379 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1397 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1380 revs = set((int(r) for r in revs))
1398 revs = set((int(r) for r in revs))
1381 def events():
1399 def events():
1382 for r in rlog:
1400 for r in rlog:
1383 yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1)))
1401 yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1)))
1384 if r in revs:
1402 if r in revs:
1385 yield 'l', (r, "r%i" % r)
1403 yield 'l', (r, "r%i" % r)
1386 elif repo:
1404 elif repo:
1387 cl = repo.changelog
1405 cl = repo.changelog
1388 tags = opts.get('tags')
1406 tags = opts.get('tags')
1389 branches = opts.get('branches')
1407 branches = opts.get('branches')
1390 if tags:
1408 if tags:
1391 labels = {}
1409 labels = {}
1392 for l, n in repo.tags().items():
1410 for l, n in repo.tags().items():
1393 labels.setdefault(cl.rev(n), []).append(l)
1411 labels.setdefault(cl.rev(n), []).append(l)
1394 def events():
1412 def events():
1395 b = "default"
1413 b = "default"
1396 for r in cl:
1414 for r in cl:
1397 if branches:
1415 if branches:
1398 newb = cl.read(cl.node(r))[5]['branch']
1416 newb = cl.read(cl.node(r))[5]['branch']
1399 if newb != b:
1417 if newb != b:
1400 yield 'a', newb
1418 yield 'a', newb
1401 b = newb
1419 b = newb
1402 yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1)))
1420 yield 'n', (r, list(set(p for p in cl.parentrevs(r) if p != -1)))
1403 if tags:
1421 if tags:
1404 ls = labels.get(r)
1422 ls = labels.get(r)
1405 if ls:
1423 if ls:
1406 for l in ls:
1424 for l in ls:
1407 yield 'l', (r, l)
1425 yield 'l', (r, l)
1408 else:
1426 else:
1409 raise util.Abort(_('need repo for changelog dag'))
1427 raise util.Abort(_('need repo for changelog dag'))
1410
1428
1411 for line in dagparser.dagtextlines(events(),
1429 for line in dagparser.dagtextlines(events(),
1412 addspaces=spaces,
1430 addspaces=spaces,
1413 wraplabels=True,
1431 wraplabels=True,
1414 wrapannotations=True,
1432 wrapannotations=True,
1415 wrapnonlinear=dots,
1433 wrapnonlinear=dots,
1416 usedots=dots,
1434 usedots=dots,
1417 maxlinewidth=70):
1435 maxlinewidth=70):
1418 ui.write(line)
1436 ui.write(line)
1419 ui.write("\n")
1437 ui.write("\n")
1420
1438
1421 def debugdata(ui, repo, file_, rev):
1439 def debugdata(ui, repo, file_, rev):
1422 """dump the contents of a data file revision"""
1440 """dump the contents of a data file revision"""
1423 r = None
1441 r = None
1424 if repo:
1442 if repo:
1425 filelog = repo.file(file_)
1443 filelog = repo.file(file_)
1426 if len(filelog):
1444 if len(filelog):
1427 r = filelog
1445 r = filelog
1428 if not r:
1446 if not r:
1429 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
1447 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
1430 file_[:-2] + ".i")
1448 file_[:-2] + ".i")
1431 try:
1449 try:
1432 ui.write(r.revision(r.lookup(rev)))
1450 ui.write(r.revision(r.lookup(rev)))
1433 except KeyError:
1451 except KeyError:
1434 raise util.Abort(_('invalid revision identifier %s') % rev)
1452 raise util.Abort(_('invalid revision identifier %s') % rev)
1435
1453
1436 def debugdate(ui, date, range=None, **opts):
1454 def debugdate(ui, date, range=None, **opts):
1437 """parse and display a date"""
1455 """parse and display a date"""
1438 if opts["extended"]:
1456 if opts["extended"]:
1439 d = util.parsedate(date, util.extendeddateformats)
1457 d = util.parsedate(date, util.extendeddateformats)
1440 else:
1458 else:
1441 d = util.parsedate(date)
1459 d = util.parsedate(date)
1442 ui.write("internal: %s %s\n" % d)
1460 ui.write("internal: %s %s\n" % d)
1443 ui.write("standard: %s\n" % util.datestr(d))
1461 ui.write("standard: %s\n" % util.datestr(d))
1444 if range:
1462 if range:
1445 m = util.matchdate(range)
1463 m = util.matchdate(range)
1446 ui.write("match: %s\n" % m(d[0]))
1464 ui.write("match: %s\n" % m(d[0]))
1447
1465
1448 def debugignore(ui, repo, *values, **opts):
1466 def debugignore(ui, repo, *values, **opts):
1449 """display the combined ignore pattern"""
1467 """display the combined ignore pattern"""
1450 ignore = repo.dirstate._ignore
1468 ignore = repo.dirstate._ignore
1451 if hasattr(ignore, 'includepat'):
1469 if hasattr(ignore, 'includepat'):
1452 ui.write("%s\n" % ignore.includepat)
1470 ui.write("%s\n" % ignore.includepat)
1453 else:
1471 else:
1454 raise util.Abort(_("no ignore patterns found"))
1472 raise util.Abort(_("no ignore patterns found"))
1455
1473
1456 def debugindex(ui, repo, file_, **opts):
1474 def debugindex(ui, repo, file_, **opts):
1457 """dump the contents of an index file"""
1475 """dump the contents of an index file"""
1458 r = None
1476 r = None
1459 if repo:
1477 if repo:
1460 filelog = repo.file(file_)
1478 filelog = repo.file(file_)
1461 if len(filelog):
1479 if len(filelog):
1462 r = filelog
1480 r = filelog
1463
1481
1464 format = opts.get('format', 0)
1482 format = opts.get('format', 0)
1465 if format not in (0, 1):
1483 if format not in (0, 1):
1466 raise util.Abort(_("unknown format %d") % format)
1484 raise util.Abort(_("unknown format %d") % format)
1467
1485
1468 if not r:
1486 if not r:
1469 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1487 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1470
1488
1471 if format == 0:
1489 if format == 0:
1472 ui.write(" rev offset length base linkrev"
1490 ui.write(" rev offset length base linkrev"
1473 " nodeid p1 p2\n")
1491 " nodeid p1 p2\n")
1474 elif format == 1:
1492 elif format == 1:
1475 ui.write(" rev flag offset length"
1493 ui.write(" rev flag offset length"
1476 " size base link p1 p2 nodeid\n")
1494 " size base link p1 p2 nodeid\n")
1477
1495
1478 for i in r:
1496 for i in r:
1479 node = r.node(i)
1497 node = r.node(i)
1480 if format == 0:
1498 if format == 0:
1481 try:
1499 try:
1482 pp = r.parents(node)
1500 pp = r.parents(node)
1483 except:
1501 except:
1484 pp = [nullid, nullid]
1502 pp = [nullid, nullid]
1485 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
1503 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
1486 i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
1504 i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
1487 short(node), short(pp[0]), short(pp[1])))
1505 short(node), short(pp[0]), short(pp[1])))
1488 elif format == 1:
1506 elif format == 1:
1489 pr = r.parentrevs(i)
1507 pr = r.parentrevs(i)
1490 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
1508 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
1491 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
1509 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
1492 r.base(i), r.linkrev(i), pr[0], pr[1], short(node)))
1510 r.base(i), r.linkrev(i), pr[0], pr[1], short(node)))
1493
1511
1494 def debugindexdot(ui, repo, file_):
1512 def debugindexdot(ui, repo, file_):
1495 """dump an index DAG as a graphviz dot file"""
1513 """dump an index DAG as a graphviz dot file"""
1496 r = None
1514 r = None
1497 if repo:
1515 if repo:
1498 filelog = repo.file(file_)
1516 filelog = repo.file(file_)
1499 if len(filelog):
1517 if len(filelog):
1500 r = filelog
1518 r = filelog
1501 if not r:
1519 if not r:
1502 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1520 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1503 ui.write("digraph G {\n")
1521 ui.write("digraph G {\n")
1504 for i in r:
1522 for i in r:
1505 node = r.node(i)
1523 node = r.node(i)
1506 pp = r.parents(node)
1524 pp = r.parents(node)
1507 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
1525 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
1508 if pp[1] != nullid:
1526 if pp[1] != nullid:
1509 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
1527 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
1510 ui.write("}\n")
1528 ui.write("}\n")
1511
1529
1512 def debuginstall(ui):
1530 def debuginstall(ui):
1513 '''test Mercurial installation
1531 '''test Mercurial installation
1514
1532
1515 Returns 0 on success.
1533 Returns 0 on success.
1516 '''
1534 '''
1517
1535
1518 def writetemp(contents):
1536 def writetemp(contents):
1519 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
1537 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
1520 f = os.fdopen(fd, "wb")
1538 f = os.fdopen(fd, "wb")
1521 f.write(contents)
1539 f.write(contents)
1522 f.close()
1540 f.close()
1523 return name
1541 return name
1524
1542
1525 problems = 0
1543 problems = 0
1526
1544
1527 # encoding
1545 # encoding
1528 ui.status(_("Checking encoding (%s)...\n") % encoding.encoding)
1546 ui.status(_("Checking encoding (%s)...\n") % encoding.encoding)
1529 try:
1547 try:
1530 encoding.fromlocal("test")
1548 encoding.fromlocal("test")
1531 except util.Abort, inst:
1549 except util.Abort, inst:
1532 ui.write(" %s\n" % inst)
1550 ui.write(" %s\n" % inst)
1533 ui.write(_(" (check that your locale is properly set)\n"))
1551 ui.write(_(" (check that your locale is properly set)\n"))
1534 problems += 1
1552 problems += 1
1535
1553
1536 # compiled modules
1554 # compiled modules
1537 ui.status(_("Checking installed modules (%s)...\n")
1555 ui.status(_("Checking installed modules (%s)...\n")
1538 % os.path.dirname(__file__))
1556 % os.path.dirname(__file__))
1539 try:
1557 try:
1540 import bdiff, mpatch, base85, osutil
1558 import bdiff, mpatch, base85, osutil
1541 except Exception, inst:
1559 except Exception, inst:
1542 ui.write(" %s\n" % inst)
1560 ui.write(" %s\n" % inst)
1543 ui.write(_(" One or more extensions could not be found"))
1561 ui.write(_(" One or more extensions could not be found"))
1544 ui.write(_(" (check that you compiled the extensions)\n"))
1562 ui.write(_(" (check that you compiled the extensions)\n"))
1545 problems += 1
1563 problems += 1
1546
1564
1547 # templates
1565 # templates
1548 ui.status(_("Checking templates...\n"))
1566 ui.status(_("Checking templates...\n"))
1549 try:
1567 try:
1550 import templater
1568 import templater
1551 templater.templater(templater.templatepath("map-cmdline.default"))
1569 templater.templater(templater.templatepath("map-cmdline.default"))
1552 except Exception, inst:
1570 except Exception, inst:
1553 ui.write(" %s\n" % inst)
1571 ui.write(" %s\n" % inst)
1554 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
1572 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
1555 problems += 1
1573 problems += 1
1556
1574
1557 # editor
1575 # editor
1558 ui.status(_("Checking commit editor...\n"))
1576 ui.status(_("Checking commit editor...\n"))
1559 editor = ui.geteditor()
1577 editor = ui.geteditor()
1560 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
1578 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
1561 if not cmdpath:
1579 if not cmdpath:
1562 if editor == 'vi':
1580 if editor == 'vi':
1563 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
1581 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
1564 ui.write(_(" (specify a commit editor in your configuration"
1582 ui.write(_(" (specify a commit editor in your configuration"
1565 " file)\n"))
1583 " file)\n"))
1566 else:
1584 else:
1567 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
1585 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
1568 ui.write(_(" (specify a commit editor in your configuration"
1586 ui.write(_(" (specify a commit editor in your configuration"
1569 " file)\n"))
1587 " file)\n"))
1570 problems += 1
1588 problems += 1
1571
1589
1572 # check username
1590 # check username
1573 ui.status(_("Checking username...\n"))
1591 ui.status(_("Checking username...\n"))
1574 try:
1592 try:
1575 ui.username()
1593 ui.username()
1576 except util.Abort, e:
1594 except util.Abort, e:
1577 ui.write(" %s\n" % e)
1595 ui.write(" %s\n" % e)
1578 ui.write(_(" (specify a username in your configuration file)\n"))
1596 ui.write(_(" (specify a username in your configuration file)\n"))
1579 problems += 1
1597 problems += 1
1580
1598
1581 if not problems:
1599 if not problems:
1582 ui.status(_("No problems detected\n"))
1600 ui.status(_("No problems detected\n"))
1583 else:
1601 else:
1584 ui.write(_("%s problems detected,"
1602 ui.write(_("%s problems detected,"
1585 " please check your install!\n") % problems)
1603 " please check your install!\n") % problems)
1586
1604
1587 return problems
1605 return problems
1588
1606
1589 def debugrename(ui, repo, file1, *pats, **opts):
1607 def debugrename(ui, repo, file1, *pats, **opts):
1590 """dump rename information"""
1608 """dump rename information"""
1591
1609
1592 ctx = cmdutil.revsingle(repo, opts.get('rev'))
1610 ctx = cmdutil.revsingle(repo, opts.get('rev'))
1593 m = cmdutil.match(repo, (file1,) + pats, opts)
1611 m = cmdutil.match(repo, (file1,) + pats, opts)
1594 for abs in ctx.walk(m):
1612 for abs in ctx.walk(m):
1595 fctx = ctx[abs]
1613 fctx = ctx[abs]
1596 o = fctx.filelog().renamed(fctx.filenode())
1614 o = fctx.filelog().renamed(fctx.filenode())
1597 rel = m.rel(abs)
1615 rel = m.rel(abs)
1598 if o:
1616 if o:
1599 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1617 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1600 else:
1618 else:
1601 ui.write(_("%s not renamed\n") % rel)
1619 ui.write(_("%s not renamed\n") % rel)
1602
1620
1603 def debugwalk(ui, repo, *pats, **opts):
1621 def debugwalk(ui, repo, *pats, **opts):
1604 """show how files match on given patterns"""
1622 """show how files match on given patterns"""
1605 m = cmdutil.match(repo, pats, opts)
1623 m = cmdutil.match(repo, pats, opts)
1606 items = list(repo.walk(m))
1624 items = list(repo.walk(m))
1607 if not items:
1625 if not items:
1608 return
1626 return
1609 fmt = 'f %%-%ds %%-%ds %%s' % (
1627 fmt = 'f %%-%ds %%-%ds %%s' % (
1610 max([len(abs) for abs in items]),
1628 max([len(abs) for abs in items]),
1611 max([len(m.rel(abs)) for abs in items]))
1629 max([len(m.rel(abs)) for abs in items]))
1612 for abs in items:
1630 for abs in items:
1613 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1631 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1614 ui.write("%s\n" % line.rstrip())
1632 ui.write("%s\n" % line.rstrip())
1615
1633
1616 def debugwireargs(ui, repopath, *vals, **opts):
1634 def debugwireargs(ui, repopath, *vals, **opts):
1617 repo = hg.repository(hg.remoteui(ui, opts), repopath)
1635 repo = hg.repository(hg.remoteui(ui, opts), repopath)
1618 for opt in remoteopts:
1636 for opt in remoteopts:
1619 del opts[opt[1]]
1637 del opts[opt[1]]
1620 args = {}
1638 args = {}
1621 for k, v in opts.iteritems():
1639 for k, v in opts.iteritems():
1622 if v:
1640 if v:
1623 args[k] = v
1641 args[k] = v
1624 # run twice to check that we don't mess up the stream for the next command
1642 # run twice to check that we don't mess up the stream for the next command
1625 res1 = repo.debugwireargs(*vals, **args)
1643 res1 = repo.debugwireargs(*vals, **args)
1626 res2 = repo.debugwireargs(*vals, **args)
1644 res2 = repo.debugwireargs(*vals, **args)
1627 ui.write("%s\n" % res1)
1645 ui.write("%s\n" % res1)
1628 if res1 != res2:
1646 if res1 != res2:
1629 ui.warn("%s\n" % res2)
1647 ui.warn("%s\n" % res2)
1630
1648
1631 def diff(ui, repo, *pats, **opts):
1649 def diff(ui, repo, *pats, **opts):
1632 """diff repository (or selected files)
1650 """diff repository (or selected files)
1633
1651
1634 Show differences between revisions for the specified files.
1652 Show differences between revisions for the specified files.
1635
1653
1636 Differences between files are shown using the unified diff format.
1654 Differences between files are shown using the unified diff format.
1637
1655
1638 .. note::
1656 .. note::
1639 diff may generate unexpected results for merges, as it will
1657 diff may generate unexpected results for merges, as it will
1640 default to comparing against the working directory's first
1658 default to comparing against the working directory's first
1641 parent changeset if no revisions are specified.
1659 parent changeset if no revisions are specified.
1642
1660
1643 When two revision arguments are given, then changes are shown
1661 When two revision arguments are given, then changes are shown
1644 between those revisions. If only one revision is specified then
1662 between those revisions. If only one revision is specified then
1645 that revision is compared to the working directory, and, when no
1663 that revision is compared to the working directory, and, when no
1646 revisions are specified, the working directory files are compared
1664 revisions are specified, the working directory files are compared
1647 to its parent.
1665 to its parent.
1648
1666
1649 Alternatively you can specify -c/--change with a revision to see
1667 Alternatively you can specify -c/--change with a revision to see
1650 the changes in that changeset relative to its first parent.
1668 the changes in that changeset relative to its first parent.
1651
1669
1652 Without the -a/--text option, diff will avoid generating diffs of
1670 Without the -a/--text option, diff will avoid generating diffs of
1653 files it detects as binary. With -a, diff will generate a diff
1671 files it detects as binary. With -a, diff will generate a diff
1654 anyway, probably with undesirable results.
1672 anyway, probably with undesirable results.
1655
1673
1656 Use the -g/--git option to generate diffs in the git extended diff
1674 Use the -g/--git option to generate diffs in the git extended diff
1657 format. For more information, read :hg:`help diffs`.
1675 format. For more information, read :hg:`help diffs`.
1658
1676
1659 Returns 0 on success.
1677 Returns 0 on success.
1660 """
1678 """
1661
1679
1662 revs = opts.get('rev')
1680 revs = opts.get('rev')
1663 change = opts.get('change')
1681 change = opts.get('change')
1664 stat = opts.get('stat')
1682 stat = opts.get('stat')
1665 reverse = opts.get('reverse')
1683 reverse = opts.get('reverse')
1666
1684
1667 if revs and change:
1685 if revs and change:
1668 msg = _('cannot specify --rev and --change at the same time')
1686 msg = _('cannot specify --rev and --change at the same time')
1669 raise util.Abort(msg)
1687 raise util.Abort(msg)
1670 elif change:
1688 elif change:
1671 node2 = cmdutil.revsingle(repo, change, None).node()
1689 node2 = cmdutil.revsingle(repo, change, None).node()
1672 node1 = repo[node2].p1().node()
1690 node1 = repo[node2].p1().node()
1673 else:
1691 else:
1674 node1, node2 = cmdutil.revpair(repo, revs)
1692 node1, node2 = cmdutil.revpair(repo, revs)
1675
1693
1676 if reverse:
1694 if reverse:
1677 node1, node2 = node2, node1
1695 node1, node2 = node2, node1
1678
1696
1679 diffopts = patch.diffopts(ui, opts)
1697 diffopts = patch.diffopts(ui, opts)
1680 m = cmdutil.match(repo, pats, opts)
1698 m = cmdutil.match(repo, pats, opts)
1681 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
1699 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
1682 listsubrepos=opts.get('subrepos'))
1700 listsubrepos=opts.get('subrepos'))
1683
1701
1684 def export(ui, repo, *changesets, **opts):
1702 def export(ui, repo, *changesets, **opts):
1685 """dump the header and diffs for one or more changesets
1703 """dump the header and diffs for one or more changesets
1686
1704
1687 Print the changeset header and diffs for one or more revisions.
1705 Print the changeset header and diffs for one or more revisions.
1688
1706
1689 The information shown in the changeset header is: author, date,
1707 The information shown in the changeset header is: author, date,
1690 branch name (if non-default), changeset hash, parent(s) and commit
1708 branch name (if non-default), changeset hash, parent(s) and commit
1691 comment.
1709 comment.
1692
1710
1693 .. note::
1711 .. note::
1694 export may generate unexpected diff output for merge
1712 export may generate unexpected diff output for merge
1695 changesets, as it will compare the merge changeset against its
1713 changesets, as it will compare the merge changeset against its
1696 first parent only.
1714 first parent only.
1697
1715
1698 Output may be to a file, in which case the name of the file is
1716 Output may be to a file, in which case the name of the file is
1699 given using a format string. The formatting rules are as follows:
1717 given using a format string. The formatting rules are as follows:
1700
1718
1701 :``%%``: literal "%" character
1719 :``%%``: literal "%" character
1702 :``%H``: changeset hash (40 hexadecimal digits)
1720 :``%H``: changeset hash (40 hexadecimal digits)
1703 :``%N``: number of patches being generated
1721 :``%N``: number of patches being generated
1704 :``%R``: changeset revision number
1722 :``%R``: changeset revision number
1705 :``%b``: basename of the exporting repository
1723 :``%b``: basename of the exporting repository
1706 :``%h``: short-form changeset hash (12 hexadecimal digits)
1724 :``%h``: short-form changeset hash (12 hexadecimal digits)
1707 :``%n``: zero-padded sequence number, starting at 1
1725 :``%n``: zero-padded sequence number, starting at 1
1708 :``%r``: zero-padded changeset revision number
1726 :``%r``: zero-padded changeset revision number
1709
1727
1710 Without the -a/--text option, export will avoid generating diffs
1728 Without the -a/--text option, export will avoid generating diffs
1711 of files it detects as binary. With -a, export will generate a
1729 of files it detects as binary. With -a, export will generate a
1712 diff anyway, probably with undesirable results.
1730 diff anyway, probably with undesirable results.
1713
1731
1714 Use the -g/--git option to generate diffs in the git extended diff
1732 Use the -g/--git option to generate diffs in the git extended diff
1715 format. See :hg:`help diffs` for more information.
1733 format. See :hg:`help diffs` for more information.
1716
1734
1717 With the --switch-parent option, the diff will be against the
1735 With the --switch-parent option, the diff will be against the
1718 second parent. It can be useful to review a merge.
1736 second parent. It can be useful to review a merge.
1719
1737
1720 Returns 0 on success.
1738 Returns 0 on success.
1721 """
1739 """
1722 changesets += tuple(opts.get('rev', []))
1740 changesets += tuple(opts.get('rev', []))
1723 if not changesets:
1741 if not changesets:
1724 raise util.Abort(_("export requires at least one changeset"))
1742 raise util.Abort(_("export requires at least one changeset"))
1725 revs = cmdutil.revrange(repo, changesets)
1743 revs = cmdutil.revrange(repo, changesets)
1726 if len(revs) > 1:
1744 if len(revs) > 1:
1727 ui.note(_('exporting patches:\n'))
1745 ui.note(_('exporting patches:\n'))
1728 else:
1746 else:
1729 ui.note(_('exporting patch:\n'))
1747 ui.note(_('exporting patch:\n'))
1730 cmdutil.export(repo, revs, template=opts.get('output'),
1748 cmdutil.export(repo, revs, template=opts.get('output'),
1731 switch_parent=opts.get('switch_parent'),
1749 switch_parent=opts.get('switch_parent'),
1732 opts=patch.diffopts(ui, opts))
1750 opts=patch.diffopts(ui, opts))
1733
1751
1734 def forget(ui, repo, *pats, **opts):
1752 def forget(ui, repo, *pats, **opts):
1735 """forget the specified files on the next commit
1753 """forget the specified files on the next commit
1736
1754
1737 Mark the specified files so they will no longer be tracked
1755 Mark the specified files so they will no longer be tracked
1738 after the next commit.
1756 after the next commit.
1739
1757
1740 This only removes files from the current branch, not from the
1758 This only removes files from the current branch, not from the
1741 entire project history, and it does not delete them from the
1759 entire project history, and it does not delete them from the
1742 working directory.
1760 working directory.
1743
1761
1744 To undo a forget before the next commit, see :hg:`add`.
1762 To undo a forget before the next commit, see :hg:`add`.
1745
1763
1746 Returns 0 on success.
1764 Returns 0 on success.
1747 """
1765 """
1748
1766
1749 if not pats:
1767 if not pats:
1750 raise util.Abort(_('no files specified'))
1768 raise util.Abort(_('no files specified'))
1751
1769
1752 m = cmdutil.match(repo, pats, opts)
1770 m = cmdutil.match(repo, pats, opts)
1753 s = repo.status(match=m, clean=True)
1771 s = repo.status(match=m, clean=True)
1754 forget = sorted(s[0] + s[1] + s[3] + s[6])
1772 forget = sorted(s[0] + s[1] + s[3] + s[6])
1755 errs = 0
1773 errs = 0
1756
1774
1757 for f in m.files():
1775 for f in m.files():
1758 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
1776 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
1759 ui.warn(_('not removing %s: file is already untracked\n')
1777 ui.warn(_('not removing %s: file is already untracked\n')
1760 % m.rel(f))
1778 % m.rel(f))
1761 errs = 1
1779 errs = 1
1762
1780
1763 for f in forget:
1781 for f in forget:
1764 if ui.verbose or not m.exact(f):
1782 if ui.verbose or not m.exact(f):
1765 ui.status(_('removing %s\n') % m.rel(f))
1783 ui.status(_('removing %s\n') % m.rel(f))
1766
1784
1767 repo[None].remove(forget, unlink=False)
1785 repo[None].remove(forget, unlink=False)
1768 return errs
1786 return errs
1769
1787
1770 def grep(ui, repo, pattern, *pats, **opts):
1788 def grep(ui, repo, pattern, *pats, **opts):
1771 """search for a pattern in specified files and revisions
1789 """search for a pattern in specified files and revisions
1772
1790
1773 Search revisions of files for a regular expression.
1791 Search revisions of files for a regular expression.
1774
1792
1775 This command behaves differently than Unix grep. It only accepts
1793 This command behaves differently than Unix grep. It only accepts
1776 Python/Perl regexps. It searches repository history, not the
1794 Python/Perl regexps. It searches repository history, not the
1777 working directory. It always prints the revision number in which a
1795 working directory. It always prints the revision number in which a
1778 match appears.
1796 match appears.
1779
1797
1780 By default, grep only prints output for the first revision of a
1798 By default, grep only prints output for the first revision of a
1781 file in which it finds a match. To get it to print every revision
1799 file in which it finds a match. To get it to print every revision
1782 that contains a change in match status ("-" for a match that
1800 that contains a change in match status ("-" for a match that
1783 becomes a non-match, or "+" for a non-match that becomes a match),
1801 becomes a non-match, or "+" for a non-match that becomes a match),
1784 use the --all flag.
1802 use the --all flag.
1785
1803
1786 Returns 0 if a match is found, 1 otherwise.
1804 Returns 0 if a match is found, 1 otherwise.
1787 """
1805 """
1788 reflags = 0
1806 reflags = 0
1789 if opts.get('ignore_case'):
1807 if opts.get('ignore_case'):
1790 reflags |= re.I
1808 reflags |= re.I
1791 try:
1809 try:
1792 regexp = re.compile(pattern, reflags)
1810 regexp = re.compile(pattern, reflags)
1793 except re.error, inst:
1811 except re.error, inst:
1794 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
1812 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
1795 return 1
1813 return 1
1796 sep, eol = ':', '\n'
1814 sep, eol = ':', '\n'
1797 if opts.get('print0'):
1815 if opts.get('print0'):
1798 sep = eol = '\0'
1816 sep = eol = '\0'
1799
1817
1800 getfile = util.lrucachefunc(repo.file)
1818 getfile = util.lrucachefunc(repo.file)
1801
1819
1802 def matchlines(body):
1820 def matchlines(body):
1803 begin = 0
1821 begin = 0
1804 linenum = 0
1822 linenum = 0
1805 while True:
1823 while True:
1806 match = regexp.search(body, begin)
1824 match = regexp.search(body, begin)
1807 if not match:
1825 if not match:
1808 break
1826 break
1809 mstart, mend = match.span()
1827 mstart, mend = match.span()
1810 linenum += body.count('\n', begin, mstart) + 1
1828 linenum += body.count('\n', begin, mstart) + 1
1811 lstart = body.rfind('\n', begin, mstart) + 1 or begin
1829 lstart = body.rfind('\n', begin, mstart) + 1 or begin
1812 begin = body.find('\n', mend) + 1 or len(body)
1830 begin = body.find('\n', mend) + 1 or len(body)
1813 lend = begin - 1
1831 lend = begin - 1
1814 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1832 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1815
1833
1816 class linestate(object):
1834 class linestate(object):
1817 def __init__(self, line, linenum, colstart, colend):
1835 def __init__(self, line, linenum, colstart, colend):
1818 self.line = line
1836 self.line = line
1819 self.linenum = linenum
1837 self.linenum = linenum
1820 self.colstart = colstart
1838 self.colstart = colstart
1821 self.colend = colend
1839 self.colend = colend
1822
1840
1823 def __hash__(self):
1841 def __hash__(self):
1824 return hash((self.linenum, self.line))
1842 return hash((self.linenum, self.line))
1825
1843
1826 def __eq__(self, other):
1844 def __eq__(self, other):
1827 return self.line == other.line
1845 return self.line == other.line
1828
1846
1829 matches = {}
1847 matches = {}
1830 copies = {}
1848 copies = {}
1831 def grepbody(fn, rev, body):
1849 def grepbody(fn, rev, body):
1832 matches[rev].setdefault(fn, [])
1850 matches[rev].setdefault(fn, [])
1833 m = matches[rev][fn]
1851 m = matches[rev][fn]
1834 for lnum, cstart, cend, line in matchlines(body):
1852 for lnum, cstart, cend, line in matchlines(body):
1835 s = linestate(line, lnum, cstart, cend)
1853 s = linestate(line, lnum, cstart, cend)
1836 m.append(s)
1854 m.append(s)
1837
1855
1838 def difflinestates(a, b):
1856 def difflinestates(a, b):
1839 sm = difflib.SequenceMatcher(None, a, b)
1857 sm = difflib.SequenceMatcher(None, a, b)
1840 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
1858 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
1841 if tag == 'insert':
1859 if tag == 'insert':
1842 for i in xrange(blo, bhi):
1860 for i in xrange(blo, bhi):
1843 yield ('+', b[i])
1861 yield ('+', b[i])
1844 elif tag == 'delete':
1862 elif tag == 'delete':
1845 for i in xrange(alo, ahi):
1863 for i in xrange(alo, ahi):
1846 yield ('-', a[i])
1864 yield ('-', a[i])
1847 elif tag == 'replace':
1865 elif tag == 'replace':
1848 for i in xrange(alo, ahi):
1866 for i in xrange(alo, ahi):
1849 yield ('-', a[i])
1867 yield ('-', a[i])
1850 for i in xrange(blo, bhi):
1868 for i in xrange(blo, bhi):
1851 yield ('+', b[i])
1869 yield ('+', b[i])
1852
1870
1853 def display(fn, ctx, pstates, states):
1871 def display(fn, ctx, pstates, states):
1854 rev = ctx.rev()
1872 rev = ctx.rev()
1855 datefunc = ui.quiet and util.shortdate or util.datestr
1873 datefunc = ui.quiet and util.shortdate or util.datestr
1856 found = False
1874 found = False
1857 filerevmatches = {}
1875 filerevmatches = {}
1858 def binary():
1876 def binary():
1859 flog = getfile(fn)
1877 flog = getfile(fn)
1860 return util.binary(flog.read(ctx.filenode(fn)))
1878 return util.binary(flog.read(ctx.filenode(fn)))
1861
1879
1862 if opts.get('all'):
1880 if opts.get('all'):
1863 iter = difflinestates(pstates, states)
1881 iter = difflinestates(pstates, states)
1864 else:
1882 else:
1865 iter = [('', l) for l in states]
1883 iter = [('', l) for l in states]
1866 for change, l in iter:
1884 for change, l in iter:
1867 cols = [fn, str(rev)]
1885 cols = [fn, str(rev)]
1868 before, match, after = None, None, None
1886 before, match, after = None, None, None
1869 if opts.get('line_number'):
1887 if opts.get('line_number'):
1870 cols.append(str(l.linenum))
1888 cols.append(str(l.linenum))
1871 if opts.get('all'):
1889 if opts.get('all'):
1872 cols.append(change)
1890 cols.append(change)
1873 if opts.get('user'):
1891 if opts.get('user'):
1874 cols.append(ui.shortuser(ctx.user()))
1892 cols.append(ui.shortuser(ctx.user()))
1875 if opts.get('date'):
1893 if opts.get('date'):
1876 cols.append(datefunc(ctx.date()))
1894 cols.append(datefunc(ctx.date()))
1877 if opts.get('files_with_matches'):
1895 if opts.get('files_with_matches'):
1878 c = (fn, rev)
1896 c = (fn, rev)
1879 if c in filerevmatches:
1897 if c in filerevmatches:
1880 continue
1898 continue
1881 filerevmatches[c] = 1
1899 filerevmatches[c] = 1
1882 else:
1900 else:
1883 before = l.line[:l.colstart]
1901 before = l.line[:l.colstart]
1884 match = l.line[l.colstart:l.colend]
1902 match = l.line[l.colstart:l.colend]
1885 after = l.line[l.colend:]
1903 after = l.line[l.colend:]
1886 ui.write(sep.join(cols))
1904 ui.write(sep.join(cols))
1887 if before is not None:
1905 if before is not None:
1888 if not opts.get('text') and binary():
1906 if not opts.get('text') and binary():
1889 ui.write(sep + " Binary file matches")
1907 ui.write(sep + " Binary file matches")
1890 else:
1908 else:
1891 ui.write(sep + before)
1909 ui.write(sep + before)
1892 ui.write(match, label='grep.match')
1910 ui.write(match, label='grep.match')
1893 ui.write(after)
1911 ui.write(after)
1894 ui.write(eol)
1912 ui.write(eol)
1895 found = True
1913 found = True
1896 return found
1914 return found
1897
1915
1898 skip = {}
1916 skip = {}
1899 revfiles = {}
1917 revfiles = {}
1900 matchfn = cmdutil.match(repo, pats, opts)
1918 matchfn = cmdutil.match(repo, pats, opts)
1901 found = False
1919 found = False
1902 follow = opts.get('follow')
1920 follow = opts.get('follow')
1903
1921
1904 def prep(ctx, fns):
1922 def prep(ctx, fns):
1905 rev = ctx.rev()
1923 rev = ctx.rev()
1906 pctx = ctx.p1()
1924 pctx = ctx.p1()
1907 parent = pctx.rev()
1925 parent = pctx.rev()
1908 matches.setdefault(rev, {})
1926 matches.setdefault(rev, {})
1909 matches.setdefault(parent, {})
1927 matches.setdefault(parent, {})
1910 files = revfiles.setdefault(rev, [])
1928 files = revfiles.setdefault(rev, [])
1911 for fn in fns:
1929 for fn in fns:
1912 flog = getfile(fn)
1930 flog = getfile(fn)
1913 try:
1931 try:
1914 fnode = ctx.filenode(fn)
1932 fnode = ctx.filenode(fn)
1915 except error.LookupError:
1933 except error.LookupError:
1916 continue
1934 continue
1917
1935
1918 copied = flog.renamed(fnode)
1936 copied = flog.renamed(fnode)
1919 copy = follow and copied and copied[0]
1937 copy = follow and copied and copied[0]
1920 if copy:
1938 if copy:
1921 copies.setdefault(rev, {})[fn] = copy
1939 copies.setdefault(rev, {})[fn] = copy
1922 if fn in skip:
1940 if fn in skip:
1923 if copy:
1941 if copy:
1924 skip[copy] = True
1942 skip[copy] = True
1925 continue
1943 continue
1926 files.append(fn)
1944 files.append(fn)
1927
1945
1928 if fn not in matches[rev]:
1946 if fn not in matches[rev]:
1929 grepbody(fn, rev, flog.read(fnode))
1947 grepbody(fn, rev, flog.read(fnode))
1930
1948
1931 pfn = copy or fn
1949 pfn = copy or fn
1932 if pfn not in matches[parent]:
1950 if pfn not in matches[parent]:
1933 try:
1951 try:
1934 fnode = pctx.filenode(pfn)
1952 fnode = pctx.filenode(pfn)
1935 grepbody(pfn, parent, flog.read(fnode))
1953 grepbody(pfn, parent, flog.read(fnode))
1936 except error.LookupError:
1954 except error.LookupError:
1937 pass
1955 pass
1938
1956
1939 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
1957 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
1940 rev = ctx.rev()
1958 rev = ctx.rev()
1941 parent = ctx.p1().rev()
1959 parent = ctx.p1().rev()
1942 for fn in sorted(revfiles.get(rev, [])):
1960 for fn in sorted(revfiles.get(rev, [])):
1943 states = matches[rev][fn]
1961 states = matches[rev][fn]
1944 copy = copies.get(rev, {}).get(fn)
1962 copy = copies.get(rev, {}).get(fn)
1945 if fn in skip:
1963 if fn in skip:
1946 if copy:
1964 if copy:
1947 skip[copy] = True
1965 skip[copy] = True
1948 continue
1966 continue
1949 pstates = matches.get(parent, {}).get(copy or fn, [])
1967 pstates = matches.get(parent, {}).get(copy or fn, [])
1950 if pstates or states:
1968 if pstates or states:
1951 r = display(fn, ctx, pstates, states)
1969 r = display(fn, ctx, pstates, states)
1952 found = found or r
1970 found = found or r
1953 if r and not opts.get('all'):
1971 if r and not opts.get('all'):
1954 skip[fn] = True
1972 skip[fn] = True
1955 if copy:
1973 if copy:
1956 skip[copy] = True
1974 skip[copy] = True
1957 del matches[rev]
1975 del matches[rev]
1958 del revfiles[rev]
1976 del revfiles[rev]
1959
1977
1960 return not found
1978 return not found
1961
1979
1962 def heads(ui, repo, *branchrevs, **opts):
1980 def heads(ui, repo, *branchrevs, **opts):
1963 """show current repository heads or show branch heads
1981 """show current repository heads or show branch heads
1964
1982
1965 With no arguments, show all repository branch heads.
1983 With no arguments, show all repository branch heads.
1966
1984
1967 Repository "heads" are changesets with no child changesets. They are
1985 Repository "heads" are changesets with no child changesets. They are
1968 where development generally takes place and are the usual targets
1986 where development generally takes place and are the usual targets
1969 for update and merge operations. Branch heads are changesets that have
1987 for update and merge operations. Branch heads are changesets that have
1970 no child changeset on the same branch.
1988 no child changeset on the same branch.
1971
1989
1972 If one or more REVs are given, only branch heads on the branches
1990 If one or more REVs are given, only branch heads on the branches
1973 associated with the specified changesets are shown.
1991 associated with the specified changesets are shown.
1974
1992
1975 If -c/--closed is specified, also show branch heads marked closed
1993 If -c/--closed is specified, also show branch heads marked closed
1976 (see :hg:`commit --close-branch`).
1994 (see :hg:`commit --close-branch`).
1977
1995
1978 If STARTREV is specified, only those heads that are descendants of
1996 If STARTREV is specified, only those heads that are descendants of
1979 STARTREV will be displayed.
1997 STARTREV will be displayed.
1980
1998
1981 If -t/--topo is specified, named branch mechanics will be ignored and only
1999 If -t/--topo is specified, named branch mechanics will be ignored and only
1982 changesets without children will be shown.
2000 changesets without children will be shown.
1983
2001
1984 Returns 0 if matching heads are found, 1 if not.
2002 Returns 0 if matching heads are found, 1 if not.
1985 """
2003 """
1986
2004
1987 start = None
2005 start = None
1988 if 'rev' in opts:
2006 if 'rev' in opts:
1989 start = cmdutil.revsingle(repo, opts['rev'], None).node()
2007 start = cmdutil.revsingle(repo, opts['rev'], None).node()
1990
2008
1991 if opts.get('topo'):
2009 if opts.get('topo'):
1992 heads = [repo[h] for h in repo.heads(start)]
2010 heads = [repo[h] for h in repo.heads(start)]
1993 else:
2011 else:
1994 heads = []
2012 heads = []
1995 for b, ls in repo.branchmap().iteritems():
2013 for b, ls in repo.branchmap().iteritems():
1996 if start is None:
2014 if start is None:
1997 heads += [repo[h] for h in ls]
2015 heads += [repo[h] for h in ls]
1998 continue
2016 continue
1999 startrev = repo.changelog.rev(start)
2017 startrev = repo.changelog.rev(start)
2000 descendants = set(repo.changelog.descendants(startrev))
2018 descendants = set(repo.changelog.descendants(startrev))
2001 descendants.add(startrev)
2019 descendants.add(startrev)
2002 rev = repo.changelog.rev
2020 rev = repo.changelog.rev
2003 heads += [repo[h] for h in ls if rev(h) in descendants]
2021 heads += [repo[h] for h in ls if rev(h) in descendants]
2004
2022
2005 if branchrevs:
2023 if branchrevs:
2006 branches = set(repo[br].branch() for br in branchrevs)
2024 branches = set(repo[br].branch() for br in branchrevs)
2007 heads = [h for h in heads if h.branch() in branches]
2025 heads = [h for h in heads if h.branch() in branches]
2008
2026
2009 if not opts.get('closed'):
2027 if not opts.get('closed'):
2010 heads = [h for h in heads if not h.extra().get('close')]
2028 heads = [h for h in heads if not h.extra().get('close')]
2011
2029
2012 if opts.get('active') and branchrevs:
2030 if opts.get('active') and branchrevs:
2013 dagheads = repo.heads(start)
2031 dagheads = repo.heads(start)
2014 heads = [h for h in heads if h.node() in dagheads]
2032 heads = [h for h in heads if h.node() in dagheads]
2015
2033
2016 if branchrevs:
2034 if branchrevs:
2017 haveheads = set(h.branch() for h in heads)
2035 haveheads = set(h.branch() for h in heads)
2018 if branches - haveheads:
2036 if branches - haveheads:
2019 headless = ', '.join(b for b in branches - haveheads)
2037 headless = ', '.join(b for b in branches - haveheads)
2020 msg = _('no open branch heads found on branches %s')
2038 msg = _('no open branch heads found on branches %s')
2021 if opts.get('rev'):
2039 if opts.get('rev'):
2022 msg += _(' (started at %s)' % opts['rev'])
2040 msg += _(' (started at %s)' % opts['rev'])
2023 ui.warn((msg + '\n') % headless)
2041 ui.warn((msg + '\n') % headless)
2024
2042
2025 if not heads:
2043 if not heads:
2026 return 1
2044 return 1
2027
2045
2028 heads = sorted(heads, key=lambda x: -x.rev())
2046 heads = sorted(heads, key=lambda x: -x.rev())
2029 displayer = cmdutil.show_changeset(ui, repo, opts)
2047 displayer = cmdutil.show_changeset(ui, repo, opts)
2030 for ctx in heads:
2048 for ctx in heads:
2031 displayer.show(ctx)
2049 displayer.show(ctx)
2032 displayer.close()
2050 displayer.close()
2033
2051
2034 def help_(ui, name=None, with_version=False, unknowncmd=False, full=True):
2052 def help_(ui, name=None, with_version=False, unknowncmd=False, full=True):
2035 """show help for a given topic or a help overview
2053 """show help for a given topic or a help overview
2036
2054
2037 With no arguments, print a list of commands with short help messages.
2055 With no arguments, print a list of commands with short help messages.
2038
2056
2039 Given a topic, extension, or command name, print help for that
2057 Given a topic, extension, or command name, print help for that
2040 topic.
2058 topic.
2041
2059
2042 Returns 0 if successful.
2060 Returns 0 if successful.
2043 """
2061 """
2044 option_lists = []
2062 option_lists = []
2045 textwidth = min(ui.termwidth(), 80) - 2
2063 textwidth = min(ui.termwidth(), 80) - 2
2046
2064
2047 def addglobalopts(aliases):
2065 def addglobalopts(aliases):
2048 if ui.verbose:
2066 if ui.verbose:
2049 option_lists.append((_("global options:"), globalopts))
2067 option_lists.append((_("global options:"), globalopts))
2050 if name == 'shortlist':
2068 if name == 'shortlist':
2051 option_lists.append((_('use "hg help" for the full list '
2069 option_lists.append((_('use "hg help" for the full list '
2052 'of commands'), ()))
2070 'of commands'), ()))
2053 else:
2071 else:
2054 if name == 'shortlist':
2072 if name == 'shortlist':
2055 msg = _('use "hg help" for the full list of commands '
2073 msg = _('use "hg help" for the full list of commands '
2056 'or "hg -v" for details')
2074 'or "hg -v" for details')
2057 elif name and not full:
2075 elif name and not full:
2058 msg = _('use "hg help %s" to show the full help text' % name)
2076 msg = _('use "hg help %s" to show the full help text' % name)
2059 elif aliases:
2077 elif aliases:
2060 msg = _('use "hg -v help%s" to show builtin aliases and '
2078 msg = _('use "hg -v help%s" to show builtin aliases and '
2061 'global options') % (name and " " + name or "")
2079 'global options') % (name and " " + name or "")
2062 else:
2080 else:
2063 msg = _('use "hg -v help %s" to show global options') % name
2081 msg = _('use "hg -v help %s" to show global options') % name
2064 option_lists.append((msg, ()))
2082 option_lists.append((msg, ()))
2065
2083
2066 def helpcmd(name):
2084 def helpcmd(name):
2067 if with_version:
2085 if with_version:
2068 version_(ui)
2086 version_(ui)
2069 ui.write('\n')
2087 ui.write('\n')
2070
2088
2071 try:
2089 try:
2072 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
2090 aliases, entry = cmdutil.findcmd(name, table, strict=unknowncmd)
2073 except error.AmbiguousCommand, inst:
2091 except error.AmbiguousCommand, inst:
2074 # py3k fix: except vars can't be used outside the scope of the
2092 # py3k fix: except vars can't be used outside the scope of the
2075 # except block, nor can be used inside a lambda. python issue4617
2093 # except block, nor can be used inside a lambda. python issue4617
2076 prefix = inst.args[0]
2094 prefix = inst.args[0]
2077 select = lambda c: c.lstrip('^').startswith(prefix)
2095 select = lambda c: c.lstrip('^').startswith(prefix)
2078 helplist(_('list of commands:\n\n'), select)
2096 helplist(_('list of commands:\n\n'), select)
2079 return
2097 return
2080
2098
2081 # check if it's an invalid alias and display its error if it is
2099 # check if it's an invalid alias and display its error if it is
2082 if getattr(entry[0], 'badalias', False):
2100 if getattr(entry[0], 'badalias', False):
2083 if not unknowncmd:
2101 if not unknowncmd:
2084 entry[0](ui)
2102 entry[0](ui)
2085 return
2103 return
2086
2104
2087 # synopsis
2105 # synopsis
2088 if len(entry) > 2:
2106 if len(entry) > 2:
2089 if entry[2].startswith('hg'):
2107 if entry[2].startswith('hg'):
2090 ui.write("%s\n" % entry[2])
2108 ui.write("%s\n" % entry[2])
2091 else:
2109 else:
2092 ui.write('hg %s %s\n' % (aliases[0], entry[2]))
2110 ui.write('hg %s %s\n' % (aliases[0], entry[2]))
2093 else:
2111 else:
2094 ui.write('hg %s\n' % aliases[0])
2112 ui.write('hg %s\n' % aliases[0])
2095
2113
2096 # aliases
2114 # aliases
2097 if full and not ui.quiet and len(aliases) > 1:
2115 if full and not ui.quiet and len(aliases) > 1:
2098 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
2116 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
2099
2117
2100 # description
2118 # description
2101 doc = gettext(entry[0].__doc__)
2119 doc = gettext(entry[0].__doc__)
2102 if not doc:
2120 if not doc:
2103 doc = _("(no help text available)")
2121 doc = _("(no help text available)")
2104 if hasattr(entry[0], 'definition'): # aliased command
2122 if hasattr(entry[0], 'definition'): # aliased command
2105 if entry[0].definition.startswith('!'): # shell alias
2123 if entry[0].definition.startswith('!'): # shell alias
2106 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
2124 doc = _('shell alias for::\n\n %s') % entry[0].definition[1:]
2107 else:
2125 else:
2108 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
2126 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
2109 if ui.quiet or not full:
2127 if ui.quiet or not full:
2110 doc = doc.splitlines()[0]
2128 doc = doc.splitlines()[0]
2111 keep = ui.verbose and ['verbose'] or []
2129 keep = ui.verbose and ['verbose'] or []
2112 formatted, pruned = minirst.format(doc, textwidth, keep=keep)
2130 formatted, pruned = minirst.format(doc, textwidth, keep=keep)
2113 ui.write("\n%s\n" % formatted)
2131 ui.write("\n%s\n" % formatted)
2114 if pruned:
2132 if pruned:
2115 ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name)
2133 ui.write(_('\nuse "hg -v help %s" to show verbose help\n') % name)
2116
2134
2117 if not ui.quiet:
2135 if not ui.quiet:
2118 # options
2136 # options
2119 if entry[1]:
2137 if entry[1]:
2120 option_lists.append((_("options:\n"), entry[1]))
2138 option_lists.append((_("options:\n"), entry[1]))
2121
2139
2122 addglobalopts(False)
2140 addglobalopts(False)
2123
2141
2124 def helplist(header, select=None):
2142 def helplist(header, select=None):
2125 h = {}
2143 h = {}
2126 cmds = {}
2144 cmds = {}
2127 for c, e in table.iteritems():
2145 for c, e in table.iteritems():
2128 f = c.split("|", 1)[0]
2146 f = c.split("|", 1)[0]
2129 if select and not select(f):
2147 if select and not select(f):
2130 continue
2148 continue
2131 if (not select and name != 'shortlist' and
2149 if (not select and name != 'shortlist' and
2132 e[0].__module__ != __name__):
2150 e[0].__module__ != __name__):
2133 continue
2151 continue
2134 if name == "shortlist" and not f.startswith("^"):
2152 if name == "shortlist" and not f.startswith("^"):
2135 continue
2153 continue
2136 f = f.lstrip("^")
2154 f = f.lstrip("^")
2137 if not ui.debugflag and f.startswith("debug"):
2155 if not ui.debugflag and f.startswith("debug"):
2138 continue
2156 continue
2139 doc = e[0].__doc__
2157 doc = e[0].__doc__
2140 if doc and 'DEPRECATED' in doc and not ui.verbose:
2158 if doc and 'DEPRECATED' in doc and not ui.verbose:
2141 continue
2159 continue
2142 doc = gettext(doc)
2160 doc = gettext(doc)
2143 if not doc:
2161 if not doc:
2144 doc = _("(no help text available)")
2162 doc = _("(no help text available)")
2145 h[f] = doc.splitlines()[0].rstrip()
2163 h[f] = doc.splitlines()[0].rstrip()
2146 cmds[f] = c.lstrip("^")
2164 cmds[f] = c.lstrip("^")
2147
2165
2148 if not h:
2166 if not h:
2149 ui.status(_('no commands defined\n'))
2167 ui.status(_('no commands defined\n'))
2150 return
2168 return
2151
2169
2152 ui.status(header)
2170 ui.status(header)
2153 fns = sorted(h)
2171 fns = sorted(h)
2154 m = max(map(len, fns))
2172 m = max(map(len, fns))
2155 for f in fns:
2173 for f in fns:
2156 if ui.verbose:
2174 if ui.verbose:
2157 commands = cmds[f].replace("|",", ")
2175 commands = cmds[f].replace("|",", ")
2158 ui.write(" %s:\n %s\n"%(commands, h[f]))
2176 ui.write(" %s:\n %s\n"%(commands, h[f]))
2159 else:
2177 else:
2160 ui.write('%s\n' % (util.wrap(h[f], textwidth,
2178 ui.write('%s\n' % (util.wrap(h[f], textwidth,
2161 initindent=' %-*s ' % (m, f),
2179 initindent=' %-*s ' % (m, f),
2162 hangindent=' ' * (m + 4))))
2180 hangindent=' ' * (m + 4))))
2163
2181
2164 if not ui.quiet:
2182 if not ui.quiet:
2165 addglobalopts(True)
2183 addglobalopts(True)
2166
2184
2167 def helptopic(name):
2185 def helptopic(name):
2168 for names, header, doc in help.helptable:
2186 for names, header, doc in help.helptable:
2169 if name in names:
2187 if name in names:
2170 break
2188 break
2171 else:
2189 else:
2172 raise error.UnknownCommand(name)
2190 raise error.UnknownCommand(name)
2173
2191
2174 # description
2192 # description
2175 if not doc:
2193 if not doc:
2176 doc = _("(no help text available)")
2194 doc = _("(no help text available)")
2177 if hasattr(doc, '__call__'):
2195 if hasattr(doc, '__call__'):
2178 doc = doc()
2196 doc = doc()
2179
2197
2180 ui.write("%s\n\n" % header)
2198 ui.write("%s\n\n" % header)
2181 ui.write("%s\n" % minirst.format(doc, textwidth, indent=4))
2199 ui.write("%s\n" % minirst.format(doc, textwidth, indent=4))
2182
2200
2183 def helpext(name):
2201 def helpext(name):
2184 try:
2202 try:
2185 mod = extensions.find(name)
2203 mod = extensions.find(name)
2186 doc = gettext(mod.__doc__) or _('no help text available')
2204 doc = gettext(mod.__doc__) or _('no help text available')
2187 except KeyError:
2205 except KeyError:
2188 mod = None
2206 mod = None
2189 doc = extensions.disabledext(name)
2207 doc = extensions.disabledext(name)
2190 if not doc:
2208 if not doc:
2191 raise error.UnknownCommand(name)
2209 raise error.UnknownCommand(name)
2192
2210
2193 if '\n' not in doc:
2211 if '\n' not in doc:
2194 head, tail = doc, ""
2212 head, tail = doc, ""
2195 else:
2213 else:
2196 head, tail = doc.split('\n', 1)
2214 head, tail = doc.split('\n', 1)
2197 ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head))
2215 ui.write(_('%s extension - %s\n\n') % (name.split('.')[-1], head))
2198 if tail:
2216 if tail:
2199 ui.write(minirst.format(tail, textwidth))
2217 ui.write(minirst.format(tail, textwidth))
2200 ui.status('\n\n')
2218 ui.status('\n\n')
2201
2219
2202 if mod:
2220 if mod:
2203 try:
2221 try:
2204 ct = mod.cmdtable
2222 ct = mod.cmdtable
2205 except AttributeError:
2223 except AttributeError:
2206 ct = {}
2224 ct = {}
2207 modcmds = set([c.split('|', 1)[0] for c in ct])
2225 modcmds = set([c.split('|', 1)[0] for c in ct])
2208 helplist(_('list of commands:\n\n'), modcmds.__contains__)
2226 helplist(_('list of commands:\n\n'), modcmds.__contains__)
2209 else:
2227 else:
2210 ui.write(_('use "hg help extensions" for information on enabling '
2228 ui.write(_('use "hg help extensions" for information on enabling '
2211 'extensions\n'))
2229 'extensions\n'))
2212
2230
2213 def helpextcmd(name):
2231 def helpextcmd(name):
2214 cmd, ext, mod = extensions.disabledcmd(ui, name, ui.config('ui', 'strict'))
2232 cmd, ext, mod = extensions.disabledcmd(ui, name, ui.config('ui', 'strict'))
2215 doc = gettext(mod.__doc__).splitlines()[0]
2233 doc = gettext(mod.__doc__).splitlines()[0]
2216
2234
2217 msg = help.listexts(_("'%s' is provided by the following "
2235 msg = help.listexts(_("'%s' is provided by the following "
2218 "extension:") % cmd, {ext: doc}, len(ext),
2236 "extension:") % cmd, {ext: doc}, len(ext),
2219 indent=4)
2237 indent=4)
2220 ui.write(minirst.format(msg, textwidth))
2238 ui.write(minirst.format(msg, textwidth))
2221 ui.write('\n\n')
2239 ui.write('\n\n')
2222 ui.write(_('use "hg help extensions" for information on enabling '
2240 ui.write(_('use "hg help extensions" for information on enabling '
2223 'extensions\n'))
2241 'extensions\n'))
2224
2242
2225 help.addtopichook('revsets', revset.makedoc)
2243 help.addtopichook('revsets', revset.makedoc)
2226 help.addtopichook('templates', templatekw.makedoc)
2244 help.addtopichook('templates', templatekw.makedoc)
2227 help.addtopichook('templates', templatefilters.makedoc)
2245 help.addtopichook('templates', templatefilters.makedoc)
2228
2246
2229 if name and name != 'shortlist':
2247 if name and name != 'shortlist':
2230 i = None
2248 i = None
2231 if unknowncmd:
2249 if unknowncmd:
2232 queries = (helpextcmd,)
2250 queries = (helpextcmd,)
2233 else:
2251 else:
2234 queries = (helptopic, helpcmd, helpext, helpextcmd)
2252 queries = (helptopic, helpcmd, helpext, helpextcmd)
2235 for f in queries:
2253 for f in queries:
2236 try:
2254 try:
2237 f(name)
2255 f(name)
2238 i = None
2256 i = None
2239 break
2257 break
2240 except error.UnknownCommand, inst:
2258 except error.UnknownCommand, inst:
2241 i = inst
2259 i = inst
2242 if i:
2260 if i:
2243 raise i
2261 raise i
2244
2262
2245 else:
2263 else:
2246 # program name
2264 # program name
2247 if ui.verbose or with_version:
2265 if ui.verbose or with_version:
2248 version_(ui)
2266 version_(ui)
2249 else:
2267 else:
2250 ui.status(_("Mercurial Distributed SCM\n"))
2268 ui.status(_("Mercurial Distributed SCM\n"))
2251 ui.status('\n')
2269 ui.status('\n')
2252
2270
2253 # list of commands
2271 # list of commands
2254 if name == "shortlist":
2272 if name == "shortlist":
2255 header = _('basic commands:\n\n')
2273 header = _('basic commands:\n\n')
2256 else:
2274 else:
2257 header = _('list of commands:\n\n')
2275 header = _('list of commands:\n\n')
2258
2276
2259 helplist(header)
2277 helplist(header)
2260 if name != 'shortlist':
2278 if name != 'shortlist':
2261 exts, maxlength = extensions.enabled()
2279 exts, maxlength = extensions.enabled()
2262 text = help.listexts(_('enabled extensions:'), exts, maxlength)
2280 text = help.listexts(_('enabled extensions:'), exts, maxlength)
2263 if text:
2281 if text:
2264 ui.write("\n%s\n" % minirst.format(text, textwidth))
2282 ui.write("\n%s\n" % minirst.format(text, textwidth))
2265
2283
2266 # list all option lists
2284 # list all option lists
2267 opt_output = []
2285 opt_output = []
2268 multioccur = False
2286 multioccur = False
2269 for title, options in option_lists:
2287 for title, options in option_lists:
2270 opt_output.append(("\n%s" % title, None))
2288 opt_output.append(("\n%s" % title, None))
2271 for option in options:
2289 for option in options:
2272 if len(option) == 5:
2290 if len(option) == 5:
2273 shortopt, longopt, default, desc, optlabel = option
2291 shortopt, longopt, default, desc, optlabel = option
2274 else:
2292 else:
2275 shortopt, longopt, default, desc = option
2293 shortopt, longopt, default, desc = option
2276 optlabel = _("VALUE") # default label
2294 optlabel = _("VALUE") # default label
2277
2295
2278 if _("DEPRECATED") in desc and not ui.verbose:
2296 if _("DEPRECATED") in desc and not ui.verbose:
2279 continue
2297 continue
2280 if isinstance(default, list):
2298 if isinstance(default, list):
2281 numqualifier = " %s [+]" % optlabel
2299 numqualifier = " %s [+]" % optlabel
2282 multioccur = True
2300 multioccur = True
2283 elif (default is not None) and not isinstance(default, bool):
2301 elif (default is not None) and not isinstance(default, bool):
2284 numqualifier = " %s" % optlabel
2302 numqualifier = " %s" % optlabel
2285 else:
2303 else:
2286 numqualifier = ""
2304 numqualifier = ""
2287 opt_output.append(("%2s%s" %
2305 opt_output.append(("%2s%s" %
2288 (shortopt and "-%s" % shortopt,
2306 (shortopt and "-%s" % shortopt,
2289 longopt and " --%s%s" %
2307 longopt and " --%s%s" %
2290 (longopt, numqualifier)),
2308 (longopt, numqualifier)),
2291 "%s%s" % (desc,
2309 "%s%s" % (desc,
2292 default
2310 default
2293 and _(" (default: %s)") % default
2311 and _(" (default: %s)") % default
2294 or "")))
2312 or "")))
2295 if multioccur:
2313 if multioccur:
2296 msg = _("\n[+] marked option can be specified multiple times")
2314 msg = _("\n[+] marked option can be specified multiple times")
2297 if ui.verbose and name != 'shortlist':
2315 if ui.verbose and name != 'shortlist':
2298 opt_output.append((msg, None))
2316 opt_output.append((msg, None))
2299 else:
2317 else:
2300 opt_output.insert(-1, (msg, None))
2318 opt_output.insert(-1, (msg, None))
2301
2319
2302 if not name:
2320 if not name:
2303 ui.write(_("\nadditional help topics:\n\n"))
2321 ui.write(_("\nadditional help topics:\n\n"))
2304 topics = []
2322 topics = []
2305 for names, header, doc in help.helptable:
2323 for names, header, doc in help.helptable:
2306 topics.append((sorted(names, key=len, reverse=True)[0], header))
2324 topics.append((sorted(names, key=len, reverse=True)[0], header))
2307 topics_len = max([len(s[0]) for s in topics])
2325 topics_len = max([len(s[0]) for s in topics])
2308 for t, desc in topics:
2326 for t, desc in topics:
2309 ui.write(" %-*s %s\n" % (topics_len, t, desc))
2327 ui.write(" %-*s %s\n" % (topics_len, t, desc))
2310
2328
2311 if opt_output:
2329 if opt_output:
2312 colwidth = encoding.colwidth
2330 colwidth = encoding.colwidth
2313 # normalize: (opt or message, desc or None, width of opt)
2331 # normalize: (opt or message, desc or None, width of opt)
2314 entries = [desc and (opt, desc, colwidth(opt)) or (opt, None, 0)
2332 entries = [desc and (opt, desc, colwidth(opt)) or (opt, None, 0)
2315 for opt, desc in opt_output]
2333 for opt, desc in opt_output]
2316 hanging = max([e[2] for e in entries])
2334 hanging = max([e[2] for e in entries])
2317 for opt, desc, width in entries:
2335 for opt, desc, width in entries:
2318 if desc:
2336 if desc:
2319 initindent = ' %s%s ' % (opt, ' ' * (hanging - width))
2337 initindent = ' %s%s ' % (opt, ' ' * (hanging - width))
2320 hangindent = ' ' * (hanging + 3)
2338 hangindent = ' ' * (hanging + 3)
2321 ui.write('%s\n' % (util.wrap(desc, textwidth,
2339 ui.write('%s\n' % (util.wrap(desc, textwidth,
2322 initindent=initindent,
2340 initindent=initindent,
2323 hangindent=hangindent)))
2341 hangindent=hangindent)))
2324 else:
2342 else:
2325 ui.write("%s\n" % opt)
2343 ui.write("%s\n" % opt)
2326
2344
2327 def identify(ui, repo, source=None, rev=None,
2345 def identify(ui, repo, source=None, rev=None,
2328 num=None, id=None, branch=None, tags=None, bookmarks=None):
2346 num=None, id=None, branch=None, tags=None, bookmarks=None):
2329 """identify the working copy or specified revision
2347 """identify the working copy or specified revision
2330
2348
2331 Print a summary identifying the repository state at REV using one or
2349 Print a summary identifying the repository state at REV using one or
2332 two parent hash identifiers, followed by a "+" if the working
2350 two parent hash identifiers, followed by a "+" if the working
2333 directory has uncommitted changes, the branch name (if not default),
2351 directory has uncommitted changes, the branch name (if not default),
2334 a list of tags, and a list of bookmarks.
2352 a list of tags, and a list of bookmarks.
2335
2353
2336 When REV is not given, print a summary of the current state of the
2354 When REV is not given, print a summary of the current state of the
2337 repository.
2355 repository.
2338
2356
2339 Specifying a path to a repository root or Mercurial bundle will
2357 Specifying a path to a repository root or Mercurial bundle will
2340 cause lookup to operate on that repository/bundle.
2358 cause lookup to operate on that repository/bundle.
2341
2359
2342 Returns 0 if successful.
2360 Returns 0 if successful.
2343 """
2361 """
2344
2362
2345 if not repo and not source:
2363 if not repo and not source:
2346 raise util.Abort(_("there is no Mercurial repository here "
2364 raise util.Abort(_("there is no Mercurial repository here "
2347 "(.hg not found)"))
2365 "(.hg not found)"))
2348
2366
2349 hexfunc = ui.debugflag and hex or short
2367 hexfunc = ui.debugflag and hex or short
2350 default = not (num or id or branch or tags or bookmarks)
2368 default = not (num or id or branch or tags or bookmarks)
2351 output = []
2369 output = []
2352 revs = []
2370 revs = []
2353
2371
2354 if source:
2372 if source:
2355 source, branches = hg.parseurl(ui.expandpath(source))
2373 source, branches = hg.parseurl(ui.expandpath(source))
2356 repo = hg.repository(ui, source)
2374 repo = hg.repository(ui, source)
2357 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
2375 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
2358
2376
2359 if not repo.local():
2377 if not repo.local():
2360 if num or branch or tags:
2378 if num or branch or tags:
2361 raise util.Abort(
2379 raise util.Abort(
2362 _("can't query remote revision number, branch, or tags"))
2380 _("can't query remote revision number, branch, or tags"))
2363 if not rev and revs:
2381 if not rev and revs:
2364 rev = revs[0]
2382 rev = revs[0]
2365 if not rev:
2383 if not rev:
2366 rev = "tip"
2384 rev = "tip"
2367
2385
2368 remoterev = repo.lookup(rev)
2386 remoterev = repo.lookup(rev)
2369 if default or id:
2387 if default or id:
2370 output = [hexfunc(remoterev)]
2388 output = [hexfunc(remoterev)]
2371
2389
2372 def getbms():
2390 def getbms():
2373 bms = []
2391 bms = []
2374
2392
2375 if 'bookmarks' in repo.listkeys('namespaces'):
2393 if 'bookmarks' in repo.listkeys('namespaces'):
2376 hexremoterev = hex(remoterev)
2394 hexremoterev = hex(remoterev)
2377 bms = [bm for bm, bmr in repo.listkeys('bookmarks').iteritems()
2395 bms = [bm for bm, bmr in repo.listkeys('bookmarks').iteritems()
2378 if bmr == hexremoterev]
2396 if bmr == hexremoterev]
2379
2397
2380 return bms
2398 return bms
2381
2399
2382 if bookmarks:
2400 if bookmarks:
2383 output.extend(getbms())
2401 output.extend(getbms())
2384 elif default and not ui.quiet:
2402 elif default and not ui.quiet:
2385 # multiple bookmarks for a single parent separated by '/'
2403 # multiple bookmarks for a single parent separated by '/'
2386 bm = '/'.join(getbms())
2404 bm = '/'.join(getbms())
2387 if bm:
2405 if bm:
2388 output.append(bm)
2406 output.append(bm)
2389 else:
2407 else:
2390 if not rev:
2408 if not rev:
2391 ctx = repo[None]
2409 ctx = repo[None]
2392 parents = ctx.parents()
2410 parents = ctx.parents()
2393 changed = ""
2411 changed = ""
2394 if default or id or num:
2412 if default or id or num:
2395 changed = util.any(repo.status()) and "+" or ""
2413 changed = util.any(repo.status()) and "+" or ""
2396 if default or id:
2414 if default or id:
2397 output = ["%s%s" %
2415 output = ["%s%s" %
2398 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
2416 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
2399 if num:
2417 if num:
2400 output.append("%s%s" %
2418 output.append("%s%s" %
2401 ('+'.join([str(p.rev()) for p in parents]), changed))
2419 ('+'.join([str(p.rev()) for p in parents]), changed))
2402 else:
2420 else:
2403 ctx = cmdutil.revsingle(repo, rev)
2421 ctx = cmdutil.revsingle(repo, rev)
2404 if default or id:
2422 if default or id:
2405 output = [hexfunc(ctx.node())]
2423 output = [hexfunc(ctx.node())]
2406 if num:
2424 if num:
2407 output.append(str(ctx.rev()))
2425 output.append(str(ctx.rev()))
2408
2426
2409 if default and not ui.quiet:
2427 if default and not ui.quiet:
2410 b = ctx.branch()
2428 b = ctx.branch()
2411 if b != 'default':
2429 if b != 'default':
2412 output.append("(%s)" % b)
2430 output.append("(%s)" % b)
2413
2431
2414 # multiple tags for a single parent separated by '/'
2432 # multiple tags for a single parent separated by '/'
2415 t = '/'.join(ctx.tags())
2433 t = '/'.join(ctx.tags())
2416 if t:
2434 if t:
2417 output.append(t)
2435 output.append(t)
2418
2436
2419 # multiple bookmarks for a single parent separated by '/'
2437 # multiple bookmarks for a single parent separated by '/'
2420 bm = '/'.join(ctx.bookmarks())
2438 bm = '/'.join(ctx.bookmarks())
2421 if bm:
2439 if bm:
2422 output.append(bm)
2440 output.append(bm)
2423 else:
2441 else:
2424 if branch:
2442 if branch:
2425 output.append(ctx.branch())
2443 output.append(ctx.branch())
2426
2444
2427 if tags:
2445 if tags:
2428 output.extend(ctx.tags())
2446 output.extend(ctx.tags())
2429
2447
2430 if bookmarks:
2448 if bookmarks:
2431 output.extend(ctx.bookmarks())
2449 output.extend(ctx.bookmarks())
2432
2450
2433 ui.write("%s\n" % ' '.join(output))
2451 ui.write("%s\n" % ' '.join(output))
2434
2452
2435 def import_(ui, repo, patch1, *patches, **opts):
2453 def import_(ui, repo, patch1, *patches, **opts):
2436 """import an ordered set of patches
2454 """import an ordered set of patches
2437
2455
2438 Import a list of patches and commit them individually (unless
2456 Import a list of patches and commit them individually (unless
2439 --no-commit is specified).
2457 --no-commit is specified).
2440
2458
2441 If there are outstanding changes in the working directory, import
2459 If there are outstanding changes in the working directory, import
2442 will abort unless given the -f/--force flag.
2460 will abort unless given the -f/--force flag.
2443
2461
2444 You can import a patch straight from a mail message. Even patches
2462 You can import a patch straight from a mail message. Even patches
2445 as attachments work (to use the body part, it must have type
2463 as attachments work (to use the body part, it must have type
2446 text/plain or text/x-patch). From and Subject headers of email
2464 text/plain or text/x-patch). From and Subject headers of email
2447 message are used as default committer and commit message. All
2465 message are used as default committer and commit message. All
2448 text/plain body parts before first diff are added to commit
2466 text/plain body parts before first diff are added to commit
2449 message.
2467 message.
2450
2468
2451 If the imported patch was generated by :hg:`export`, user and
2469 If the imported patch was generated by :hg:`export`, user and
2452 description from patch override values from message headers and
2470 description from patch override values from message headers and
2453 body. Values given on command line with -m/--message and -u/--user
2471 body. Values given on command line with -m/--message and -u/--user
2454 override these.
2472 override these.
2455
2473
2456 If --exact is specified, import will set the working directory to
2474 If --exact is specified, import will set the working directory to
2457 the parent of each patch before applying it, and will abort if the
2475 the parent of each patch before applying it, and will abort if the
2458 resulting changeset has a different ID than the one recorded in
2476 resulting changeset has a different ID than the one recorded in
2459 the patch. This may happen due to character set problems or other
2477 the patch. This may happen due to character set problems or other
2460 deficiencies in the text patch format.
2478 deficiencies in the text patch format.
2461
2479
2462 With -s/--similarity, hg will attempt to discover renames and
2480 With -s/--similarity, hg will attempt to discover renames and
2463 copies in the patch in the same way as 'addremove'.
2481 copies in the patch in the same way as 'addremove'.
2464
2482
2465 To read a patch from standard input, use "-" as the patch name. If
2483 To read a patch from standard input, use "-" as the patch name. If
2466 a URL is specified, the patch will be downloaded from it.
2484 a URL is specified, the patch will be downloaded from it.
2467 See :hg:`help dates` for a list of formats valid for -d/--date.
2485 See :hg:`help dates` for a list of formats valid for -d/--date.
2468
2486
2469 Returns 0 on success.
2487 Returns 0 on success.
2470 """
2488 """
2471 patches = (patch1,) + patches
2489 patches = (patch1,) + patches
2472
2490
2473 date = opts.get('date')
2491 date = opts.get('date')
2474 if date:
2492 if date:
2475 opts['date'] = util.parsedate(date)
2493 opts['date'] = util.parsedate(date)
2476
2494
2477 try:
2495 try:
2478 sim = float(opts.get('similarity') or 0)
2496 sim = float(opts.get('similarity') or 0)
2479 except ValueError:
2497 except ValueError:
2480 raise util.Abort(_('similarity must be a number'))
2498 raise util.Abort(_('similarity must be a number'))
2481 if sim < 0 or sim > 100:
2499 if sim < 0 or sim > 100:
2482 raise util.Abort(_('similarity must be between 0 and 100'))
2500 raise util.Abort(_('similarity must be between 0 and 100'))
2483
2501
2484 if opts.get('exact') or not opts.get('force'):
2502 if opts.get('exact') or not opts.get('force'):
2485 cmdutil.bail_if_changed(repo)
2503 cmdutil.bail_if_changed(repo)
2486
2504
2487 d = opts["base"]
2505 d = opts["base"]
2488 strip = opts["strip"]
2506 strip = opts["strip"]
2489 wlock = lock = None
2507 wlock = lock = None
2490 msgs = []
2508 msgs = []
2491
2509
2492 def tryone(ui, hunk):
2510 def tryone(ui, hunk):
2493 tmpname, message, user, date, branch, nodeid, p1, p2 = \
2511 tmpname, message, user, date, branch, nodeid, p1, p2 = \
2494 patch.extract(ui, hunk)
2512 patch.extract(ui, hunk)
2495
2513
2496 if not tmpname:
2514 if not tmpname:
2497 return None
2515 return None
2498 commitid = _('to working directory')
2516 commitid = _('to working directory')
2499
2517
2500 try:
2518 try:
2501 cmdline_message = cmdutil.logmessage(opts)
2519 cmdline_message = cmdutil.logmessage(opts)
2502 if cmdline_message:
2520 if cmdline_message:
2503 # pickup the cmdline msg
2521 # pickup the cmdline msg
2504 message = cmdline_message
2522 message = cmdline_message
2505 elif message:
2523 elif message:
2506 # pickup the patch msg
2524 # pickup the patch msg
2507 message = message.strip()
2525 message = message.strip()
2508 else:
2526 else:
2509 # launch the editor
2527 # launch the editor
2510 message = None
2528 message = None
2511 ui.debug('message:\n%s\n' % message)
2529 ui.debug('message:\n%s\n' % message)
2512
2530
2513 wp = repo.parents()
2531 wp = repo.parents()
2514 if opts.get('exact'):
2532 if opts.get('exact'):
2515 if not nodeid or not p1:
2533 if not nodeid or not p1:
2516 raise util.Abort(_('not a Mercurial patch'))
2534 raise util.Abort(_('not a Mercurial patch'))
2517 p1 = repo.lookup(p1)
2535 p1 = repo.lookup(p1)
2518 p2 = repo.lookup(p2 or hex(nullid))
2536 p2 = repo.lookup(p2 or hex(nullid))
2519
2537
2520 if p1 != wp[0].node():
2538 if p1 != wp[0].node():
2521 hg.clean(repo, p1)
2539 hg.clean(repo, p1)
2522 repo.dirstate.setparents(p1, p2)
2540 repo.dirstate.setparents(p1, p2)
2523 elif p2:
2541 elif p2:
2524 try:
2542 try:
2525 p1 = repo.lookup(p1)
2543 p1 = repo.lookup(p1)
2526 p2 = repo.lookup(p2)
2544 p2 = repo.lookup(p2)
2527 if p1 == wp[0].node():
2545 if p1 == wp[0].node():
2528 repo.dirstate.setparents(p1, p2)
2546 repo.dirstate.setparents(p1, p2)
2529 except error.RepoError:
2547 except error.RepoError:
2530 pass
2548 pass
2531 if opts.get('exact') or opts.get('import_branch'):
2549 if opts.get('exact') or opts.get('import_branch'):
2532 repo.dirstate.setbranch(branch or 'default')
2550 repo.dirstate.setbranch(branch or 'default')
2533
2551
2534 files = {}
2552 files = {}
2535 try:
2553 try:
2536 patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
2554 patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
2537 files=files, eolmode=None)
2555 files=files, eolmode=None)
2538 finally:
2556 finally:
2539 files = cmdutil.updatedir(ui, repo, files,
2557 files = cmdutil.updatedir(ui, repo, files,
2540 similarity=sim / 100.0)
2558 similarity=sim / 100.0)
2541 if opts.get('no_commit'):
2559 if opts.get('no_commit'):
2542 if message:
2560 if message:
2543 msgs.append(message)
2561 msgs.append(message)
2544 else:
2562 else:
2545 if opts.get('exact'):
2563 if opts.get('exact'):
2546 m = None
2564 m = None
2547 else:
2565 else:
2548 m = cmdutil.matchfiles(repo, files or [])
2566 m = cmdutil.matchfiles(repo, files or [])
2549 n = repo.commit(message, opts.get('user') or user,
2567 n = repo.commit(message, opts.get('user') or user,
2550 opts.get('date') or date, match=m,
2568 opts.get('date') or date, match=m,
2551 editor=cmdutil.commiteditor)
2569 editor=cmdutil.commiteditor)
2552 if opts.get('exact'):
2570 if opts.get('exact'):
2553 if hex(n) != nodeid:
2571 if hex(n) != nodeid:
2554 repo.rollback()
2572 repo.rollback()
2555 raise util.Abort(_('patch is damaged'
2573 raise util.Abort(_('patch is damaged'
2556 ' or loses information'))
2574 ' or loses information'))
2557 # Force a dirstate write so that the next transaction
2575 # Force a dirstate write so that the next transaction
2558 # backups an up-do-date file.
2576 # backups an up-do-date file.
2559 repo.dirstate.write()
2577 repo.dirstate.write()
2560 if n:
2578 if n:
2561 commitid = short(n)
2579 commitid = short(n)
2562
2580
2563 return commitid
2581 return commitid
2564 finally:
2582 finally:
2565 os.unlink(tmpname)
2583 os.unlink(tmpname)
2566
2584
2567 try:
2585 try:
2568 wlock = repo.wlock()
2586 wlock = repo.wlock()
2569 lock = repo.lock()
2587 lock = repo.lock()
2570 lastcommit = None
2588 lastcommit = None
2571 for p in patches:
2589 for p in patches:
2572 pf = os.path.join(d, p)
2590 pf = os.path.join(d, p)
2573
2591
2574 if pf == '-':
2592 if pf == '-':
2575 ui.status(_("applying patch from stdin\n"))
2593 ui.status(_("applying patch from stdin\n"))
2576 pf = sys.stdin
2594 pf = sys.stdin
2577 else:
2595 else:
2578 ui.status(_("applying %s\n") % p)
2596 ui.status(_("applying %s\n") % p)
2579 pf = url.open(ui, pf)
2597 pf = url.open(ui, pf)
2580
2598
2581 haspatch = False
2599 haspatch = False
2582 for hunk in patch.split(pf):
2600 for hunk in patch.split(pf):
2583 commitid = tryone(ui, hunk)
2601 commitid = tryone(ui, hunk)
2584 if commitid:
2602 if commitid:
2585 haspatch = True
2603 haspatch = True
2586 if lastcommit:
2604 if lastcommit:
2587 ui.status(_('applied %s\n') % lastcommit)
2605 ui.status(_('applied %s\n') % lastcommit)
2588 lastcommit = commitid
2606 lastcommit = commitid
2589
2607
2590 if not haspatch:
2608 if not haspatch:
2591 raise util.Abort(_('no diffs found'))
2609 raise util.Abort(_('no diffs found'))
2592
2610
2593 if msgs:
2611 if msgs:
2594 repo.opener('last-message.txt', 'wb').write('\n* * *\n'.join(msgs))
2612 repo.opener('last-message.txt', 'wb').write('\n* * *\n'.join(msgs))
2595 finally:
2613 finally:
2596 release(lock, wlock)
2614 release(lock, wlock)
2597
2615
2598 def incoming(ui, repo, source="default", **opts):
2616 def incoming(ui, repo, source="default", **opts):
2599 """show new changesets found in source
2617 """show new changesets found in source
2600
2618
2601 Show new changesets found in the specified path/URL or the default
2619 Show new changesets found in the specified path/URL or the default
2602 pull location. These are the changesets that would have been pulled
2620 pull location. These are the changesets that would have been pulled
2603 if a pull at the time you issued this command.
2621 if a pull at the time you issued this command.
2604
2622
2605 For remote repository, using --bundle avoids downloading the
2623 For remote repository, using --bundle avoids downloading the
2606 changesets twice if the incoming is followed by a pull.
2624 changesets twice if the incoming is followed by a pull.
2607
2625
2608 See pull for valid source format details.
2626 See pull for valid source format details.
2609
2627
2610 Returns 0 if there are incoming changes, 1 otherwise.
2628 Returns 0 if there are incoming changes, 1 otherwise.
2611 """
2629 """
2612 if opts.get('bundle') and opts.get('subrepos'):
2630 if opts.get('bundle') and opts.get('subrepos'):
2613 raise util.Abort(_('cannot combine --bundle and --subrepos'))
2631 raise util.Abort(_('cannot combine --bundle and --subrepos'))
2614
2632
2615 if opts.get('bookmarks'):
2633 if opts.get('bookmarks'):
2616 source, branches = hg.parseurl(ui.expandpath(source),
2634 source, branches = hg.parseurl(ui.expandpath(source),
2617 opts.get('branch'))
2635 opts.get('branch'))
2618 other = hg.repository(hg.remoteui(repo, opts), source)
2636 other = hg.repository(hg.remoteui(repo, opts), source)
2619 if 'bookmarks' not in other.listkeys('namespaces'):
2637 if 'bookmarks' not in other.listkeys('namespaces'):
2620 ui.warn(_("remote doesn't support bookmarks\n"))
2638 ui.warn(_("remote doesn't support bookmarks\n"))
2621 return 0
2639 return 0
2622 ui.status(_('comparing with %s\n') % util.hidepassword(source))
2640 ui.status(_('comparing with %s\n') % util.hidepassword(source))
2623 return bookmarks.diff(ui, repo, other)
2641 return bookmarks.diff(ui, repo, other)
2624
2642
2625 ret = hg.incoming(ui, repo, source, opts)
2643 ret = hg.incoming(ui, repo, source, opts)
2626 return ret
2644 return ret
2627
2645
2628 def init(ui, dest=".", **opts):
2646 def init(ui, dest=".", **opts):
2629 """create a new repository in the given directory
2647 """create a new repository in the given directory
2630
2648
2631 Initialize a new repository in the given directory. If the given
2649 Initialize a new repository in the given directory. If the given
2632 directory does not exist, it will be created.
2650 directory does not exist, it will be created.
2633
2651
2634 If no directory is given, the current directory is used.
2652 If no directory is given, the current directory is used.
2635
2653
2636 It is possible to specify an ``ssh://`` URL as the destination.
2654 It is possible to specify an ``ssh://`` URL as the destination.
2637 See :hg:`help urls` for more information.
2655 See :hg:`help urls` for more information.
2638
2656
2639 Returns 0 on success.
2657 Returns 0 on success.
2640 """
2658 """
2641 hg.repository(hg.remoteui(ui, opts), ui.expandpath(dest), create=1)
2659 hg.repository(hg.remoteui(ui, opts), ui.expandpath(dest), create=1)
2642
2660
2643 def locate(ui, repo, *pats, **opts):
2661 def locate(ui, repo, *pats, **opts):
2644 """locate files matching specific patterns
2662 """locate files matching specific patterns
2645
2663
2646 Print files under Mercurial control in the working directory whose
2664 Print files under Mercurial control in the working directory whose
2647 names match the given patterns.
2665 names match the given patterns.
2648
2666
2649 By default, this command searches all directories in the working
2667 By default, this command searches all directories in the working
2650 directory. To search just the current directory and its
2668 directory. To search just the current directory and its
2651 subdirectories, use "--include .".
2669 subdirectories, use "--include .".
2652
2670
2653 If no patterns are given to match, this command prints the names
2671 If no patterns are given to match, this command prints the names
2654 of all files under Mercurial control in the working directory.
2672 of all files under Mercurial control in the working directory.
2655
2673
2656 If you want to feed the output of this command into the "xargs"
2674 If you want to feed the output of this command into the "xargs"
2657 command, use the -0 option to both this command and "xargs". This
2675 command, use the -0 option to both this command and "xargs". This
2658 will avoid the problem of "xargs" treating single filenames that
2676 will avoid the problem of "xargs" treating single filenames that
2659 contain whitespace as multiple filenames.
2677 contain whitespace as multiple filenames.
2660
2678
2661 Returns 0 if a match is found, 1 otherwise.
2679 Returns 0 if a match is found, 1 otherwise.
2662 """
2680 """
2663 end = opts.get('print0') and '\0' or '\n'
2681 end = opts.get('print0') and '\0' or '\n'
2664 rev = cmdutil.revsingle(repo, opts.get('rev'), None).node()
2682 rev = cmdutil.revsingle(repo, opts.get('rev'), None).node()
2665
2683
2666 ret = 1
2684 ret = 1
2667 m = cmdutil.match(repo, pats, opts, default='relglob')
2685 m = cmdutil.match(repo, pats, opts, default='relglob')
2668 m.bad = lambda x, y: False
2686 m.bad = lambda x, y: False
2669 for abs in repo[rev].walk(m):
2687 for abs in repo[rev].walk(m):
2670 if not rev and abs not in repo.dirstate:
2688 if not rev and abs not in repo.dirstate:
2671 continue
2689 continue
2672 if opts.get('fullpath'):
2690 if opts.get('fullpath'):
2673 ui.write(repo.wjoin(abs), end)
2691 ui.write(repo.wjoin(abs), end)
2674 else:
2692 else:
2675 ui.write(((pats and m.rel(abs)) or abs), end)
2693 ui.write(((pats and m.rel(abs)) or abs), end)
2676 ret = 0
2694 ret = 0
2677
2695
2678 return ret
2696 return ret
2679
2697
2680 def log(ui, repo, *pats, **opts):
2698 def log(ui, repo, *pats, **opts):
2681 """show revision history of entire repository or files
2699 """show revision history of entire repository or files
2682
2700
2683 Print the revision history of the specified files or the entire
2701 Print the revision history of the specified files or the entire
2684 project.
2702 project.
2685
2703
2686 File history is shown without following rename or copy history of
2704 File history is shown without following rename or copy history of
2687 files. Use -f/--follow with a filename to follow history across
2705 files. Use -f/--follow with a filename to follow history across
2688 renames and copies. --follow without a filename will only show
2706 renames and copies. --follow without a filename will only show
2689 ancestors or descendants of the starting revision. --follow-first
2707 ancestors or descendants of the starting revision. --follow-first
2690 only follows the first parent of merge revisions.
2708 only follows the first parent of merge revisions.
2691
2709
2692 If no revision range is specified, the default is ``tip:0`` unless
2710 If no revision range is specified, the default is ``tip:0`` unless
2693 --follow is set, in which case the working directory parent is
2711 --follow is set, in which case the working directory parent is
2694 used as the starting revision. You can specify a revision set for
2712 used as the starting revision. You can specify a revision set for
2695 log, see :hg:`help revsets` for more information.
2713 log, see :hg:`help revsets` for more information.
2696
2714
2697 See :hg:`help dates` for a list of formats valid for -d/--date.
2715 See :hg:`help dates` for a list of formats valid for -d/--date.
2698
2716
2699 By default this command prints revision number and changeset id,
2717 By default this command prints revision number and changeset id,
2700 tags, non-trivial parents, user, date and time, and a summary for
2718 tags, non-trivial parents, user, date and time, and a summary for
2701 each commit. When the -v/--verbose switch is used, the list of
2719 each commit. When the -v/--verbose switch is used, the list of
2702 changed files and full commit message are shown.
2720 changed files and full commit message are shown.
2703
2721
2704 .. note::
2722 .. note::
2705 log -p/--patch may generate unexpected diff output for merge
2723 log -p/--patch may generate unexpected diff output for merge
2706 changesets, as it will only compare the merge changeset against
2724 changesets, as it will only compare the merge changeset against
2707 its first parent. Also, only files different from BOTH parents
2725 its first parent. Also, only files different from BOTH parents
2708 will appear in files:.
2726 will appear in files:.
2709
2727
2710 Returns 0 on success.
2728 Returns 0 on success.
2711 """
2729 """
2712
2730
2713 matchfn = cmdutil.match(repo, pats, opts)
2731 matchfn = cmdutil.match(repo, pats, opts)
2714 limit = cmdutil.loglimit(opts)
2732 limit = cmdutil.loglimit(opts)
2715 count = 0
2733 count = 0
2716
2734
2717 endrev = None
2735 endrev = None
2718 if opts.get('copies') and opts.get('rev'):
2736 if opts.get('copies') and opts.get('rev'):
2719 endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
2737 endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
2720
2738
2721 df = False
2739 df = False
2722 if opts["date"]:
2740 if opts["date"]:
2723 df = util.matchdate(opts["date"])
2741 df = util.matchdate(opts["date"])
2724
2742
2725 branches = opts.get('branch', []) + opts.get('only_branch', [])
2743 branches = opts.get('branch', []) + opts.get('only_branch', [])
2726 opts['branch'] = [repo.lookupbranch(b) for b in branches]
2744 opts['branch'] = [repo.lookupbranch(b) for b in branches]
2727
2745
2728 displayer = cmdutil.show_changeset(ui, repo, opts, True)
2746 displayer = cmdutil.show_changeset(ui, repo, opts, True)
2729 def prep(ctx, fns):
2747 def prep(ctx, fns):
2730 rev = ctx.rev()
2748 rev = ctx.rev()
2731 parents = [p for p in repo.changelog.parentrevs(rev)
2749 parents = [p for p in repo.changelog.parentrevs(rev)
2732 if p != nullrev]
2750 if p != nullrev]
2733 if opts.get('no_merges') and len(parents) == 2:
2751 if opts.get('no_merges') and len(parents) == 2:
2734 return
2752 return
2735 if opts.get('only_merges') and len(parents) != 2:
2753 if opts.get('only_merges') and len(parents) != 2:
2736 return
2754 return
2737 if opts.get('branch') and ctx.branch() not in opts['branch']:
2755 if opts.get('branch') and ctx.branch() not in opts['branch']:
2738 return
2756 return
2739 if df and not df(ctx.date()[0]):
2757 if df and not df(ctx.date()[0]):
2740 return
2758 return
2741 if opts['user'] and not [k for k in opts['user']
2759 if opts['user'] and not [k for k in opts['user']
2742 if k.lower() in ctx.user().lower()]:
2760 if k.lower() in ctx.user().lower()]:
2743 return
2761 return
2744 if opts.get('keyword'):
2762 if opts.get('keyword'):
2745 for k in [kw.lower() for kw in opts['keyword']]:
2763 for k in [kw.lower() for kw in opts['keyword']]:
2746 if (k in ctx.user().lower() or
2764 if (k in ctx.user().lower() or
2747 k in ctx.description().lower() or
2765 k in ctx.description().lower() or
2748 k in " ".join(ctx.files()).lower()):
2766 k in " ".join(ctx.files()).lower()):
2749 break
2767 break
2750 else:
2768 else:
2751 return
2769 return
2752
2770
2753 copies = None
2771 copies = None
2754 if opts.get('copies') and rev:
2772 if opts.get('copies') and rev:
2755 copies = []
2773 copies = []
2756 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
2774 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
2757 for fn in ctx.files():
2775 for fn in ctx.files():
2758 rename = getrenamed(fn, rev)
2776 rename = getrenamed(fn, rev)
2759 if rename:
2777 if rename:
2760 copies.append((fn, rename[0]))
2778 copies.append((fn, rename[0]))
2761
2779
2762 revmatchfn = None
2780 revmatchfn = None
2763 if opts.get('patch') or opts.get('stat'):
2781 if opts.get('patch') or opts.get('stat'):
2764 if opts.get('follow') or opts.get('follow_first'):
2782 if opts.get('follow') or opts.get('follow_first'):
2765 # note: this might be wrong when following through merges
2783 # note: this might be wrong when following through merges
2766 revmatchfn = cmdutil.match(repo, fns, default='path')
2784 revmatchfn = cmdutil.match(repo, fns, default='path')
2767 else:
2785 else:
2768 revmatchfn = matchfn
2786 revmatchfn = matchfn
2769
2787
2770 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
2788 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
2771
2789
2772 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2790 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
2773 if count == limit:
2791 if count == limit:
2774 break
2792 break
2775 if displayer.flush(ctx.rev()):
2793 if displayer.flush(ctx.rev()):
2776 count += 1
2794 count += 1
2777 displayer.close()
2795 displayer.close()
2778
2796
2779 def manifest(ui, repo, node=None, rev=None):
2797 def manifest(ui, repo, node=None, rev=None):
2780 """output the current or given revision of the project manifest
2798 """output the current or given revision of the project manifest
2781
2799
2782 Print a list of version controlled files for the given revision.
2800 Print a list of version controlled files for the given revision.
2783 If no revision is given, the first parent of the working directory
2801 If no revision is given, the first parent of the working directory
2784 is used, or the null revision if no revision is checked out.
2802 is used, or the null revision if no revision is checked out.
2785
2803
2786 With -v, print file permissions, symlink and executable bits.
2804 With -v, print file permissions, symlink and executable bits.
2787 With --debug, print file revision hashes.
2805 With --debug, print file revision hashes.
2788
2806
2789 Returns 0 on success.
2807 Returns 0 on success.
2790 """
2808 """
2791
2809
2792 if rev and node:
2810 if rev and node:
2793 raise util.Abort(_("please specify just one revision"))
2811 raise util.Abort(_("please specify just one revision"))
2794
2812
2795 if not node:
2813 if not node:
2796 node = rev
2814 node = rev
2797
2815
2798 decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '}
2816 decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '}
2799 ctx = cmdutil.revsingle(repo, node)
2817 ctx = cmdutil.revsingle(repo, node)
2800 for f in ctx:
2818 for f in ctx:
2801 if ui.debugflag:
2819 if ui.debugflag:
2802 ui.write("%40s " % hex(ctx.manifest()[f]))
2820 ui.write("%40s " % hex(ctx.manifest()[f]))
2803 if ui.verbose:
2821 if ui.verbose:
2804 ui.write(decor[ctx.flags(f)])
2822 ui.write(decor[ctx.flags(f)])
2805 ui.write("%s\n" % f)
2823 ui.write("%s\n" % f)
2806
2824
2807 def merge(ui, repo, node=None, **opts):
2825 def merge(ui, repo, node=None, **opts):
2808 """merge working directory with another revision
2826 """merge working directory with another revision
2809
2827
2810 The current working directory is updated with all changes made in
2828 The current working directory is updated with all changes made in
2811 the requested revision since the last common predecessor revision.
2829 the requested revision since the last common predecessor revision.
2812
2830
2813 Files that changed between either parent are marked as changed for
2831 Files that changed between either parent are marked as changed for
2814 the next commit and a commit must be performed before any further
2832 the next commit and a commit must be performed before any further
2815 updates to the repository are allowed. The next commit will have
2833 updates to the repository are allowed. The next commit will have
2816 two parents.
2834 two parents.
2817
2835
2818 ``--tool`` can be used to specify the merge tool used for file
2836 ``--tool`` can be used to specify the merge tool used for file
2819 merges. It overrides the HGMERGE environment variable and your
2837 merges. It overrides the HGMERGE environment variable and your
2820 configuration files. See :hg:`help merge-tools` for options.
2838 configuration files. See :hg:`help merge-tools` for options.
2821
2839
2822 If no revision is specified, the working directory's parent is a
2840 If no revision is specified, the working directory's parent is a
2823 head revision, and the current branch contains exactly one other
2841 head revision, and the current branch contains exactly one other
2824 head, the other head is merged with by default. Otherwise, an
2842 head, the other head is merged with by default. Otherwise, an
2825 explicit revision with which to merge with must be provided.
2843 explicit revision with which to merge with must be provided.
2826
2844
2827 :hg:`resolve` must be used to resolve unresolved files.
2845 :hg:`resolve` must be used to resolve unresolved files.
2828
2846
2829 To undo an uncommitted merge, use :hg:`update --clean .` which
2847 To undo an uncommitted merge, use :hg:`update --clean .` which
2830 will check out a clean copy of the original merge parent, losing
2848 will check out a clean copy of the original merge parent, losing
2831 all changes.
2849 all changes.
2832
2850
2833 Returns 0 on success, 1 if there are unresolved files.
2851 Returns 0 on success, 1 if there are unresolved files.
2834 """
2852 """
2835
2853
2836 if opts.get('rev') and node:
2854 if opts.get('rev') and node:
2837 raise util.Abort(_("please specify just one revision"))
2855 raise util.Abort(_("please specify just one revision"))
2838 if not node:
2856 if not node:
2839 node = opts.get('rev')
2857 node = opts.get('rev')
2840
2858
2841 if not node:
2859 if not node:
2842 branch = repo[None].branch()
2860 branch = repo[None].branch()
2843 bheads = repo.branchheads(branch)
2861 bheads = repo.branchheads(branch)
2844 if len(bheads) > 2:
2862 if len(bheads) > 2:
2845 raise util.Abort(_(
2863 raise util.Abort(_(
2846 'branch \'%s\' has %d heads - '
2864 'branch \'%s\' has %d heads - '
2847 'please merge with an explicit rev\n'
2865 'please merge with an explicit rev\n'
2848 '(run \'hg heads .\' to see heads)')
2866 '(run \'hg heads .\' to see heads)')
2849 % (branch, len(bheads)))
2867 % (branch, len(bheads)))
2850
2868
2851 parent = repo.dirstate.p1()
2869 parent = repo.dirstate.p1()
2852 if len(bheads) == 1:
2870 if len(bheads) == 1:
2853 if len(repo.heads()) > 1:
2871 if len(repo.heads()) > 1:
2854 raise util.Abort(_(
2872 raise util.Abort(_(
2855 'branch \'%s\' has one head - '
2873 'branch \'%s\' has one head - '
2856 'please merge with an explicit rev\n'
2874 'please merge with an explicit rev\n'
2857 '(run \'hg heads\' to see all heads)')
2875 '(run \'hg heads\' to see all heads)')
2858 % branch)
2876 % branch)
2859 msg = _('there is nothing to merge')
2877 msg = _('there is nothing to merge')
2860 if parent != repo.lookup(repo[None].branch()):
2878 if parent != repo.lookup(repo[None].branch()):
2861 msg = _('%s - use "hg update" instead') % msg
2879 msg = _('%s - use "hg update" instead') % msg
2862 raise util.Abort(msg)
2880 raise util.Abort(msg)
2863
2881
2864 if parent not in bheads:
2882 if parent not in bheads:
2865 raise util.Abort(_('working dir not at a head rev - '
2883 raise util.Abort(_('working dir not at a head rev - '
2866 'use "hg update" or merge with an explicit rev'))
2884 'use "hg update" or merge with an explicit rev'))
2867 node = parent == bheads[0] and bheads[-1] or bheads[0]
2885 node = parent == bheads[0] and bheads[-1] or bheads[0]
2868 else:
2886 else:
2869 node = cmdutil.revsingle(repo, node).node()
2887 node = cmdutil.revsingle(repo, node).node()
2870
2888
2871 if opts.get('preview'):
2889 if opts.get('preview'):
2872 # find nodes that are ancestors of p2 but not of p1
2890 # find nodes that are ancestors of p2 but not of p1
2873 p1 = repo.lookup('.')
2891 p1 = repo.lookup('.')
2874 p2 = repo.lookup(node)
2892 p2 = repo.lookup(node)
2875 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
2893 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
2876
2894
2877 displayer = cmdutil.show_changeset(ui, repo, opts)
2895 displayer = cmdutil.show_changeset(ui, repo, opts)
2878 for node in nodes:
2896 for node in nodes:
2879 displayer.show(repo[node])
2897 displayer.show(repo[node])
2880 displayer.close()
2898 displayer.close()
2881 return 0
2899 return 0
2882
2900
2883 try:
2901 try:
2884 # ui.forcemerge is an internal variable, do not document
2902 # ui.forcemerge is an internal variable, do not document
2885 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
2903 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
2886 return hg.merge(repo, node, force=opts.get('force'))
2904 return hg.merge(repo, node, force=opts.get('force'))
2887 finally:
2905 finally:
2888 ui.setconfig('ui', 'forcemerge', '')
2906 ui.setconfig('ui', 'forcemerge', '')
2889
2907
2890 def outgoing(ui, repo, dest=None, **opts):
2908 def outgoing(ui, repo, dest=None, **opts):
2891 """show changesets not found in the destination
2909 """show changesets not found in the destination
2892
2910
2893 Show changesets not found in the specified destination repository
2911 Show changesets not found in the specified destination repository
2894 or the default push location. These are the changesets that would
2912 or the default push location. These are the changesets that would
2895 be pushed if a push was requested.
2913 be pushed if a push was requested.
2896
2914
2897 See pull for details of valid destination formats.
2915 See pull for details of valid destination formats.
2898
2916
2899 Returns 0 if there are outgoing changes, 1 otherwise.
2917 Returns 0 if there are outgoing changes, 1 otherwise.
2900 """
2918 """
2901
2919
2902 if opts.get('bookmarks'):
2920 if opts.get('bookmarks'):
2903 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2921 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2904 dest, branches = hg.parseurl(dest, opts.get('branch'))
2922 dest, branches = hg.parseurl(dest, opts.get('branch'))
2905 other = hg.repository(hg.remoteui(repo, opts), dest)
2923 other = hg.repository(hg.remoteui(repo, opts), dest)
2906 if 'bookmarks' not in other.listkeys('namespaces'):
2924 if 'bookmarks' not in other.listkeys('namespaces'):
2907 ui.warn(_("remote doesn't support bookmarks\n"))
2925 ui.warn(_("remote doesn't support bookmarks\n"))
2908 return 0
2926 return 0
2909 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
2927 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
2910 return bookmarks.diff(ui, other, repo)
2928 return bookmarks.diff(ui, other, repo)
2911
2929
2912 ret = hg.outgoing(ui, repo, dest, opts)
2930 ret = hg.outgoing(ui, repo, dest, opts)
2913 return ret
2931 return ret
2914
2932
2915 def parents(ui, repo, file_=None, **opts):
2933 def parents(ui, repo, file_=None, **opts):
2916 """show the parents of the working directory or revision
2934 """show the parents of the working directory or revision
2917
2935
2918 Print the working directory's parent revisions. If a revision is
2936 Print the working directory's parent revisions. If a revision is
2919 given via -r/--rev, the parent of that revision will be printed.
2937 given via -r/--rev, the parent of that revision will be printed.
2920 If a file argument is given, the revision in which the file was
2938 If a file argument is given, the revision in which the file was
2921 last changed (before the working directory revision or the
2939 last changed (before the working directory revision or the
2922 argument to --rev if given) is printed.
2940 argument to --rev if given) is printed.
2923
2941
2924 Returns 0 on success.
2942 Returns 0 on success.
2925 """
2943 """
2926
2944
2927 ctx = cmdutil.revsingle(repo, opts.get('rev'), None)
2945 ctx = cmdutil.revsingle(repo, opts.get('rev'), None)
2928
2946
2929 if file_:
2947 if file_:
2930 m = cmdutil.match(repo, (file_,), opts)
2948 m = cmdutil.match(repo, (file_,), opts)
2931 if m.anypats() or len(m.files()) != 1:
2949 if m.anypats() or len(m.files()) != 1:
2932 raise util.Abort(_('can only specify an explicit filename'))
2950 raise util.Abort(_('can only specify an explicit filename'))
2933 file_ = m.files()[0]
2951 file_ = m.files()[0]
2934 filenodes = []
2952 filenodes = []
2935 for cp in ctx.parents():
2953 for cp in ctx.parents():
2936 if not cp:
2954 if not cp:
2937 continue
2955 continue
2938 try:
2956 try:
2939 filenodes.append(cp.filenode(file_))
2957 filenodes.append(cp.filenode(file_))
2940 except error.LookupError:
2958 except error.LookupError:
2941 pass
2959 pass
2942 if not filenodes:
2960 if not filenodes:
2943 raise util.Abort(_("'%s' not found in manifest!") % file_)
2961 raise util.Abort(_("'%s' not found in manifest!") % file_)
2944 fl = repo.file(file_)
2962 fl = repo.file(file_)
2945 p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes]
2963 p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes]
2946 else:
2964 else:
2947 p = [cp.node() for cp in ctx.parents()]
2965 p = [cp.node() for cp in ctx.parents()]
2948
2966
2949 displayer = cmdutil.show_changeset(ui, repo, opts)
2967 displayer = cmdutil.show_changeset(ui, repo, opts)
2950 for n in p:
2968 for n in p:
2951 if n != nullid:
2969 if n != nullid:
2952 displayer.show(repo[n])
2970 displayer.show(repo[n])
2953 displayer.close()
2971 displayer.close()
2954
2972
2955 def paths(ui, repo, search=None):
2973 def paths(ui, repo, search=None):
2956 """show aliases for remote repositories
2974 """show aliases for remote repositories
2957
2975
2958 Show definition of symbolic path name NAME. If no name is given,
2976 Show definition of symbolic path name NAME. If no name is given,
2959 show definition of all available names.
2977 show definition of all available names.
2960
2978
2961 Path names are defined in the [paths] section of your
2979 Path names are defined in the [paths] section of your
2962 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
2980 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
2963 repository, ``.hg/hgrc`` is used, too.
2981 repository, ``.hg/hgrc`` is used, too.
2964
2982
2965 The path names ``default`` and ``default-push`` have a special
2983 The path names ``default`` and ``default-push`` have a special
2966 meaning. When performing a push or pull operation, they are used
2984 meaning. When performing a push or pull operation, they are used
2967 as fallbacks if no location is specified on the command-line.
2985 as fallbacks if no location is specified on the command-line.
2968 When ``default-push`` is set, it will be used for push and
2986 When ``default-push`` is set, it will be used for push and
2969 ``default`` will be used for pull; otherwise ``default`` is used
2987 ``default`` will be used for pull; otherwise ``default`` is used
2970 as the fallback for both. When cloning a repository, the clone
2988 as the fallback for both. When cloning a repository, the clone
2971 source is written as ``default`` in ``.hg/hgrc``. Note that
2989 source is written as ``default`` in ``.hg/hgrc``. Note that
2972 ``default`` and ``default-push`` apply to all inbound (e.g.
2990 ``default`` and ``default-push`` apply to all inbound (e.g.
2973 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
2991 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
2974 :hg:`bundle`) operations.
2992 :hg:`bundle`) operations.
2975
2993
2976 See :hg:`help urls` for more information.
2994 See :hg:`help urls` for more information.
2977
2995
2978 Returns 0 on success.
2996 Returns 0 on success.
2979 """
2997 """
2980 if search:
2998 if search:
2981 for name, path in ui.configitems("paths"):
2999 for name, path in ui.configitems("paths"):
2982 if name == search:
3000 if name == search:
2983 ui.write("%s\n" % util.hidepassword(path))
3001 ui.write("%s\n" % util.hidepassword(path))
2984 return
3002 return
2985 ui.warn(_("not found!\n"))
3003 ui.warn(_("not found!\n"))
2986 return 1
3004 return 1
2987 else:
3005 else:
2988 for name, path in ui.configitems("paths"):
3006 for name, path in ui.configitems("paths"):
2989 ui.write("%s = %s\n" % (name, util.hidepassword(path)))
3007 ui.write("%s = %s\n" % (name, util.hidepassword(path)))
2990
3008
2991 def postincoming(ui, repo, modheads, optupdate, checkout):
3009 def postincoming(ui, repo, modheads, optupdate, checkout):
2992 if modheads == 0:
3010 if modheads == 0:
2993 return
3011 return
2994 if optupdate:
3012 if optupdate:
2995 if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout:
3013 if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout:
2996 return hg.update(repo, checkout)
3014 return hg.update(repo, checkout)
2997 else:
3015 else:
2998 ui.status(_("not updating, since new heads added\n"))
3016 ui.status(_("not updating, since new heads added\n"))
2999 if modheads > 1:
3017 if modheads > 1:
3000 currentbranchheads = len(repo.branchheads())
3018 currentbranchheads = len(repo.branchheads())
3001 if currentbranchheads == modheads:
3019 if currentbranchheads == modheads:
3002 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
3020 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
3003 elif currentbranchheads > 1:
3021 elif currentbranchheads > 1:
3004 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to merge)\n"))
3022 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to merge)\n"))
3005 else:
3023 else:
3006 ui.status(_("(run 'hg heads' to see heads)\n"))
3024 ui.status(_("(run 'hg heads' to see heads)\n"))
3007 else:
3025 else:
3008 ui.status(_("(run 'hg update' to get a working copy)\n"))
3026 ui.status(_("(run 'hg update' to get a working copy)\n"))
3009
3027
3010 def pull(ui, repo, source="default", **opts):
3028 def pull(ui, repo, source="default", **opts):
3011 """pull changes from the specified source
3029 """pull changes from the specified source
3012
3030
3013 Pull changes from a remote repository to a local one.
3031 Pull changes from a remote repository to a local one.
3014
3032
3015 This finds all changes from the repository at the specified path
3033 This finds all changes from the repository at the specified path
3016 or URL and adds them to a local repository (the current one unless
3034 or URL and adds them to a local repository (the current one unless
3017 -R is specified). By default, this does not update the copy of the
3035 -R is specified). By default, this does not update the copy of the
3018 project in the working directory.
3036 project in the working directory.
3019
3037
3020 Use :hg:`incoming` if you want to see what would have been added
3038 Use :hg:`incoming` if you want to see what would have been added
3021 by a pull at the time you issued this command. If you then decide
3039 by a pull at the time you issued this command. If you then decide
3022 to add those changes to the repository, you should use :hg:`pull
3040 to add those changes to the repository, you should use :hg:`pull
3023 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
3041 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
3024
3042
3025 If SOURCE is omitted, the 'default' path will be used.
3043 If SOURCE is omitted, the 'default' path will be used.
3026 See :hg:`help urls` for more information.
3044 See :hg:`help urls` for more information.
3027
3045
3028 Returns 0 on success, 1 if an update had unresolved files.
3046 Returns 0 on success, 1 if an update had unresolved files.
3029 """
3047 """
3030 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
3048 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
3031 other = hg.repository(hg.remoteui(repo, opts), source)
3049 other = hg.repository(hg.remoteui(repo, opts), source)
3032 ui.status(_('pulling from %s\n') % util.hidepassword(source))
3050 ui.status(_('pulling from %s\n') % util.hidepassword(source))
3033 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
3051 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
3034
3052
3035 if opts.get('bookmark'):
3053 if opts.get('bookmark'):
3036 if not revs:
3054 if not revs:
3037 revs = []
3055 revs = []
3038 rb = other.listkeys('bookmarks')
3056 rb = other.listkeys('bookmarks')
3039 for b in opts['bookmark']:
3057 for b in opts['bookmark']:
3040 if b not in rb:
3058 if b not in rb:
3041 raise util.Abort(_('remote bookmark %s not found!') % b)
3059 raise util.Abort(_('remote bookmark %s not found!') % b)
3042 revs.append(rb[b])
3060 revs.append(rb[b])
3043
3061
3044 if revs:
3062 if revs:
3045 try:
3063 try:
3046 revs = [other.lookup(rev) for rev in revs]
3064 revs = [other.lookup(rev) for rev in revs]
3047 except error.CapabilityError:
3065 except error.CapabilityError:
3048 err = _("other repository doesn't support revision lookup, "
3066 err = _("other repository doesn't support revision lookup, "
3049 "so a rev cannot be specified.")
3067 "so a rev cannot be specified.")
3050 raise util.Abort(err)
3068 raise util.Abort(err)
3051
3069
3052 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
3070 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
3053 bookmarks.updatefromremote(ui, repo, other)
3071 bookmarks.updatefromremote(ui, repo, other)
3054 if checkout:
3072 if checkout:
3055 checkout = str(repo.changelog.rev(other.lookup(checkout)))
3073 checkout = str(repo.changelog.rev(other.lookup(checkout)))
3056 repo._subtoppath = source
3074 repo._subtoppath = source
3057 try:
3075 try:
3058 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
3076 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
3059
3077
3060 finally:
3078 finally:
3061 del repo._subtoppath
3079 del repo._subtoppath
3062
3080
3063 # update specified bookmarks
3081 # update specified bookmarks
3064 if opts.get('bookmark'):
3082 if opts.get('bookmark'):
3065 for b in opts['bookmark']:
3083 for b in opts['bookmark']:
3066 # explicit pull overrides local bookmark if any
3084 # explicit pull overrides local bookmark if any
3067 ui.status(_("importing bookmark %s\n") % b)
3085 ui.status(_("importing bookmark %s\n") % b)
3068 repo._bookmarks[b] = repo[rb[b]].node()
3086 repo._bookmarks[b] = repo[rb[b]].node()
3069 bookmarks.write(repo)
3087 bookmarks.write(repo)
3070
3088
3071 return ret
3089 return ret
3072
3090
3073 def push(ui, repo, dest=None, **opts):
3091 def push(ui, repo, dest=None, **opts):
3074 """push changes to the specified destination
3092 """push changes to the specified destination
3075
3093
3076 Push changesets from the local repository to the specified
3094 Push changesets from the local repository to the specified
3077 destination.
3095 destination.
3078
3096
3079 This operation is symmetrical to pull: it is identical to a pull
3097 This operation is symmetrical to pull: it is identical to a pull
3080 in the destination repository from the current one.
3098 in the destination repository from the current one.
3081
3099
3082 By default, push will not allow creation of new heads at the
3100 By default, push will not allow creation of new heads at the
3083 destination, since multiple heads would make it unclear which head
3101 destination, since multiple heads would make it unclear which head
3084 to use. In this situation, it is recommended to pull and merge
3102 to use. In this situation, it is recommended to pull and merge
3085 before pushing.
3103 before pushing.
3086
3104
3087 Use --new-branch if you want to allow push to create a new named
3105 Use --new-branch if you want to allow push to create a new named
3088 branch that is not present at the destination. This allows you to
3106 branch that is not present at the destination. This allows you to
3089 only create a new branch without forcing other changes.
3107 only create a new branch without forcing other changes.
3090
3108
3091 Use -f/--force to override the default behavior and push all
3109 Use -f/--force to override the default behavior and push all
3092 changesets on all branches.
3110 changesets on all branches.
3093
3111
3094 If -r/--rev is used, the specified revision and all its ancestors
3112 If -r/--rev is used, the specified revision and all its ancestors
3095 will be pushed to the remote repository.
3113 will be pushed to the remote repository.
3096
3114
3097 Please see :hg:`help urls` for important details about ``ssh://``
3115 Please see :hg:`help urls` for important details about ``ssh://``
3098 URLs. If DESTINATION is omitted, a default path will be used.
3116 URLs. If DESTINATION is omitted, a default path will be used.
3099
3117
3100 Returns 0 if push was successful, 1 if nothing to push.
3118 Returns 0 if push was successful, 1 if nothing to push.
3101 """
3119 """
3102
3120
3103 if opts.get('bookmark'):
3121 if opts.get('bookmark'):
3104 for b in opts['bookmark']:
3122 for b in opts['bookmark']:
3105 # translate -B options to -r so changesets get pushed
3123 # translate -B options to -r so changesets get pushed
3106 if b in repo._bookmarks:
3124 if b in repo._bookmarks:
3107 opts.setdefault('rev', []).append(b)
3125 opts.setdefault('rev', []).append(b)
3108 else:
3126 else:
3109 # if we try to push a deleted bookmark, translate it to null
3127 # if we try to push a deleted bookmark, translate it to null
3110 # this lets simultaneous -r, -b options continue working
3128 # this lets simultaneous -r, -b options continue working
3111 opts.setdefault('rev', []).append("null")
3129 opts.setdefault('rev', []).append("null")
3112
3130
3113 dest = ui.expandpath(dest or 'default-push', dest or 'default')
3131 dest = ui.expandpath(dest or 'default-push', dest or 'default')
3114 dest, branches = hg.parseurl(dest, opts.get('branch'))
3132 dest, branches = hg.parseurl(dest, opts.get('branch'))
3115 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
3133 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
3116 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
3134 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
3117 other = hg.repository(hg.remoteui(repo, opts), dest)
3135 other = hg.repository(hg.remoteui(repo, opts), dest)
3118 if revs:
3136 if revs:
3119 revs = [repo.lookup(rev) for rev in revs]
3137 revs = [repo.lookup(rev) for rev in revs]
3120
3138
3121 repo._subtoppath = dest
3139 repo._subtoppath = dest
3122 try:
3140 try:
3123 # push subrepos depth-first for coherent ordering
3141 # push subrepos depth-first for coherent ordering
3124 c = repo['']
3142 c = repo['']
3125 subs = c.substate # only repos that are committed
3143 subs = c.substate # only repos that are committed
3126 for s in sorted(subs):
3144 for s in sorted(subs):
3127 if not c.sub(s).push(opts.get('force')):
3145 if not c.sub(s).push(opts.get('force')):
3128 return False
3146 return False
3129 finally:
3147 finally:
3130 del repo._subtoppath
3148 del repo._subtoppath
3131 result = repo.push(other, opts.get('force'), revs=revs,
3149 result = repo.push(other, opts.get('force'), revs=revs,
3132 newbranch=opts.get('new_branch'))
3150 newbranch=opts.get('new_branch'))
3133
3151
3134 result = (result == 0)
3152 result = (result == 0)
3135
3153
3136 if opts.get('bookmark'):
3154 if opts.get('bookmark'):
3137 rb = other.listkeys('bookmarks')
3155 rb = other.listkeys('bookmarks')
3138 for b in opts['bookmark']:
3156 for b in opts['bookmark']:
3139 # explicit push overrides remote bookmark if any
3157 # explicit push overrides remote bookmark if any
3140 if b in repo._bookmarks:
3158 if b in repo._bookmarks:
3141 ui.status(_("exporting bookmark %s\n") % b)
3159 ui.status(_("exporting bookmark %s\n") % b)
3142 new = repo[b].hex()
3160 new = repo[b].hex()
3143 elif b in rb:
3161 elif b in rb:
3144 ui.status(_("deleting remote bookmark %s\n") % b)
3162 ui.status(_("deleting remote bookmark %s\n") % b)
3145 new = '' # delete
3163 new = '' # delete
3146 else:
3164 else:
3147 ui.warn(_('bookmark %s does not exist on the local '
3165 ui.warn(_('bookmark %s does not exist on the local '
3148 'or remote repository!\n') % b)
3166 'or remote repository!\n') % b)
3149 return 2
3167 return 2
3150 old = rb.get(b, '')
3168 old = rb.get(b, '')
3151 r = other.pushkey('bookmarks', b, old, new)
3169 r = other.pushkey('bookmarks', b, old, new)
3152 if not r:
3170 if not r:
3153 ui.warn(_('updating bookmark %s failed!\n') % b)
3171 ui.warn(_('updating bookmark %s failed!\n') % b)
3154 if not result:
3172 if not result:
3155 result = 2
3173 result = 2
3156
3174
3157 return result
3175 return result
3158
3176
3159 def recover(ui, repo):
3177 def recover(ui, repo):
3160 """roll back an interrupted transaction
3178 """roll back an interrupted transaction
3161
3179
3162 Recover from an interrupted commit or pull.
3180 Recover from an interrupted commit or pull.
3163
3181
3164 This command tries to fix the repository status after an
3182 This command tries to fix the repository status after an
3165 interrupted operation. It should only be necessary when Mercurial
3183 interrupted operation. It should only be necessary when Mercurial
3166 suggests it.
3184 suggests it.
3167
3185
3168 Returns 0 if successful, 1 if nothing to recover or verify fails.
3186 Returns 0 if successful, 1 if nothing to recover or verify fails.
3169 """
3187 """
3170 if repo.recover():
3188 if repo.recover():
3171 return hg.verify(repo)
3189 return hg.verify(repo)
3172 return 1
3190 return 1
3173
3191
3174 def remove(ui, repo, *pats, **opts):
3192 def remove(ui, repo, *pats, **opts):
3175 """remove the specified files on the next commit
3193 """remove the specified files on the next commit
3176
3194
3177 Schedule the indicated files for removal from the repository.
3195 Schedule the indicated files for removal from the repository.
3178
3196
3179 This only removes files from the current branch, not from the
3197 This only removes files from the current branch, not from the
3180 entire project history. -A/--after can be used to remove only
3198 entire project history. -A/--after can be used to remove only
3181 files that have already been deleted, -f/--force can be used to
3199 files that have already been deleted, -f/--force can be used to
3182 force deletion, and -Af can be used to remove files from the next
3200 force deletion, and -Af can be used to remove files from the next
3183 revision without deleting them from the working directory.
3201 revision without deleting them from the working directory.
3184
3202
3185 The following table details the behavior of remove for different
3203 The following table details the behavior of remove for different
3186 file states (columns) and option combinations (rows). The file
3204 file states (columns) and option combinations (rows). The file
3187 states are Added [A], Clean [C], Modified [M] and Missing [!] (as
3205 states are Added [A], Clean [C], Modified [M] and Missing [!] (as
3188 reported by :hg:`status`). The actions are Warn, Remove (from
3206 reported by :hg:`status`). The actions are Warn, Remove (from
3189 branch) and Delete (from disk)::
3207 branch) and Delete (from disk)::
3190
3208
3191 A C M !
3209 A C M !
3192 none W RD W R
3210 none W RD W R
3193 -f R RD RD R
3211 -f R RD RD R
3194 -A W W W R
3212 -A W W W R
3195 -Af R R R R
3213 -Af R R R R
3196
3214
3197 This command schedules the files to be removed at the next commit.
3215 This command schedules the files to be removed at the next commit.
3198 To undo a remove before that, see :hg:`revert`.
3216 To undo a remove before that, see :hg:`revert`.
3199
3217
3200 Returns 0 on success, 1 if any warnings encountered.
3218 Returns 0 on success, 1 if any warnings encountered.
3201 """
3219 """
3202
3220
3203 ret = 0
3221 ret = 0
3204 after, force = opts.get('after'), opts.get('force')
3222 after, force = opts.get('after'), opts.get('force')
3205 if not pats and not after:
3223 if not pats and not after:
3206 raise util.Abort(_('no files specified'))
3224 raise util.Abort(_('no files specified'))
3207
3225
3208 m = cmdutil.match(repo, pats, opts)
3226 m = cmdutil.match(repo, pats, opts)
3209 s = repo.status(match=m, clean=True)
3227 s = repo.status(match=m, clean=True)
3210 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
3228 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
3211
3229
3212 for f in m.files():
3230 for f in m.files():
3213 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
3231 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
3214 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
3232 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
3215 ret = 1
3233 ret = 1
3216
3234
3217 if force:
3235 if force:
3218 remove, forget = modified + deleted + clean, added
3236 remove, forget = modified + deleted + clean, added
3219 elif after:
3237 elif after:
3220 remove, forget = deleted, []
3238 remove, forget = deleted, []
3221 for f in modified + added + clean:
3239 for f in modified + added + clean:
3222 ui.warn(_('not removing %s: file still exists (use -f'
3240 ui.warn(_('not removing %s: file still exists (use -f'
3223 ' to force removal)\n') % m.rel(f))
3241 ' to force removal)\n') % m.rel(f))
3224 ret = 1
3242 ret = 1
3225 else:
3243 else:
3226 remove, forget = deleted + clean, []
3244 remove, forget = deleted + clean, []
3227 for f in modified:
3245 for f in modified:
3228 ui.warn(_('not removing %s: file is modified (use -f'
3246 ui.warn(_('not removing %s: file is modified (use -f'
3229 ' to force removal)\n') % m.rel(f))
3247 ' to force removal)\n') % m.rel(f))
3230 ret = 1
3248 ret = 1
3231 for f in added:
3249 for f in added:
3232 ui.warn(_('not removing %s: file has been marked for add (use -f'
3250 ui.warn(_('not removing %s: file has been marked for add (use -f'
3233 ' to force removal)\n') % m.rel(f))
3251 ' to force removal)\n') % m.rel(f))
3234 ret = 1
3252 ret = 1
3235
3253
3236 for f in sorted(remove + forget):
3254 for f in sorted(remove + forget):
3237 if ui.verbose or not m.exact(f):
3255 if ui.verbose or not m.exact(f):
3238 ui.status(_('removing %s\n') % m.rel(f))
3256 ui.status(_('removing %s\n') % m.rel(f))
3239
3257
3240 repo[None].forget(forget)
3258 repo[None].forget(forget)
3241 repo[None].remove(remove, unlink=not after)
3259 repo[None].remove(remove, unlink=not after)
3242 return ret
3260 return ret
3243
3261
3244 def rename(ui, repo, *pats, **opts):
3262 def rename(ui, repo, *pats, **opts):
3245 """rename files; equivalent of copy + remove
3263 """rename files; equivalent of copy + remove
3246
3264
3247 Mark dest as copies of sources; mark sources for deletion. If dest
3265 Mark dest as copies of sources; mark sources for deletion. If dest
3248 is a directory, copies are put in that directory. If dest is a
3266 is a directory, copies are put in that directory. If dest is a
3249 file, there can only be one source.
3267 file, there can only be one source.
3250
3268
3251 By default, this command copies the contents of files as they
3269 By default, this command copies the contents of files as they
3252 exist in the working directory. If invoked with -A/--after, the
3270 exist in the working directory. If invoked with -A/--after, the
3253 operation is recorded, but no copying is performed.
3271 operation is recorded, but no copying is performed.
3254
3272
3255 This command takes effect at the next commit. To undo a rename
3273 This command takes effect at the next commit. To undo a rename
3256 before that, see :hg:`revert`.
3274 before that, see :hg:`revert`.
3257
3275
3258 Returns 0 on success, 1 if errors are encountered.
3276 Returns 0 on success, 1 if errors are encountered.
3259 """
3277 """
3260 wlock = repo.wlock(False)
3278 wlock = repo.wlock(False)
3261 try:
3279 try:
3262 return cmdutil.copy(ui, repo, pats, opts, rename=True)
3280 return cmdutil.copy(ui, repo, pats, opts, rename=True)
3263 finally:
3281 finally:
3264 wlock.release()
3282 wlock.release()
3265
3283
3266 def resolve(ui, repo, *pats, **opts):
3284 def resolve(ui, repo, *pats, **opts):
3267 """redo merges or set/view the merge status of files
3285 """redo merges or set/view the merge status of files
3268
3286
3269 Merges with unresolved conflicts are often the result of
3287 Merges with unresolved conflicts are often the result of
3270 non-interactive merging using the ``internal:merge`` configuration
3288 non-interactive merging using the ``internal:merge`` configuration
3271 setting, or a command-line merge tool like ``diff3``. The resolve
3289 setting, or a command-line merge tool like ``diff3``. The resolve
3272 command is used to manage the files involved in a merge, after
3290 command is used to manage the files involved in a merge, after
3273 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
3291 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
3274 working directory must have two parents).
3292 working directory must have two parents).
3275
3293
3276 The resolve command can be used in the following ways:
3294 The resolve command can be used in the following ways:
3277
3295
3278 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
3296 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
3279 files, discarding any previous merge attempts. Re-merging is not
3297 files, discarding any previous merge attempts. Re-merging is not
3280 performed for files already marked as resolved. Use ``--all/-a``
3298 performed for files already marked as resolved. Use ``--all/-a``
3281 to selects all unresolved files. ``--tool`` can be used to specify
3299 to selects all unresolved files. ``--tool`` can be used to specify
3282 the merge tool used for the given files. It overrides the HGMERGE
3300 the merge tool used for the given files. It overrides the HGMERGE
3283 environment variable and your configuration files.
3301 environment variable and your configuration files.
3284
3302
3285 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
3303 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
3286 (e.g. after having manually fixed-up the files). The default is
3304 (e.g. after having manually fixed-up the files). The default is
3287 to mark all unresolved files.
3305 to mark all unresolved files.
3288
3306
3289 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
3307 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
3290 default is to mark all resolved files.
3308 default is to mark all resolved files.
3291
3309
3292 - :hg:`resolve -l`: list files which had or still have conflicts.
3310 - :hg:`resolve -l`: list files which had or still have conflicts.
3293 In the printed list, ``U`` = unresolved and ``R`` = resolved.
3311 In the printed list, ``U`` = unresolved and ``R`` = resolved.
3294
3312
3295 Note that Mercurial will not let you commit files with unresolved
3313 Note that Mercurial will not let you commit files with unresolved
3296 merge conflicts. You must use :hg:`resolve -m ...` before you can
3314 merge conflicts. You must use :hg:`resolve -m ...` before you can
3297 commit after a conflicting merge.
3315 commit after a conflicting merge.
3298
3316
3299 Returns 0 on success, 1 if any files fail a resolve attempt.
3317 Returns 0 on success, 1 if any files fail a resolve attempt.
3300 """
3318 """
3301
3319
3302 all, mark, unmark, show, nostatus = \
3320 all, mark, unmark, show, nostatus = \
3303 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
3321 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
3304
3322
3305 if (show and (mark or unmark)) or (mark and unmark):
3323 if (show and (mark or unmark)) or (mark and unmark):
3306 raise util.Abort(_("too many options specified"))
3324 raise util.Abort(_("too many options specified"))
3307 if pats and all:
3325 if pats and all:
3308 raise util.Abort(_("can't specify --all and patterns"))
3326 raise util.Abort(_("can't specify --all and patterns"))
3309 if not (all or pats or show or mark or unmark):
3327 if not (all or pats or show or mark or unmark):
3310 raise util.Abort(_('no files or directories specified; '
3328 raise util.Abort(_('no files or directories specified; '
3311 'use --all to remerge all files'))
3329 'use --all to remerge all files'))
3312
3330
3313 ms = mergemod.mergestate(repo)
3331 ms = mergemod.mergestate(repo)
3314 m = cmdutil.match(repo, pats, opts)
3332 m = cmdutil.match(repo, pats, opts)
3315 ret = 0
3333 ret = 0
3316
3334
3317 for f in ms:
3335 for f in ms:
3318 if m(f):
3336 if m(f):
3319 if show:
3337 if show:
3320 if nostatus:
3338 if nostatus:
3321 ui.write("%s\n" % f)
3339 ui.write("%s\n" % f)
3322 else:
3340 else:
3323 ui.write("%s %s\n" % (ms[f].upper(), f),
3341 ui.write("%s %s\n" % (ms[f].upper(), f),
3324 label='resolve.' +
3342 label='resolve.' +
3325 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
3343 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
3326 elif mark:
3344 elif mark:
3327 ms.mark(f, "r")
3345 ms.mark(f, "r")
3328 elif unmark:
3346 elif unmark:
3329 ms.mark(f, "u")
3347 ms.mark(f, "u")
3330 else:
3348 else:
3331 wctx = repo[None]
3349 wctx = repo[None]
3332 mctx = wctx.parents()[-1]
3350 mctx = wctx.parents()[-1]
3333
3351
3334 # backup pre-resolve (merge uses .orig for its own purposes)
3352 # backup pre-resolve (merge uses .orig for its own purposes)
3335 a = repo.wjoin(f)
3353 a = repo.wjoin(f)
3336 util.copyfile(a, a + ".resolve")
3354 util.copyfile(a, a + ".resolve")
3337
3355
3338 try:
3356 try:
3339 # resolve file
3357 # resolve file
3340 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
3358 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
3341 if ms.resolve(f, wctx, mctx):
3359 if ms.resolve(f, wctx, mctx):
3342 ret = 1
3360 ret = 1
3343 finally:
3361 finally:
3344 ui.setconfig('ui', 'forcemerge', '')
3362 ui.setconfig('ui', 'forcemerge', '')
3345
3363
3346 # replace filemerge's .orig file with our resolve file
3364 # replace filemerge's .orig file with our resolve file
3347 util.rename(a + ".resolve", a + ".orig")
3365 util.rename(a + ".resolve", a + ".orig")
3348
3366
3349 ms.commit()
3367 ms.commit()
3350 return ret
3368 return ret
3351
3369
3352 def revert(ui, repo, *pats, **opts):
3370 def revert(ui, repo, *pats, **opts):
3353 """restore individual files or directories to an earlier state
3371 """restore individual files or directories to an earlier state
3354
3372
3355 .. note::
3373 .. note::
3356 This command is most likely not what you are looking for.
3374 This command is most likely not what you are looking for.
3357 Revert will partially overwrite content in the working
3375 Revert will partially overwrite content in the working
3358 directory without changing the working directory parents. Use
3376 directory without changing the working directory parents. Use
3359 :hg:`update -r rev` to check out earlier revisions, or
3377 :hg:`update -r rev` to check out earlier revisions, or
3360 :hg:`update --clean .` to undo a merge which has added another
3378 :hg:`update --clean .` to undo a merge which has added another
3361 parent.
3379 parent.
3362
3380
3363 With no revision specified, revert the named files or directories
3381 With no revision specified, revert the named files or directories
3364 to the contents they had in the parent of the working directory.
3382 to the contents they had in the parent of the working directory.
3365 This restores the contents of the affected files to an unmodified
3383 This restores the contents of the affected files to an unmodified
3366 state and unschedules adds, removes, copies, and renames. If the
3384 state and unschedules adds, removes, copies, and renames. If the
3367 working directory has two parents, you must explicitly specify a
3385 working directory has two parents, you must explicitly specify a
3368 revision.
3386 revision.
3369
3387
3370 Using the -r/--rev option, revert the given files or directories
3388 Using the -r/--rev option, revert the given files or directories
3371 to their contents as of a specific revision. This can be helpful
3389 to their contents as of a specific revision. This can be helpful
3372 to "roll back" some or all of an earlier change. See :hg:`help
3390 to "roll back" some or all of an earlier change. See :hg:`help
3373 dates` for a list of formats valid for -d/--date.
3391 dates` for a list of formats valid for -d/--date.
3374
3392
3375 Revert modifies the working directory. It does not commit any
3393 Revert modifies the working directory. It does not commit any
3376 changes, or change the parent of the working directory. If you
3394 changes, or change the parent of the working directory. If you
3377 revert to a revision other than the parent of the working
3395 revert to a revision other than the parent of the working
3378 directory, the reverted files will thus appear modified
3396 directory, the reverted files will thus appear modified
3379 afterwards.
3397 afterwards.
3380
3398
3381 If a file has been deleted, it is restored. Files scheduled for
3399 If a file has been deleted, it is restored. Files scheduled for
3382 addition are just unscheduled and left as they are. If the
3400 addition are just unscheduled and left as they are. If the
3383 executable mode of a file was changed, it is reset.
3401 executable mode of a file was changed, it is reset.
3384
3402
3385 If names are given, all files matching the names are reverted.
3403 If names are given, all files matching the names are reverted.
3386 If no arguments are given, no files are reverted.
3404 If no arguments are given, no files are reverted.
3387
3405
3388 Modified files are saved with a .orig suffix before reverting.
3406 Modified files are saved with a .orig suffix before reverting.
3389 To disable these backups, use --no-backup.
3407 To disable these backups, use --no-backup.
3390
3408
3391 Returns 0 on success.
3409 Returns 0 on success.
3392 """
3410 """
3393
3411
3394 if opts.get("date"):
3412 if opts.get("date"):
3395 if opts.get("rev"):
3413 if opts.get("rev"):
3396 raise util.Abort(_("you can't specify a revision and a date"))
3414 raise util.Abort(_("you can't specify a revision and a date"))
3397 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
3415 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
3398
3416
3399 parent, p2 = repo.dirstate.parents()
3417 parent, p2 = repo.dirstate.parents()
3400 if not opts.get('rev') and p2 != nullid:
3418 if not opts.get('rev') and p2 != nullid:
3401 raise util.Abort(_('uncommitted merge - '
3419 raise util.Abort(_('uncommitted merge - '
3402 'use "hg update", see "hg help revert"'))
3420 'use "hg update", see "hg help revert"'))
3403
3421
3404 if not pats and not opts.get('all'):
3422 if not pats and not opts.get('all'):
3405 raise util.Abort(_('no files or directories specified; '
3423 raise util.Abort(_('no files or directories specified; '
3406 'use --all to revert the whole repo'))
3424 'use --all to revert the whole repo'))
3407
3425
3408 ctx = cmdutil.revsingle(repo, opts.get('rev'))
3426 ctx = cmdutil.revsingle(repo, opts.get('rev'))
3409 node = ctx.node()
3427 node = ctx.node()
3410 mf = ctx.manifest()
3428 mf = ctx.manifest()
3411 if node == parent:
3429 if node == parent:
3412 pmf = mf
3430 pmf = mf
3413 else:
3431 else:
3414 pmf = None
3432 pmf = None
3415
3433
3416 # need all matching names in dirstate and manifest of target rev,
3434 # need all matching names in dirstate and manifest of target rev,
3417 # so have to walk both. do not print errors if files exist in one
3435 # so have to walk both. do not print errors if files exist in one
3418 # but not other.
3436 # but not other.
3419
3437
3420 names = {}
3438 names = {}
3421
3439
3422 wlock = repo.wlock()
3440 wlock = repo.wlock()
3423 try:
3441 try:
3424 # walk dirstate.
3442 # walk dirstate.
3425
3443
3426 m = cmdutil.match(repo, pats, opts)
3444 m = cmdutil.match(repo, pats, opts)
3427 m.bad = lambda x, y: False
3445 m.bad = lambda x, y: False
3428 for abs in repo.walk(m):
3446 for abs in repo.walk(m):
3429 names[abs] = m.rel(abs), m.exact(abs)
3447 names[abs] = m.rel(abs), m.exact(abs)
3430
3448
3431 # walk target manifest.
3449 # walk target manifest.
3432
3450
3433 def badfn(path, msg):
3451 def badfn(path, msg):
3434 if path in names:
3452 if path in names:
3435 return
3453 return
3436 path_ = path + '/'
3454 path_ = path + '/'
3437 for f in names:
3455 for f in names:
3438 if f.startswith(path_):
3456 if f.startswith(path_):
3439 return
3457 return
3440 ui.warn("%s: %s\n" % (m.rel(path), msg))
3458 ui.warn("%s: %s\n" % (m.rel(path), msg))
3441
3459
3442 m = cmdutil.match(repo, pats, opts)
3460 m = cmdutil.match(repo, pats, opts)
3443 m.bad = badfn
3461 m.bad = badfn
3444 for abs in repo[node].walk(m):
3462 for abs in repo[node].walk(m):
3445 if abs not in names:
3463 if abs not in names:
3446 names[abs] = m.rel(abs), m.exact(abs)
3464 names[abs] = m.rel(abs), m.exact(abs)
3447
3465
3448 m = cmdutil.matchfiles(repo, names)
3466 m = cmdutil.matchfiles(repo, names)
3449 changes = repo.status(match=m)[:4]
3467 changes = repo.status(match=m)[:4]
3450 modified, added, removed, deleted = map(set, changes)
3468 modified, added, removed, deleted = map(set, changes)
3451
3469
3452 # if f is a rename, also revert the source
3470 # if f is a rename, also revert the source
3453 cwd = repo.getcwd()
3471 cwd = repo.getcwd()
3454 for f in added:
3472 for f in added:
3455 src = repo.dirstate.copied(f)
3473 src = repo.dirstate.copied(f)
3456 if src and src not in names and repo.dirstate[src] == 'r':
3474 if src and src not in names and repo.dirstate[src] == 'r':
3457 removed.add(src)
3475 removed.add(src)
3458 names[src] = (repo.pathto(src, cwd), True)
3476 names[src] = (repo.pathto(src, cwd), True)
3459
3477
3460 def removeforget(abs):
3478 def removeforget(abs):
3461 if repo.dirstate[abs] == 'a':
3479 if repo.dirstate[abs] == 'a':
3462 return _('forgetting %s\n')
3480 return _('forgetting %s\n')
3463 return _('removing %s\n')
3481 return _('removing %s\n')
3464
3482
3465 revert = ([], _('reverting %s\n'))
3483 revert = ([], _('reverting %s\n'))
3466 add = ([], _('adding %s\n'))
3484 add = ([], _('adding %s\n'))
3467 remove = ([], removeforget)
3485 remove = ([], removeforget)
3468 undelete = ([], _('undeleting %s\n'))
3486 undelete = ([], _('undeleting %s\n'))
3469
3487
3470 disptable = (
3488 disptable = (
3471 # dispatch table:
3489 # dispatch table:
3472 # file state
3490 # file state
3473 # action if in target manifest
3491 # action if in target manifest
3474 # action if not in target manifest
3492 # action if not in target manifest
3475 # make backup if in target manifest
3493 # make backup if in target manifest
3476 # make backup if not in target manifest
3494 # make backup if not in target manifest
3477 (modified, revert, remove, True, True),
3495 (modified, revert, remove, True, True),
3478 (added, revert, remove, True, False),
3496 (added, revert, remove, True, False),
3479 (removed, undelete, None, False, False),
3497 (removed, undelete, None, False, False),
3480 (deleted, revert, remove, False, False),
3498 (deleted, revert, remove, False, False),
3481 )
3499 )
3482
3500
3483 for abs, (rel, exact) in sorted(names.items()):
3501 for abs, (rel, exact) in sorted(names.items()):
3484 mfentry = mf.get(abs)
3502 mfentry = mf.get(abs)
3485 target = repo.wjoin(abs)
3503 target = repo.wjoin(abs)
3486 def handle(xlist, dobackup):
3504 def handle(xlist, dobackup):
3487 xlist[0].append(abs)
3505 xlist[0].append(abs)
3488 if (dobackup and not opts.get('no_backup') and
3506 if (dobackup and not opts.get('no_backup') and
3489 os.path.lexists(target)):
3507 os.path.lexists(target)):
3490 bakname = "%s.orig" % rel
3508 bakname = "%s.orig" % rel
3491 ui.note(_('saving current version of %s as %s\n') %
3509 ui.note(_('saving current version of %s as %s\n') %
3492 (rel, bakname))
3510 (rel, bakname))
3493 if not opts.get('dry_run'):
3511 if not opts.get('dry_run'):
3494 util.rename(target, bakname)
3512 util.rename(target, bakname)
3495 if ui.verbose or not exact:
3513 if ui.verbose or not exact:
3496 msg = xlist[1]
3514 msg = xlist[1]
3497 if not isinstance(msg, basestring):
3515 if not isinstance(msg, basestring):
3498 msg = msg(abs)
3516 msg = msg(abs)
3499 ui.status(msg % rel)
3517 ui.status(msg % rel)
3500 for table, hitlist, misslist, backuphit, backupmiss in disptable:
3518 for table, hitlist, misslist, backuphit, backupmiss in disptable:
3501 if abs not in table:
3519 if abs not in table:
3502 continue
3520 continue
3503 # file has changed in dirstate
3521 # file has changed in dirstate
3504 if mfentry:
3522 if mfentry:
3505 handle(hitlist, backuphit)
3523 handle(hitlist, backuphit)
3506 elif misslist is not None:
3524 elif misslist is not None:
3507 handle(misslist, backupmiss)
3525 handle(misslist, backupmiss)
3508 break
3526 break
3509 else:
3527 else:
3510 if abs not in repo.dirstate:
3528 if abs not in repo.dirstate:
3511 if mfentry:
3529 if mfentry:
3512 handle(add, True)
3530 handle(add, True)
3513 elif exact:
3531 elif exact:
3514 ui.warn(_('file not managed: %s\n') % rel)
3532 ui.warn(_('file not managed: %s\n') % rel)
3515 continue
3533 continue
3516 # file has not changed in dirstate
3534 # file has not changed in dirstate
3517 if node == parent:
3535 if node == parent:
3518 if exact:
3536 if exact:
3519 ui.warn(_('no changes needed to %s\n') % rel)
3537 ui.warn(_('no changes needed to %s\n') % rel)
3520 continue
3538 continue
3521 if pmf is None:
3539 if pmf is None:
3522 # only need parent manifest in this unlikely case,
3540 # only need parent manifest in this unlikely case,
3523 # so do not read by default
3541 # so do not read by default
3524 pmf = repo[parent].manifest()
3542 pmf = repo[parent].manifest()
3525 if abs in pmf:
3543 if abs in pmf:
3526 if mfentry:
3544 if mfentry:
3527 # if version of file is same in parent and target
3545 # if version of file is same in parent and target
3528 # manifests, do nothing
3546 # manifests, do nothing
3529 if (pmf[abs] != mfentry or
3547 if (pmf[abs] != mfentry or
3530 pmf.flags(abs) != mf.flags(abs)):
3548 pmf.flags(abs) != mf.flags(abs)):
3531 handle(revert, False)
3549 handle(revert, False)
3532 else:
3550 else:
3533 handle(remove, False)
3551 handle(remove, False)
3534
3552
3535 if not opts.get('dry_run'):
3553 if not opts.get('dry_run'):
3536 def checkout(f):
3554 def checkout(f):
3537 fc = ctx[f]
3555 fc = ctx[f]
3538 repo.wwrite(f, fc.data(), fc.flags())
3556 repo.wwrite(f, fc.data(), fc.flags())
3539
3557
3540 audit_path = scmutil.path_auditor(repo.root)
3558 audit_path = scmutil.path_auditor(repo.root)
3541 for f in remove[0]:
3559 for f in remove[0]:
3542 if repo.dirstate[f] == 'a':
3560 if repo.dirstate[f] == 'a':
3543 repo.dirstate.forget(f)
3561 repo.dirstate.forget(f)
3544 continue
3562 continue
3545 audit_path(f)
3563 audit_path(f)
3546 try:
3564 try:
3547 util.unlinkpath(repo.wjoin(f))
3565 util.unlinkpath(repo.wjoin(f))
3548 except OSError:
3566 except OSError:
3549 pass
3567 pass
3550 repo.dirstate.remove(f)
3568 repo.dirstate.remove(f)
3551
3569
3552 normal = None
3570 normal = None
3553 if node == parent:
3571 if node == parent:
3554 # We're reverting to our parent. If possible, we'd like status
3572 # We're reverting to our parent. If possible, we'd like status
3555 # to report the file as clean. We have to use normallookup for
3573 # to report the file as clean. We have to use normallookup for
3556 # merges to avoid losing information about merged/dirty files.
3574 # merges to avoid losing information about merged/dirty files.
3557 if p2 != nullid:
3575 if p2 != nullid:
3558 normal = repo.dirstate.normallookup
3576 normal = repo.dirstate.normallookup
3559 else:
3577 else:
3560 normal = repo.dirstate.normal
3578 normal = repo.dirstate.normal
3561 for f in revert[0]:
3579 for f in revert[0]:
3562 checkout(f)
3580 checkout(f)
3563 if normal:
3581 if normal:
3564 normal(f)
3582 normal(f)
3565
3583
3566 for f in add[0]:
3584 for f in add[0]:
3567 checkout(f)
3585 checkout(f)
3568 repo.dirstate.add(f)
3586 repo.dirstate.add(f)
3569
3587
3570 normal = repo.dirstate.normallookup
3588 normal = repo.dirstate.normallookup
3571 if node == parent and p2 == nullid:
3589 if node == parent and p2 == nullid:
3572 normal = repo.dirstate.normal
3590 normal = repo.dirstate.normal
3573 for f in undelete[0]:
3591 for f in undelete[0]:
3574 checkout(f)
3592 checkout(f)
3575 normal(f)
3593 normal(f)
3576
3594
3577 finally:
3595 finally:
3578 wlock.release()
3596 wlock.release()
3579
3597
3580 def rollback(ui, repo, **opts):
3598 def rollback(ui, repo, **opts):
3581 """roll back the last transaction (dangerous)
3599 """roll back the last transaction (dangerous)
3582
3600
3583 This command should be used with care. There is only one level of
3601 This command should be used with care. There is only one level of
3584 rollback, and there is no way to undo a rollback. It will also
3602 rollback, and there is no way to undo a rollback. It will also
3585 restore the dirstate at the time of the last transaction, losing
3603 restore the dirstate at the time of the last transaction, losing
3586 any dirstate changes since that time. This command does not alter
3604 any dirstate changes since that time. This command does not alter
3587 the working directory.
3605 the working directory.
3588
3606
3589 Transactions are used to encapsulate the effects of all commands
3607 Transactions are used to encapsulate the effects of all commands
3590 that create new changesets or propagate existing changesets into a
3608 that create new changesets or propagate existing changesets into a
3591 repository. For example, the following commands are transactional,
3609 repository. For example, the following commands are transactional,
3592 and their effects can be rolled back:
3610 and their effects can be rolled back:
3593
3611
3594 - commit
3612 - commit
3595 - import
3613 - import
3596 - pull
3614 - pull
3597 - push (with this repository as the destination)
3615 - push (with this repository as the destination)
3598 - unbundle
3616 - unbundle
3599
3617
3600 This command is not intended for use on public repositories. Once
3618 This command is not intended for use on public repositories. Once
3601 changes are visible for pull by other users, rolling a transaction
3619 changes are visible for pull by other users, rolling a transaction
3602 back locally is ineffective (someone else may already have pulled
3620 back locally is ineffective (someone else may already have pulled
3603 the changes). Furthermore, a race is possible with readers of the
3621 the changes). Furthermore, a race is possible with readers of the
3604 repository; for example an in-progress pull from the repository
3622 repository; for example an in-progress pull from the repository
3605 may fail if a rollback is performed.
3623 may fail if a rollback is performed.
3606
3624
3607 Returns 0 on success, 1 if no rollback data is available.
3625 Returns 0 on success, 1 if no rollback data is available.
3608 """
3626 """
3609 return repo.rollback(opts.get('dry_run'))
3627 return repo.rollback(opts.get('dry_run'))
3610
3628
3611 def root(ui, repo):
3629 def root(ui, repo):
3612 """print the root (top) of the current working directory
3630 """print the root (top) of the current working directory
3613
3631
3614 Print the root directory of the current repository.
3632 Print the root directory of the current repository.
3615
3633
3616 Returns 0 on success.
3634 Returns 0 on success.
3617 """
3635 """
3618 ui.write(repo.root + "\n")
3636 ui.write(repo.root + "\n")
3619
3637
3620 def serve(ui, repo, **opts):
3638 def serve(ui, repo, **opts):
3621 """start stand-alone webserver
3639 """start stand-alone webserver
3622
3640
3623 Start a local HTTP repository browser and pull server. You can use
3641 Start a local HTTP repository browser and pull server. You can use
3624 this for ad-hoc sharing and browsing of repositories. It is
3642 this for ad-hoc sharing and browsing of repositories. It is
3625 recommended to use a real web server to serve a repository for
3643 recommended to use a real web server to serve a repository for
3626 longer periods of time.
3644 longer periods of time.
3627
3645
3628 Please note that the server does not implement access control.
3646 Please note that the server does not implement access control.
3629 This means that, by default, anybody can read from the server and
3647 This means that, by default, anybody can read from the server and
3630 nobody can write to it by default. Set the ``web.allow_push``
3648 nobody can write to it by default. Set the ``web.allow_push``
3631 option to ``*`` to allow everybody to push to the server. You
3649 option to ``*`` to allow everybody to push to the server. You
3632 should use a real web server if you need to authenticate users.
3650 should use a real web server if you need to authenticate users.
3633
3651
3634 By default, the server logs accesses to stdout and errors to
3652 By default, the server logs accesses to stdout and errors to
3635 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
3653 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
3636 files.
3654 files.
3637
3655
3638 To have the server choose a free port number to listen on, specify
3656 To have the server choose a free port number to listen on, specify
3639 a port number of 0; in this case, the server will print the port
3657 a port number of 0; in this case, the server will print the port
3640 number it uses.
3658 number it uses.
3641
3659
3642 Returns 0 on success.
3660 Returns 0 on success.
3643 """
3661 """
3644
3662
3645 if opts["stdio"]:
3663 if opts["stdio"]:
3646 if repo is None:
3664 if repo is None:
3647 raise error.RepoError(_("There is no Mercurial repository here"
3665 raise error.RepoError(_("There is no Mercurial repository here"
3648 " (.hg not found)"))
3666 " (.hg not found)"))
3649 s = sshserver.sshserver(ui, repo)
3667 s = sshserver.sshserver(ui, repo)
3650 s.serve_forever()
3668 s.serve_forever()
3651
3669
3652 # this way we can check if something was given in the command-line
3670 # this way we can check if something was given in the command-line
3653 if opts.get('port'):
3671 if opts.get('port'):
3654 opts['port'] = util.getport(opts.get('port'))
3672 opts['port'] = util.getport(opts.get('port'))
3655
3673
3656 baseui = repo and repo.baseui or ui
3674 baseui = repo and repo.baseui or ui
3657 optlist = ("name templates style address port prefix ipv6"
3675 optlist = ("name templates style address port prefix ipv6"
3658 " accesslog errorlog certificate encoding")
3676 " accesslog errorlog certificate encoding")
3659 for o in optlist.split():
3677 for o in optlist.split():
3660 val = opts.get(o, '')
3678 val = opts.get(o, '')
3661 if val in (None, ''): # should check against default options instead
3679 if val in (None, ''): # should check against default options instead
3662 continue
3680 continue
3663 baseui.setconfig("web", o, val)
3681 baseui.setconfig("web", o, val)
3664 if repo and repo.ui != baseui:
3682 if repo and repo.ui != baseui:
3665 repo.ui.setconfig("web", o, val)
3683 repo.ui.setconfig("web", o, val)
3666
3684
3667 o = opts.get('web_conf') or opts.get('webdir_conf')
3685 o = opts.get('web_conf') or opts.get('webdir_conf')
3668 if not o:
3686 if not o:
3669 if not repo:
3687 if not repo:
3670 raise error.RepoError(_("There is no Mercurial repository"
3688 raise error.RepoError(_("There is no Mercurial repository"
3671 " here (.hg not found)"))
3689 " here (.hg not found)"))
3672 o = repo.root
3690 o = repo.root
3673
3691
3674 app = hgweb.hgweb(o, baseui=ui)
3692 app = hgweb.hgweb(o, baseui=ui)
3675
3693
3676 class service(object):
3694 class service(object):
3677 def init(self):
3695 def init(self):
3678 util.set_signal_handler()
3696 util.set_signal_handler()
3679 self.httpd = hgweb.server.create_server(ui, app)
3697 self.httpd = hgweb.server.create_server(ui, app)
3680
3698
3681 if opts['port'] and not ui.verbose:
3699 if opts['port'] and not ui.verbose:
3682 return
3700 return
3683
3701
3684 if self.httpd.prefix:
3702 if self.httpd.prefix:
3685 prefix = self.httpd.prefix.strip('/') + '/'
3703 prefix = self.httpd.prefix.strip('/') + '/'
3686 else:
3704 else:
3687 prefix = ''
3705 prefix = ''
3688
3706
3689 port = ':%d' % self.httpd.port
3707 port = ':%d' % self.httpd.port
3690 if port == ':80':
3708 if port == ':80':
3691 port = ''
3709 port = ''
3692
3710
3693 bindaddr = self.httpd.addr
3711 bindaddr = self.httpd.addr
3694 if bindaddr == '0.0.0.0':
3712 if bindaddr == '0.0.0.0':
3695 bindaddr = '*'
3713 bindaddr = '*'
3696 elif ':' in bindaddr: # IPv6
3714 elif ':' in bindaddr: # IPv6
3697 bindaddr = '[%s]' % bindaddr
3715 bindaddr = '[%s]' % bindaddr
3698
3716
3699 fqaddr = self.httpd.fqaddr
3717 fqaddr = self.httpd.fqaddr
3700 if ':' in fqaddr:
3718 if ':' in fqaddr:
3701 fqaddr = '[%s]' % fqaddr
3719 fqaddr = '[%s]' % fqaddr
3702 if opts['port']:
3720 if opts['port']:
3703 write = ui.status
3721 write = ui.status
3704 else:
3722 else:
3705 write = ui.write
3723 write = ui.write
3706 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
3724 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
3707 (fqaddr, port, prefix, bindaddr, self.httpd.port))
3725 (fqaddr, port, prefix, bindaddr, self.httpd.port))
3708
3726
3709 def run(self):
3727 def run(self):
3710 self.httpd.serve_forever()
3728 self.httpd.serve_forever()
3711
3729
3712 service = service()
3730 service = service()
3713
3731
3714 cmdutil.service(opts, initfn=service.init, runfn=service.run)
3732 cmdutil.service(opts, initfn=service.init, runfn=service.run)
3715
3733
3716 def status(ui, repo, *pats, **opts):
3734 def status(ui, repo, *pats, **opts):
3717 """show changed files in the working directory
3735 """show changed files in the working directory
3718
3736
3719 Show status of files in the repository. If names are given, only
3737 Show status of files in the repository. If names are given, only
3720 files that match are shown. Files that are clean or ignored or
3738 files that match are shown. Files that are clean or ignored or
3721 the source of a copy/move operation, are not listed unless
3739 the source of a copy/move operation, are not listed unless
3722 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
3740 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
3723 Unless options described with "show only ..." are given, the
3741 Unless options described with "show only ..." are given, the
3724 options -mardu are used.
3742 options -mardu are used.
3725
3743
3726 Option -q/--quiet hides untracked (unknown and ignored) files
3744 Option -q/--quiet hides untracked (unknown and ignored) files
3727 unless explicitly requested with -u/--unknown or -i/--ignored.
3745 unless explicitly requested with -u/--unknown or -i/--ignored.
3728
3746
3729 .. note::
3747 .. note::
3730 status may appear to disagree with diff if permissions have
3748 status may appear to disagree with diff if permissions have
3731 changed or a merge has occurred. The standard diff format does
3749 changed or a merge has occurred. The standard diff format does
3732 not report permission changes and diff only reports changes
3750 not report permission changes and diff only reports changes
3733 relative to one merge parent.
3751 relative to one merge parent.
3734
3752
3735 If one revision is given, it is used as the base revision.
3753 If one revision is given, it is used as the base revision.
3736 If two revisions are given, the differences between them are
3754 If two revisions are given, the differences between them are
3737 shown. The --change option can also be used as a shortcut to list
3755 shown. The --change option can also be used as a shortcut to list
3738 the changed files of a revision from its first parent.
3756 the changed files of a revision from its first parent.
3739
3757
3740 The codes used to show the status of files are::
3758 The codes used to show the status of files are::
3741
3759
3742 M = modified
3760 M = modified
3743 A = added
3761 A = added
3744 R = removed
3762 R = removed
3745 C = clean
3763 C = clean
3746 ! = missing (deleted by non-hg command, but still tracked)
3764 ! = missing (deleted by non-hg command, but still tracked)
3747 ? = not tracked
3765 ? = not tracked
3748 I = ignored
3766 I = ignored
3749 = origin of the previous file listed as A (added)
3767 = origin of the previous file listed as A (added)
3750
3768
3751 Returns 0 on success.
3769 Returns 0 on success.
3752 """
3770 """
3753
3771
3754 revs = opts.get('rev')
3772 revs = opts.get('rev')
3755 change = opts.get('change')
3773 change = opts.get('change')
3756
3774
3757 if revs and change:
3775 if revs and change:
3758 msg = _('cannot specify --rev and --change at the same time')
3776 msg = _('cannot specify --rev and --change at the same time')
3759 raise util.Abort(msg)
3777 raise util.Abort(msg)
3760 elif change:
3778 elif change:
3761 node2 = repo.lookup(change)
3779 node2 = repo.lookup(change)
3762 node1 = repo[node2].p1().node()
3780 node1 = repo[node2].p1().node()
3763 else:
3781 else:
3764 node1, node2 = cmdutil.revpair(repo, revs)
3782 node1, node2 = cmdutil.revpair(repo, revs)
3765
3783
3766 cwd = (pats and repo.getcwd()) or ''
3784 cwd = (pats and repo.getcwd()) or ''
3767 end = opts.get('print0') and '\0' or '\n'
3785 end = opts.get('print0') and '\0' or '\n'
3768 copy = {}
3786 copy = {}
3769 states = 'modified added removed deleted unknown ignored clean'.split()
3787 states = 'modified added removed deleted unknown ignored clean'.split()
3770 show = [k for k in states if opts.get(k)]
3788 show = [k for k in states if opts.get(k)]
3771 if opts.get('all'):
3789 if opts.get('all'):
3772 show += ui.quiet and (states[:4] + ['clean']) or states
3790 show += ui.quiet and (states[:4] + ['clean']) or states
3773 if not show:
3791 if not show:
3774 show = ui.quiet and states[:4] or states[:5]
3792 show = ui.quiet and states[:4] or states[:5]
3775
3793
3776 stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
3794 stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
3777 'ignored' in show, 'clean' in show, 'unknown' in show,
3795 'ignored' in show, 'clean' in show, 'unknown' in show,
3778 opts.get('subrepos'))
3796 opts.get('subrepos'))
3779 changestates = zip(states, 'MAR!?IC', stat)
3797 changestates = zip(states, 'MAR!?IC', stat)
3780
3798
3781 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
3799 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
3782 ctxn = repo[nullid]
3800 ctxn = repo[nullid]
3783 ctx1 = repo[node1]
3801 ctx1 = repo[node1]
3784 ctx2 = repo[node2]
3802 ctx2 = repo[node2]
3785 added = stat[1]
3803 added = stat[1]
3786 if node2 is None:
3804 if node2 is None:
3787 added = stat[0] + stat[1] # merged?
3805 added = stat[0] + stat[1] # merged?
3788
3806
3789 for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems():
3807 for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems():
3790 if k in added:
3808 if k in added:
3791 copy[k] = v
3809 copy[k] = v
3792 elif v in added:
3810 elif v in added:
3793 copy[v] = k
3811 copy[v] = k
3794
3812
3795 for state, char, files in changestates:
3813 for state, char, files in changestates:
3796 if state in show:
3814 if state in show:
3797 format = "%s %%s%s" % (char, end)
3815 format = "%s %%s%s" % (char, end)
3798 if opts.get('no_status'):
3816 if opts.get('no_status'):
3799 format = "%%s%s" % end
3817 format = "%%s%s" % end
3800
3818
3801 for f in files:
3819 for f in files:
3802 ui.write(format % repo.pathto(f, cwd),
3820 ui.write(format % repo.pathto(f, cwd),
3803 label='status.' + state)
3821 label='status.' + state)
3804 if f in copy:
3822 if f in copy:
3805 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end),
3823 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end),
3806 label='status.copied')
3824 label='status.copied')
3807
3825
3808 def summary(ui, repo, **opts):
3826 def summary(ui, repo, **opts):
3809 """summarize working directory state
3827 """summarize working directory state
3810
3828
3811 This generates a brief summary of the working directory state,
3829 This generates a brief summary of the working directory state,
3812 including parents, branch, commit status, and available updates.
3830 including parents, branch, commit status, and available updates.
3813
3831
3814 With the --remote option, this will check the default paths for
3832 With the --remote option, this will check the default paths for
3815 incoming and outgoing changes. This can be time-consuming.
3833 incoming and outgoing changes. This can be time-consuming.
3816
3834
3817 Returns 0 on success.
3835 Returns 0 on success.
3818 """
3836 """
3819
3837
3820 ctx = repo[None]
3838 ctx = repo[None]
3821 parents = ctx.parents()
3839 parents = ctx.parents()
3822 pnode = parents[0].node()
3840 pnode = parents[0].node()
3823
3841
3824 for p in parents:
3842 for p in parents:
3825 # label with log.changeset (instead of log.parent) since this
3843 # label with log.changeset (instead of log.parent) since this
3826 # shows a working directory parent *changeset*:
3844 # shows a working directory parent *changeset*:
3827 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
3845 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
3828 label='log.changeset')
3846 label='log.changeset')
3829 ui.write(' '.join(p.tags()), label='log.tag')
3847 ui.write(' '.join(p.tags()), label='log.tag')
3830 if p.bookmarks():
3848 if p.bookmarks():
3831 ui.write(' ' + ' '.join(p.bookmarks()), label='log.bookmark')
3849 ui.write(' ' + ' '.join(p.bookmarks()), label='log.bookmark')
3832 if p.rev() == -1:
3850 if p.rev() == -1:
3833 if not len(repo):
3851 if not len(repo):
3834 ui.write(_(' (empty repository)'))
3852 ui.write(_(' (empty repository)'))
3835 else:
3853 else:
3836 ui.write(_(' (no revision checked out)'))
3854 ui.write(_(' (no revision checked out)'))
3837 ui.write('\n')
3855 ui.write('\n')
3838 if p.description():
3856 if p.description():
3839 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
3857 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
3840 label='log.summary')
3858 label='log.summary')
3841
3859
3842 branch = ctx.branch()
3860 branch = ctx.branch()
3843 bheads = repo.branchheads(branch)
3861 bheads = repo.branchheads(branch)
3844 m = _('branch: %s\n') % branch
3862 m = _('branch: %s\n') % branch
3845 if branch != 'default':
3863 if branch != 'default':
3846 ui.write(m, label='log.branch')
3864 ui.write(m, label='log.branch')
3847 else:
3865 else:
3848 ui.status(m, label='log.branch')
3866 ui.status(m, label='log.branch')
3849
3867
3850 st = list(repo.status(unknown=True))[:6]
3868 st = list(repo.status(unknown=True))[:6]
3851
3869
3852 c = repo.dirstate.copies()
3870 c = repo.dirstate.copies()
3853 copied, renamed = [], []
3871 copied, renamed = [], []
3854 for d, s in c.iteritems():
3872 for d, s in c.iteritems():
3855 if s in st[2]:
3873 if s in st[2]:
3856 st[2].remove(s)
3874 st[2].remove(s)
3857 renamed.append(d)
3875 renamed.append(d)
3858 else:
3876 else:
3859 copied.append(d)
3877 copied.append(d)
3860 if d in st[1]:
3878 if d in st[1]:
3861 st[1].remove(d)
3879 st[1].remove(d)
3862 st.insert(3, renamed)
3880 st.insert(3, renamed)
3863 st.insert(4, copied)
3881 st.insert(4, copied)
3864
3882
3865 ms = mergemod.mergestate(repo)
3883 ms = mergemod.mergestate(repo)
3866 st.append([f for f in ms if ms[f] == 'u'])
3884 st.append([f for f in ms if ms[f] == 'u'])
3867
3885
3868 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
3886 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
3869 st.append(subs)
3887 st.append(subs)
3870
3888
3871 labels = [ui.label(_('%d modified'), 'status.modified'),
3889 labels = [ui.label(_('%d modified'), 'status.modified'),
3872 ui.label(_('%d added'), 'status.added'),
3890 ui.label(_('%d added'), 'status.added'),
3873 ui.label(_('%d removed'), 'status.removed'),
3891 ui.label(_('%d removed'), 'status.removed'),
3874 ui.label(_('%d renamed'), 'status.copied'),
3892 ui.label(_('%d renamed'), 'status.copied'),
3875 ui.label(_('%d copied'), 'status.copied'),
3893 ui.label(_('%d copied'), 'status.copied'),
3876 ui.label(_('%d deleted'), 'status.deleted'),
3894 ui.label(_('%d deleted'), 'status.deleted'),
3877 ui.label(_('%d unknown'), 'status.unknown'),
3895 ui.label(_('%d unknown'), 'status.unknown'),
3878 ui.label(_('%d ignored'), 'status.ignored'),
3896 ui.label(_('%d ignored'), 'status.ignored'),
3879 ui.label(_('%d unresolved'), 'resolve.unresolved'),
3897 ui.label(_('%d unresolved'), 'resolve.unresolved'),
3880 ui.label(_('%d subrepos'), 'status.modified')]
3898 ui.label(_('%d subrepos'), 'status.modified')]
3881 t = []
3899 t = []
3882 for s, l in zip(st, labels):
3900 for s, l in zip(st, labels):
3883 if s:
3901 if s:
3884 t.append(l % len(s))
3902 t.append(l % len(s))
3885
3903
3886 t = ', '.join(t)
3904 t = ', '.join(t)
3887 cleanworkdir = False
3905 cleanworkdir = False
3888
3906
3889 if len(parents) > 1:
3907 if len(parents) > 1:
3890 t += _(' (merge)')
3908 t += _(' (merge)')
3891 elif branch != parents[0].branch():
3909 elif branch != parents[0].branch():
3892 t += _(' (new branch)')
3910 t += _(' (new branch)')
3893 elif (parents[0].extra().get('close') and
3911 elif (parents[0].extra().get('close') and
3894 pnode in repo.branchheads(branch, closed=True)):
3912 pnode in repo.branchheads(branch, closed=True)):
3895 t += _(' (head closed)')
3913 t += _(' (head closed)')
3896 elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
3914 elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
3897 t += _(' (clean)')
3915 t += _(' (clean)')
3898 cleanworkdir = True
3916 cleanworkdir = True
3899 elif pnode not in bheads:
3917 elif pnode not in bheads:
3900 t += _(' (new branch head)')
3918 t += _(' (new branch head)')
3901
3919
3902 if cleanworkdir:
3920 if cleanworkdir:
3903 ui.status(_('commit: %s\n') % t.strip())
3921 ui.status(_('commit: %s\n') % t.strip())
3904 else:
3922 else:
3905 ui.write(_('commit: %s\n') % t.strip())
3923 ui.write(_('commit: %s\n') % t.strip())
3906
3924
3907 # all ancestors of branch heads - all ancestors of parent = new csets
3925 # all ancestors of branch heads - all ancestors of parent = new csets
3908 new = [0] * len(repo)
3926 new = [0] * len(repo)
3909 cl = repo.changelog
3927 cl = repo.changelog
3910 for a in [cl.rev(n) for n in bheads]:
3928 for a in [cl.rev(n) for n in bheads]:
3911 new[a] = 1
3929 new[a] = 1
3912 for a in cl.ancestors(*[cl.rev(n) for n in bheads]):
3930 for a in cl.ancestors(*[cl.rev(n) for n in bheads]):
3913 new[a] = 1
3931 new[a] = 1
3914 for a in [p.rev() for p in parents]:
3932 for a in [p.rev() for p in parents]:
3915 if a >= 0:
3933 if a >= 0:
3916 new[a] = 0
3934 new[a] = 0
3917 for a in cl.ancestors(*[p.rev() for p in parents]):
3935 for a in cl.ancestors(*[p.rev() for p in parents]):
3918 new[a] = 0
3936 new[a] = 0
3919 new = sum(new)
3937 new = sum(new)
3920
3938
3921 if new == 0:
3939 if new == 0:
3922 ui.status(_('update: (current)\n'))
3940 ui.status(_('update: (current)\n'))
3923 elif pnode not in bheads:
3941 elif pnode not in bheads:
3924 ui.write(_('update: %d new changesets (update)\n') % new)
3942 ui.write(_('update: %d new changesets (update)\n') % new)
3925 else:
3943 else:
3926 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
3944 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
3927 (new, len(bheads)))
3945 (new, len(bheads)))
3928
3946
3929 if opts.get('remote'):
3947 if opts.get('remote'):
3930 t = []
3948 t = []
3931 source, branches = hg.parseurl(ui.expandpath('default'))
3949 source, branches = hg.parseurl(ui.expandpath('default'))
3932 other = hg.repository(hg.remoteui(repo, {}), source)
3950 other = hg.repository(hg.remoteui(repo, {}), source)
3933 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
3951 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
3934 ui.debug('comparing with %s\n' % util.hidepassword(source))
3952 ui.debug('comparing with %s\n' % util.hidepassword(source))
3935 repo.ui.pushbuffer()
3953 repo.ui.pushbuffer()
3936 common, incoming, rheads = discovery.findcommonincoming(repo, other)
3954 common, incoming, rheads = discovery.findcommonincoming(repo, other)
3937 repo.ui.popbuffer()
3955 repo.ui.popbuffer()
3938 if incoming:
3956 if incoming:
3939 t.append(_('1 or more incoming'))
3957 t.append(_('1 or more incoming'))
3940
3958
3941 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
3959 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
3942 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
3960 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
3943 other = hg.repository(hg.remoteui(repo, {}), dest)
3961 other = hg.repository(hg.remoteui(repo, {}), dest)
3944 ui.debug('comparing with %s\n' % util.hidepassword(dest))
3962 ui.debug('comparing with %s\n' % util.hidepassword(dest))
3945 repo.ui.pushbuffer()
3963 repo.ui.pushbuffer()
3946 common, _anyinc, _heads = discovery.findcommonincoming(repo, other)
3964 common, _anyinc, _heads = discovery.findcommonincoming(repo, other)
3947 repo.ui.popbuffer()
3965 repo.ui.popbuffer()
3948 o = repo.changelog.findmissing(common=common)
3966 o = repo.changelog.findmissing(common=common)
3949 if o:
3967 if o:
3950 t.append(_('%d outgoing') % len(o))
3968 t.append(_('%d outgoing') % len(o))
3951 if 'bookmarks' in other.listkeys('namespaces'):
3969 if 'bookmarks' in other.listkeys('namespaces'):
3952 lmarks = repo.listkeys('bookmarks')
3970 lmarks = repo.listkeys('bookmarks')
3953 rmarks = other.listkeys('bookmarks')
3971 rmarks = other.listkeys('bookmarks')
3954 diff = set(rmarks) - set(lmarks)
3972 diff = set(rmarks) - set(lmarks)
3955 if len(diff) > 0:
3973 if len(diff) > 0:
3956 t.append(_('%d incoming bookmarks') % len(diff))
3974 t.append(_('%d incoming bookmarks') % len(diff))
3957 diff = set(lmarks) - set(rmarks)
3975 diff = set(lmarks) - set(rmarks)
3958 if len(diff) > 0:
3976 if len(diff) > 0:
3959 t.append(_('%d outgoing bookmarks') % len(diff))
3977 t.append(_('%d outgoing bookmarks') % len(diff))
3960
3978
3961 if t:
3979 if t:
3962 ui.write(_('remote: %s\n') % (', '.join(t)))
3980 ui.write(_('remote: %s\n') % (', '.join(t)))
3963 else:
3981 else:
3964 ui.status(_('remote: (synced)\n'))
3982 ui.status(_('remote: (synced)\n'))
3965
3983
3966 def tag(ui, repo, name1, *names, **opts):
3984 def tag(ui, repo, name1, *names, **opts):
3967 """add one or more tags for the current or given revision
3985 """add one or more tags for the current or given revision
3968
3986
3969 Name a particular revision using <name>.
3987 Name a particular revision using <name>.
3970
3988
3971 Tags are used to name particular revisions of the repository and are
3989 Tags are used to name particular revisions of the repository and are
3972 very useful to compare different revisions, to go back to significant
3990 very useful to compare different revisions, to go back to significant
3973 earlier versions or to mark branch points as releases, etc. Changing
3991 earlier versions or to mark branch points as releases, etc. Changing
3974 an existing tag is normally disallowed; use -f/--force to override.
3992 an existing tag is normally disallowed; use -f/--force to override.
3975
3993
3976 If no revision is given, the parent of the working directory is
3994 If no revision is given, the parent of the working directory is
3977 used, or tip if no revision is checked out.
3995 used, or tip if no revision is checked out.
3978
3996
3979 To facilitate version control, distribution, and merging of tags,
3997 To facilitate version control, distribution, and merging of tags,
3980 they are stored as a file named ".hgtags" which is managed similarly
3998 they are stored as a file named ".hgtags" which is managed similarly
3981 to other project files and can be hand-edited if necessary. This
3999 to other project files and can be hand-edited if necessary. This
3982 also means that tagging creates a new commit. The file
4000 also means that tagging creates a new commit. The file
3983 ".hg/localtags" is used for local tags (not shared among
4001 ".hg/localtags" is used for local tags (not shared among
3984 repositories).
4002 repositories).
3985
4003
3986 Tag commits are usually made at the head of a branch. If the parent
4004 Tag commits are usually made at the head of a branch. If the parent
3987 of the working directory is not a branch head, :hg:`tag` aborts; use
4005 of the working directory is not a branch head, :hg:`tag` aborts; use
3988 -f/--force to force the tag commit to be based on a non-head
4006 -f/--force to force the tag commit to be based on a non-head
3989 changeset.
4007 changeset.
3990
4008
3991 See :hg:`help dates` for a list of formats valid for -d/--date.
4009 See :hg:`help dates` for a list of formats valid for -d/--date.
3992
4010
3993 Since tag names have priority over branch names during revision
4011 Since tag names have priority over branch names during revision
3994 lookup, using an existing branch name as a tag name is discouraged.
4012 lookup, using an existing branch name as a tag name is discouraged.
3995
4013
3996 Returns 0 on success.
4014 Returns 0 on success.
3997 """
4015 """
3998
4016
3999 rev_ = "."
4017 rev_ = "."
4000 names = [t.strip() for t in (name1,) + names]
4018 names = [t.strip() for t in (name1,) + names]
4001 if len(names) != len(set(names)):
4019 if len(names) != len(set(names)):
4002 raise util.Abort(_('tag names must be unique'))
4020 raise util.Abort(_('tag names must be unique'))
4003 for n in names:
4021 for n in names:
4004 if n in ['tip', '.', 'null']:
4022 if n in ['tip', '.', 'null']:
4005 raise util.Abort(_('the name \'%s\' is reserved') % n)
4023 raise util.Abort(_('the name \'%s\' is reserved') % n)
4006 if not n:
4024 if not n:
4007 raise util.Abort(_('tag names cannot consist entirely of whitespace'))
4025 raise util.Abort(_('tag names cannot consist entirely of whitespace'))
4008 if opts.get('rev') and opts.get('remove'):
4026 if opts.get('rev') and opts.get('remove'):
4009 raise util.Abort(_("--rev and --remove are incompatible"))
4027 raise util.Abort(_("--rev and --remove are incompatible"))
4010 if opts.get('rev'):
4028 if opts.get('rev'):
4011 rev_ = opts['rev']
4029 rev_ = opts['rev']
4012 message = opts.get('message')
4030 message = opts.get('message')
4013 if opts.get('remove'):
4031 if opts.get('remove'):
4014 expectedtype = opts.get('local') and 'local' or 'global'
4032 expectedtype = opts.get('local') and 'local' or 'global'
4015 for n in names:
4033 for n in names:
4016 if not repo.tagtype(n):
4034 if not repo.tagtype(n):
4017 raise util.Abort(_('tag \'%s\' does not exist') % n)
4035 raise util.Abort(_('tag \'%s\' does not exist') % n)
4018 if repo.tagtype(n) != expectedtype:
4036 if repo.tagtype(n) != expectedtype:
4019 if expectedtype == 'global':
4037 if expectedtype == 'global':
4020 raise util.Abort(_('tag \'%s\' is not a global tag') % n)
4038 raise util.Abort(_('tag \'%s\' is not a global tag') % n)
4021 else:
4039 else:
4022 raise util.Abort(_('tag \'%s\' is not a local tag') % n)
4040 raise util.Abort(_('tag \'%s\' is not a local tag') % n)
4023 rev_ = nullid
4041 rev_ = nullid
4024 if not message:
4042 if not message:
4025 # we don't translate commit messages
4043 # we don't translate commit messages
4026 message = 'Removed tag %s' % ', '.join(names)
4044 message = 'Removed tag %s' % ', '.join(names)
4027 elif not opts.get('force'):
4045 elif not opts.get('force'):
4028 for n in names:
4046 for n in names:
4029 if n in repo.tags():
4047 if n in repo.tags():
4030 raise util.Abort(_('tag \'%s\' already exists '
4048 raise util.Abort(_('tag \'%s\' already exists '
4031 '(use -f to force)') % n)
4049 '(use -f to force)') % n)
4032 if not opts.get('local'):
4050 if not opts.get('local'):
4033 p1, p2 = repo.dirstate.parents()
4051 p1, p2 = repo.dirstate.parents()
4034 if p2 != nullid:
4052 if p2 != nullid:
4035 raise util.Abort(_('uncommitted merge'))
4053 raise util.Abort(_('uncommitted merge'))
4036 bheads = repo.branchheads()
4054 bheads = repo.branchheads()
4037 if not opts.get('force') and bheads and p1 not in bheads:
4055 if not opts.get('force') and bheads and p1 not in bheads:
4038 raise util.Abort(_('not at a branch head (use -f to force)'))
4056 raise util.Abort(_('not at a branch head (use -f to force)'))
4039 r = cmdutil.revsingle(repo, rev_).node()
4057 r = cmdutil.revsingle(repo, rev_).node()
4040
4058
4041 if not message:
4059 if not message:
4042 # we don't translate commit messages
4060 # we don't translate commit messages
4043 message = ('Added tag %s for changeset %s' %
4061 message = ('Added tag %s for changeset %s' %
4044 (', '.join(names), short(r)))
4062 (', '.join(names), short(r)))
4045
4063
4046 date = opts.get('date')
4064 date = opts.get('date')
4047 if date:
4065 if date:
4048 date = util.parsedate(date)
4066 date = util.parsedate(date)
4049
4067
4050 if opts.get('edit'):
4068 if opts.get('edit'):
4051 message = ui.edit(message, ui.username())
4069 message = ui.edit(message, ui.username())
4052
4070
4053 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
4071 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
4054
4072
4055 def tags(ui, repo):
4073 def tags(ui, repo):
4056 """list repository tags
4074 """list repository tags
4057
4075
4058 This lists both regular and local tags. When the -v/--verbose
4076 This lists both regular and local tags. When the -v/--verbose
4059 switch is used, a third column "local" is printed for local tags.
4077 switch is used, a third column "local" is printed for local tags.
4060
4078
4061 Returns 0 on success.
4079 Returns 0 on success.
4062 """
4080 """
4063
4081
4064 hexfunc = ui.debugflag and hex or short
4082 hexfunc = ui.debugflag and hex or short
4065 tagtype = ""
4083 tagtype = ""
4066
4084
4067 for t, n in reversed(repo.tagslist()):
4085 for t, n in reversed(repo.tagslist()):
4068 if ui.quiet:
4086 if ui.quiet:
4069 ui.write("%s\n" % t)
4087 ui.write("%s\n" % t)
4070 continue
4088 continue
4071
4089
4072 hn = hexfunc(n)
4090 hn = hexfunc(n)
4073 r = "%5d:%s" % (repo.changelog.rev(n), hn)
4091 r = "%5d:%s" % (repo.changelog.rev(n), hn)
4074 spaces = " " * (30 - encoding.colwidth(t))
4092 spaces = " " * (30 - encoding.colwidth(t))
4075
4093
4076 if ui.verbose:
4094 if ui.verbose:
4077 if repo.tagtype(t) == 'local':
4095 if repo.tagtype(t) == 'local':
4078 tagtype = " local"
4096 tagtype = " local"
4079 else:
4097 else:
4080 tagtype = ""
4098 tagtype = ""
4081 ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
4099 ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
4082
4100
4083 def tip(ui, repo, **opts):
4101 def tip(ui, repo, **opts):
4084 """show the tip revision
4102 """show the tip revision
4085
4103
4086 The tip revision (usually just called the tip) is the changeset
4104 The tip revision (usually just called the tip) is the changeset
4087 most recently added to the repository (and therefore the most
4105 most recently added to the repository (and therefore the most
4088 recently changed head).
4106 recently changed head).
4089
4107
4090 If you have just made a commit, that commit will be the tip. If
4108 If you have just made a commit, that commit will be the tip. If
4091 you have just pulled changes from another repository, the tip of
4109 you have just pulled changes from another repository, the tip of
4092 that repository becomes the current tip. The "tip" tag is special
4110 that repository becomes the current tip. The "tip" tag is special
4093 and cannot be renamed or assigned to a different changeset.
4111 and cannot be renamed or assigned to a different changeset.
4094
4112
4095 Returns 0 on success.
4113 Returns 0 on success.
4096 """
4114 """
4097 displayer = cmdutil.show_changeset(ui, repo, opts)
4115 displayer = cmdutil.show_changeset(ui, repo, opts)
4098 displayer.show(repo[len(repo) - 1])
4116 displayer.show(repo[len(repo) - 1])
4099 displayer.close()
4117 displayer.close()
4100
4118
4101 def unbundle(ui, repo, fname1, *fnames, **opts):
4119 def unbundle(ui, repo, fname1, *fnames, **opts):
4102 """apply one or more changegroup files
4120 """apply one or more changegroup files
4103
4121
4104 Apply one or more compressed changegroup files generated by the
4122 Apply one or more compressed changegroup files generated by the
4105 bundle command.
4123 bundle command.
4106
4124
4107 Returns 0 on success, 1 if an update has unresolved files.
4125 Returns 0 on success, 1 if an update has unresolved files.
4108 """
4126 """
4109 fnames = (fname1,) + fnames
4127 fnames = (fname1,) + fnames
4110
4128
4111 lock = repo.lock()
4129 lock = repo.lock()
4112 wc = repo['.']
4130 wc = repo['.']
4113 try:
4131 try:
4114 for fname in fnames:
4132 for fname in fnames:
4115 f = url.open(ui, fname)
4133 f = url.open(ui, fname)
4116 gen = changegroup.readbundle(f, fname)
4134 gen = changegroup.readbundle(f, fname)
4117 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname,
4135 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname,
4118 lock=lock)
4136 lock=lock)
4119 bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch())
4137 bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch())
4120 finally:
4138 finally:
4121 lock.release()
4139 lock.release()
4122 return postincoming(ui, repo, modheads, opts.get('update'), None)
4140 return postincoming(ui, repo, modheads, opts.get('update'), None)
4123
4141
4124 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
4142 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
4125 """update working directory (or switch revisions)
4143 """update working directory (or switch revisions)
4126
4144
4127 Update the repository's working directory to the specified
4145 Update the repository's working directory to the specified
4128 changeset. If no changeset is specified, update to the tip of the
4146 changeset. If no changeset is specified, update to the tip of the
4129 current named branch.
4147 current named branch.
4130
4148
4131 If the changeset is not a descendant of the working directory's
4149 If the changeset is not a descendant of the working directory's
4132 parent, the update is aborted. With the -c/--check option, the
4150 parent, the update is aborted. With the -c/--check option, the
4133 working directory is checked for uncommitted changes; if none are
4151 working directory is checked for uncommitted changes; if none are
4134 found, the working directory is updated to the specified
4152 found, the working directory is updated to the specified
4135 changeset.
4153 changeset.
4136
4154
4137 The following rules apply when the working directory contains
4155 The following rules apply when the working directory contains
4138 uncommitted changes:
4156 uncommitted changes:
4139
4157
4140 1. If neither -c/--check nor -C/--clean is specified, and if
4158 1. If neither -c/--check nor -C/--clean is specified, and if
4141 the requested changeset is an ancestor or descendant of
4159 the requested changeset is an ancestor or descendant of
4142 the working directory's parent, the uncommitted changes
4160 the working directory's parent, the uncommitted changes
4143 are merged into the requested changeset and the merged
4161 are merged into the requested changeset and the merged
4144 result is left uncommitted. If the requested changeset is
4162 result is left uncommitted. If the requested changeset is
4145 not an ancestor or descendant (that is, it is on another
4163 not an ancestor or descendant (that is, it is on another
4146 branch), the update is aborted and the uncommitted changes
4164 branch), the update is aborted and the uncommitted changes
4147 are preserved.
4165 are preserved.
4148
4166
4149 2. With the -c/--check option, the update is aborted and the
4167 2. With the -c/--check option, the update is aborted and the
4150 uncommitted changes are preserved.
4168 uncommitted changes are preserved.
4151
4169
4152 3. With the -C/--clean option, uncommitted changes are discarded and
4170 3. With the -C/--clean option, uncommitted changes are discarded and
4153 the working directory is updated to the requested changeset.
4171 the working directory is updated to the requested changeset.
4154
4172
4155 Use null as the changeset to remove the working directory (like
4173 Use null as the changeset to remove the working directory (like
4156 :hg:`clone -U`).
4174 :hg:`clone -U`).
4157
4175
4158 If you want to update just one file to an older changeset, use
4176 If you want to update just one file to an older changeset, use
4159 :hg:`revert`.
4177 :hg:`revert`.
4160
4178
4161 See :hg:`help dates` for a list of formats valid for -d/--date.
4179 See :hg:`help dates` for a list of formats valid for -d/--date.
4162
4180
4163 Returns 0 on success, 1 if there are unresolved files.
4181 Returns 0 on success, 1 if there are unresolved files.
4164 """
4182 """
4165 if rev and node:
4183 if rev and node:
4166 raise util.Abort(_("please specify just one revision"))
4184 raise util.Abort(_("please specify just one revision"))
4167
4185
4168 if rev is None or rev == '':
4186 if rev is None or rev == '':
4169 rev = node
4187 rev = node
4170
4188
4171 # if we defined a bookmark, we have to remember the original bookmark name
4189 # if we defined a bookmark, we have to remember the original bookmark name
4172 brev = rev
4190 brev = rev
4173 rev = cmdutil.revsingle(repo, rev, rev).rev()
4191 rev = cmdutil.revsingle(repo, rev, rev).rev()
4174
4192
4175 if check and clean:
4193 if check and clean:
4176 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
4194 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
4177
4195
4178 if check:
4196 if check:
4179 # we could use dirty() but we can ignore merge and branch trivia
4197 # we could use dirty() but we can ignore merge and branch trivia
4180 c = repo[None]
4198 c = repo[None]
4181 if c.modified() or c.added() or c.removed():
4199 if c.modified() or c.added() or c.removed():
4182 raise util.Abort(_("uncommitted local changes"))
4200 raise util.Abort(_("uncommitted local changes"))
4183
4201
4184 if date:
4202 if date:
4185 if rev is not None:
4203 if rev is not None:
4186 raise util.Abort(_("you can't specify a revision and a date"))
4204 raise util.Abort(_("you can't specify a revision and a date"))
4187 rev = cmdutil.finddate(ui, repo, date)
4205 rev = cmdutil.finddate(ui, repo, date)
4188
4206
4189 if clean or check:
4207 if clean or check:
4190 ret = hg.clean(repo, rev)
4208 ret = hg.clean(repo, rev)
4191 else:
4209 else:
4192 ret = hg.update(repo, rev)
4210 ret = hg.update(repo, rev)
4193
4211
4194 if brev in repo._bookmarks:
4212 if brev in repo._bookmarks:
4195 bookmarks.setcurrent(repo, brev)
4213 bookmarks.setcurrent(repo, brev)
4196
4214
4197 return ret
4215 return ret
4198
4216
4199 def verify(ui, repo):
4217 def verify(ui, repo):
4200 """verify the integrity of the repository
4218 """verify the integrity of the repository
4201
4219
4202 Verify the integrity of the current repository.
4220 Verify the integrity of the current repository.
4203
4221
4204 This will perform an extensive check of the repository's
4222 This will perform an extensive check of the repository's
4205 integrity, validating the hashes and checksums of each entry in
4223 integrity, validating the hashes and checksums of each entry in
4206 the changelog, manifest, and tracked files, as well as the
4224 the changelog, manifest, and tracked files, as well as the
4207 integrity of their crosslinks and indices.
4225 integrity of their crosslinks and indices.
4208
4226
4209 Returns 0 on success, 1 if errors are encountered.
4227 Returns 0 on success, 1 if errors are encountered.
4210 """
4228 """
4211 return hg.verify(repo)
4229 return hg.verify(repo)
4212
4230
4213 def version_(ui):
4231 def version_(ui):
4214 """output version and copyright information"""
4232 """output version and copyright information"""
4215 ui.write(_("Mercurial Distributed SCM (version %s)\n")
4233 ui.write(_("Mercurial Distributed SCM (version %s)\n")
4216 % util.version())
4234 % util.version())
4217 ui.status(_(
4235 ui.status(_(
4218 "(see http://mercurial.selenic.com for more information)\n"
4236 "(see http://mercurial.selenic.com for more information)\n"
4219 "\nCopyright (C) 2005-2011 Matt Mackall and others\n"
4237 "\nCopyright (C) 2005-2011 Matt Mackall and others\n"
4220 "This is free software; see the source for copying conditions. "
4238 "This is free software; see the source for copying conditions. "
4221 "There is NO\nwarranty; "
4239 "There is NO\nwarranty; "
4222 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
4240 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
4223 ))
4241 ))
4224
4242
4225 # Command options and aliases are listed here, alphabetically
4243 # Command options and aliases are listed here, alphabetically
4226
4244
4227 globalopts = [
4245 globalopts = [
4228 ('R', 'repository', '',
4246 ('R', 'repository', '',
4229 _('repository root directory or name of overlay bundle file'),
4247 _('repository root directory or name of overlay bundle file'),
4230 _('REPO')),
4248 _('REPO')),
4231 ('', 'cwd', '',
4249 ('', 'cwd', '',
4232 _('change working directory'), _('DIR')),
4250 _('change working directory'), _('DIR')),
4233 ('y', 'noninteractive', None,
4251 ('y', 'noninteractive', None,
4234 _('do not prompt, assume \'yes\' for any required answers')),
4252 _('do not prompt, assume \'yes\' for any required answers')),
4235 ('q', 'quiet', None, _('suppress output')),
4253 ('q', 'quiet', None, _('suppress output')),
4236 ('v', 'verbose', None, _('enable additional output')),
4254 ('v', 'verbose', None, _('enable additional output')),
4237 ('', 'config', [],
4255 ('', 'config', [],
4238 _('set/override config option (use \'section.name=value\')'),
4256 _('set/override config option (use \'section.name=value\')'),
4239 _('CONFIG')),
4257 _('CONFIG')),
4240 ('', 'debug', None, _('enable debugging output')),
4258 ('', 'debug', None, _('enable debugging output')),
4241 ('', 'debugger', None, _('start debugger')),
4259 ('', 'debugger', None, _('start debugger')),
4242 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
4260 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
4243 _('ENCODE')),
4261 _('ENCODE')),
4244 ('', 'encodingmode', encoding.encodingmode,
4262 ('', 'encodingmode', encoding.encodingmode,
4245 _('set the charset encoding mode'), _('MODE')),
4263 _('set the charset encoding mode'), _('MODE')),
4246 ('', 'traceback', None, _('always print a traceback on exception')),
4264 ('', 'traceback', None, _('always print a traceback on exception')),
4247 ('', 'time', None, _('time how long the command takes')),
4265 ('', 'time', None, _('time how long the command takes')),
4248 ('', 'profile', None, _('print command execution profile')),
4266 ('', 'profile', None, _('print command execution profile')),
4249 ('', 'version', None, _('output version information and exit')),
4267 ('', 'version', None, _('output version information and exit')),
4250 ('h', 'help', None, _('display help and exit')),
4268 ('h', 'help', None, _('display help and exit')),
4251 ]
4269 ]
4252
4270
4253 dryrunopts = [('n', 'dry-run', None,
4271 dryrunopts = [('n', 'dry-run', None,
4254 _('do not perform actions, just print output'))]
4272 _('do not perform actions, just print output'))]
4255
4273
4256 remoteopts = [
4274 remoteopts = [
4257 ('e', 'ssh', '',
4275 ('e', 'ssh', '',
4258 _('specify ssh command to use'), _('CMD')),
4276 _('specify ssh command to use'), _('CMD')),
4259 ('', 'remotecmd', '',
4277 ('', 'remotecmd', '',
4260 _('specify hg command to run on the remote side'), _('CMD')),
4278 _('specify hg command to run on the remote side'), _('CMD')),
4261 ('', 'insecure', None,
4279 ('', 'insecure', None,
4262 _('do not verify server certificate (ignoring web.cacerts config)')),
4280 _('do not verify server certificate (ignoring web.cacerts config)')),
4263 ]
4281 ]
4264
4282
4265 walkopts = [
4283 walkopts = [
4266 ('I', 'include', [],
4284 ('I', 'include', [],
4267 _('include names matching the given patterns'), _('PATTERN')),
4285 _('include names matching the given patterns'), _('PATTERN')),
4268 ('X', 'exclude', [],
4286 ('X', 'exclude', [],
4269 _('exclude names matching the given patterns'), _('PATTERN')),
4287 _('exclude names matching the given patterns'), _('PATTERN')),
4270 ]
4288 ]
4271
4289
4272 commitopts = [
4290 commitopts = [
4273 ('m', 'message', '',
4291 ('m', 'message', '',
4274 _('use text as commit message'), _('TEXT')),
4292 _('use text as commit message'), _('TEXT')),
4275 ('l', 'logfile', '',
4293 ('l', 'logfile', '',
4276 _('read commit message from file'), _('FILE')),
4294 _('read commit message from file'), _('FILE')),
4277 ]
4295 ]
4278
4296
4279 commitopts2 = [
4297 commitopts2 = [
4280 ('d', 'date', '',
4298 ('d', 'date', '',
4281 _('record the specified date as commit date'), _('DATE')),
4299 _('record the specified date as commit date'), _('DATE')),
4282 ('u', 'user', '',
4300 ('u', 'user', '',
4283 _('record the specified user as committer'), _('USER')),
4301 _('record the specified user as committer'), _('USER')),
4284 ]
4302 ]
4285
4303
4286 templateopts = [
4304 templateopts = [
4287 ('', 'style', '',
4305 ('', 'style', '',
4288 _('display using template map file'), _('STYLE')),
4306 _('display using template map file'), _('STYLE')),
4289 ('', 'template', '',
4307 ('', 'template', '',
4290 _('display with template'), _('TEMPLATE')),
4308 _('display with template'), _('TEMPLATE')),
4291 ]
4309 ]
4292
4310
4293 logopts = [
4311 logopts = [
4294 ('p', 'patch', None, _('show patch')),
4312 ('p', 'patch', None, _('show patch')),
4295 ('g', 'git', None, _('use git extended diff format')),
4313 ('g', 'git', None, _('use git extended diff format')),
4296 ('l', 'limit', '',
4314 ('l', 'limit', '',
4297 _('limit number of changes displayed'), _('NUM')),
4315 _('limit number of changes displayed'), _('NUM')),
4298 ('M', 'no-merges', None, _('do not show merges')),
4316 ('M', 'no-merges', None, _('do not show merges')),
4299 ('', 'stat', None, _('output diffstat-style summary of changes')),
4317 ('', 'stat', None, _('output diffstat-style summary of changes')),
4300 ] + templateopts
4318 ] + templateopts
4301
4319
4302 diffopts = [
4320 diffopts = [
4303 ('a', 'text', None, _('treat all files as text')),
4321 ('a', 'text', None, _('treat all files as text')),
4304 ('g', 'git', None, _('use git extended diff format')),
4322 ('g', 'git', None, _('use git extended diff format')),
4305 ('', 'nodates', None, _('omit dates from diff headers'))
4323 ('', 'nodates', None, _('omit dates from diff headers'))
4306 ]
4324 ]
4307
4325
4308 diffopts2 = [
4326 diffopts2 = [
4309 ('p', 'show-function', None, _('show which function each change is in')),
4327 ('p', 'show-function', None, _('show which function each change is in')),
4310 ('', 'reverse', None, _('produce a diff that undoes the changes')),
4328 ('', 'reverse', None, _('produce a diff that undoes the changes')),
4311 ('w', 'ignore-all-space', None,
4329 ('w', 'ignore-all-space', None,
4312 _('ignore white space when comparing lines')),
4330 _('ignore white space when comparing lines')),
4313 ('b', 'ignore-space-change', None,
4331 ('b', 'ignore-space-change', None,
4314 _('ignore changes in the amount of white space')),
4332 _('ignore changes in the amount of white space')),
4315 ('B', 'ignore-blank-lines', None,
4333 ('B', 'ignore-blank-lines', None,
4316 _('ignore changes whose lines are all blank')),
4334 _('ignore changes whose lines are all blank')),
4317 ('U', 'unified', '',
4335 ('U', 'unified', '',
4318 _('number of lines of context to show'), _('NUM')),
4336 _('number of lines of context to show'), _('NUM')),
4319 ('', 'stat', None, _('output diffstat-style summary of changes')),
4337 ('', 'stat', None, _('output diffstat-style summary of changes')),
4320 ]
4338 ]
4321
4339
4322 similarityopts = [
4340 similarityopts = [
4323 ('s', 'similarity', '',
4341 ('s', 'similarity', '',
4324 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
4342 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
4325 ]
4343 ]
4326
4344
4327 subrepoopts = [
4345 subrepoopts = [
4328 ('S', 'subrepos', None,
4346 ('S', 'subrepos', None,
4329 _('recurse into subrepositories'))
4347 _('recurse into subrepositories'))
4330 ]
4348 ]
4331
4349
4332 table = {
4350 table = {
4333 "^add": (add, walkopts + subrepoopts + dryrunopts,
4351 "^add": (add, walkopts + subrepoopts + dryrunopts,
4334 _('[OPTION]... [FILE]...')),
4352 _('[OPTION]... [FILE]...')),
4335 "addremove":
4353 "addremove":
4336 (addremove, similarityopts + walkopts + dryrunopts,
4354 (addremove, similarityopts + walkopts + dryrunopts,
4337 _('[OPTION]... [FILE]...')),
4355 _('[OPTION]... [FILE]...')),
4338 "^annotate|blame":
4356 "^annotate|blame":
4339 (annotate,
4357 (annotate,
4340 [('r', 'rev', '',
4358 [('r', 'rev', '',
4341 _('annotate the specified revision'), _('REV')),
4359 _('annotate the specified revision'), _('REV')),
4342 ('', 'follow', None,
4360 ('', 'follow', None,
4343 _('follow copies/renames and list the filename (DEPRECATED)')),
4361 _('follow copies/renames and list the filename (DEPRECATED)')),
4344 ('', 'no-follow', None, _("don't follow copies and renames")),
4362 ('', 'no-follow', None, _("don't follow copies and renames")),
4345 ('a', 'text', None, _('treat all files as text')),
4363 ('a', 'text', None, _('treat all files as text')),
4346 ('u', 'user', None, _('list the author (long with -v)')),
4364 ('u', 'user', None, _('list the author (long with -v)')),
4347 ('f', 'file', None, _('list the filename')),
4365 ('f', 'file', None, _('list the filename')),
4348 ('d', 'date', None, _('list the date (short with -q)')),
4366 ('d', 'date', None, _('list the date (short with -q)')),
4349 ('n', 'number', None, _('list the revision number (default)')),
4367 ('n', 'number', None, _('list the revision number (default)')),
4350 ('c', 'changeset', None, _('list the changeset')),
4368 ('c', 'changeset', None, _('list the changeset')),
4351 ('l', 'line-number', None,
4369 ('l', 'line-number', None,
4352 _('show line number at the first appearance'))
4370 _('show line number at the first appearance'))
4353 ] + walkopts,
4371 ] + walkopts,
4354 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')),
4372 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')),
4355 "archive":
4373 "archive":
4356 (archive,
4374 (archive,
4357 [('', 'no-decode', None, _('do not pass files through decoders')),
4375 [('', 'no-decode', None, _('do not pass files through decoders')),
4358 ('p', 'prefix', '',
4376 ('p', 'prefix', '',
4359 _('directory prefix for files in archive'), _('PREFIX')),
4377 _('directory prefix for files in archive'), _('PREFIX')),
4360 ('r', 'rev', '',
4378 ('r', 'rev', '',
4361 _('revision to distribute'), _('REV')),
4379 _('revision to distribute'), _('REV')),
4362 ('t', 'type', '',
4380 ('t', 'type', '',
4363 _('type of distribution to create'), _('TYPE')),
4381 _('type of distribution to create'), _('TYPE')),
4364 ] + subrepoopts + walkopts,
4382 ] + subrepoopts + walkopts,
4365 _('[OPTION]... DEST')),
4383 _('[OPTION]... DEST')),
4366 "backout":
4384 "backout":
4367 (backout,
4385 (backout,
4368 [('', 'merge', None,
4386 [('', 'merge', None,
4369 _('merge with old dirstate parent after backout')),
4387 _('merge with old dirstate parent after backout')),
4370 ('', 'parent', '',
4388 ('', 'parent', '',
4371 _('parent to choose when backing out merge'), _('REV')),
4389 _('parent to choose when backing out merge'), _('REV')),
4372 ('t', 'tool', '',
4390 ('t', 'tool', '',
4373 _('specify merge tool')),
4391 _('specify merge tool')),
4374 ('r', 'rev', '',
4392 ('r', 'rev', '',
4375 _('revision to backout'), _('REV')),
4393 _('revision to backout'), _('REV')),
4376 ] + walkopts + commitopts + commitopts2,
4394 ] + walkopts + commitopts + commitopts2,
4377 _('[OPTION]... [-r] REV')),
4395 _('[OPTION]... [-r] REV')),
4378 "bisect":
4396 "bisect":
4379 (bisect,
4397 (bisect,
4380 [('r', 'reset', False, _('reset bisect state')),
4398 [('r', 'reset', False, _('reset bisect state')),
4381 ('g', 'good', False, _('mark changeset good')),
4399 ('g', 'good', False, _('mark changeset good')),
4382 ('b', 'bad', False, _('mark changeset bad')),
4400 ('b', 'bad', False, _('mark changeset bad')),
4383 ('s', 'skip', False, _('skip testing changeset')),
4401 ('s', 'skip', False, _('skip testing changeset')),
4384 ('e', 'extend', False, _('extend the bisect range')),
4402 ('e', 'extend', False, _('extend the bisect range')),
4385 ('c', 'command', '',
4403 ('c', 'command', '',
4386 _('use command to check changeset state'), _('CMD')),
4404 _('use command to check changeset state'), _('CMD')),
4387 ('U', 'noupdate', False, _('do not update to target'))],
4405 ('U', 'noupdate', False, _('do not update to target'))],
4388 _("[-gbsr] [-U] [-c CMD] [REV]")),
4406 _("[-gbsr] [-U] [-c CMD] [REV]")),
4389 "bookmarks":
4407 "bookmarks":
4390 (bookmark,
4408 (bookmark,
4391 [('f', 'force', False, _('force')),
4409 [('f', 'force', False, _('force')),
4392 ('r', 'rev', '', _('revision'), _('REV')),
4410 ('r', 'rev', '', _('revision'), _('REV')),
4393 ('d', 'delete', False, _('delete a given bookmark')),
4411 ('d', 'delete', False, _('delete a given bookmark')),
4394 ('m', 'rename', '', _('rename a given bookmark'), _('NAME'))],
4412 ('m', 'rename', '', _('rename a given bookmark'), _('NAME'))],
4395 _('hg bookmarks [-f] [-d] [-m NAME] [-r REV] [NAME]')),
4413 _('hg bookmarks [-f] [-d] [-m NAME] [-r REV] [NAME]')),
4396 "branch":
4414 "branch":
4397 (branch,
4415 (branch,
4398 [('f', 'force', None,
4416 [('f', 'force', None,
4399 _('set branch name even if it shadows an existing branch')),
4417 _('set branch name even if it shadows an existing branch')),
4400 ('C', 'clean', None, _('reset branch name to parent branch name'))],
4418 ('C', 'clean', None, _('reset branch name to parent branch name'))],
4401 _('[-fC] [NAME]')),
4419 _('[-fC] [NAME]')),
4402 "branches":
4420 "branches":
4403 (branches,
4421 (branches,
4404 [('a', 'active', False,
4422 [('a', 'active', False,
4405 _('show only branches that have unmerged heads')),
4423 _('show only branches that have unmerged heads')),
4406 ('c', 'closed', False,
4424 ('c', 'closed', False,
4407 _('show normal and closed branches'))],
4425 _('show normal and closed branches'))],
4408 _('[-ac]')),
4426 _('[-ac]')),
4409 "bundle":
4427 "bundle":
4410 (bundle,
4428 (bundle,
4411 [('f', 'force', None,
4429 [('f', 'force', None,
4412 _('run even when the destination is unrelated')),
4430 _('run even when the destination is unrelated')),
4413 ('r', 'rev', [],
4431 ('r', 'rev', [],
4414 _('a changeset intended to be added to the destination'),
4432 _('a changeset intended to be added to the destination'),
4415 _('REV')),
4433 _('REV')),
4416 ('b', 'branch', [],
4434 ('b', 'branch', [],
4417 _('a specific branch you would like to bundle'),
4435 _('a specific branch you would like to bundle'),
4418 _('BRANCH')),
4436 _('BRANCH')),
4419 ('', 'base', [],
4437 ('', 'base', [],
4420 _('a base changeset assumed to be available at the destination'),
4438 _('a base changeset assumed to be available at the destination'),
4421 _('REV')),
4439 _('REV')),
4422 ('a', 'all', None, _('bundle all changesets in the repository')),
4440 ('a', 'all', None, _('bundle all changesets in the repository')),
4423 ('t', 'type', 'bzip2',
4441 ('t', 'type', 'bzip2',
4424 _('bundle compression type to use'), _('TYPE')),
4442 _('bundle compression type to use'), _('TYPE')),
4425 ] + remoteopts,
4443 ] + remoteopts,
4426 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')),
4444 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]')),
4427 "cat":
4445 "cat":
4428 (cat,
4446 (cat,
4429 [('o', 'output', '',
4447 [('o', 'output', '',
4430 _('print output to file with formatted name'), _('FORMAT')),
4448 _('print output to file with formatted name'), _('FORMAT')),
4431 ('r', 'rev', '',
4449 ('r', 'rev', '',
4432 _('print the given revision'), _('REV')),
4450 _('print the given revision'), _('REV')),
4433 ('', 'decode', None, _('apply any matching decode filter')),
4451 ('', 'decode', None, _('apply any matching decode filter')),
4434 ] + walkopts,
4452 ] + walkopts,
4435 _('[OPTION]... FILE...')),
4453 _('[OPTION]... FILE...')),
4436 "^clone":
4454 "^clone":
4437 (clone,
4455 (clone,
4438 [('U', 'noupdate', None,
4456 [('U', 'noupdate', None,
4439 _('the clone will include an empty working copy (only a repository)')),
4457 _('the clone will include an empty working copy (only a repository)')),
4440 ('u', 'updaterev', '',
4458 ('u', 'updaterev', '',
4441 _('revision, tag or branch to check out'), _('REV')),
4459 _('revision, tag or branch to check out'), _('REV')),
4442 ('r', 'rev', [],
4460 ('r', 'rev', [],
4443 _('include the specified changeset'), _('REV')),
4461 _('include the specified changeset'), _('REV')),
4444 ('b', 'branch', [],
4462 ('b', 'branch', [],
4445 _('clone only the specified branch'), _('BRANCH')),
4463 _('clone only the specified branch'), _('BRANCH')),
4446 ('', 'pull', None, _('use pull protocol to copy metadata')),
4464 ('', 'pull', None, _('use pull protocol to copy metadata')),
4447 ('', 'uncompressed', None,
4465 ('', 'uncompressed', None,
4448 _('use uncompressed transfer (fast over LAN)')),
4466 _('use uncompressed transfer (fast over LAN)')),
4449 ] + remoteopts,
4467 ] + remoteopts,
4450 _('[OPTION]... SOURCE [DEST]')),
4468 _('[OPTION]... SOURCE [DEST]')),
4451 "^commit|ci":
4469 "^commit|ci":
4452 (commit,
4470 (commit,
4453 [('A', 'addremove', None,
4471 [('A', 'addremove', None,
4454 _('mark new/missing files as added/removed before committing')),
4472 _('mark new/missing files as added/removed before committing')),
4455 ('', 'close-branch', None,
4473 ('', 'close-branch', None,
4456 _('mark a branch as closed, hiding it from the branch list')),
4474 _('mark a branch as closed, hiding it from the branch list')),
4457 ] + walkopts + commitopts + commitopts2,
4475 ] + walkopts + commitopts + commitopts2,
4458 _('[OPTION]... [FILE]...')),
4476 _('[OPTION]... [FILE]...')),
4459 "copy|cp":
4477 "copy|cp":
4460 (copy,
4478 (copy,
4461 [('A', 'after', None, _('record a copy that has already occurred')),
4479 [('A', 'after', None, _('record a copy that has already occurred')),
4462 ('f', 'force', None,
4480 ('f', 'force', None,
4463 _('forcibly copy over an existing managed file')),
4481 _('forcibly copy over an existing managed file')),
4464 ] + walkopts + dryrunopts,
4482 ] + walkopts + dryrunopts,
4465 _('[OPTION]... [SOURCE]... DEST')),
4483 _('[OPTION]... [SOURCE]... DEST')),
4466 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
4484 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
4467 "debugbuilddag":
4485 "debugbuilddag":
4468 (debugbuilddag,
4486 (debugbuilddag,
4469 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
4487 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
4470 ('a', 'appended-file', None, _('add single file all revs append to')),
4471 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
4488 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
4472 ('n', 'new-file', None, _('add new file at each rev')),
4489 ('n', 'new-file', None, _('add new file at each rev')),
4473 ],
4490 ],
4474 _('[OPTION]... TEXT')),
4491 _('[OPTION]... TEXT')),
4475 "debugbundle":
4492 "debugbundle":
4476 (debugbundle,
4493 (debugbundle,
4477 [('a', 'all', None, _('show all details')),
4494 [('a', 'all', None, _('show all details')),
4478 ],
4495 ],
4479 _('FILE')),
4496 _('FILE')),
4480 "debugcheckstate": (debugcheckstate, [], ''),
4497 "debugcheckstate": (debugcheckstate, [], ''),
4481 "debugcommands": (debugcommands, [], _('[COMMAND]')),
4498 "debugcommands": (debugcommands, [], _('[COMMAND]')),
4482 "debugcomplete":
4499 "debugcomplete":
4483 (debugcomplete,
4500 (debugcomplete,
4484 [('o', 'options', None, _('show the command options'))],
4501 [('o', 'options', None, _('show the command options'))],
4485 _('[-o] CMD')),
4502 _('[-o] CMD')),
4486 "debugdag":
4503 "debugdag":
4487 (debugdag,
4504 (debugdag,
4488 [('t', 'tags', None, _('use tags as labels')),
4505 [('t', 'tags', None, _('use tags as labels')),
4489 ('b', 'branches', None, _('annotate with branch names')),
4506 ('b', 'branches', None, _('annotate with branch names')),
4490 ('', 'dots', None, _('use dots for runs')),
4507 ('', 'dots', None, _('use dots for runs')),
4491 ('s', 'spaces', None, _('separate elements by spaces')),
4508 ('s', 'spaces', None, _('separate elements by spaces')),
4492 ],
4509 ],
4493 _('[OPTION]... [FILE [REV]...]')),
4510 _('[OPTION]... [FILE [REV]...]')),
4494 "debugdate":
4511 "debugdate":
4495 (debugdate,
4512 (debugdate,
4496 [('e', 'extended', None, _('try extended date formats'))],
4513 [('e', 'extended', None, _('try extended date formats'))],
4497 _('[-e] DATE [RANGE]')),
4514 _('[-e] DATE [RANGE]')),
4498 "debugdata": (debugdata, [], _('FILE REV')),
4515 "debugdata": (debugdata, [], _('FILE REV')),
4499 "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
4516 "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
4500 "debuggetbundle":
4517 "debuggetbundle":
4501 (debuggetbundle,
4518 (debuggetbundle,
4502 [('H', 'head', [], _('id of head node'), _('ID')),
4519 [('H', 'head', [], _('id of head node'), _('ID')),
4503 ('C', 'common', [], _('id of common node'), _('ID')),
4520 ('C', 'common', [], _('id of common node'), _('ID')),
4504 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
4521 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
4505 ],
4522 ],
4506 _('REPO FILE [-H|-C ID]...')),
4523 _('REPO FILE [-H|-C ID]...')),
4507 "debugignore": (debugignore, [], ''),
4524 "debugignore": (debugignore, [], ''),
4508 "debugindex": (debugindex,
4525 "debugindex": (debugindex,
4509 [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
4526 [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
4510 _('FILE')),
4527 _('FILE')),
4511 "debugindexdot": (debugindexdot, [], _('FILE')),
4528 "debugindexdot": (debugindexdot, [], _('FILE')),
4512 "debuginstall": (debuginstall, [], ''),
4529 "debuginstall": (debuginstall, [], ''),
4513 "debugknown": (debugknown, [], _('REPO ID...')),
4530 "debugknown": (debugknown, [], _('REPO ID...')),
4514 "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
4531 "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
4515 "debugrebuildstate":
4532 "debugrebuildstate":
4516 (debugrebuildstate,
4533 (debugrebuildstate,
4517 [('r', 'rev', '',
4534 [('r', 'rev', '',
4518 _('revision to rebuild to'), _('REV'))],
4535 _('revision to rebuild to'), _('REV'))],
4519 _('[-r REV] [REV]')),
4536 _('[-r REV] [REV]')),
4520 "debugrename":
4537 "debugrename":
4521 (debugrename,
4538 (debugrename,
4522 [('r', 'rev', '',
4539 [('r', 'rev', '',
4523 _('revision to debug'), _('REV'))],
4540 _('revision to debug'), _('REV'))],
4524 _('[-r REV] FILE')),
4541 _('[-r REV] FILE')),
4525 "debugrevspec":
4542 "debugrevspec":
4526 (debugrevspec, [], ('REVSPEC')),
4543 (debugrevspec, [], ('REVSPEC')),
4527 "debugsetparents":
4544 "debugsetparents":
4528 (debugsetparents, [], _('REV1 [REV2]')),
4545 (debugsetparents, [], _('REV1 [REV2]')),
4529 "debugstate":
4546 "debugstate":
4530 (debugstate,
4547 (debugstate,
4531 [('', 'nodates', None, _('do not display the saved mtime')),
4548 [('', 'nodates', None, _('do not display the saved mtime')),
4532 ('', 'datesort', None, _('sort by saved mtime'))],
4549 ('', 'datesort', None, _('sort by saved mtime'))],
4533 _('[OPTION]...')),
4550 _('[OPTION]...')),
4534 "debugsub":
4551 "debugsub":
4535 (debugsub,
4552 (debugsub,
4536 [('r', 'rev', '',
4553 [('r', 'rev', '',
4537 _('revision to check'), _('REV'))],
4554 _('revision to check'), _('REV'))],
4538 _('[-r REV] [REV]')),
4555 _('[-r REV] [REV]')),
4539 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
4556 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
4540 "debugwireargs":
4557 "debugwireargs":
4541 (debugwireargs,
4558 (debugwireargs,
4542 [('', 'three', '', 'three'),
4559 [('', 'three', '', 'three'),
4543 ('', 'four', '', 'four'),
4560 ('', 'four', '', 'four'),
4544 ('', 'five', '', 'five'),
4561 ('', 'five', '', 'five'),
4545 ] + remoteopts,
4562 ] + remoteopts,
4546 _('REPO [OPTIONS]... [ONE [TWO]]')),
4563 _('REPO [OPTIONS]... [ONE [TWO]]')),
4547 "^diff":
4564 "^diff":
4548 (diff,
4565 (diff,
4549 [('r', 'rev', [],
4566 [('r', 'rev', [],
4550 _('revision'), _('REV')),
4567 _('revision'), _('REV')),
4551 ('c', 'change', '',
4568 ('c', 'change', '',
4552 _('change made by revision'), _('REV'))
4569 _('change made by revision'), _('REV'))
4553 ] + diffopts + diffopts2 + walkopts + subrepoopts,
4570 ] + diffopts + diffopts2 + walkopts + subrepoopts,
4554 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...')),
4571 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...')),
4555 "^export":
4572 "^export":
4556 (export,
4573 (export,
4557 [('o', 'output', '',
4574 [('o', 'output', '',
4558 _('print output to file with formatted name'), _('FORMAT')),
4575 _('print output to file with formatted name'), _('FORMAT')),
4559 ('', 'switch-parent', None, _('diff against the second parent')),
4576 ('', 'switch-parent', None, _('diff against the second parent')),
4560 ('r', 'rev', [],
4577 ('r', 'rev', [],
4561 _('revisions to export'), _('REV')),
4578 _('revisions to export'), _('REV')),
4562 ] + diffopts,
4579 ] + diffopts,
4563 _('[OPTION]... [-o OUTFILESPEC] REV...')),
4580 _('[OPTION]... [-o OUTFILESPEC] REV...')),
4564 "^forget":
4581 "^forget":
4565 (forget,
4582 (forget,
4566 [] + walkopts,
4583 [] + walkopts,
4567 _('[OPTION]... FILE...')),
4584 _('[OPTION]... FILE...')),
4568 "grep":
4585 "grep":
4569 (grep,
4586 (grep,
4570 [('0', 'print0', None, _('end fields with NUL')),
4587 [('0', 'print0', None, _('end fields with NUL')),
4571 ('', 'all', None, _('print all revisions that match')),
4588 ('', 'all', None, _('print all revisions that match')),
4572 ('a', 'text', None, _('treat all files as text')),
4589 ('a', 'text', None, _('treat all files as text')),
4573 ('f', 'follow', None,
4590 ('f', 'follow', None,
4574 _('follow changeset history,'
4591 _('follow changeset history,'
4575 ' or file history across copies and renames')),
4592 ' or file history across copies and renames')),
4576 ('i', 'ignore-case', None, _('ignore case when matching')),
4593 ('i', 'ignore-case', None, _('ignore case when matching')),
4577 ('l', 'files-with-matches', None,
4594 ('l', 'files-with-matches', None,
4578 _('print only filenames and revisions that match')),
4595 _('print only filenames and revisions that match')),
4579 ('n', 'line-number', None, _('print matching line numbers')),
4596 ('n', 'line-number', None, _('print matching line numbers')),
4580 ('r', 'rev', [],
4597 ('r', 'rev', [],
4581 _('only search files changed within revision range'), _('REV')),
4598 _('only search files changed within revision range'), _('REV')),
4582 ('u', 'user', None, _('list the author (long with -v)')),
4599 ('u', 'user', None, _('list the author (long with -v)')),
4583 ('d', 'date', None, _('list the date (short with -q)')),
4600 ('d', 'date', None, _('list the date (short with -q)')),
4584 ] + walkopts,
4601 ] + walkopts,
4585 _('[OPTION]... PATTERN [FILE]...')),
4602 _('[OPTION]... PATTERN [FILE]...')),
4586 "heads":
4603 "heads":
4587 (heads,
4604 (heads,
4588 [('r', 'rev', '',
4605 [('r', 'rev', '',
4589 _('show only heads which are descendants of STARTREV'),
4606 _('show only heads which are descendants of STARTREV'),
4590 _('STARTREV')),
4607 _('STARTREV')),
4591 ('t', 'topo', False, _('show topological heads only')),
4608 ('t', 'topo', False, _('show topological heads only')),
4592 ('a', 'active', False,
4609 ('a', 'active', False,
4593 _('show active branchheads only (DEPRECATED)')),
4610 _('show active branchheads only (DEPRECATED)')),
4594 ('c', 'closed', False,
4611 ('c', 'closed', False,
4595 _('show normal and closed branch heads')),
4612 _('show normal and closed branch heads')),
4596 ] + templateopts,
4613 ] + templateopts,
4597 _('[-ac] [-r STARTREV] [REV]...')),
4614 _('[-ac] [-r STARTREV] [REV]...')),
4598 "help": (help_, [], _('[TOPIC]')),
4615 "help": (help_, [], _('[TOPIC]')),
4599 "identify|id":
4616 "identify|id":
4600 (identify,
4617 (identify,
4601 [('r', 'rev', '',
4618 [('r', 'rev', '',
4602 _('identify the specified revision'), _('REV')),
4619 _('identify the specified revision'), _('REV')),
4603 ('n', 'num', None, _('show local revision number')),
4620 ('n', 'num', None, _('show local revision number')),
4604 ('i', 'id', None, _('show global revision id')),
4621 ('i', 'id', None, _('show global revision id')),
4605 ('b', 'branch', None, _('show branch')),
4622 ('b', 'branch', None, _('show branch')),
4606 ('t', 'tags', None, _('show tags')),
4623 ('t', 'tags', None, _('show tags')),
4607 ('B', 'bookmarks', None, _('show bookmarks'))],
4624 ('B', 'bookmarks', None, _('show bookmarks'))],
4608 _('[-nibtB] [-r REV] [SOURCE]')),
4625 _('[-nibtB] [-r REV] [SOURCE]')),
4609 "import|patch":
4626 "import|patch":
4610 (import_,
4627 (import_,
4611 [('p', 'strip', 1,
4628 [('p', 'strip', 1,
4612 _('directory strip option for patch. This has the same '
4629 _('directory strip option for patch. This has the same '
4613 'meaning as the corresponding patch option'),
4630 'meaning as the corresponding patch option'),
4614 _('NUM')),
4631 _('NUM')),
4615 ('b', 'base', '',
4632 ('b', 'base', '',
4616 _('base path'), _('PATH')),
4633 _('base path'), _('PATH')),
4617 ('f', 'force', None,
4634 ('f', 'force', None,
4618 _('skip check for outstanding uncommitted changes')),
4635 _('skip check for outstanding uncommitted changes')),
4619 ('', 'no-commit', None,
4636 ('', 'no-commit', None,
4620 _("don't commit, just update the working directory")),
4637 _("don't commit, just update the working directory")),
4621 ('', 'exact', None,
4638 ('', 'exact', None,
4622 _('apply patch to the nodes from which it was generated')),
4639 _('apply patch to the nodes from which it was generated')),
4623 ('', 'import-branch', None,
4640 ('', 'import-branch', None,
4624 _('use any branch information in patch (implied by --exact)'))] +
4641 _('use any branch information in patch (implied by --exact)'))] +
4625 commitopts + commitopts2 + similarityopts,
4642 commitopts + commitopts2 + similarityopts,
4626 _('[OPTION]... PATCH...')),
4643 _('[OPTION]... PATCH...')),
4627 "incoming|in":
4644 "incoming|in":
4628 (incoming,
4645 (incoming,
4629 [('f', 'force', None,
4646 [('f', 'force', None,
4630 _('run even if remote repository is unrelated')),
4647 _('run even if remote repository is unrelated')),
4631 ('n', 'newest-first', None, _('show newest record first')),
4648 ('n', 'newest-first', None, _('show newest record first')),
4632 ('', 'bundle', '',
4649 ('', 'bundle', '',
4633 _('file to store the bundles into'), _('FILE')),
4650 _('file to store the bundles into'), _('FILE')),
4634 ('r', 'rev', [],
4651 ('r', 'rev', [],
4635 _('a remote changeset intended to be added'), _('REV')),
4652 _('a remote changeset intended to be added'), _('REV')),
4636 ('B', 'bookmarks', False, _("compare bookmarks")),
4653 ('B', 'bookmarks', False, _("compare bookmarks")),
4637 ('b', 'branch', [],
4654 ('b', 'branch', [],
4638 _('a specific branch you would like to pull'), _('BRANCH')),
4655 _('a specific branch you would like to pull'), _('BRANCH')),
4639 ] + logopts + remoteopts + subrepoopts,
4656 ] + logopts + remoteopts + subrepoopts,
4640 _('[-p] [-n] [-M] [-f] [-r REV]...'
4657 _('[-p] [-n] [-M] [-f] [-r REV]...'
4641 ' [--bundle FILENAME] [SOURCE]')),
4658 ' [--bundle FILENAME] [SOURCE]')),
4642 "^init":
4659 "^init":
4643 (init,
4660 (init,
4644 remoteopts,
4661 remoteopts,
4645 _('[-e CMD] [--remotecmd CMD] [DEST]')),
4662 _('[-e CMD] [--remotecmd CMD] [DEST]')),
4646 "locate":
4663 "locate":
4647 (locate,
4664 (locate,
4648 [('r', 'rev', '',
4665 [('r', 'rev', '',
4649 _('search the repository as it is in REV'), _('REV')),
4666 _('search the repository as it is in REV'), _('REV')),
4650 ('0', 'print0', None,
4667 ('0', 'print0', None,
4651 _('end filenames with NUL, for use with xargs')),
4668 _('end filenames with NUL, for use with xargs')),
4652 ('f', 'fullpath', None,
4669 ('f', 'fullpath', None,
4653 _('print complete paths from the filesystem root')),
4670 _('print complete paths from the filesystem root')),
4654 ] + walkopts,
4671 ] + walkopts,
4655 _('[OPTION]... [PATTERN]...')),
4672 _('[OPTION]... [PATTERN]...')),
4656 "^log|history":
4673 "^log|history":
4657 (log,
4674 (log,
4658 [('f', 'follow', None,
4675 [('f', 'follow', None,
4659 _('follow changeset history,'
4676 _('follow changeset history,'
4660 ' or file history across copies and renames')),
4677 ' or file history across copies and renames')),
4661 ('', 'follow-first', None,
4678 ('', 'follow-first', None,
4662 _('only follow the first parent of merge changesets')),
4679 _('only follow the first parent of merge changesets')),
4663 ('d', 'date', '',
4680 ('d', 'date', '',
4664 _('show revisions matching date spec'), _('DATE')),
4681 _('show revisions matching date spec'), _('DATE')),
4665 ('C', 'copies', None, _('show copied files')),
4682 ('C', 'copies', None, _('show copied files')),
4666 ('k', 'keyword', [],
4683 ('k', 'keyword', [],
4667 _('do case-insensitive search for a given text'), _('TEXT')),
4684 _('do case-insensitive search for a given text'), _('TEXT')),
4668 ('r', 'rev', [],
4685 ('r', 'rev', [],
4669 _('show the specified revision or range'), _('REV')),
4686 _('show the specified revision or range'), _('REV')),
4670 ('', 'removed', None, _('include revisions where files were removed')),
4687 ('', 'removed', None, _('include revisions where files were removed')),
4671 ('m', 'only-merges', None, _('show only merges')),
4688 ('m', 'only-merges', None, _('show only merges')),
4672 ('u', 'user', [],
4689 ('u', 'user', [],
4673 _('revisions committed by user'), _('USER')),
4690 _('revisions committed by user'), _('USER')),
4674 ('', 'only-branch', [],
4691 ('', 'only-branch', [],
4675 _('show only changesets within the given named branch (DEPRECATED)'),
4692 _('show only changesets within the given named branch (DEPRECATED)'),
4676 _('BRANCH')),
4693 _('BRANCH')),
4677 ('b', 'branch', [],
4694 ('b', 'branch', [],
4678 _('show changesets within the given named branch'), _('BRANCH')),
4695 _('show changesets within the given named branch'), _('BRANCH')),
4679 ('P', 'prune', [],
4696 ('P', 'prune', [],
4680 _('do not display revision or any of its ancestors'), _('REV')),
4697 _('do not display revision or any of its ancestors'), _('REV')),
4681 ] + logopts + walkopts,
4698 ] + logopts + walkopts,
4682 _('[OPTION]... [FILE]')),
4699 _('[OPTION]... [FILE]')),
4683 "manifest":
4700 "manifest":
4684 (manifest,
4701 (manifest,
4685 [('r', 'rev', '',
4702 [('r', 'rev', '',
4686 _('revision to display'), _('REV'))],
4703 _('revision to display'), _('REV'))],
4687 _('[-r REV]')),
4704 _('[-r REV]')),
4688 "^merge":
4705 "^merge":
4689 (merge,
4706 (merge,
4690 [('f', 'force', None, _('force a merge with outstanding changes')),
4707 [('f', 'force', None, _('force a merge with outstanding changes')),
4691 ('t', 'tool', '', _('specify merge tool')),
4708 ('t', 'tool', '', _('specify merge tool')),
4692 ('r', 'rev', '',
4709 ('r', 'rev', '',
4693 _('revision to merge'), _('REV')),
4710 _('revision to merge'), _('REV')),
4694 ('P', 'preview', None,
4711 ('P', 'preview', None,
4695 _('review revisions to merge (no merge is performed)'))],
4712 _('review revisions to merge (no merge is performed)'))],
4696 _('[-P] [-f] [[-r] REV]')),
4713 _('[-P] [-f] [[-r] REV]')),
4697 "outgoing|out":
4714 "outgoing|out":
4698 (outgoing,
4715 (outgoing,
4699 [('f', 'force', None,
4716 [('f', 'force', None,
4700 _('run even when the destination is unrelated')),
4717 _('run even when the destination is unrelated')),
4701 ('r', 'rev', [],
4718 ('r', 'rev', [],
4702 _('a changeset intended to be included in the destination'),
4719 _('a changeset intended to be included in the destination'),
4703 _('REV')),
4720 _('REV')),
4704 ('n', 'newest-first', None, _('show newest record first')),
4721 ('n', 'newest-first', None, _('show newest record first')),
4705 ('B', 'bookmarks', False, _("compare bookmarks")),
4722 ('B', 'bookmarks', False, _("compare bookmarks")),
4706 ('b', 'branch', [],
4723 ('b', 'branch', [],
4707 _('a specific branch you would like to push'), _('BRANCH')),
4724 _('a specific branch you would like to push'), _('BRANCH')),
4708 ] + logopts + remoteopts + subrepoopts,
4725 ] + logopts + remoteopts + subrepoopts,
4709 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
4726 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
4710 "parents":
4727 "parents":
4711 (parents,
4728 (parents,
4712 [('r', 'rev', '',
4729 [('r', 'rev', '',
4713 _('show parents of the specified revision'), _('REV')),
4730 _('show parents of the specified revision'), _('REV')),
4714 ] + templateopts,
4731 ] + templateopts,
4715 _('[-r REV] [FILE]')),
4732 _('[-r REV] [FILE]')),
4716 "paths": (paths, [], _('[NAME]')),
4733 "paths": (paths, [], _('[NAME]')),
4717 "^pull":
4734 "^pull":
4718 (pull,
4735 (pull,
4719 [('u', 'update', None,
4736 [('u', 'update', None,
4720 _('update to new branch head if changesets were pulled')),
4737 _('update to new branch head if changesets were pulled')),
4721 ('f', 'force', None,
4738 ('f', 'force', None,
4722 _('run even when remote repository is unrelated')),
4739 _('run even when remote repository is unrelated')),
4723 ('r', 'rev', [],
4740 ('r', 'rev', [],
4724 _('a remote changeset intended to be added'), _('REV')),
4741 _('a remote changeset intended to be added'), _('REV')),
4725 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
4742 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
4726 ('b', 'branch', [],
4743 ('b', 'branch', [],
4727 _('a specific branch you would like to pull'), _('BRANCH')),
4744 _('a specific branch you would like to pull'), _('BRANCH')),
4728 ] + remoteopts,
4745 ] + remoteopts,
4729 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
4746 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
4730 "^push":
4747 "^push":
4731 (push,
4748 (push,
4732 [('f', 'force', None, _('force push')),
4749 [('f', 'force', None, _('force push')),
4733 ('r', 'rev', [],
4750 ('r', 'rev', [],
4734 _('a changeset intended to be included in the destination'),
4751 _('a changeset intended to be included in the destination'),
4735 _('REV')),
4752 _('REV')),
4736 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4753 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4737 ('b', 'branch', [],
4754 ('b', 'branch', [],
4738 _('a specific branch you would like to push'), _('BRANCH')),
4755 _('a specific branch you would like to push'), _('BRANCH')),
4739 ('', 'new-branch', False, _('allow pushing a new branch')),
4756 ('', 'new-branch', False, _('allow pushing a new branch')),
4740 ] + remoteopts,
4757 ] + remoteopts,
4741 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
4758 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
4742 "recover": (recover, []),
4759 "recover": (recover, []),
4743 "^remove|rm":
4760 "^remove|rm":
4744 (remove,
4761 (remove,
4745 [('A', 'after', None, _('record delete for missing files')),
4762 [('A', 'after', None, _('record delete for missing files')),
4746 ('f', 'force', None,
4763 ('f', 'force', None,
4747 _('remove (and delete) file even if added or modified')),
4764 _('remove (and delete) file even if added or modified')),
4748 ] + walkopts,
4765 ] + walkopts,
4749 _('[OPTION]... FILE...')),
4766 _('[OPTION]... FILE...')),
4750 "rename|move|mv":
4767 "rename|move|mv":
4751 (rename,
4768 (rename,
4752 [('A', 'after', None, _('record a rename that has already occurred')),
4769 [('A', 'after', None, _('record a rename that has already occurred')),
4753 ('f', 'force', None,
4770 ('f', 'force', None,
4754 _('forcibly copy over an existing managed file')),
4771 _('forcibly copy over an existing managed file')),
4755 ] + walkopts + dryrunopts,
4772 ] + walkopts + dryrunopts,
4756 _('[OPTION]... SOURCE... DEST')),
4773 _('[OPTION]... SOURCE... DEST')),
4757 "resolve":
4774 "resolve":
4758 (resolve,
4775 (resolve,
4759 [('a', 'all', None, _('select all unresolved files')),
4776 [('a', 'all', None, _('select all unresolved files')),
4760 ('l', 'list', None, _('list state of files needing merge')),
4777 ('l', 'list', None, _('list state of files needing merge')),
4761 ('m', 'mark', None, _('mark files as resolved')),
4778 ('m', 'mark', None, _('mark files as resolved')),
4762 ('u', 'unmark', None, _('mark files as unresolved')),
4779 ('u', 'unmark', None, _('mark files as unresolved')),
4763 ('t', 'tool', '', _('specify merge tool')),
4780 ('t', 'tool', '', _('specify merge tool')),
4764 ('n', 'no-status', None, _('hide status prefix'))]
4781 ('n', 'no-status', None, _('hide status prefix'))]
4765 + walkopts,
4782 + walkopts,
4766 _('[OPTION]... [FILE]...')),
4783 _('[OPTION]... [FILE]...')),
4767 "revert":
4784 "revert":
4768 (revert,
4785 (revert,
4769 [('a', 'all', None, _('revert all changes when no arguments given')),
4786 [('a', 'all', None, _('revert all changes when no arguments given')),
4770 ('d', 'date', '',
4787 ('d', 'date', '',
4771 _('tipmost revision matching date'), _('DATE')),
4788 _('tipmost revision matching date'), _('DATE')),
4772 ('r', 'rev', '',
4789 ('r', 'rev', '',
4773 _('revert to the specified revision'), _('REV')),
4790 _('revert to the specified revision'), _('REV')),
4774 ('', 'no-backup', None, _('do not save backup copies of files')),
4791 ('', 'no-backup', None, _('do not save backup copies of files')),
4775 ] + walkopts + dryrunopts,
4792 ] + walkopts + dryrunopts,
4776 _('[OPTION]... [-r REV] [NAME]...')),
4793 _('[OPTION]... [-r REV] [NAME]...')),
4777 "rollback": (rollback, dryrunopts),
4794 "rollback": (rollback, dryrunopts),
4778 "root": (root, []),
4795 "root": (root, []),
4779 "^serve":
4796 "^serve":
4780 (serve,
4797 (serve,
4781 [('A', 'accesslog', '',
4798 [('A', 'accesslog', '',
4782 _('name of access log file to write to'), _('FILE')),
4799 _('name of access log file to write to'), _('FILE')),
4783 ('d', 'daemon', None, _('run server in background')),
4800 ('d', 'daemon', None, _('run server in background')),
4784 ('', 'daemon-pipefds', '',
4801 ('', 'daemon-pipefds', '',
4785 _('used internally by daemon mode'), _('NUM')),
4802 _('used internally by daemon mode'), _('NUM')),
4786 ('E', 'errorlog', '',
4803 ('E', 'errorlog', '',
4787 _('name of error log file to write to'), _('FILE')),
4804 _('name of error log file to write to'), _('FILE')),
4788 # use string type, then we can check if something was passed
4805 # use string type, then we can check if something was passed
4789 ('p', 'port', '',
4806 ('p', 'port', '',
4790 _('port to listen on (default: 8000)'), _('PORT')),
4807 _('port to listen on (default: 8000)'), _('PORT')),
4791 ('a', 'address', '',
4808 ('a', 'address', '',
4792 _('address to listen on (default: all interfaces)'), _('ADDR')),
4809 _('address to listen on (default: all interfaces)'), _('ADDR')),
4793 ('', 'prefix', '',
4810 ('', 'prefix', '',
4794 _('prefix path to serve from (default: server root)'), _('PREFIX')),
4811 _('prefix path to serve from (default: server root)'), _('PREFIX')),
4795 ('n', 'name', '',
4812 ('n', 'name', '',
4796 _('name to show in web pages (default: working directory)'),
4813 _('name to show in web pages (default: working directory)'),
4797 _('NAME')),
4814 _('NAME')),
4798 ('', 'web-conf', '',
4815 ('', 'web-conf', '',
4799 _('name of the hgweb config file (see "hg help hgweb")'),
4816 _('name of the hgweb config file (see "hg help hgweb")'),
4800 _('FILE')),
4817 _('FILE')),
4801 ('', 'webdir-conf', '',
4818 ('', 'webdir-conf', '',
4802 _('name of the hgweb config file (DEPRECATED)'), _('FILE')),
4819 _('name of the hgweb config file (DEPRECATED)'), _('FILE')),
4803 ('', 'pid-file', '',
4820 ('', 'pid-file', '',
4804 _('name of file to write process ID to'), _('FILE')),
4821 _('name of file to write process ID to'), _('FILE')),
4805 ('', 'stdio', None, _('for remote clients')),
4822 ('', 'stdio', None, _('for remote clients')),
4806 ('t', 'templates', '',
4823 ('t', 'templates', '',
4807 _('web templates to use'), _('TEMPLATE')),
4824 _('web templates to use'), _('TEMPLATE')),
4808 ('', 'style', '',
4825 ('', 'style', '',
4809 _('template style to use'), _('STYLE')),
4826 _('template style to use'), _('STYLE')),
4810 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4827 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
4811 ('', 'certificate', '',
4828 ('', 'certificate', '',
4812 _('SSL certificate file'), _('FILE'))],
4829 _('SSL certificate file'), _('FILE'))],
4813 _('[OPTION]...')),
4830 _('[OPTION]...')),
4814 "showconfig|debugconfig":
4831 "showconfig|debugconfig":
4815 (showconfig,
4832 (showconfig,
4816 [('u', 'untrusted', None, _('show untrusted configuration options'))],
4833 [('u', 'untrusted', None, _('show untrusted configuration options'))],
4817 _('[-u] [NAME]...')),
4834 _('[-u] [NAME]...')),
4818 "^summary|sum":
4835 "^summary|sum":
4819 (summary,
4836 (summary,
4820 [('', 'remote', None, _('check for push and pull'))], '[--remote]'),
4837 [('', 'remote', None, _('check for push and pull'))], '[--remote]'),
4821 "^status|st":
4838 "^status|st":
4822 (status,
4839 (status,
4823 [('A', 'all', None, _('show status of all files')),
4840 [('A', 'all', None, _('show status of all files')),
4824 ('m', 'modified', None, _('show only modified files')),
4841 ('m', 'modified', None, _('show only modified files')),
4825 ('a', 'added', None, _('show only added files')),
4842 ('a', 'added', None, _('show only added files')),
4826 ('r', 'removed', None, _('show only removed files')),
4843 ('r', 'removed', None, _('show only removed files')),
4827 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4844 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
4828 ('c', 'clean', None, _('show only files without changes')),
4845 ('c', 'clean', None, _('show only files without changes')),
4829 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4846 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
4830 ('i', 'ignored', None, _('show only ignored files')),
4847 ('i', 'ignored', None, _('show only ignored files')),
4831 ('n', 'no-status', None, _('hide status prefix')),
4848 ('n', 'no-status', None, _('hide status prefix')),
4832 ('C', 'copies', None, _('show source of copied files')),
4849 ('C', 'copies', None, _('show source of copied files')),
4833 ('0', 'print0', None,
4850 ('0', 'print0', None,
4834 _('end filenames with NUL, for use with xargs')),
4851 _('end filenames with NUL, for use with xargs')),
4835 ('', 'rev', [],
4852 ('', 'rev', [],
4836 _('show difference from revision'), _('REV')),
4853 _('show difference from revision'), _('REV')),
4837 ('', 'change', '',
4854 ('', 'change', '',
4838 _('list the changed files of a revision'), _('REV')),
4855 _('list the changed files of a revision'), _('REV')),
4839 ] + walkopts + subrepoopts,
4856 ] + walkopts + subrepoopts,
4840 _('[OPTION]... [FILE]...')),
4857 _('[OPTION]... [FILE]...')),
4841 "tag":
4858 "tag":
4842 (tag,
4859 (tag,
4843 [('f', 'force', None, _('force tag')),
4860 [('f', 'force', None, _('force tag')),
4844 ('l', 'local', None, _('make the tag local')),
4861 ('l', 'local', None, _('make the tag local')),
4845 ('r', 'rev', '',
4862 ('r', 'rev', '',
4846 _('revision to tag'), _('REV')),
4863 _('revision to tag'), _('REV')),
4847 ('', 'remove', None, _('remove a tag')),
4864 ('', 'remove', None, _('remove a tag')),
4848 # -l/--local is already there, commitopts cannot be used
4865 # -l/--local is already there, commitopts cannot be used
4849 ('e', 'edit', None, _('edit commit message')),
4866 ('e', 'edit', None, _('edit commit message')),
4850 ('m', 'message', '',
4867 ('m', 'message', '',
4851 _('use <text> as commit message'), _('TEXT')),
4868 _('use <text> as commit message'), _('TEXT')),
4852 ] + commitopts2,
4869 ] + commitopts2,
4853 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')),
4870 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')),
4854 "tags": (tags, [], ''),
4871 "tags": (tags, [], ''),
4855 "tip":
4872 "tip":
4856 (tip,
4873 (tip,
4857 [('p', 'patch', None, _('show patch')),
4874 [('p', 'patch', None, _('show patch')),
4858 ('g', 'git', None, _('use git extended diff format')),
4875 ('g', 'git', None, _('use git extended diff format')),
4859 ] + templateopts,
4876 ] + templateopts,
4860 _('[-p] [-g]')),
4877 _('[-p] [-g]')),
4861 "unbundle":
4878 "unbundle":
4862 (unbundle,
4879 (unbundle,
4863 [('u', 'update', None,
4880 [('u', 'update', None,
4864 _('update to new branch head if changesets were unbundled'))],
4881 _('update to new branch head if changesets were unbundled'))],
4865 _('[-u] FILE...')),
4882 _('[-u] FILE...')),
4866 "^update|up|checkout|co":
4883 "^update|up|checkout|co":
4867 (update,
4884 (update,
4868 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
4885 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
4869 ('c', 'check', None,
4886 ('c', 'check', None,
4870 _('update across branches if no uncommitted changes')),
4887 _('update across branches if no uncommitted changes')),
4871 ('d', 'date', '',
4888 ('d', 'date', '',
4872 _('tipmost revision matching date'), _('DATE')),
4889 _('tipmost revision matching date'), _('DATE')),
4873 ('r', 'rev', '',
4890 ('r', 'rev', '',
4874 _('revision'), _('REV'))],
4891 _('revision'), _('REV'))],
4875 _('[-c] [-C] [-d DATE] [[-r] REV]')),
4892 _('[-c] [-C] [-d DATE] [[-r] REV]')),
4876 "verify": (verify, []),
4893 "verify": (verify, []),
4877 "version": (version_, []),
4894 "version": (version_, []),
4878 }
4895 }
4879
4896
4880 norepo = ("clone init version help debugcommands debugcomplete"
4897 norepo = ("clone init version help debugcommands debugcomplete"
4881 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
4898 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
4882 " debugknown debuggetbundle debugbundle")
4899 " debugknown debuggetbundle debugbundle")
4883 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
4900 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
4884 " debugdata debugindex debugindexdot")
4901 " debugdata debugindex debugindexdot")
@@ -1,321 +1,313 b''
1 $ echo "[extensions]" >> $HGRCPATH
1 $ echo "[extensions]" >> $HGRCPATH
2 $ echo "graphlog=" >> $HGRCPATH
2 $ echo "graphlog=" >> $HGRCPATH
3
3
4 overwritten and appended files
4 plain
5
5
6 $ rm -rf repo
6 $ rm -rf repo
7 $ hg init repo
7 $ hg init repo
8 $ cd repo
8 $ cd repo
9 $ hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2' -q -oa
9 $ hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2'
10 tags
11 $ cat .hg/localtags
12 66f7d451a68b85ed82ff5fcc254daf50c74144bd f
13 bebd167eb94d257ace0e814aeb98e6972ed2970d p2
10 dag
14 dag
11 $ hg debugdag -t -b
15 $ hg debugdag -t -b
12 +2:f
16 +2:f
13 +3:p2
17 +3:p2
14 @temp*f+3
18 @temp*f+3
15 @default*/p2+2:tip
19 @default*/p2+2:tip
16 tip
20 tip
17 $ hg id
21 $ hg id
18 f96e381c614c tip
22 000000000000
19 glog
23 glog
20 $ hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
24 $ hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
21 @ 11: r11 [] @ 11.00
25 o 11: r11 [] @ 11.00
26 |
27 o 10: r10 [] @ 10.00
28 |
29 o 9: r9 [] @ 9.00
30 |\
31 | o 8: r8 [temp] @ 8.00
32 | |
33 | o 7: r7 [temp] @ 7.00
34 | |
35 | o 6: r6 [temp] @ 6.00
36 | |
37 | o 5: r5 [temp] @ 5.00
38 | |
39 o | 4: r4 [] @ 4.00
40 | |
41 o | 3: r3 [] @ 3.00
42 | |
43 o | 2: r2 [] @ 2.00
44 |/
45 o 1: r1 [] @ 1.00
46 |
47 o 0: r0 [] @ 0.00
48
49
50 overwritten files
51
52 $ rm -rf repo
53 $ hg init repo
54 $ cd repo
55 $ hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2' -q -o
56 tags
57 $ cat .hg/localtags
58 2a8ed67d317e370eac733dccc501b12d7b9c441a f
59 4226a30965b7af58f94d0cda7e6c2c9c63e6bf90 p2
60 dag
61 $ hg debugdag -t -b
62 +2:f
63 +3:p2
64 @temp*f+3
65 @default*/p2+2:tip
66 tip
67 $ hg id
68 000000000000
69 glog
70 $ hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
71 o 11: r11 [] @ 11.00
22 |
72 |
23 o 10: r10 [] @ 10.00
73 o 10: r10 [] @ 10.00
24 |
74 |
25 o 9: r9 [] @ 9.00
75 o 9: r9 [] @ 9.00
26 |\
76 |\
27 | o 8: r8 [temp] @ 8.00
77 | o 8: r8 [temp] @ 8.00
28 | |
78 | |
29 | o 7: r7 [temp] @ 7.00
79 | o 7: r7 [temp] @ 7.00
30 | |
80 | |
31 | o 6: r6 [temp] @ 6.00
81 | o 6: r6 [temp] @ 6.00
32 | |
82 | |
33 | o 5: r5 [temp] @ 5.00
83 | o 5: r5 [temp] @ 5.00
34 | |
84 | |
35 o | 4: r4 [] @ 4.00
85 o | 4: r4 [] @ 4.00
36 | |
86 | |
37 o | 3: r3 [] @ 3.00
87 o | 3: r3 [] @ 3.00
38 | |
88 | |
39 o | 2: r2 [] @ 2.00
89 o | 2: r2 [] @ 2.00
40 |/
90 |/
41 o 1: r1 [] @ 1.00
91 o 1: r1 [] @ 1.00
42 |
92 |
43 o 0: r0 [] @ 0.00
93 o 0: r0 [] @ 0.00
44
94
45 glog of
95 glog of
46 $ hg glog --template '{rev}: {desc} [{branches}]\n' of
96 $ hg glog --template '{rev}: {desc} [{branches}]\n' of
47 @ 11: r11 []
97 o 11: r11 []
48 |
49 o 10: r10 []
50 |
51 o 9: r9 []
52 |\
53 | o 8: r8 [temp]
54 | |
55 | o 7: r7 [temp]
56 | |
57 | o 6: r6 [temp]
58 | |
59 | o 5: r5 [temp]
60 | |
61 o | 4: r4 []
62 | |
63 o | 3: r3 []
64 | |
65 o | 2: r2 []
66 |/
67 o 1: r1 []
68 |
69 o 0: r0 []
70
71 glog af
72 $ hg glog --template '{rev}: {desc} [{branches}]\n' af
73 @ 11: r11 []
74 |
98 |
75 o 10: r10 []
99 o 10: r10 []
76 |
100 |
77 o 9: r9 []
101 o 9: r9 []
78 |\
102 |\
79 | o 8: r8 [temp]
103 | o 8: r8 [temp]
80 | |
104 | |
81 | o 7: r7 [temp]
105 | o 7: r7 [temp]
82 | |
106 | |
83 | o 6: r6 [temp]
107 | o 6: r6 [temp]
84 | |
108 | |
85 | o 5: r5 [temp]
109 | o 5: r5 [temp]
86 | |
110 | |
87 o | 4: r4 []
111 o | 4: r4 []
88 | |
112 | |
89 o | 3: r3 []
113 o | 3: r3 []
90 | |
114 | |
91 o | 2: r2 []
115 o | 2: r2 []
92 |/
116 |/
93 o 1: r1 []
117 o 1: r1 []
94 |
118 |
95 o 0: r0 []
119 o 0: r0 []
96
120
97 tags
121 tags
98 $ hg tags -v
122 $ hg tags -v
99 tip 11:f96e381c614c
123 tip 11:58a51e5eb988
100 p2 4:d9d6db981b55 local
124 p2 4:4226a30965b7 local
101 f 1:73253def624e local
125 f 1:2a8ed67d317e local
102 cat of
126 cat of
103 $ hg cat of
127 $ hg cat of --rev tip
104 r11
105 cat af
106 $ hg cat af
107 r0
108 r1
109 r5
110 r6
111 r7
112 r8
113 r9
114 r10
115 r11
128 r11
116 $ cd ..
129 $ cd ..
117
130
131
118 new and mergeable files
132 new and mergeable files
119
133
120 $ rm -rf repo
134 $ rm -rf repo
121 $ hg init repo
135 $ hg init repo
122 $ cd repo
136 $ cd repo
123 $ hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2' -q -mn
137 $ hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2' -q -mn
124 dag
138 dag
125 $ hg debugdag -t -b
139 $ hg debugdag -t -b
126 +2:f
140 +2:f
127 +3:p2
141 +3:p2
128 @temp*f+3
142 @temp*f+3
129 @default*/p2+2:tip
143 @default*/p2+2:tip
130 tip
144 tip
131 $ hg id
145 $ hg id
132 9c5ce9b70771 tip
146 000000000000
133 glog
147 glog
134 $ hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
148 $ hg glog --template '{rev}: {desc} [{branches}] @ {date}\n'
135 @ 11: r11 [] @ 11.00
149 o 11: r11 [] @ 11.00
136 |
150 |
137 o 10: r10 [] @ 10.00
151 o 10: r10 [] @ 10.00
138 |
152 |
139 o 9: r9 [] @ 9.00
153 o 9: r9 [] @ 9.00
140 |\
154 |\
141 | o 8: r8 [temp] @ 8.00
155 | o 8: r8 [temp] @ 8.00
142 | |
156 | |
143 | o 7: r7 [temp] @ 7.00
157 | o 7: r7 [temp] @ 7.00
144 | |
158 | |
145 | o 6: r6 [temp] @ 6.00
159 | o 6: r6 [temp] @ 6.00
146 | |
160 | |
147 | o 5: r5 [temp] @ 5.00
161 | o 5: r5 [temp] @ 5.00
148 | |
162 | |
149 o | 4: r4 [] @ 4.00
163 o | 4: r4 [] @ 4.00
150 | |
164 | |
151 o | 3: r3 [] @ 3.00
165 o | 3: r3 [] @ 3.00
152 | |
166 | |
153 o | 2: r2 [] @ 2.00
167 o | 2: r2 [] @ 2.00
154 |/
168 |/
155 o 1: r1 [] @ 1.00
169 o 1: r1 [] @ 1.00
156 |
170 |
157 o 0: r0 [] @ 0.00
171 o 0: r0 [] @ 0.00
158
172
159 glog mf
173 glog mf
160 $ hg glog --template '{rev}: {desc} [{branches}]\n' mf
174 $ hg glog --template '{rev}: {desc} [{branches}]\n' mf
161 @ 11: r11 []
175 o 11: r11 []
162 |
176 |
163 o 10: r10 []
177 o 10: r10 []
164 |
178 |
165 o 9: r9 []
179 o 9: r9 []
166 |\
180 |\
167 | o 8: r8 [temp]
181 | o 8: r8 [temp]
168 | |
182 | |
169 | o 7: r7 [temp]
183 | o 7: r7 [temp]
170 | |
184 | |
171 | o 6: r6 [temp]
185 | o 6: r6 [temp]
172 | |
186 | |
173 | o 5: r5 [temp]
187 | o 5: r5 [temp]
174 | |
188 | |
175 o | 4: r4 []
189 o | 4: r4 []
176 | |
190 | |
177 o | 3: r3 []
191 o | 3: r3 []
178 | |
192 | |
179 o | 2: r2 []
193 o | 2: r2 []
180 |/
194 |/
181 o 1: r1 []
195 o 1: r1 []
182 |
196 |
183 o 0: r0 []
197 o 0: r0 []
184
198
185
199
186 man r4
200 man r4
187 $ hg manifest -r4
201 $ hg manifest -r4
188 mf
202 mf
189 nf0
203 nf0
190 nf1
204 nf1
191 nf2
205 nf2
192 nf3
206 nf3
193 nf4
207 nf4
194 cat r4 mf
208 cat r4 mf
195 $ hg cat -r4 mf
209 $ hg cat -r4 mf
196 0 r0
210 0 r0
197 1
211 1
198 2 r1
212 2 r1
199 3
213 3
200 4 r2
214 4 r2
201 5
215 5
202 6 r3
216 6 r3
203 7
217 7
204 8 r4
218 8 r4
205 9
219 9
206 10
220 10
207 11
221 11
208 12
222 12
209 13
223 13
210 14
224 14
211 15
225 15
212 16
226 16
213 17
227 17
214 18
228 18
215 19
229 19
216 20
230 20
217 21
231 21
218 22
232 22
219 23
233 23
220 man r8
234 man r8
221 $ hg manifest -r8
235 $ hg manifest -r8
222 mf
236 mf
223 nf0
237 nf0
224 nf1
238 nf1
225 nf5
239 nf5
226 nf6
240 nf6
227 nf7
241 nf7
228 nf8
242 nf8
229 cat r8 mf
243 cat r8 mf
230 $ hg cat -r8 mf
244 $ hg cat -r8 mf
231 0 r0
245 0 r0
232 1
246 1
233 2 r1
247 2 r1
234 3
248 3
235 4
249 4
236 5
250 5
237 6
251 6
238 7
252 7
239 8
253 8
240 9
254 9
241 10 r5
255 10 r5
242 11
256 11
243 12 r6
257 12 r6
244 13
258 13
245 14 r7
259 14 r7
246 15
260 15
247 16 r8
261 16 r8
248 17
262 17
249 18
263 18
250 19
264 19
251 20
265 20
252 21
266 21
253 22
267 22
254 23
268 23
255 man
269 man
256 $ hg manifest
270 $ hg manifest --rev tip
257 mf
271 mf
258 nf0
272 nf0
259 nf1
273 nf1
260 nf10
274 nf10
261 nf11
275 nf11
262 nf2
276 nf2
263 nf3
277 nf3
264 nf4
278 nf4
265 nf5
279 nf5
266 nf6
280 nf6
267 nf7
281 nf7
268 nf8
282 nf8
269 nf9
283 nf9
270 cat mf
284 cat mf
271 $ hg cat mf
285 $ hg cat mf --rev tip
272 0 r0
286 0 r0
273 1
287 1
274 2 r1
288 2 r1
275 3
289 3
276 4 r2
290 4 r2
277 5
291 5
278 6 r3
292 6 r3
279 7
293 7
280 8 r4
294 8 r4
281 9
295 9
282 10 r5
296 10 r5
283 11
297 11
284 12 r6
298 12 r6
285 13
299 13
286 14 r7
300 14 r7
287 15
301 15
288 16 r8
302 16 r8
289 17
303 17
290 18 r9
304 18 r9
291 19
305 19
292 20 r10
306 20 r10
293 21
307 21
294 22 r11
308 22 r11
295 23
309 23
296 $ cd ..
310 $ cd ..
297
311
298 command
299
312
300 $ rm -rf repo
313
301 $ hg init repo
302 $ cd repo
303 $ hg debugbuilddag '+2 !"touch X" +2' -q -o
304 dag
305 $ hg debugdag -t -b
306 +4:tip
307 glog
308 $ hg glog --template '{rev}: {desc} [{branches}]\n'
309 @ 3: r3 []
310 |
311 o 2: r2 []
312 |
313 o 1: r1 []
314 |
315 o 0: r0 []
316
317 glog X
318 $ hg glog --template '{rev}: {desc} [{branches}]\n' X
319 o 2: r2 []
320 |
321 $ cd ..
@@ -1,261 +1,261 b''
1 Show all commands except debug commands
1 Show all commands except debug commands
2 $ hg debugcomplete
2 $ hg debugcomplete
3 add
3 add
4 addremove
4 addremove
5 annotate
5 annotate
6 archive
6 archive
7 backout
7 backout
8 bisect
8 bisect
9 bookmarks
9 bookmarks
10 branch
10 branch
11 branches
11 branches
12 bundle
12 bundle
13 cat
13 cat
14 clone
14 clone
15 commit
15 commit
16 copy
16 copy
17 diff
17 diff
18 export
18 export
19 forget
19 forget
20 grep
20 grep
21 heads
21 heads
22 help
22 help
23 identify
23 identify
24 import
24 import
25 incoming
25 incoming
26 init
26 init
27 locate
27 locate
28 log
28 log
29 manifest
29 manifest
30 merge
30 merge
31 outgoing
31 outgoing
32 parents
32 parents
33 paths
33 paths
34 pull
34 pull
35 push
35 push
36 recover
36 recover
37 remove
37 remove
38 rename
38 rename
39 resolve
39 resolve
40 revert
40 revert
41 rollback
41 rollback
42 root
42 root
43 serve
43 serve
44 showconfig
44 showconfig
45 status
45 status
46 summary
46 summary
47 tag
47 tag
48 tags
48 tags
49 tip
49 tip
50 unbundle
50 unbundle
51 update
51 update
52 verify
52 verify
53 version
53 version
54
54
55 Show all commands that start with "a"
55 Show all commands that start with "a"
56 $ hg debugcomplete a
56 $ hg debugcomplete a
57 add
57 add
58 addremove
58 addremove
59 annotate
59 annotate
60 archive
60 archive
61
61
62 Do not show debug commands if there are other candidates
62 Do not show debug commands if there are other candidates
63 $ hg debugcomplete d
63 $ hg debugcomplete d
64 diff
64 diff
65
65
66 Show debug commands if there are no other candidates
66 Show debug commands if there are no other candidates
67 $ hg debugcomplete debug
67 $ hg debugcomplete debug
68 debugancestor
68 debugancestor
69 debugbuilddag
69 debugbuilddag
70 debugbundle
70 debugbundle
71 debugcheckstate
71 debugcheckstate
72 debugcommands
72 debugcommands
73 debugcomplete
73 debugcomplete
74 debugconfig
74 debugconfig
75 debugdag
75 debugdag
76 debugdata
76 debugdata
77 debugdate
77 debugdate
78 debugfsinfo
78 debugfsinfo
79 debuggetbundle
79 debuggetbundle
80 debugignore
80 debugignore
81 debugindex
81 debugindex
82 debugindexdot
82 debugindexdot
83 debuginstall
83 debuginstall
84 debugknown
84 debugknown
85 debugpushkey
85 debugpushkey
86 debugrebuildstate
86 debugrebuildstate
87 debugrename
87 debugrename
88 debugrevspec
88 debugrevspec
89 debugsetparents
89 debugsetparents
90 debugstate
90 debugstate
91 debugsub
91 debugsub
92 debugwalk
92 debugwalk
93 debugwireargs
93 debugwireargs
94
94
95 Do not show the alias of a debug command if there are other candidates
95 Do not show the alias of a debug command if there are other candidates
96 (this should hide rawcommit)
96 (this should hide rawcommit)
97 $ hg debugcomplete r
97 $ hg debugcomplete r
98 recover
98 recover
99 remove
99 remove
100 rename
100 rename
101 resolve
101 resolve
102 revert
102 revert
103 rollback
103 rollback
104 root
104 root
105 Show the alias of a debug command if there are no other candidates
105 Show the alias of a debug command if there are no other candidates
106 $ hg debugcomplete rawc
106 $ hg debugcomplete rawc
107
107
108
108
109 Show the global options
109 Show the global options
110 $ hg debugcomplete --options | sort
110 $ hg debugcomplete --options | sort
111 --config
111 --config
112 --cwd
112 --cwd
113 --debug
113 --debug
114 --debugger
114 --debugger
115 --encoding
115 --encoding
116 --encodingmode
116 --encodingmode
117 --help
117 --help
118 --noninteractive
118 --noninteractive
119 --profile
119 --profile
120 --quiet
120 --quiet
121 --repository
121 --repository
122 --time
122 --time
123 --traceback
123 --traceback
124 --verbose
124 --verbose
125 --version
125 --version
126 -R
126 -R
127 -h
127 -h
128 -q
128 -q
129 -v
129 -v
130 -y
130 -y
131
131
132 Show the options for the "serve" command
132 Show the options for the "serve" command
133 $ hg debugcomplete --options serve | sort
133 $ hg debugcomplete --options serve | sort
134 --accesslog
134 --accesslog
135 --address
135 --address
136 --certificate
136 --certificate
137 --config
137 --config
138 --cwd
138 --cwd
139 --daemon
139 --daemon
140 --daemon-pipefds
140 --daemon-pipefds
141 --debug
141 --debug
142 --debugger
142 --debugger
143 --encoding
143 --encoding
144 --encodingmode
144 --encodingmode
145 --errorlog
145 --errorlog
146 --help
146 --help
147 --ipv6
147 --ipv6
148 --name
148 --name
149 --noninteractive
149 --noninteractive
150 --pid-file
150 --pid-file
151 --port
151 --port
152 --prefix
152 --prefix
153 --profile
153 --profile
154 --quiet
154 --quiet
155 --repository
155 --repository
156 --stdio
156 --stdio
157 --style
157 --style
158 --templates
158 --templates
159 --time
159 --time
160 --traceback
160 --traceback
161 --verbose
161 --verbose
162 --version
162 --version
163 --web-conf
163 --web-conf
164 -6
164 -6
165 -A
165 -A
166 -E
166 -E
167 -R
167 -R
168 -a
168 -a
169 -d
169 -d
170 -h
170 -h
171 -n
171 -n
172 -p
172 -p
173 -q
173 -q
174 -t
174 -t
175 -v
175 -v
176 -y
176 -y
177
177
178 Show an error if we use --options with an ambiguous abbreviation
178 Show an error if we use --options with an ambiguous abbreviation
179 $ hg debugcomplete --options s
179 $ hg debugcomplete --options s
180 hg: command 's' is ambiguous:
180 hg: command 's' is ambiguous:
181 serve showconfig status summary
181 serve showconfig status summary
182 [255]
182 [255]
183
183
184 Show all commands + options
184 Show all commands + options
185 $ hg debugcommands
185 $ hg debugcommands
186 add: include, exclude, subrepos, dry-run
186 add: include, exclude, subrepos, dry-run
187 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, include, exclude
187 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, include, exclude
188 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
188 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
189 commit: addremove, close-branch, include, exclude, message, logfile, date, user
189 commit: addremove, close-branch, include, exclude, message, logfile, date, user
190 diff: rev, change, text, git, nodates, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
190 diff: rev, change, text, git, nodates, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
191 export: output, switch-parent, rev, text, git, nodates
191 export: output, switch-parent, rev, text, git, nodates
192 forget: include, exclude
192 forget: include, exclude
193 init: ssh, remotecmd, insecure
193 init: ssh, remotecmd, insecure
194 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, style, template, include, exclude
194 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, style, template, include, exclude
195 merge: force, tool, rev, preview
195 merge: force, tool, rev, preview
196 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
196 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
197 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
197 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
198 remove: after, force, include, exclude
198 remove: after, force, include, exclude
199 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, templates, style, ipv6, certificate
199 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, templates, style, ipv6, certificate
200 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos
200 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos
201 summary: remote
201 summary: remote
202 update: clean, check, date, rev
202 update: clean, check, date, rev
203 addremove: similarity, include, exclude, dry-run
203 addremove: similarity, include, exclude, dry-run
204 archive: no-decode, prefix, rev, type, subrepos, include, exclude
204 archive: no-decode, prefix, rev, type, subrepos, include, exclude
205 backout: merge, parent, tool, rev, include, exclude, message, logfile, date, user
205 backout: merge, parent, tool, rev, include, exclude, message, logfile, date, user
206 bisect: reset, good, bad, skip, extend, command, noupdate
206 bisect: reset, good, bad, skip, extend, command, noupdate
207 bookmarks: force, rev, delete, rename
207 bookmarks: force, rev, delete, rename
208 branch: force, clean
208 branch: force, clean
209 branches: active, closed
209 branches: active, closed
210 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
210 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
211 cat: output, rev, decode, include, exclude
211 cat: output, rev, decode, include, exclude
212 copy: after, force, include, exclude, dry-run
212 copy: after, force, include, exclude, dry-run
213 debugancestor:
213 debugancestor:
214 debugbuilddag: mergeable-file, appended-file, overwritten-file, new-file
214 debugbuilddag: mergeable-file, overwritten-file, new-file
215 debugbundle: all
215 debugbundle: all
216 debugcheckstate:
216 debugcheckstate:
217 debugcommands:
217 debugcommands:
218 debugcomplete: options
218 debugcomplete: options
219 debugdag: tags, branches, dots, spaces
219 debugdag: tags, branches, dots, spaces
220 debugdata:
220 debugdata:
221 debugdate: extended
221 debugdate: extended
222 debugfsinfo:
222 debugfsinfo:
223 debuggetbundle: head, common, type
223 debuggetbundle: head, common, type
224 debugignore:
224 debugignore:
225 debugindex: format
225 debugindex: format
226 debugindexdot:
226 debugindexdot:
227 debuginstall:
227 debuginstall:
228 debugknown:
228 debugknown:
229 debugpushkey:
229 debugpushkey:
230 debugrebuildstate: rev
230 debugrebuildstate: rev
231 debugrename: rev
231 debugrename: rev
232 debugrevspec:
232 debugrevspec:
233 debugsetparents:
233 debugsetparents:
234 debugstate: nodates, datesort
234 debugstate: nodates, datesort
235 debugsub: rev
235 debugsub: rev
236 debugwalk: include, exclude
236 debugwalk: include, exclude
237 debugwireargs: three, four, five, ssh, remotecmd, insecure
237 debugwireargs: three, four, five, ssh, remotecmd, insecure
238 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
238 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
239 heads: rev, topo, active, closed, style, template
239 heads: rev, topo, active, closed, style, template
240 help:
240 help:
241 identify: rev, num, id, branch, tags, bookmarks
241 identify: rev, num, id, branch, tags, bookmarks
242 import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
242 import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
243 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
243 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
244 locate: rev, print0, fullpath, include, exclude
244 locate: rev, print0, fullpath, include, exclude
245 manifest: rev
245 manifest: rev
246 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
246 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
247 parents: rev, style, template
247 parents: rev, style, template
248 paths:
248 paths:
249 recover:
249 recover:
250 rename: after, force, include, exclude, dry-run
250 rename: after, force, include, exclude, dry-run
251 resolve: all, list, mark, unmark, tool, no-status, include, exclude
251 resolve: all, list, mark, unmark, tool, no-status, include, exclude
252 revert: all, date, rev, no-backup, include, exclude, dry-run
252 revert: all, date, rev, no-backup, include, exclude, dry-run
253 rollback: dry-run
253 rollback: dry-run
254 root:
254 root:
255 showconfig: untrusted
255 showconfig: untrusted
256 tag: force, local, rev, remove, edit, message, date, user
256 tag: force, local, rev, remove, edit, message, date, user
257 tags:
257 tags:
258 tip: patch, git, style, template
258 tip: patch, git, style, template
259 unbundle: update
259 unbundle: update
260 verify:
260 verify:
261 version:
261 version:
@@ -1,253 +1,253 b''
1
1
2 = Test the getbundle() protocol function =
2 = Test the getbundle() protocol function =
3
3
4 Enable graphlog extension:
4 Enable graphlog extension:
5
5
6 $ echo "[extensions]" >> $HGRCPATH
6 $ echo "[extensions]" >> $HGRCPATH
7 $ echo "graphlog=" >> $HGRCPATH
7 $ echo "graphlog=" >> $HGRCPATH
8
8
9 Create a test repository:
9 Create a test repository:
10
10
11 $ hg init repo
11 $ hg init repo
12 $ cd repo
12 $ cd repo
13 $ hg debugbuilddag -n -m '+2 :fork +5 :p1 *fork +6 :p2 /p1 :m1 +3' > /dev/null
13 $ hg debugbuilddag -n -m '+2 :fork +5 :p1 *fork +6 :p2 /p1 :m1 +3' > /dev/null
14 $ hg glog --template '{node}\n'
14 $ hg glog --template '{node}\n'
15 @ 2bba2f40f321484159b395a43f20101d4bb7ead0
15 o 10c14a2cc935e1d8c31f9e98587dcf27fb08a6da
16 |
16 |
17 o d9e5488323c782fe684573f3043369d199038b6f
17 o 4801a72e5d88cb515b0c7e40fae34180f3f837f2
18 |
18 |
19 o 6e9a5adf5437e49c746288cf95c5ac34fa8f2f72
19 o 0b2f73f04880d9cb6a5cd8a757f0db0ad01e32c3
20 |
20 |
21 o 733bf0910832b26b768a09172f325f995b5476e1
21 o 8365676dbab05860ce0d9110f2af51368b961bbd
22 |\
22 |\
23 | o b5af5d6ea56d73ce24c40bc3cd19a862f74888ac
23 | o 5686dbbd9fc46cb806599c878d02fe1cb56b83d3
24 | |
24 | |
25 | o 6b57ee934bb2996050540f84cdfc8dcad1e7267d
25 | o 13c0170174366b441dc68e8e33757232fa744458
26 | |
26 | |
27 | o 2c0ec49482e8abe888b7bd090b5827acfc22b3d7
27 | o 63476832d8ec6558cf9bbe3cbe0c757e5cf18043
28 | |
28 | |
29 | o c1818a9f5977dd4139a48f93f5425c67d44a9368
29 | o 700b7e19db54103633c4bf4a6a6b6d55f4d50c03
30 | |
30 | |
31 | o 6c725a58ad10aea441540bfd06c507f63e8b9cdd
31 | o 928b5f94cdb278bb536eba552de348a4e92ef24d
32 | |
32 | |
33 | o 18063366a155bd56b5618229ae2ac3e91849aa5e
33 | o f34414c64173e0ecb61b25dc55e116dbbcc89bee
34 | |
34 | |
35 | o a21d913c992197a2eb60b298521ec0f045a04799
35 | o 8931463777131cd73923e560b760061f2aa8a4bc
36 | |
36 | |
37 o | b6b2b682253df2ffedc10e9415e4114202b303c5
37 o | 6621d79f61b23ec74cf4b69464343d9e0980ec8b
38 | |
38 | |
39 o | 2114148793524fd045998f71a45b0aaf139f752b
39 o | bac16991d12ff45f9dc43c52da1946dfadb83e80
40 | |
40 | |
41 o | 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc
41 o | ff42371d57168345fdf1a3aac66a51f6a45d41d2
42 | |
42 | |
43 o | ea919464b16e003894c48b6cb68df3cd9411b544
43 o | d5f6e1ea452285324836a49d7d3c2a63cfed1d31
44 | |
44 | |
45 o | 0f82d97ec2778746743fbc996740d409558fda22
45 o | 713346a995c363120712aed1aee7e04afd867638
46 |/
46 |/
47 o 6e23b016bc0f0e79c7bd9dd372ccee07055d7fd4
47 o 29a4d1f17bd3f0779ca0525bebb1cfb51067c738
48 |
48 |
49 o 10e64d654571f11577745b4d8372e859d9e4df63
49 o 7704483d56b2a7b5db54dcee7c62378ac629b348
50
50
51 $ cd ..
51 $ cd ..
52
52
53
53
54 = Test locally =
54 = Test locally =
55
55
56 Get everything:
56 Get everything:
57
57
58 $ hg debuggetbundle repo bundle
58 $ hg debuggetbundle repo bundle
59 $ hg debugbundle bundle
59 $ hg debugbundle bundle
60 10e64d654571f11577745b4d8372e859d9e4df63
60 7704483d56b2a7b5db54dcee7c62378ac629b348
61 6e23b016bc0f0e79c7bd9dd372ccee07055d7fd4
61 29a4d1f17bd3f0779ca0525bebb1cfb51067c738
62 0f82d97ec2778746743fbc996740d409558fda22
62 713346a995c363120712aed1aee7e04afd867638
63 ea919464b16e003894c48b6cb68df3cd9411b544
63 d5f6e1ea452285324836a49d7d3c2a63cfed1d31
64 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc
64 ff42371d57168345fdf1a3aac66a51f6a45d41d2
65 2114148793524fd045998f71a45b0aaf139f752b
65 bac16991d12ff45f9dc43c52da1946dfadb83e80
66 b6b2b682253df2ffedc10e9415e4114202b303c5
66 6621d79f61b23ec74cf4b69464343d9e0980ec8b
67 a21d913c992197a2eb60b298521ec0f045a04799
67 8931463777131cd73923e560b760061f2aa8a4bc
68 18063366a155bd56b5618229ae2ac3e91849aa5e
68 f34414c64173e0ecb61b25dc55e116dbbcc89bee
69 6c725a58ad10aea441540bfd06c507f63e8b9cdd
69 928b5f94cdb278bb536eba552de348a4e92ef24d
70 c1818a9f5977dd4139a48f93f5425c67d44a9368
70 700b7e19db54103633c4bf4a6a6b6d55f4d50c03
71 2c0ec49482e8abe888b7bd090b5827acfc22b3d7
71 63476832d8ec6558cf9bbe3cbe0c757e5cf18043
72 6b57ee934bb2996050540f84cdfc8dcad1e7267d
72 13c0170174366b441dc68e8e33757232fa744458
73 b5af5d6ea56d73ce24c40bc3cd19a862f74888ac
73 5686dbbd9fc46cb806599c878d02fe1cb56b83d3
74 733bf0910832b26b768a09172f325f995b5476e1
74 8365676dbab05860ce0d9110f2af51368b961bbd
75 6e9a5adf5437e49c746288cf95c5ac34fa8f2f72
75 0b2f73f04880d9cb6a5cd8a757f0db0ad01e32c3
76 d9e5488323c782fe684573f3043369d199038b6f
76 4801a72e5d88cb515b0c7e40fae34180f3f837f2
77 2bba2f40f321484159b395a43f20101d4bb7ead0
77 10c14a2cc935e1d8c31f9e98587dcf27fb08a6da
78
78
79 Get part of linear run:
79 Get part of linear run:
80
80
81 $ hg debuggetbundle repo bundle -H d9e5488323c782fe684573f3043369d199038b6f -C 733bf0910832b26b768a09172f325f995b5476e1
81 $ hg debuggetbundle repo bundle -H 4801a72e5d88cb515b0c7e40fae34180f3f837f2 -C 8365676dbab05860ce0d9110f2af51368b961bbd
82 $ hg debugbundle bundle
82 $ hg debugbundle bundle
83 6e9a5adf5437e49c746288cf95c5ac34fa8f2f72
83 0b2f73f04880d9cb6a5cd8a757f0db0ad01e32c3
84 d9e5488323c782fe684573f3043369d199038b6f
84 4801a72e5d88cb515b0c7e40fae34180f3f837f2
85
85
86 Get missing branch and merge:
86 Get missing branch and merge:
87
87
88 $ hg debuggetbundle repo bundle -H d9e5488323c782fe684573f3043369d199038b6f -C 6b57ee934bb2996050540f84cdfc8dcad1e7267d
88 $ hg debuggetbundle repo bundle -H 4801a72e5d88cb515b0c7e40fae34180f3f837f2 -C 13c0170174366b441dc68e8e33757232fa744458
89 $ hg debugbundle bundle
89 $ hg debugbundle bundle
90 0f82d97ec2778746743fbc996740d409558fda22
90 713346a995c363120712aed1aee7e04afd867638
91 ea919464b16e003894c48b6cb68df3cd9411b544
91 d5f6e1ea452285324836a49d7d3c2a63cfed1d31
92 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc
92 ff42371d57168345fdf1a3aac66a51f6a45d41d2
93 2114148793524fd045998f71a45b0aaf139f752b
93 bac16991d12ff45f9dc43c52da1946dfadb83e80
94 b6b2b682253df2ffedc10e9415e4114202b303c5
94 6621d79f61b23ec74cf4b69464343d9e0980ec8b
95 b5af5d6ea56d73ce24c40bc3cd19a862f74888ac
95 5686dbbd9fc46cb806599c878d02fe1cb56b83d3
96 733bf0910832b26b768a09172f325f995b5476e1
96 8365676dbab05860ce0d9110f2af51368b961bbd
97 6e9a5adf5437e49c746288cf95c5ac34fa8f2f72
97 0b2f73f04880d9cb6a5cd8a757f0db0ad01e32c3
98 d9e5488323c782fe684573f3043369d199038b6f
98 4801a72e5d88cb515b0c7e40fae34180f3f837f2
99
99
100 Get from only one head:
100 Get from only one head:
101
101
102 $ hg debuggetbundle repo bundle -H 6c725a58ad10aea441540bfd06c507f63e8b9cdd -C 6e23b016bc0f0e79c7bd9dd372ccee07055d7fd4
102 $ hg debuggetbundle repo bundle -H 928b5f94cdb278bb536eba552de348a4e92ef24d -C 29a4d1f17bd3f0779ca0525bebb1cfb51067c738
103 $ hg debugbundle bundle
103 $ hg debugbundle bundle
104 a21d913c992197a2eb60b298521ec0f045a04799
104 8931463777131cd73923e560b760061f2aa8a4bc
105 18063366a155bd56b5618229ae2ac3e91849aa5e
105 f34414c64173e0ecb61b25dc55e116dbbcc89bee
106 6c725a58ad10aea441540bfd06c507f63e8b9cdd
106 928b5f94cdb278bb536eba552de348a4e92ef24d
107
107
108 Get parts of two branches:
108 Get parts of two branches:
109
109
110 $ hg debuggetbundle repo bundle -H 6b57ee934bb2996050540f84cdfc8dcad1e7267d -C c1818a9f5977dd4139a48f93f5425c67d44a9368 -H 2114148793524fd045998f71a45b0aaf139f752b -C ea919464b16e003894c48b6cb68df3cd9411b544
110 $ hg debuggetbundle repo bundle -H 13c0170174366b441dc68e8e33757232fa744458 -C 700b7e19db54103633c4bf4a6a6b6d55f4d50c03 -H bac16991d12ff45f9dc43c52da1946dfadb83e80 -C d5f6e1ea452285324836a49d7d3c2a63cfed1d31
111 $ hg debugbundle bundle
111 $ hg debugbundle bundle
112 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc
112 ff42371d57168345fdf1a3aac66a51f6a45d41d2
113 2114148793524fd045998f71a45b0aaf139f752b
113 bac16991d12ff45f9dc43c52da1946dfadb83e80
114 2c0ec49482e8abe888b7bd090b5827acfc22b3d7
114 63476832d8ec6558cf9bbe3cbe0c757e5cf18043
115 6b57ee934bb2996050540f84cdfc8dcad1e7267d
115 13c0170174366b441dc68e8e33757232fa744458
116
116
117 Check that we get all needed file changes:
117 Check that we get all needed file changes:
118
118
119 $ hg debugbundle bundle --all
119 $ hg debugbundle bundle --all
120 format: id, p1, p2, cset, delta base, len(delta)
120 format: id, p1, p2, cset, delta base, len(delta)
121
121
122 changelog
122 changelog
123 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc ea919464b16e003894c48b6cb68df3cd9411b544 0000000000000000000000000000000000000000 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc ea919464b16e003894c48b6cb68df3cd9411b544 99
123 ff42371d57168345fdf1a3aac66a51f6a45d41d2 d5f6e1ea452285324836a49d7d3c2a63cfed1d31 0000000000000000000000000000000000000000 ff42371d57168345fdf1a3aac66a51f6a45d41d2 d5f6e1ea452285324836a49d7d3c2a63cfed1d31 99
124 2114148793524fd045998f71a45b0aaf139f752b 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 0000000000000000000000000000000000000000 2114148793524fd045998f71a45b0aaf139f752b 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 99
124 bac16991d12ff45f9dc43c52da1946dfadb83e80 ff42371d57168345fdf1a3aac66a51f6a45d41d2 0000000000000000000000000000000000000000 bac16991d12ff45f9dc43c52da1946dfadb83e80 ff42371d57168345fdf1a3aac66a51f6a45d41d2 99
125 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 c1818a9f5977dd4139a48f93f5425c67d44a9368 0000000000000000000000000000000000000000 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 2114148793524fd045998f71a45b0aaf139f752b 102
125 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 700b7e19db54103633c4bf4a6a6b6d55f4d50c03 0000000000000000000000000000000000000000 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 bac16991d12ff45f9dc43c52da1946dfadb83e80 102
126 6b57ee934bb2996050540f84cdfc8dcad1e7267d 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 0000000000000000000000000000000000000000 6b57ee934bb2996050540f84cdfc8dcad1e7267d 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 102
126 13c0170174366b441dc68e8e33757232fa744458 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 0000000000000000000000000000000000000000 13c0170174366b441dc68e8e33757232fa744458 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 102
127
127
128 manifest
128 manifest
129 dac7984588fc4eea7acbf39693a9c1b06f5b175d 591f732a3faf1fb903815273f3c199a514a61ccb 0000000000000000000000000000000000000000 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 591f732a3faf1fb903815273f3c199a514a61ccb 113
129 dac7984588fc4eea7acbf39693a9c1b06f5b175d 591f732a3faf1fb903815273f3c199a514a61ccb 0000000000000000000000000000000000000000 ff42371d57168345fdf1a3aac66a51f6a45d41d2 591f732a3faf1fb903815273f3c199a514a61ccb 113
130 0772616e6b48a76afb6c1458e193cbb3dae2e4ff dac7984588fc4eea7acbf39693a9c1b06f5b175d 0000000000000000000000000000000000000000 2114148793524fd045998f71a45b0aaf139f752b dac7984588fc4eea7acbf39693a9c1b06f5b175d 113
130 0772616e6b48a76afb6c1458e193cbb3dae2e4ff dac7984588fc4eea7acbf39693a9c1b06f5b175d 0000000000000000000000000000000000000000 bac16991d12ff45f9dc43c52da1946dfadb83e80 dac7984588fc4eea7acbf39693a9c1b06f5b175d 113
131 eb498cd9af6c44108e43041e951ce829e29f6c80 bff2f4817ced57b386caf7c4e3e36a4bc9af7e93 0000000000000000000000000000000000000000 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 0772616e6b48a76afb6c1458e193cbb3dae2e4ff 295
131 eb498cd9af6c44108e43041e951ce829e29f6c80 bff2f4817ced57b386caf7c4e3e36a4bc9af7e93 0000000000000000000000000000000000000000 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 0772616e6b48a76afb6c1458e193cbb3dae2e4ff 295
132 b15709c071ddd2d93188508ba156196ab4f19620 eb498cd9af6c44108e43041e951ce829e29f6c80 0000000000000000000000000000000000000000 6b57ee934bb2996050540f84cdfc8dcad1e7267d eb498cd9af6c44108e43041e951ce829e29f6c80 114
132 b15709c071ddd2d93188508ba156196ab4f19620 eb498cd9af6c44108e43041e951ce829e29f6c80 0000000000000000000000000000000000000000 13c0170174366b441dc68e8e33757232fa744458 eb498cd9af6c44108e43041e951ce829e29f6c80 114
133
133
134 mf
134 mf
135 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 301ca08d026bb72cb4258a9d211bdf7ca0bcd810 0000000000000000000000000000000000000000 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 301ca08d026bb72cb4258a9d211bdf7ca0bcd810 17
135 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 301ca08d026bb72cb4258a9d211bdf7ca0bcd810 0000000000000000000000000000000000000000 ff42371d57168345fdf1a3aac66a51f6a45d41d2 301ca08d026bb72cb4258a9d211bdf7ca0bcd810 17
136 c7b583de053293870e145f45bd2d61643563fd06 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 0000000000000000000000000000000000000000 2114148793524fd045998f71a45b0aaf139f752b 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 18
136 c7b583de053293870e145f45bd2d61643563fd06 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 0000000000000000000000000000000000000000 bac16991d12ff45f9dc43c52da1946dfadb83e80 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 18
137 266ee3c0302a5a18f1cf96817ac79a51836179e9 edc0f6b8db80d68ae6aff2b19f7e5347ab68fa63 0000000000000000000000000000000000000000 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 c7b583de053293870e145f45bd2d61643563fd06 149
137 266ee3c0302a5a18f1cf96817ac79a51836179e9 edc0f6b8db80d68ae6aff2b19f7e5347ab68fa63 0000000000000000000000000000000000000000 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 c7b583de053293870e145f45bd2d61643563fd06 149
138 698c6a36220548cd3903ca7dada27c59aa500c52 266ee3c0302a5a18f1cf96817ac79a51836179e9 0000000000000000000000000000000000000000 6b57ee934bb2996050540f84cdfc8dcad1e7267d 266ee3c0302a5a18f1cf96817ac79a51836179e9 19
138 698c6a36220548cd3903ca7dada27c59aa500c52 266ee3c0302a5a18f1cf96817ac79a51836179e9 0000000000000000000000000000000000000000 13c0170174366b441dc68e8e33757232fa744458 266ee3c0302a5a18f1cf96817ac79a51836179e9 19
139
139
140 nf11
140 nf11
141 33fbc651630ffa7ccbebfe4eb91320a873e7291c 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 0000000000000000000000000000000000000000 16
141 33fbc651630ffa7ccbebfe4eb91320a873e7291c 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 0000000000000000000000000000000000000000 16
142
142
143 nf12
143 nf12
144 ddce0544363f037e9fb889faca058f52dc01c0a5 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 6b57ee934bb2996050540f84cdfc8dcad1e7267d 0000000000000000000000000000000000000000 16
144 ddce0544363f037e9fb889faca058f52dc01c0a5 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 13c0170174366b441dc68e8e33757232fa744458 0000000000000000000000000000000000000000 16
145
145
146 nf4
146 nf4
147 3c1407305701051cbed9f9cb9a68bdfb5997c235 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 0000000000000000000000000000000000000000 15
147 3c1407305701051cbed9f9cb9a68bdfb5997c235 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 ff42371d57168345fdf1a3aac66a51f6a45d41d2 0000000000000000000000000000000000000000 15
148
148
149 nf5
149 nf5
150 0dbd89c185f53a1727c54cd1ce256482fa23968e 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 2114148793524fd045998f71a45b0aaf139f752b 0000000000000000000000000000000000000000 15
150 0dbd89c185f53a1727c54cd1ce256482fa23968e 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 bac16991d12ff45f9dc43c52da1946dfadb83e80 0000000000000000000000000000000000000000 15
151
151
152 Get branch and merge:
152 Get branch and merge:
153
153
154 $ hg debuggetbundle repo bundle -C 10e64d654571f11577745b4d8372e859d9e4df63 -H 6e9a5adf5437e49c746288cf95c5ac34fa8f2f72
154 $ hg debuggetbundle repo bundle -C 7704483d56b2a7b5db54dcee7c62378ac629b348 -H 0b2f73f04880d9cb6a5cd8a757f0db0ad01e32c3
155 $ hg debugbundle bundle
155 $ hg debugbundle bundle
156 6e23b016bc0f0e79c7bd9dd372ccee07055d7fd4
156 29a4d1f17bd3f0779ca0525bebb1cfb51067c738
157 0f82d97ec2778746743fbc996740d409558fda22
157 713346a995c363120712aed1aee7e04afd867638
158 ea919464b16e003894c48b6cb68df3cd9411b544
158 d5f6e1ea452285324836a49d7d3c2a63cfed1d31
159 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc
159 ff42371d57168345fdf1a3aac66a51f6a45d41d2
160 2114148793524fd045998f71a45b0aaf139f752b
160 bac16991d12ff45f9dc43c52da1946dfadb83e80
161 b6b2b682253df2ffedc10e9415e4114202b303c5
161 6621d79f61b23ec74cf4b69464343d9e0980ec8b
162 a21d913c992197a2eb60b298521ec0f045a04799
162 8931463777131cd73923e560b760061f2aa8a4bc
163 18063366a155bd56b5618229ae2ac3e91849aa5e
163 f34414c64173e0ecb61b25dc55e116dbbcc89bee
164 6c725a58ad10aea441540bfd06c507f63e8b9cdd
164 928b5f94cdb278bb536eba552de348a4e92ef24d
165 c1818a9f5977dd4139a48f93f5425c67d44a9368
165 700b7e19db54103633c4bf4a6a6b6d55f4d50c03
166 2c0ec49482e8abe888b7bd090b5827acfc22b3d7
166 63476832d8ec6558cf9bbe3cbe0c757e5cf18043
167 6b57ee934bb2996050540f84cdfc8dcad1e7267d
167 13c0170174366b441dc68e8e33757232fa744458
168 b5af5d6ea56d73ce24c40bc3cd19a862f74888ac
168 5686dbbd9fc46cb806599c878d02fe1cb56b83d3
169 733bf0910832b26b768a09172f325f995b5476e1
169 8365676dbab05860ce0d9110f2af51368b961bbd
170 6e9a5adf5437e49c746288cf95c5ac34fa8f2f72
170 0b2f73f04880d9cb6a5cd8a757f0db0ad01e32c3
171
171
172
172
173 = Test via HTTP =
173 = Test via HTTP =
174
174
175 Get everything:
175 Get everything:
176
176
177 $ hg serve -R repo -p $HGPORT -d --pid-file=hg.pid -E error.log -A access.log
177 $ hg serve -R repo -p $HGPORT -d --pid-file=hg.pid -E error.log -A access.log
178 $ cat hg.pid >> $DAEMON_PIDS
178 $ cat hg.pid >> $DAEMON_PIDS
179 $ hg debuggetbundle http://localhost:$HGPORT/ bundle
179 $ hg debuggetbundle http://localhost:$HGPORT/ bundle
180 $ hg debugbundle bundle
180 $ hg debugbundle bundle
181 10e64d654571f11577745b4d8372e859d9e4df63
181 7704483d56b2a7b5db54dcee7c62378ac629b348
182 6e23b016bc0f0e79c7bd9dd372ccee07055d7fd4
182 29a4d1f17bd3f0779ca0525bebb1cfb51067c738
183 0f82d97ec2778746743fbc996740d409558fda22
183 713346a995c363120712aed1aee7e04afd867638
184 ea919464b16e003894c48b6cb68df3cd9411b544
184 d5f6e1ea452285324836a49d7d3c2a63cfed1d31
185 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc
185 ff42371d57168345fdf1a3aac66a51f6a45d41d2
186 2114148793524fd045998f71a45b0aaf139f752b
186 bac16991d12ff45f9dc43c52da1946dfadb83e80
187 b6b2b682253df2ffedc10e9415e4114202b303c5
187 6621d79f61b23ec74cf4b69464343d9e0980ec8b
188 a21d913c992197a2eb60b298521ec0f045a04799
188 8931463777131cd73923e560b760061f2aa8a4bc
189 18063366a155bd56b5618229ae2ac3e91849aa5e
189 f34414c64173e0ecb61b25dc55e116dbbcc89bee
190 6c725a58ad10aea441540bfd06c507f63e8b9cdd
190 928b5f94cdb278bb536eba552de348a4e92ef24d
191 c1818a9f5977dd4139a48f93f5425c67d44a9368
191 700b7e19db54103633c4bf4a6a6b6d55f4d50c03
192 2c0ec49482e8abe888b7bd090b5827acfc22b3d7
192 63476832d8ec6558cf9bbe3cbe0c757e5cf18043
193 6b57ee934bb2996050540f84cdfc8dcad1e7267d
193 13c0170174366b441dc68e8e33757232fa744458
194 b5af5d6ea56d73ce24c40bc3cd19a862f74888ac
194 5686dbbd9fc46cb806599c878d02fe1cb56b83d3
195 733bf0910832b26b768a09172f325f995b5476e1
195 8365676dbab05860ce0d9110f2af51368b961bbd
196 6e9a5adf5437e49c746288cf95c5ac34fa8f2f72
196 0b2f73f04880d9cb6a5cd8a757f0db0ad01e32c3
197 d9e5488323c782fe684573f3043369d199038b6f
197 4801a72e5d88cb515b0c7e40fae34180f3f837f2
198 2bba2f40f321484159b395a43f20101d4bb7ead0
198 10c14a2cc935e1d8c31f9e98587dcf27fb08a6da
199
199
200 Get parts of two branches:
200 Get parts of two branches:
201
201
202 $ hg debuggetbundle http://localhost:$HGPORT/ bundle -H 6b57ee934bb2996050540f84cdfc8dcad1e7267d -C c1818a9f5977dd4139a48f93f5425c67d44a9368 -H 2114148793524fd045998f71a45b0aaf139f752b -C ea919464b16e003894c48b6cb68df3cd9411b544
202 $ hg debuggetbundle http://localhost:$HGPORT/ bundle -H 13c0170174366b441dc68e8e33757232fa744458 -C 700b7e19db54103633c4bf4a6a6b6d55f4d50c03 -H bac16991d12ff45f9dc43c52da1946dfadb83e80 -C d5f6e1ea452285324836a49d7d3c2a63cfed1d31
203 $ hg debugbundle bundle
203 $ hg debugbundle bundle
204 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc
204 ff42371d57168345fdf1a3aac66a51f6a45d41d2
205 2114148793524fd045998f71a45b0aaf139f752b
205 bac16991d12ff45f9dc43c52da1946dfadb83e80
206 2c0ec49482e8abe888b7bd090b5827acfc22b3d7
206 63476832d8ec6558cf9bbe3cbe0c757e5cf18043
207 6b57ee934bb2996050540f84cdfc8dcad1e7267d
207 13c0170174366b441dc68e8e33757232fa744458
208
208
209 Check that we get all needed file changes:
209 Check that we get all needed file changes:
210
210
211 $ hg debugbundle bundle --all
211 $ hg debugbundle bundle --all
212 format: id, p1, p2, cset, delta base, len(delta)
212 format: id, p1, p2, cset, delta base, len(delta)
213
213
214 changelog
214 changelog
215 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc ea919464b16e003894c48b6cb68df3cd9411b544 0000000000000000000000000000000000000000 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc ea919464b16e003894c48b6cb68df3cd9411b544 99
215 ff42371d57168345fdf1a3aac66a51f6a45d41d2 d5f6e1ea452285324836a49d7d3c2a63cfed1d31 0000000000000000000000000000000000000000 ff42371d57168345fdf1a3aac66a51f6a45d41d2 d5f6e1ea452285324836a49d7d3c2a63cfed1d31 99
216 2114148793524fd045998f71a45b0aaf139f752b 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 0000000000000000000000000000000000000000 2114148793524fd045998f71a45b0aaf139f752b 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 99
216 bac16991d12ff45f9dc43c52da1946dfadb83e80 ff42371d57168345fdf1a3aac66a51f6a45d41d2 0000000000000000000000000000000000000000 bac16991d12ff45f9dc43c52da1946dfadb83e80 ff42371d57168345fdf1a3aac66a51f6a45d41d2 99
217 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 c1818a9f5977dd4139a48f93f5425c67d44a9368 0000000000000000000000000000000000000000 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 2114148793524fd045998f71a45b0aaf139f752b 102
217 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 700b7e19db54103633c4bf4a6a6b6d55f4d50c03 0000000000000000000000000000000000000000 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 bac16991d12ff45f9dc43c52da1946dfadb83e80 102
218 6b57ee934bb2996050540f84cdfc8dcad1e7267d 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 0000000000000000000000000000000000000000 6b57ee934bb2996050540f84cdfc8dcad1e7267d 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 102
218 13c0170174366b441dc68e8e33757232fa744458 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 0000000000000000000000000000000000000000 13c0170174366b441dc68e8e33757232fa744458 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 102
219
219
220 manifest
220 manifest
221 dac7984588fc4eea7acbf39693a9c1b06f5b175d 591f732a3faf1fb903815273f3c199a514a61ccb 0000000000000000000000000000000000000000 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 591f732a3faf1fb903815273f3c199a514a61ccb 113
221 dac7984588fc4eea7acbf39693a9c1b06f5b175d 591f732a3faf1fb903815273f3c199a514a61ccb 0000000000000000000000000000000000000000 ff42371d57168345fdf1a3aac66a51f6a45d41d2 591f732a3faf1fb903815273f3c199a514a61ccb 113
222 0772616e6b48a76afb6c1458e193cbb3dae2e4ff dac7984588fc4eea7acbf39693a9c1b06f5b175d 0000000000000000000000000000000000000000 2114148793524fd045998f71a45b0aaf139f752b dac7984588fc4eea7acbf39693a9c1b06f5b175d 113
222 0772616e6b48a76afb6c1458e193cbb3dae2e4ff dac7984588fc4eea7acbf39693a9c1b06f5b175d 0000000000000000000000000000000000000000 bac16991d12ff45f9dc43c52da1946dfadb83e80 dac7984588fc4eea7acbf39693a9c1b06f5b175d 113
223 eb498cd9af6c44108e43041e951ce829e29f6c80 bff2f4817ced57b386caf7c4e3e36a4bc9af7e93 0000000000000000000000000000000000000000 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 0772616e6b48a76afb6c1458e193cbb3dae2e4ff 295
223 eb498cd9af6c44108e43041e951ce829e29f6c80 bff2f4817ced57b386caf7c4e3e36a4bc9af7e93 0000000000000000000000000000000000000000 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 0772616e6b48a76afb6c1458e193cbb3dae2e4ff 295
224 b15709c071ddd2d93188508ba156196ab4f19620 eb498cd9af6c44108e43041e951ce829e29f6c80 0000000000000000000000000000000000000000 6b57ee934bb2996050540f84cdfc8dcad1e7267d eb498cd9af6c44108e43041e951ce829e29f6c80 114
224 b15709c071ddd2d93188508ba156196ab4f19620 eb498cd9af6c44108e43041e951ce829e29f6c80 0000000000000000000000000000000000000000 13c0170174366b441dc68e8e33757232fa744458 eb498cd9af6c44108e43041e951ce829e29f6c80 114
225
225
226 mf
226 mf
227 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 301ca08d026bb72cb4258a9d211bdf7ca0bcd810 0000000000000000000000000000000000000000 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 301ca08d026bb72cb4258a9d211bdf7ca0bcd810 17
227 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 301ca08d026bb72cb4258a9d211bdf7ca0bcd810 0000000000000000000000000000000000000000 ff42371d57168345fdf1a3aac66a51f6a45d41d2 301ca08d026bb72cb4258a9d211bdf7ca0bcd810 17
228 c7b583de053293870e145f45bd2d61643563fd06 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 0000000000000000000000000000000000000000 2114148793524fd045998f71a45b0aaf139f752b 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 18
228 c7b583de053293870e145f45bd2d61643563fd06 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 0000000000000000000000000000000000000000 bac16991d12ff45f9dc43c52da1946dfadb83e80 4f73f97080266ab8e0c0561ca8d0da3eaf65b695 18
229 266ee3c0302a5a18f1cf96817ac79a51836179e9 edc0f6b8db80d68ae6aff2b19f7e5347ab68fa63 0000000000000000000000000000000000000000 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 c7b583de053293870e145f45bd2d61643563fd06 149
229 266ee3c0302a5a18f1cf96817ac79a51836179e9 edc0f6b8db80d68ae6aff2b19f7e5347ab68fa63 0000000000000000000000000000000000000000 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 c7b583de053293870e145f45bd2d61643563fd06 149
230 698c6a36220548cd3903ca7dada27c59aa500c52 266ee3c0302a5a18f1cf96817ac79a51836179e9 0000000000000000000000000000000000000000 6b57ee934bb2996050540f84cdfc8dcad1e7267d 266ee3c0302a5a18f1cf96817ac79a51836179e9 19
230 698c6a36220548cd3903ca7dada27c59aa500c52 266ee3c0302a5a18f1cf96817ac79a51836179e9 0000000000000000000000000000000000000000 13c0170174366b441dc68e8e33757232fa744458 266ee3c0302a5a18f1cf96817ac79a51836179e9 19
231
231
232 nf11
232 nf11
233 33fbc651630ffa7ccbebfe4eb91320a873e7291c 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 2c0ec49482e8abe888b7bd090b5827acfc22b3d7 0000000000000000000000000000000000000000 16
233 33fbc651630ffa7ccbebfe4eb91320a873e7291c 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 63476832d8ec6558cf9bbe3cbe0c757e5cf18043 0000000000000000000000000000000000000000 16
234
234
235 nf12
235 nf12
236 ddce0544363f037e9fb889faca058f52dc01c0a5 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 6b57ee934bb2996050540f84cdfc8dcad1e7267d 0000000000000000000000000000000000000000 16
236 ddce0544363f037e9fb889faca058f52dc01c0a5 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 13c0170174366b441dc68e8e33757232fa744458 0000000000000000000000000000000000000000 16
237
237
238 nf4
238 nf4
239 3c1407305701051cbed9f9cb9a68bdfb5997c235 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 74a573f2ae100f1cedfad9aa7b96f8eaab1dabfc 0000000000000000000000000000000000000000 15
239 3c1407305701051cbed9f9cb9a68bdfb5997c235 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 ff42371d57168345fdf1a3aac66a51f6a45d41d2 0000000000000000000000000000000000000000 15
240
240
241 nf5
241 nf5
242 0dbd89c185f53a1727c54cd1ce256482fa23968e 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 2114148793524fd045998f71a45b0aaf139f752b 0000000000000000000000000000000000000000 15
242 0dbd89c185f53a1727c54cd1ce256482fa23968e 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 bac16991d12ff45f9dc43c52da1946dfadb83e80 0000000000000000000000000000000000000000 15
243
243
244 Verify we hit the HTTP server:
244 Verify we hit the HTTP server:
245
245
246 $ cat access.log
246 $ cat access.log
247 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
247 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
248 * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 - (glob)
248 * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 - (glob)
249 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
249 * - - [*] "GET /?cmd=capabilities HTTP/1.1" 200 - (glob)
250 * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:common=c1818a9f5977dd4139a48f93f5425c67d44a9368+ea919464b16e003894c48b6cb68df3cd9411b544&heads=6b57ee934bb2996050540f84cdfc8dcad1e7267d+2114148793524fd045998f71a45b0aaf139f752b (glob)
250 * - - [*] "GET /?cmd=getbundle HTTP/1.1" 200 - x-hgarg-1:common=700b7e19db54103633c4bf4a6a6b6d55f4d50c03+d5f6e1ea452285324836a49d7d3c2a63cfed1d31&heads=13c0170174366b441dc68e8e33757232fa744458+bac16991d12ff45f9dc43c52da1946dfadb83e80 (glob)
251
251
252 $ cat error.log
252 $ cat error.log
253
253
General Comments 0
You need to be logged in to leave comments. Login now