##// END OF EJS Templates
heads: modernize documentation (issue3992)...
Matt Mackall -
r19469:bf6bc468 stable
parent child Browse files
Show More
@@ -1,5908 +1,5906 b''
1 1 # commands.py - command processing for mercurial
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from node import hex, bin, nullid, nullrev, short
9 9 from lock import release
10 10 from i18n import _
11 11 import os, re, difflib, time, tempfile, errno
12 12 import hg, scmutil, util, revlog, copies, error, bookmarks
13 13 import patch, help, encoding, templatekw, discovery
14 14 import archival, changegroup, cmdutil, hbisect
15 15 import sshserver, hgweb, hgweb.server, commandserver
16 16 import merge as mergemod
17 17 import minirst, revset, fileset
18 18 import dagparser, context, simplemerge, graphmod
19 19 import random, setdiscovery, treediscovery, dagutil, pvec, localrepo
20 20 import phases, obsolete
21 21
22 22 table = {}
23 23
24 24 command = cmdutil.command(table)
25 25
26 26 # common command options
27 27
28 28 globalopts = [
29 29 ('R', 'repository', '',
30 30 _('repository root directory or name of overlay bundle file'),
31 31 _('REPO')),
32 32 ('', 'cwd', '',
33 33 _('change working directory'), _('DIR')),
34 34 ('y', 'noninteractive', None,
35 35 _('do not prompt, automatically pick the first choice for all prompts')),
36 36 ('q', 'quiet', None, _('suppress output')),
37 37 ('v', 'verbose', None, _('enable additional output')),
38 38 ('', 'config', [],
39 39 _('set/override config option (use \'section.name=value\')'),
40 40 _('CONFIG')),
41 41 ('', 'debug', None, _('enable debugging output')),
42 42 ('', 'debugger', None, _('start debugger')),
43 43 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
44 44 _('ENCODE')),
45 45 ('', 'encodingmode', encoding.encodingmode,
46 46 _('set the charset encoding mode'), _('MODE')),
47 47 ('', 'traceback', None, _('always print a traceback on exception')),
48 48 ('', 'time', None, _('time how long the command takes')),
49 49 ('', 'profile', None, _('print command execution profile')),
50 50 ('', 'version', None, _('output version information and exit')),
51 51 ('h', 'help', None, _('display help and exit')),
52 52 ('', 'hidden', False, _('consider hidden changesets')),
53 53 ]
54 54
55 55 dryrunopts = [('n', 'dry-run', None,
56 56 _('do not perform actions, just print output'))]
57 57
58 58 remoteopts = [
59 59 ('e', 'ssh', '',
60 60 _('specify ssh command to use'), _('CMD')),
61 61 ('', 'remotecmd', '',
62 62 _('specify hg command to run on the remote side'), _('CMD')),
63 63 ('', 'insecure', None,
64 64 _('do not verify server certificate (ignoring web.cacerts config)')),
65 65 ]
66 66
67 67 walkopts = [
68 68 ('I', 'include', [],
69 69 _('include names matching the given patterns'), _('PATTERN')),
70 70 ('X', 'exclude', [],
71 71 _('exclude names matching the given patterns'), _('PATTERN')),
72 72 ]
73 73
74 74 commitopts = [
75 75 ('m', 'message', '',
76 76 _('use text as commit message'), _('TEXT')),
77 77 ('l', 'logfile', '',
78 78 _('read commit message from file'), _('FILE')),
79 79 ]
80 80
81 81 commitopts2 = [
82 82 ('d', 'date', '',
83 83 _('record the specified date as commit date'), _('DATE')),
84 84 ('u', 'user', '',
85 85 _('record the specified user as committer'), _('USER')),
86 86 ]
87 87
88 88 templateopts = [
89 89 ('', 'style', '',
90 90 _('display using template map file'), _('STYLE')),
91 91 ('', 'template', '',
92 92 _('display with template'), _('TEMPLATE')),
93 93 ]
94 94
95 95 logopts = [
96 96 ('p', 'patch', None, _('show patch')),
97 97 ('g', 'git', None, _('use git extended diff format')),
98 98 ('l', 'limit', '',
99 99 _('limit number of changes displayed'), _('NUM')),
100 100 ('M', 'no-merges', None, _('do not show merges')),
101 101 ('', 'stat', None, _('output diffstat-style summary of changes')),
102 102 ('G', 'graph', None, _("show the revision DAG")),
103 103 ] + templateopts
104 104
105 105 diffopts = [
106 106 ('a', 'text', None, _('treat all files as text')),
107 107 ('g', 'git', None, _('use git extended diff format')),
108 108 ('', 'nodates', None, _('omit dates from diff headers'))
109 109 ]
110 110
111 111 diffwsopts = [
112 112 ('w', 'ignore-all-space', None,
113 113 _('ignore white space when comparing lines')),
114 114 ('b', 'ignore-space-change', None,
115 115 _('ignore changes in the amount of white space')),
116 116 ('B', 'ignore-blank-lines', None,
117 117 _('ignore changes whose lines are all blank')),
118 118 ]
119 119
120 120 diffopts2 = [
121 121 ('p', 'show-function', None, _('show which function each change is in')),
122 122 ('', 'reverse', None, _('produce a diff that undoes the changes')),
123 123 ] + diffwsopts + [
124 124 ('U', 'unified', '',
125 125 _('number of lines of context to show'), _('NUM')),
126 126 ('', 'stat', None, _('output diffstat-style summary of changes')),
127 127 ]
128 128
129 129 mergetoolopts = [
130 130 ('t', 'tool', '', _('specify merge tool')),
131 131 ]
132 132
133 133 similarityopts = [
134 134 ('s', 'similarity', '',
135 135 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
136 136 ]
137 137
138 138 subrepoopts = [
139 139 ('S', 'subrepos', None,
140 140 _('recurse into subrepositories'))
141 141 ]
142 142
143 143 # Commands start here, listed alphabetically
144 144
145 145 @command('^add',
146 146 walkopts + subrepoopts + dryrunopts,
147 147 _('[OPTION]... [FILE]...'))
148 148 def add(ui, repo, *pats, **opts):
149 149 """add the specified files on the next commit
150 150
151 151 Schedule files to be version controlled and added to the
152 152 repository.
153 153
154 154 The files will be added to the repository at the next commit. To
155 155 undo an add before that, see :hg:`forget`.
156 156
157 157 If no names are given, add all files to the repository.
158 158
159 159 .. container:: verbose
160 160
161 161 An example showing how new (unknown) files are added
162 162 automatically by :hg:`add`::
163 163
164 164 $ ls
165 165 foo.c
166 166 $ hg status
167 167 ? foo.c
168 168 $ hg add
169 169 adding foo.c
170 170 $ hg status
171 171 A foo.c
172 172
173 173 Returns 0 if all files are successfully added.
174 174 """
175 175
176 176 m = scmutil.match(repo[None], pats, opts)
177 177 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
178 178 opts.get('subrepos'), prefix="", explicitonly=False)
179 179 return rejected and 1 or 0
180 180
181 181 @command('addremove',
182 182 similarityopts + walkopts + dryrunopts,
183 183 _('[OPTION]... [FILE]...'))
184 184 def addremove(ui, repo, *pats, **opts):
185 185 """add all new files, delete all missing files
186 186
187 187 Add all new files and remove all missing files from the
188 188 repository.
189 189
190 190 New files are ignored if they match any of the patterns in
191 191 ``.hgignore``. As with add, these changes take effect at the next
192 192 commit.
193 193
194 194 Use the -s/--similarity option to detect renamed files. This
195 195 option takes a percentage between 0 (disabled) and 100 (files must
196 196 be identical) as its parameter. With a parameter greater than 0,
197 197 this compares every removed file with every added file and records
198 198 those similar enough as renames. Detecting renamed files this way
199 199 can be expensive. After using this option, :hg:`status -C` can be
200 200 used to check which files were identified as moved or renamed. If
201 201 not specified, -s/--similarity defaults to 100 and only renames of
202 202 identical files are detected.
203 203
204 204 Returns 0 if all files are successfully added.
205 205 """
206 206 try:
207 207 sim = float(opts.get('similarity') or 100)
208 208 except ValueError:
209 209 raise util.Abort(_('similarity must be a number'))
210 210 if sim < 0 or sim > 100:
211 211 raise util.Abort(_('similarity must be between 0 and 100'))
212 212 return scmutil.addremove(repo, pats, opts, similarity=sim / 100.0)
213 213
214 214 @command('^annotate|blame',
215 215 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
216 216 ('', 'follow', None,
217 217 _('follow copies/renames and list the filename (DEPRECATED)')),
218 218 ('', 'no-follow', None, _("don't follow copies and renames")),
219 219 ('a', 'text', None, _('treat all files as text')),
220 220 ('u', 'user', None, _('list the author (long with -v)')),
221 221 ('f', 'file', None, _('list the filename')),
222 222 ('d', 'date', None, _('list the date (short with -q)')),
223 223 ('n', 'number', None, _('list the revision number (default)')),
224 224 ('c', 'changeset', None, _('list the changeset')),
225 225 ('l', 'line-number', None, _('show line number at the first appearance'))
226 226 ] + diffwsopts + walkopts,
227 227 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'))
228 228 def annotate(ui, repo, *pats, **opts):
229 229 """show changeset information by line for each file
230 230
231 231 List changes in files, showing the revision id responsible for
232 232 each line
233 233
234 234 This command is useful for discovering when a change was made and
235 235 by whom.
236 236
237 237 Without the -a/--text option, annotate will avoid processing files
238 238 it detects as binary. With -a, annotate will annotate the file
239 239 anyway, although the results will probably be neither useful
240 240 nor desirable.
241 241
242 242 Returns 0 on success.
243 243 """
244 244 if opts.get('follow'):
245 245 # --follow is deprecated and now just an alias for -f/--file
246 246 # to mimic the behavior of Mercurial before version 1.5
247 247 opts['file'] = True
248 248
249 249 datefunc = ui.quiet and util.shortdate or util.datestr
250 250 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
251 251
252 252 if not pats:
253 253 raise util.Abort(_('at least one filename or pattern is required'))
254 254
255 255 hexfn = ui.debugflag and hex or short
256 256
257 257 opmap = [('user', ' ', lambda x: ui.shortuser(x[0].user())),
258 258 ('number', ' ', lambda x: str(x[0].rev())),
259 259 ('changeset', ' ', lambda x: hexfn(x[0].node())),
260 260 ('date', ' ', getdate),
261 261 ('file', ' ', lambda x: x[0].path()),
262 262 ('line_number', ':', lambda x: str(x[1])),
263 263 ]
264 264
265 265 if (not opts.get('user') and not opts.get('changeset')
266 266 and not opts.get('date') and not opts.get('file')):
267 267 opts['number'] = True
268 268
269 269 linenumber = opts.get('line_number') is not None
270 270 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
271 271 raise util.Abort(_('at least one of -n/-c is required for -l'))
272 272
273 273 funcmap = [(func, sep) for op, sep, func in opmap if opts.get(op)]
274 274 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
275 275
276 276 def bad(x, y):
277 277 raise util.Abort("%s: %s" % (x, y))
278 278
279 279 ctx = scmutil.revsingle(repo, opts.get('rev'))
280 280 m = scmutil.match(ctx, pats, opts)
281 281 m.bad = bad
282 282 follow = not opts.get('no_follow')
283 283 diffopts = patch.diffopts(ui, opts, section='annotate')
284 284 for abs in ctx.walk(m):
285 285 fctx = ctx[abs]
286 286 if not opts.get('text') and util.binary(fctx.data()):
287 287 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
288 288 continue
289 289
290 290 lines = fctx.annotate(follow=follow, linenumber=linenumber,
291 291 diffopts=diffopts)
292 292 pieces = []
293 293
294 294 for f, sep in funcmap:
295 295 l = [f(n) for n, dummy in lines]
296 296 if l:
297 297 sized = [(x, encoding.colwidth(x)) for x in l]
298 298 ml = max([w for x, w in sized])
299 299 pieces.append(["%s%s%s" % (sep, ' ' * (ml - w), x)
300 300 for x, w in sized])
301 301
302 302 if pieces:
303 303 for p, l in zip(zip(*pieces), lines):
304 304 ui.write("%s: %s" % ("".join(p), l[1]))
305 305
306 306 if lines and not lines[-1][1].endswith('\n'):
307 307 ui.write('\n')
308 308
309 309 @command('archive',
310 310 [('', 'no-decode', None, _('do not pass files through decoders')),
311 311 ('p', 'prefix', '', _('directory prefix for files in archive'),
312 312 _('PREFIX')),
313 313 ('r', 'rev', '', _('revision to distribute'), _('REV')),
314 314 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
315 315 ] + subrepoopts + walkopts,
316 316 _('[OPTION]... DEST'))
317 317 def archive(ui, repo, dest, **opts):
318 318 '''create an unversioned archive of a repository revision
319 319
320 320 By default, the revision used is the parent of the working
321 321 directory; use -r/--rev to specify a different revision.
322 322
323 323 The archive type is automatically detected based on file
324 324 extension (or override using -t/--type).
325 325
326 326 .. container:: verbose
327 327
328 328 Examples:
329 329
330 330 - create a zip file containing the 1.0 release::
331 331
332 332 hg archive -r 1.0 project-1.0.zip
333 333
334 334 - create a tarball excluding .hg files::
335 335
336 336 hg archive project.tar.gz -X ".hg*"
337 337
338 338 Valid types are:
339 339
340 340 :``files``: a directory full of files (default)
341 341 :``tar``: tar archive, uncompressed
342 342 :``tbz2``: tar archive, compressed using bzip2
343 343 :``tgz``: tar archive, compressed using gzip
344 344 :``uzip``: zip archive, uncompressed
345 345 :``zip``: zip archive, compressed using deflate
346 346
347 347 The exact name of the destination archive or directory is given
348 348 using a format string; see :hg:`help export` for details.
349 349
350 350 Each member added to an archive file has a directory prefix
351 351 prepended. Use -p/--prefix to specify a format string for the
352 352 prefix. The default is the basename of the archive, with suffixes
353 353 removed.
354 354
355 355 Returns 0 on success.
356 356 '''
357 357
358 358 ctx = scmutil.revsingle(repo, opts.get('rev'))
359 359 if not ctx:
360 360 raise util.Abort(_('no working directory: please specify a revision'))
361 361 node = ctx.node()
362 362 dest = cmdutil.makefilename(repo, dest, node)
363 363 if os.path.realpath(dest) == repo.root:
364 364 raise util.Abort(_('repository root cannot be destination'))
365 365
366 366 kind = opts.get('type') or archival.guesskind(dest) or 'files'
367 367 prefix = opts.get('prefix')
368 368
369 369 if dest == '-':
370 370 if kind == 'files':
371 371 raise util.Abort(_('cannot archive plain files to stdout'))
372 372 dest = cmdutil.makefileobj(repo, dest)
373 373 if not prefix:
374 374 prefix = os.path.basename(repo.root) + '-%h'
375 375
376 376 prefix = cmdutil.makefilename(repo, prefix, node)
377 377 matchfn = scmutil.match(ctx, [], opts)
378 378 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
379 379 matchfn, prefix, subrepos=opts.get('subrepos'))
380 380
381 381 @command('backout',
382 382 [('', 'merge', None, _('merge with old dirstate parent after backout')),
383 383 ('', 'parent', '',
384 384 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
385 385 ('r', 'rev', '', _('revision to backout'), _('REV')),
386 386 ] + mergetoolopts + walkopts + commitopts + commitopts2,
387 387 _('[OPTION]... [-r] REV'))
388 388 def backout(ui, repo, node=None, rev=None, **opts):
389 389 '''reverse effect of earlier changeset
390 390
391 391 Prepare a new changeset with the effect of REV undone in the
392 392 current working directory.
393 393
394 394 If REV is the parent of the working directory, then this new changeset
395 395 is committed automatically. Otherwise, hg needs to merge the
396 396 changes and the merged result is left uncommitted.
397 397
398 398 .. note::
399 399 backout cannot be used to fix either an unwanted or
400 400 incorrect merge.
401 401
402 402 .. container:: verbose
403 403
404 404 By default, the pending changeset will have one parent,
405 405 maintaining a linear history. With --merge, the pending
406 406 changeset will instead have two parents: the old parent of the
407 407 working directory and a new child of REV that simply undoes REV.
408 408
409 409 Before version 1.7, the behavior without --merge was equivalent
410 410 to specifying --merge followed by :hg:`update --clean .` to
411 411 cancel the merge and leave the child of REV as a head to be
412 412 merged separately.
413 413
414 414 See :hg:`help dates` for a list of formats valid for -d/--date.
415 415
416 416 Returns 0 on success.
417 417 '''
418 418 if rev and node:
419 419 raise util.Abort(_("please specify just one revision"))
420 420
421 421 if not rev:
422 422 rev = node
423 423
424 424 if not rev:
425 425 raise util.Abort(_("please specify a revision to backout"))
426 426
427 427 date = opts.get('date')
428 428 if date:
429 429 opts['date'] = util.parsedate(date)
430 430
431 431 cmdutil.bailifchanged(repo)
432 432 node = scmutil.revsingle(repo, rev).node()
433 433
434 434 op1, op2 = repo.dirstate.parents()
435 435 a = repo.changelog.ancestor(op1, node)
436 436 if a != node:
437 437 raise util.Abort(_('cannot backout change on a different branch'))
438 438
439 439 p1, p2 = repo.changelog.parents(node)
440 440 if p1 == nullid:
441 441 raise util.Abort(_('cannot backout a change with no parents'))
442 442 if p2 != nullid:
443 443 if not opts.get('parent'):
444 444 raise util.Abort(_('cannot backout a merge changeset'))
445 445 p = repo.lookup(opts['parent'])
446 446 if p not in (p1, p2):
447 447 raise util.Abort(_('%s is not a parent of %s') %
448 448 (short(p), short(node)))
449 449 parent = p
450 450 else:
451 451 if opts.get('parent'):
452 452 raise util.Abort(_('cannot use --parent on non-merge changeset'))
453 453 parent = p1
454 454
455 455 # the backout should appear on the same branch
456 456 wlock = repo.wlock()
457 457 try:
458 458 branch = repo.dirstate.branch()
459 459 bheads = repo.branchheads(branch)
460 460 hg.clean(repo, node, show_stats=False)
461 461 repo.dirstate.setbranch(branch)
462 462 rctx = scmutil.revsingle(repo, hex(parent))
463 463 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
464 464 if not opts.get('merge') and op1 != node:
465 465 try:
466 466 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
467 467 return hg.update(repo, op1)
468 468 finally:
469 469 ui.setconfig('ui', 'forcemerge', '')
470 470
471 471 e = cmdutil.commiteditor
472 472 if not opts['message'] and not opts['logfile']:
473 473 # we don't translate commit messages
474 474 opts['message'] = "Backed out changeset %s" % short(node)
475 475 e = cmdutil.commitforceeditor
476 476
477 477 def commitfunc(ui, repo, message, match, opts):
478 478 return repo.commit(message, opts.get('user'), opts.get('date'),
479 479 match, editor=e)
480 480 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
481 481 cmdutil.commitstatus(repo, newnode, branch, bheads)
482 482
483 483 def nice(node):
484 484 return '%d:%s' % (repo.changelog.rev(node), short(node))
485 485 ui.status(_('changeset %s backs out changeset %s\n') %
486 486 (nice(repo.changelog.tip()), nice(node)))
487 487 if opts.get('merge') and op1 != node:
488 488 hg.clean(repo, op1, show_stats=False)
489 489 ui.status(_('merging with changeset %s\n')
490 490 % nice(repo.changelog.tip()))
491 491 try:
492 492 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
493 493 return hg.merge(repo, hex(repo.changelog.tip()))
494 494 finally:
495 495 ui.setconfig('ui', 'forcemerge', '')
496 496 finally:
497 497 wlock.release()
498 498 return 0
499 499
500 500 @command('bisect',
501 501 [('r', 'reset', False, _('reset bisect state')),
502 502 ('g', 'good', False, _('mark changeset good')),
503 503 ('b', 'bad', False, _('mark changeset bad')),
504 504 ('s', 'skip', False, _('skip testing changeset')),
505 505 ('e', 'extend', False, _('extend the bisect range')),
506 506 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
507 507 ('U', 'noupdate', False, _('do not update to target'))],
508 508 _("[-gbsr] [-U] [-c CMD] [REV]"))
509 509 def bisect(ui, repo, rev=None, extra=None, command=None,
510 510 reset=None, good=None, bad=None, skip=None, extend=None,
511 511 noupdate=None):
512 512 """subdivision search of changesets
513 513
514 514 This command helps to find changesets which introduce problems. To
515 515 use, mark the earliest changeset you know exhibits the problem as
516 516 bad, then mark the latest changeset which is free from the problem
517 517 as good. Bisect will update your working directory to a revision
518 518 for testing (unless the -U/--noupdate option is specified). Once
519 519 you have performed tests, mark the working directory as good or
520 520 bad, and bisect will either update to another candidate changeset
521 521 or announce that it has found the bad revision.
522 522
523 523 As a shortcut, you can also use the revision argument to mark a
524 524 revision as good or bad without checking it out first.
525 525
526 526 If you supply a command, it will be used for automatic bisection.
527 527 The environment variable HG_NODE will contain the ID of the
528 528 changeset being tested. The exit status of the command will be
529 529 used to mark revisions as good or bad: status 0 means good, 125
530 530 means to skip the revision, 127 (command not found) will abort the
531 531 bisection, and any other non-zero exit status means the revision
532 532 is bad.
533 533
534 534 .. container:: verbose
535 535
536 536 Some examples:
537 537
538 538 - start a bisection with known bad revision 12, and good revision 34::
539 539
540 540 hg bisect --bad 34
541 541 hg bisect --good 12
542 542
543 543 - advance the current bisection by marking current revision as good or
544 544 bad::
545 545
546 546 hg bisect --good
547 547 hg bisect --bad
548 548
549 549 - mark the current revision, or a known revision, to be skipped (e.g. if
550 550 that revision is not usable because of another issue)::
551 551
552 552 hg bisect --skip
553 553 hg bisect --skip 23
554 554
555 555 - skip all revisions that do not touch directories ``foo`` or ``bar``
556 556
557 557 hg bisect --skip '!( file("path:foo") & file("path:bar") )'
558 558
559 559 - forget the current bisection::
560 560
561 561 hg bisect --reset
562 562
563 563 - use 'make && make tests' to automatically find the first broken
564 564 revision::
565 565
566 566 hg bisect --reset
567 567 hg bisect --bad 34
568 568 hg bisect --good 12
569 569 hg bisect --command 'make && make tests'
570 570
571 571 - see all changesets whose states are already known in the current
572 572 bisection::
573 573
574 574 hg log -r "bisect(pruned)"
575 575
576 576 - see the changeset currently being bisected (especially useful
577 577 if running with -U/--noupdate)::
578 578
579 579 hg log -r "bisect(current)"
580 580
581 581 - see all changesets that took part in the current bisection::
582 582
583 583 hg log -r "bisect(range)"
584 584
585 585 - with the graphlog extension, you can even get a nice graph::
586 586
587 587 hg log --graph -r "bisect(range)"
588 588
589 589 See :hg:`help revsets` for more about the `bisect()` keyword.
590 590
591 591 Returns 0 on success.
592 592 """
593 593 def extendbisectrange(nodes, good):
594 594 # bisect is incomplete when it ends on a merge node and
595 595 # one of the parent was not checked.
596 596 parents = repo[nodes[0]].parents()
597 597 if len(parents) > 1:
598 598 side = good and state['bad'] or state['good']
599 599 num = len(set(i.node() for i in parents) & set(side))
600 600 if num == 1:
601 601 return parents[0].ancestor(parents[1])
602 602 return None
603 603
604 604 def print_result(nodes, good):
605 605 displayer = cmdutil.show_changeset(ui, repo, {})
606 606 if len(nodes) == 1:
607 607 # narrowed it down to a single revision
608 608 if good:
609 609 ui.write(_("The first good revision is:\n"))
610 610 else:
611 611 ui.write(_("The first bad revision is:\n"))
612 612 displayer.show(repo[nodes[0]])
613 613 extendnode = extendbisectrange(nodes, good)
614 614 if extendnode is not None:
615 615 ui.write(_('Not all ancestors of this changeset have been'
616 616 ' checked.\nUse bisect --extend to continue the '
617 617 'bisection from\nthe common ancestor, %s.\n')
618 618 % extendnode)
619 619 else:
620 620 # multiple possible revisions
621 621 if good:
622 622 ui.write(_("Due to skipped revisions, the first "
623 623 "good revision could be any of:\n"))
624 624 else:
625 625 ui.write(_("Due to skipped revisions, the first "
626 626 "bad revision could be any of:\n"))
627 627 for n in nodes:
628 628 displayer.show(repo[n])
629 629 displayer.close()
630 630
631 631 def check_state(state, interactive=True):
632 632 if not state['good'] or not state['bad']:
633 633 if (good or bad or skip or reset) and interactive:
634 634 return
635 635 if not state['good']:
636 636 raise util.Abort(_('cannot bisect (no known good revisions)'))
637 637 else:
638 638 raise util.Abort(_('cannot bisect (no known bad revisions)'))
639 639 return True
640 640
641 641 # backward compatibility
642 642 if rev in "good bad reset init".split():
643 643 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
644 644 cmd, rev, extra = rev, extra, None
645 645 if cmd == "good":
646 646 good = True
647 647 elif cmd == "bad":
648 648 bad = True
649 649 else:
650 650 reset = True
651 651 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
652 652 raise util.Abort(_('incompatible arguments'))
653 653
654 654 if reset:
655 655 p = repo.join("bisect.state")
656 656 if os.path.exists(p):
657 657 os.unlink(p)
658 658 return
659 659
660 660 state = hbisect.load_state(repo)
661 661
662 662 if command:
663 663 changesets = 1
664 664 try:
665 665 node = state['current'][0]
666 666 except LookupError:
667 667 if noupdate:
668 668 raise util.Abort(_('current bisect revision is unknown - '
669 669 'start a new bisect to fix'))
670 670 node, p2 = repo.dirstate.parents()
671 671 if p2 != nullid:
672 672 raise util.Abort(_('current bisect revision is a merge'))
673 673 try:
674 674 while changesets:
675 675 # update state
676 676 state['current'] = [node]
677 677 hbisect.save_state(repo, state)
678 678 status = util.system(command,
679 679 environ={'HG_NODE': hex(node)},
680 680 out=ui.fout)
681 681 if status == 125:
682 682 transition = "skip"
683 683 elif status == 0:
684 684 transition = "good"
685 685 # status < 0 means process was killed
686 686 elif status == 127:
687 687 raise util.Abort(_("failed to execute %s") % command)
688 688 elif status < 0:
689 689 raise util.Abort(_("%s killed") % command)
690 690 else:
691 691 transition = "bad"
692 692 ctx = scmutil.revsingle(repo, rev, node)
693 693 rev = None # clear for future iterations
694 694 state[transition].append(ctx.node())
695 695 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
696 696 check_state(state, interactive=False)
697 697 # bisect
698 698 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
699 699 # update to next check
700 700 node = nodes[0]
701 701 if not noupdate:
702 702 cmdutil.bailifchanged(repo)
703 703 hg.clean(repo, node, show_stats=False)
704 704 finally:
705 705 state['current'] = [node]
706 706 hbisect.save_state(repo, state)
707 707 print_result(nodes, good)
708 708 return
709 709
710 710 # update state
711 711
712 712 if rev:
713 713 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
714 714 else:
715 715 nodes = [repo.lookup('.')]
716 716
717 717 if good or bad or skip:
718 718 if good:
719 719 state['good'] += nodes
720 720 elif bad:
721 721 state['bad'] += nodes
722 722 elif skip:
723 723 state['skip'] += nodes
724 724 hbisect.save_state(repo, state)
725 725
726 726 if not check_state(state):
727 727 return
728 728
729 729 # actually bisect
730 730 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
731 731 if extend:
732 732 if not changesets:
733 733 extendnode = extendbisectrange(nodes, good)
734 734 if extendnode is not None:
735 735 ui.write(_("Extending search to changeset %d:%s\n"
736 736 % (extendnode.rev(), extendnode)))
737 737 state['current'] = [extendnode.node()]
738 738 hbisect.save_state(repo, state)
739 739 if noupdate:
740 740 return
741 741 cmdutil.bailifchanged(repo)
742 742 return hg.clean(repo, extendnode.node())
743 743 raise util.Abort(_("nothing to extend"))
744 744
745 745 if changesets == 0:
746 746 print_result(nodes, good)
747 747 else:
748 748 assert len(nodes) == 1 # only a single node can be tested next
749 749 node = nodes[0]
750 750 # compute the approximate number of remaining tests
751 751 tests, size = 0, 2
752 752 while size <= changesets:
753 753 tests, size = tests + 1, size * 2
754 754 rev = repo.changelog.rev(node)
755 755 ui.write(_("Testing changeset %d:%s "
756 756 "(%d changesets remaining, ~%d tests)\n")
757 757 % (rev, short(node), changesets, tests))
758 758 state['current'] = [node]
759 759 hbisect.save_state(repo, state)
760 760 if not noupdate:
761 761 cmdutil.bailifchanged(repo)
762 762 return hg.clean(repo, node)
763 763
764 764 @command('bookmarks|bookmark',
765 765 [('f', 'force', False, _('force')),
766 766 ('r', 'rev', '', _('revision'), _('REV')),
767 767 ('d', 'delete', False, _('delete a given bookmark')),
768 768 ('m', 'rename', '', _('rename a given bookmark'), _('NAME')),
769 769 ('i', 'inactive', False, _('mark a bookmark inactive'))],
770 770 _('hg bookmarks [OPTIONS]... [NAME]...'))
771 771 def bookmark(ui, repo, *names, **opts):
772 772 '''track a line of development with movable markers
773 773
774 774 Bookmarks are pointers to certain commits that move when committing.
775 775 Bookmarks are local. They can be renamed, copied and deleted. It is
776 776 possible to use :hg:`merge NAME` to merge from a given bookmark, and
777 777 :hg:`update NAME` to update to a given bookmark.
778 778
779 779 You can use :hg:`bookmark NAME` to set a bookmark on the working
780 780 directory's parent revision with the given name. If you specify
781 781 a revision using -r REV (where REV may be an existing bookmark),
782 782 the bookmark is assigned to that revision.
783 783
784 784 Bookmarks can be pushed and pulled between repositories (see :hg:`help
785 785 push` and :hg:`help pull`). This requires both the local and remote
786 786 repositories to support bookmarks. For versions prior to 1.8, this means
787 787 the bookmarks extension must be enabled.
788 788
789 789 If you set a bookmark called '@', new clones of the repository will
790 790 have that revision checked out (and the bookmark made active) by
791 791 default.
792 792
793 793 With -i/--inactive, the new bookmark will not be made the active
794 794 bookmark. If -r/--rev is given, the new bookmark will not be made
795 795 active even if -i/--inactive is not given. If no NAME is given, the
796 796 current active bookmark will be marked inactive.
797 797 '''
798 798 force = opts.get('force')
799 799 rev = opts.get('rev')
800 800 delete = opts.get('delete')
801 801 rename = opts.get('rename')
802 802 inactive = opts.get('inactive')
803 803
804 804 hexfn = ui.debugflag and hex or short
805 805 marks = repo._bookmarks
806 806 cur = repo.changectx('.').node()
807 807
808 808 def checkformat(mark):
809 809 mark = mark.strip()
810 810 if not mark:
811 811 raise util.Abort(_("bookmark names cannot consist entirely of "
812 812 "whitespace"))
813 813 scmutil.checknewlabel(repo, mark, 'bookmark')
814 814 return mark
815 815
816 816 def checkconflict(repo, mark, force=False, target=None):
817 817 if mark in marks and not force:
818 818 if target:
819 819 if marks[mark] == target and target == cur:
820 820 # re-activating a bookmark
821 821 return
822 822 anc = repo.changelog.ancestors([repo[target].rev()])
823 823 bmctx = repo[marks[mark]]
824 824 divs = [repo[b].node() for b in marks
825 825 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
826 826
827 827 # allow resolving a single divergent bookmark even if moving
828 828 # the bookmark across branches when a revision is specified
829 829 # that contains a divergent bookmark
830 830 if bmctx.rev() not in anc and target in divs:
831 831 bookmarks.deletedivergent(repo, [target], mark)
832 832 return
833 833
834 834 deletefrom = [b for b in divs
835 835 if repo[b].rev() in anc or b == target]
836 836 bookmarks.deletedivergent(repo, deletefrom, mark)
837 837 if bmctx.rev() in anc:
838 838 ui.status(_("moving bookmark '%s' forward from %s\n") %
839 839 (mark, short(bmctx.node())))
840 840 return
841 841 raise util.Abort(_("bookmark '%s' already exists "
842 842 "(use -f to force)") % mark)
843 843 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
844 844 and not force):
845 845 raise util.Abort(
846 846 _("a bookmark cannot have the name of an existing branch"))
847 847
848 848 if delete and rename:
849 849 raise util.Abort(_("--delete and --rename are incompatible"))
850 850 if delete and rev:
851 851 raise util.Abort(_("--rev is incompatible with --delete"))
852 852 if rename and rev:
853 853 raise util.Abort(_("--rev is incompatible with --rename"))
854 854 if not names and (delete or rev):
855 855 raise util.Abort(_("bookmark name required"))
856 856
857 857 if delete:
858 858 for mark in names:
859 859 if mark not in marks:
860 860 raise util.Abort(_("bookmark '%s' does not exist") % mark)
861 861 if mark == repo._bookmarkcurrent:
862 862 bookmarks.setcurrent(repo, None)
863 863 del marks[mark]
864 864 marks.write()
865 865
866 866 elif rename:
867 867 if not names:
868 868 raise util.Abort(_("new bookmark name required"))
869 869 elif len(names) > 1:
870 870 raise util.Abort(_("only one new bookmark name allowed"))
871 871 mark = checkformat(names[0])
872 872 if rename not in marks:
873 873 raise util.Abort(_("bookmark '%s' does not exist") % rename)
874 874 checkconflict(repo, mark, force)
875 875 marks[mark] = marks[rename]
876 876 if repo._bookmarkcurrent == rename and not inactive:
877 877 bookmarks.setcurrent(repo, mark)
878 878 del marks[rename]
879 879 marks.write()
880 880
881 881 elif names:
882 882 newact = None
883 883 for mark in names:
884 884 mark = checkformat(mark)
885 885 if newact is None:
886 886 newact = mark
887 887 if inactive and mark == repo._bookmarkcurrent:
888 888 bookmarks.setcurrent(repo, None)
889 889 return
890 890 tgt = cur
891 891 if rev:
892 892 tgt = scmutil.revsingle(repo, rev).node()
893 893 checkconflict(repo, mark, force, tgt)
894 894 marks[mark] = tgt
895 895 if not inactive and cur == marks[newact] and not rev:
896 896 bookmarks.setcurrent(repo, newact)
897 897 elif cur != tgt and newact == repo._bookmarkcurrent:
898 898 bookmarks.setcurrent(repo, None)
899 899 marks.write()
900 900
901 901 # Same message whether trying to deactivate the current bookmark (-i
902 902 # with no NAME) or listing bookmarks
903 903 elif len(marks) == 0:
904 904 ui.status(_("no bookmarks set\n"))
905 905
906 906 elif inactive:
907 907 if not repo._bookmarkcurrent:
908 908 ui.status(_("no active bookmark\n"))
909 909 else:
910 910 bookmarks.setcurrent(repo, None)
911 911
912 912 else: # show bookmarks
913 913 for bmark, n in sorted(marks.iteritems()):
914 914 current = repo._bookmarkcurrent
915 915 if bmark == current:
916 916 prefix, label = '*', 'bookmarks.current'
917 917 else:
918 918 prefix, label = ' ', ''
919 919
920 920 if ui.quiet:
921 921 ui.write("%s\n" % bmark, label=label)
922 922 else:
923 923 ui.write(" %s %-25s %d:%s\n" % (
924 924 prefix, bmark, repo.changelog.rev(n), hexfn(n)),
925 925 label=label)
926 926
927 927 @command('branch',
928 928 [('f', 'force', None,
929 929 _('set branch name even if it shadows an existing branch')),
930 930 ('C', 'clean', None, _('reset branch name to parent branch name'))],
931 931 _('[-fC] [NAME]'))
932 932 def branch(ui, repo, label=None, **opts):
933 933 """set or show the current branch name
934 934
935 935 .. note::
936 936 Branch names are permanent and global. Use :hg:`bookmark` to create a
937 937 light-weight bookmark instead. See :hg:`help glossary` for more
938 938 information about named branches and bookmarks.
939 939
940 940 With no argument, show the current branch name. With one argument,
941 941 set the working directory branch name (the branch will not exist
942 942 in the repository until the next commit). Standard practice
943 943 recommends that primary development take place on the 'default'
944 944 branch.
945 945
946 946 Unless -f/--force is specified, branch will not let you set a
947 947 branch name that already exists, even if it's inactive.
948 948
949 949 Use -C/--clean to reset the working directory branch to that of
950 950 the parent of the working directory, negating a previous branch
951 951 change.
952 952
953 953 Use the command :hg:`update` to switch to an existing branch. Use
954 954 :hg:`commit --close-branch` to mark this branch as closed.
955 955
956 956 Returns 0 on success.
957 957 """
958 958 if label:
959 959 label = label.strip()
960 960
961 961 if not opts.get('clean') and not label:
962 962 ui.write("%s\n" % repo.dirstate.branch())
963 963 return
964 964
965 965 wlock = repo.wlock()
966 966 try:
967 967 if opts.get('clean'):
968 968 label = repo[None].p1().branch()
969 969 repo.dirstate.setbranch(label)
970 970 ui.status(_('reset working directory to branch %s\n') % label)
971 971 elif label:
972 972 if not opts.get('force') and label in repo.branchmap():
973 973 if label not in [p.branch() for p in repo.parents()]:
974 974 raise util.Abort(_('a branch of the same name already'
975 975 ' exists'),
976 976 # i18n: "it" refers to an existing branch
977 977 hint=_("use 'hg update' to switch to it"))
978 978 scmutil.checknewlabel(repo, label, 'branch')
979 979 repo.dirstate.setbranch(label)
980 980 ui.status(_('marked working directory as branch %s\n') % label)
981 981 ui.status(_('(branches are permanent and global, '
982 982 'did you want a bookmark?)\n'))
983 983 finally:
984 984 wlock.release()
985 985
986 986 @command('branches',
987 987 [('a', 'active', False, _('show only branches that have unmerged heads')),
988 988 ('c', 'closed', False, _('show normal and closed branches'))],
989 989 _('[-ac]'))
990 990 def branches(ui, repo, active=False, closed=False):
991 991 """list repository named branches
992 992
993 993 List the repository's named branches, indicating which ones are
994 994 inactive. If -c/--closed is specified, also list branches which have
995 995 been marked closed (see :hg:`commit --close-branch`).
996 996
997 997 If -a/--active is specified, only show active branches. A branch
998 998 is considered active if it contains repository heads.
999 999
1000 1000 Use the command :hg:`update` to switch to an existing branch.
1001 1001
1002 1002 Returns 0.
1003 1003 """
1004 1004
1005 1005 hexfunc = ui.debugflag and hex or short
1006 1006
1007 1007 activebranches = set([repo[n].branch() for n in repo.heads()])
1008 1008 branches = []
1009 1009 for tag, heads in repo.branchmap().iteritems():
1010 1010 for h in reversed(heads):
1011 1011 ctx = repo[h]
1012 1012 isopen = not ctx.closesbranch()
1013 1013 if isopen:
1014 1014 tip = ctx
1015 1015 break
1016 1016 else:
1017 1017 tip = repo[heads[-1]]
1018 1018 isactive = tag in activebranches and isopen
1019 1019 branches.append((tip, isactive, isopen))
1020 1020 branches.sort(key=lambda i: (i[1], i[0].rev(), i[0].branch(), i[2]),
1021 1021 reverse=True)
1022 1022
1023 1023 for ctx, isactive, isopen in branches:
1024 1024 if (not active) or isactive:
1025 1025 if isactive:
1026 1026 label = 'branches.active'
1027 1027 notice = ''
1028 1028 elif not isopen:
1029 1029 if not closed:
1030 1030 continue
1031 1031 label = 'branches.closed'
1032 1032 notice = _(' (closed)')
1033 1033 else:
1034 1034 label = 'branches.inactive'
1035 1035 notice = _(' (inactive)')
1036 1036 if ctx.branch() == repo.dirstate.branch():
1037 1037 label = 'branches.current'
1038 1038 rev = str(ctx.rev()).rjust(31 - encoding.colwidth(ctx.branch()))
1039 1039 rev = ui.label('%s:%s' % (rev, hexfunc(ctx.node())),
1040 1040 'log.changeset changeset.%s' % ctx.phasestr())
1041 1041 tag = ui.label(ctx.branch(), label)
1042 1042 if ui.quiet:
1043 1043 ui.write("%s\n" % tag)
1044 1044 else:
1045 1045 ui.write("%s %s%s\n" % (tag, rev, notice))
1046 1046
1047 1047 @command('bundle',
1048 1048 [('f', 'force', None, _('run even when the destination is unrelated')),
1049 1049 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1050 1050 _('REV')),
1051 1051 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1052 1052 _('BRANCH')),
1053 1053 ('', 'base', [],
1054 1054 _('a base changeset assumed to be available at the destination'),
1055 1055 _('REV')),
1056 1056 ('a', 'all', None, _('bundle all changesets in the repository')),
1057 1057 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1058 1058 ] + remoteopts,
1059 1059 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1060 1060 def bundle(ui, repo, fname, dest=None, **opts):
1061 1061 """create a changegroup file
1062 1062
1063 1063 Generate a compressed changegroup file collecting changesets not
1064 1064 known to be in another repository.
1065 1065
1066 1066 If you omit the destination repository, then hg assumes the
1067 1067 destination will have all the nodes you specify with --base
1068 1068 parameters. To create a bundle containing all changesets, use
1069 1069 -a/--all (or --base null).
1070 1070
1071 1071 You can change compression method with the -t/--type option.
1072 1072 The available compression methods are: none, bzip2, and
1073 1073 gzip (by default, bundles are compressed using bzip2).
1074 1074
1075 1075 The bundle file can then be transferred using conventional means
1076 1076 and applied to another repository with the unbundle or pull
1077 1077 command. This is useful when direct push and pull are not
1078 1078 available or when exporting an entire repository is undesirable.
1079 1079
1080 1080 Applying bundles preserves all changeset contents including
1081 1081 permissions, copy/rename information, and revision history.
1082 1082
1083 1083 Returns 0 on success, 1 if no changes found.
1084 1084 """
1085 1085 revs = None
1086 1086 if 'rev' in opts:
1087 1087 revs = scmutil.revrange(repo, opts['rev'])
1088 1088
1089 1089 bundletype = opts.get('type', 'bzip2').lower()
1090 1090 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1091 1091 bundletype = btypes.get(bundletype)
1092 1092 if bundletype not in changegroup.bundletypes:
1093 1093 raise util.Abort(_('unknown bundle type specified with --type'))
1094 1094
1095 1095 if opts.get('all'):
1096 1096 base = ['null']
1097 1097 else:
1098 1098 base = scmutil.revrange(repo, opts.get('base'))
1099 1099 # TODO: get desired bundlecaps from command line.
1100 1100 bundlecaps = None
1101 1101 if base:
1102 1102 if dest:
1103 1103 raise util.Abort(_("--base is incompatible with specifying "
1104 1104 "a destination"))
1105 1105 common = [repo.lookup(rev) for rev in base]
1106 1106 heads = revs and map(repo.lookup, revs) or revs
1107 1107 cg = repo.getbundle('bundle', heads=heads, common=common,
1108 1108 bundlecaps=bundlecaps)
1109 1109 outgoing = None
1110 1110 else:
1111 1111 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1112 1112 dest, branches = hg.parseurl(dest, opts.get('branch'))
1113 1113 other = hg.peer(repo, opts, dest)
1114 1114 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1115 1115 heads = revs and map(repo.lookup, revs) or revs
1116 1116 outgoing = discovery.findcommonoutgoing(repo, other,
1117 1117 onlyheads=heads,
1118 1118 force=opts.get('force'),
1119 1119 portable=True)
1120 1120 cg = repo.getlocalbundle('bundle', outgoing, bundlecaps)
1121 1121 if not cg:
1122 1122 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1123 1123 return 1
1124 1124
1125 1125 changegroup.writebundle(cg, fname, bundletype)
1126 1126
1127 1127 @command('cat',
1128 1128 [('o', 'output', '',
1129 1129 _('print output to file with formatted name'), _('FORMAT')),
1130 1130 ('r', 'rev', '', _('print the given revision'), _('REV')),
1131 1131 ('', 'decode', None, _('apply any matching decode filter')),
1132 1132 ] + walkopts,
1133 1133 _('[OPTION]... FILE...'))
1134 1134 def cat(ui, repo, file1, *pats, **opts):
1135 1135 """output the current or given revision of files
1136 1136
1137 1137 Print the specified files as they were at the given revision. If
1138 1138 no revision is given, the parent of the working directory is used.
1139 1139
1140 1140 Output may be to a file, in which case the name of the file is
1141 1141 given using a format string. The formatting rules are the same as
1142 1142 for the export command, with the following additions:
1143 1143
1144 1144 :``%s``: basename of file being printed
1145 1145 :``%d``: dirname of file being printed, or '.' if in repository root
1146 1146 :``%p``: root-relative path name of file being printed
1147 1147
1148 1148 Returns 0 on success.
1149 1149 """
1150 1150 ctx = scmutil.revsingle(repo, opts.get('rev'))
1151 1151 err = 1
1152 1152 m = scmutil.match(ctx, (file1,) + pats, opts)
1153 1153 for abs in ctx.walk(m):
1154 1154 fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(),
1155 1155 pathname=abs)
1156 1156 data = ctx[abs].data()
1157 1157 if opts.get('decode'):
1158 1158 data = repo.wwritedata(abs, data)
1159 1159 fp.write(data)
1160 1160 fp.close()
1161 1161 err = 0
1162 1162 return err
1163 1163
1164 1164 @command('^clone',
1165 1165 [('U', 'noupdate', None,
1166 1166 _('the clone will include an empty working copy (only a repository)')),
1167 1167 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1168 1168 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1169 1169 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1170 1170 ('', 'pull', None, _('use pull protocol to copy metadata')),
1171 1171 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1172 1172 ] + remoteopts,
1173 1173 _('[OPTION]... SOURCE [DEST]'))
1174 1174 def clone(ui, source, dest=None, **opts):
1175 1175 """make a copy of an existing repository
1176 1176
1177 1177 Create a copy of an existing repository in a new directory.
1178 1178
1179 1179 If no destination directory name is specified, it defaults to the
1180 1180 basename of the source.
1181 1181
1182 1182 The location of the source is added to the new repository's
1183 1183 ``.hg/hgrc`` file, as the default to be used for future pulls.
1184 1184
1185 1185 Only local paths and ``ssh://`` URLs are supported as
1186 1186 destinations. For ``ssh://`` destinations, no working directory or
1187 1187 ``.hg/hgrc`` will be created on the remote side.
1188 1188
1189 1189 To pull only a subset of changesets, specify one or more revisions
1190 1190 identifiers with -r/--rev or branches with -b/--branch. The
1191 1191 resulting clone will contain only the specified changesets and
1192 1192 their ancestors. These options (or 'clone src#rev dest') imply
1193 1193 --pull, even for local source repositories. Note that specifying a
1194 1194 tag will include the tagged changeset but not the changeset
1195 1195 containing the tag.
1196 1196
1197 1197 If the source repository has a bookmark called '@' set, that
1198 1198 revision will be checked out in the new repository by default.
1199 1199
1200 1200 To check out a particular version, use -u/--update, or
1201 1201 -U/--noupdate to create a clone with no working directory.
1202 1202
1203 1203 .. container:: verbose
1204 1204
1205 1205 For efficiency, hardlinks are used for cloning whenever the
1206 1206 source and destination are on the same filesystem (note this
1207 1207 applies only to the repository data, not to the working
1208 1208 directory). Some filesystems, such as AFS, implement hardlinking
1209 1209 incorrectly, but do not report errors. In these cases, use the
1210 1210 --pull option to avoid hardlinking.
1211 1211
1212 1212 In some cases, you can clone repositories and the working
1213 1213 directory using full hardlinks with ::
1214 1214
1215 1215 $ cp -al REPO REPOCLONE
1216 1216
1217 1217 This is the fastest way to clone, but it is not always safe. The
1218 1218 operation is not atomic (making sure REPO is not modified during
1219 1219 the operation is up to you) and you have to make sure your
1220 1220 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1221 1221 so). Also, this is not compatible with certain extensions that
1222 1222 place their metadata under the .hg directory, such as mq.
1223 1223
1224 1224 Mercurial will update the working directory to the first applicable
1225 1225 revision from this list:
1226 1226
1227 1227 a) null if -U or the source repository has no changesets
1228 1228 b) if -u . and the source repository is local, the first parent of
1229 1229 the source repository's working directory
1230 1230 c) the changeset specified with -u (if a branch name, this means the
1231 1231 latest head of that branch)
1232 1232 d) the changeset specified with -r
1233 1233 e) the tipmost head specified with -b
1234 1234 f) the tipmost head specified with the url#branch source syntax
1235 1235 g) the revision marked with the '@' bookmark, if present
1236 1236 h) the tipmost head of the default branch
1237 1237 i) tip
1238 1238
1239 1239 Examples:
1240 1240
1241 1241 - clone a remote repository to a new directory named hg/::
1242 1242
1243 1243 hg clone http://selenic.com/hg
1244 1244
1245 1245 - create a lightweight local clone::
1246 1246
1247 1247 hg clone project/ project-feature/
1248 1248
1249 1249 - clone from an absolute path on an ssh server (note double-slash)::
1250 1250
1251 1251 hg clone ssh://user@server//home/projects/alpha/
1252 1252
1253 1253 - do a high-speed clone over a LAN while checking out a
1254 1254 specified version::
1255 1255
1256 1256 hg clone --uncompressed http://server/repo -u 1.5
1257 1257
1258 1258 - create a repository without changesets after a particular revision::
1259 1259
1260 1260 hg clone -r 04e544 experimental/ good/
1261 1261
1262 1262 - clone (and track) a particular named branch::
1263 1263
1264 1264 hg clone http://selenic.com/hg#stable
1265 1265
1266 1266 See :hg:`help urls` for details on specifying URLs.
1267 1267
1268 1268 Returns 0 on success.
1269 1269 """
1270 1270 if opts.get('noupdate') and opts.get('updaterev'):
1271 1271 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1272 1272
1273 1273 r = hg.clone(ui, opts, source, dest,
1274 1274 pull=opts.get('pull'),
1275 1275 stream=opts.get('uncompressed'),
1276 1276 rev=opts.get('rev'),
1277 1277 update=opts.get('updaterev') or not opts.get('noupdate'),
1278 1278 branch=opts.get('branch'))
1279 1279
1280 1280 return r is None
1281 1281
1282 1282 @command('^commit|ci',
1283 1283 [('A', 'addremove', None,
1284 1284 _('mark new/missing files as added/removed before committing')),
1285 1285 ('', 'close-branch', None,
1286 1286 _('mark a branch as closed, hiding it from the branch list')),
1287 1287 ('', 'amend', None, _('amend the parent of the working dir')),
1288 1288 ('s', 'secret', None, _('use the secret phase for committing')),
1289 1289 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1290 1290 _('[OPTION]... [FILE]...'))
1291 1291 def commit(ui, repo, *pats, **opts):
1292 1292 """commit the specified files or all outstanding changes
1293 1293
1294 1294 Commit changes to the given files into the repository. Unlike a
1295 1295 centralized SCM, this operation is a local operation. See
1296 1296 :hg:`push` for a way to actively distribute your changes.
1297 1297
1298 1298 If a list of files is omitted, all changes reported by :hg:`status`
1299 1299 will be committed.
1300 1300
1301 1301 If you are committing the result of a merge, do not provide any
1302 1302 filenames or -I/-X filters.
1303 1303
1304 1304 If no commit message is specified, Mercurial starts your
1305 1305 configured editor where you can enter a message. In case your
1306 1306 commit fails, you will find a backup of your message in
1307 1307 ``.hg/last-message.txt``.
1308 1308
1309 1309 The --amend flag can be used to amend the parent of the
1310 1310 working directory with a new commit that contains the changes
1311 1311 in the parent in addition to those currently reported by :hg:`status`,
1312 1312 if there are any. The old commit is stored in a backup bundle in
1313 1313 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1314 1314 on how to restore it).
1315 1315
1316 1316 Message, user and date are taken from the amended commit unless
1317 1317 specified. When a message isn't specified on the command line,
1318 1318 the editor will open with the message of the amended commit.
1319 1319
1320 1320 It is not possible to amend public changesets (see :hg:`help phases`)
1321 1321 or changesets that have children.
1322 1322
1323 1323 See :hg:`help dates` for a list of formats valid for -d/--date.
1324 1324
1325 1325 Returns 0 on success, 1 if nothing changed.
1326 1326 """
1327 1327 if opts.get('subrepos'):
1328 1328 if opts.get('amend'):
1329 1329 raise util.Abort(_('cannot amend with --subrepos'))
1330 1330 # Let --subrepos on the command line override config setting.
1331 1331 ui.setconfig('ui', 'commitsubrepos', True)
1332 1332
1333 1333 # Save this for restoring it later
1334 1334 oldcommitphase = ui.config('phases', 'new-commit')
1335 1335
1336 1336 if repo.vfs.exists('graftstate'):
1337 1337 raise util.Abort(_('cannot commit an interrupted graft operation'),
1338 1338 hint=_('use "hg graft -c" to continue graft'))
1339 1339
1340 1340 branch = repo[None].branch()
1341 1341 bheads = repo.branchheads(branch)
1342 1342
1343 1343 extra = {}
1344 1344 if opts.get('close_branch'):
1345 1345 extra['close'] = 1
1346 1346
1347 1347 if not bheads:
1348 1348 raise util.Abort(_('can only close branch heads'))
1349 1349 elif opts.get('amend'):
1350 1350 if repo.parents()[0].p1().branch() != branch and \
1351 1351 repo.parents()[0].p2().branch() != branch:
1352 1352 raise util.Abort(_('can only close branch heads'))
1353 1353
1354 1354 if opts.get('amend'):
1355 1355 if ui.configbool('ui', 'commitsubrepos'):
1356 1356 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1357 1357
1358 1358 old = repo['.']
1359 1359 if old.phase() == phases.public:
1360 1360 raise util.Abort(_('cannot amend public changesets'))
1361 1361 if len(repo[None].parents()) > 1:
1362 1362 raise util.Abort(_('cannot amend while merging'))
1363 1363 if (not obsolete._enabled) and old.children():
1364 1364 raise util.Abort(_('cannot amend changeset with children'))
1365 1365
1366 1366 e = cmdutil.commiteditor
1367 1367 if opts.get('force_editor'):
1368 1368 e = cmdutil.commitforceeditor
1369 1369
1370 1370 def commitfunc(ui, repo, message, match, opts):
1371 1371 editor = e
1372 1372 # message contains text from -m or -l, if it's empty,
1373 1373 # open the editor with the old message
1374 1374 if not message:
1375 1375 message = old.description()
1376 1376 editor = cmdutil.commitforceeditor
1377 1377 try:
1378 1378 if opts.get('secret'):
1379 1379 ui.setconfig('phases', 'new-commit', 'secret')
1380 1380
1381 1381 return repo.commit(message,
1382 1382 opts.get('user') or old.user(),
1383 1383 opts.get('date') or old.date(),
1384 1384 match,
1385 1385 editor=editor,
1386 1386 extra=extra)
1387 1387 finally:
1388 1388 ui.setconfig('phases', 'new-commit', oldcommitphase)
1389 1389
1390 1390 current = repo._bookmarkcurrent
1391 1391 marks = old.bookmarks()
1392 1392 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1393 1393 if node == old.node():
1394 1394 ui.status(_("nothing changed\n"))
1395 1395 return 1
1396 1396 elif marks:
1397 1397 ui.debug('moving bookmarks %r from %s to %s\n' %
1398 1398 (marks, old.hex(), hex(node)))
1399 1399 newmarks = repo._bookmarks
1400 1400 for bm in marks:
1401 1401 newmarks[bm] = node
1402 1402 if bm == current:
1403 1403 bookmarks.setcurrent(repo, bm)
1404 1404 newmarks.write()
1405 1405 else:
1406 1406 e = cmdutil.commiteditor
1407 1407 if opts.get('force_editor'):
1408 1408 e = cmdutil.commitforceeditor
1409 1409
1410 1410 def commitfunc(ui, repo, message, match, opts):
1411 1411 try:
1412 1412 if opts.get('secret'):
1413 1413 ui.setconfig('phases', 'new-commit', 'secret')
1414 1414
1415 1415 return repo.commit(message, opts.get('user'), opts.get('date'),
1416 1416 match, editor=e, extra=extra)
1417 1417 finally:
1418 1418 ui.setconfig('phases', 'new-commit', oldcommitphase)
1419 1419
1420 1420
1421 1421 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1422 1422
1423 1423 if not node:
1424 1424 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1425 1425 if stat[3]:
1426 1426 ui.status(_("nothing changed (%d missing files, see "
1427 1427 "'hg status')\n") % len(stat[3]))
1428 1428 else:
1429 1429 ui.status(_("nothing changed\n"))
1430 1430 return 1
1431 1431
1432 1432 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1433 1433
1434 1434 @command('copy|cp',
1435 1435 [('A', 'after', None, _('record a copy that has already occurred')),
1436 1436 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1437 1437 ] + walkopts + dryrunopts,
1438 1438 _('[OPTION]... [SOURCE]... DEST'))
1439 1439 def copy(ui, repo, *pats, **opts):
1440 1440 """mark files as copied for the next commit
1441 1441
1442 1442 Mark dest as having copies of source files. If dest is a
1443 1443 directory, copies are put in that directory. If dest is a file,
1444 1444 the source must be a single file.
1445 1445
1446 1446 By default, this command copies the contents of files as they
1447 1447 exist in the working directory. If invoked with -A/--after, the
1448 1448 operation is recorded, but no copying is performed.
1449 1449
1450 1450 This command takes effect with the next commit. To undo a copy
1451 1451 before that, see :hg:`revert`.
1452 1452
1453 1453 Returns 0 on success, 1 if errors are encountered.
1454 1454 """
1455 1455 wlock = repo.wlock(False)
1456 1456 try:
1457 1457 return cmdutil.copy(ui, repo, pats, opts)
1458 1458 finally:
1459 1459 wlock.release()
1460 1460
1461 1461 @command('debugancestor', [], _('[INDEX] REV1 REV2'))
1462 1462 def debugancestor(ui, repo, *args):
1463 1463 """find the ancestor revision of two revisions in a given index"""
1464 1464 if len(args) == 3:
1465 1465 index, rev1, rev2 = args
1466 1466 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1467 1467 lookup = r.lookup
1468 1468 elif len(args) == 2:
1469 1469 if not repo:
1470 1470 raise util.Abort(_("there is no Mercurial repository here "
1471 1471 "(.hg not found)"))
1472 1472 rev1, rev2 = args
1473 1473 r = repo.changelog
1474 1474 lookup = repo.lookup
1475 1475 else:
1476 1476 raise util.Abort(_('either two or three arguments required'))
1477 1477 a = r.ancestor(lookup(rev1), lookup(rev2))
1478 1478 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1479 1479
1480 1480 @command('debugbuilddag',
1481 1481 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1482 1482 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1483 1483 ('n', 'new-file', None, _('add new file at each rev'))],
1484 1484 _('[OPTION]... [TEXT]'))
1485 1485 def debugbuilddag(ui, repo, text=None,
1486 1486 mergeable_file=False,
1487 1487 overwritten_file=False,
1488 1488 new_file=False):
1489 1489 """builds a repo with a given DAG from scratch in the current empty repo
1490 1490
1491 1491 The description of the DAG is read from stdin if not given on the
1492 1492 command line.
1493 1493
1494 1494 Elements:
1495 1495
1496 1496 - "+n" is a linear run of n nodes based on the current default parent
1497 1497 - "." is a single node based on the current default parent
1498 1498 - "$" resets the default parent to null (implied at the start);
1499 1499 otherwise the default parent is always the last node created
1500 1500 - "<p" sets the default parent to the backref p
1501 1501 - "*p" is a fork at parent p, which is a backref
1502 1502 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1503 1503 - "/p2" is a merge of the preceding node and p2
1504 1504 - ":tag" defines a local tag for the preceding node
1505 1505 - "@branch" sets the named branch for subsequent nodes
1506 1506 - "#...\\n" is a comment up to the end of the line
1507 1507
1508 1508 Whitespace between the above elements is ignored.
1509 1509
1510 1510 A backref is either
1511 1511
1512 1512 - a number n, which references the node curr-n, where curr is the current
1513 1513 node, or
1514 1514 - the name of a local tag you placed earlier using ":tag", or
1515 1515 - empty to denote the default parent.
1516 1516
1517 1517 All string valued-elements are either strictly alphanumeric, or must
1518 1518 be enclosed in double quotes ("..."), with "\\" as escape character.
1519 1519 """
1520 1520
1521 1521 if text is None:
1522 1522 ui.status(_("reading DAG from stdin\n"))
1523 1523 text = ui.fin.read()
1524 1524
1525 1525 cl = repo.changelog
1526 1526 if len(cl) > 0:
1527 1527 raise util.Abort(_('repository is not empty'))
1528 1528
1529 1529 # determine number of revs in DAG
1530 1530 total = 0
1531 1531 for type, data in dagparser.parsedag(text):
1532 1532 if type == 'n':
1533 1533 total += 1
1534 1534
1535 1535 if mergeable_file:
1536 1536 linesperrev = 2
1537 1537 # make a file with k lines per rev
1538 1538 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1539 1539 initialmergedlines.append("")
1540 1540
1541 1541 tags = []
1542 1542
1543 1543 lock = tr = None
1544 1544 try:
1545 1545 lock = repo.lock()
1546 1546 tr = repo.transaction("builddag")
1547 1547
1548 1548 at = -1
1549 1549 atbranch = 'default'
1550 1550 nodeids = []
1551 1551 id = 0
1552 1552 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1553 1553 for type, data in dagparser.parsedag(text):
1554 1554 if type == 'n':
1555 1555 ui.note(('node %s\n' % str(data)))
1556 1556 id, ps = data
1557 1557
1558 1558 files = []
1559 1559 fctxs = {}
1560 1560
1561 1561 p2 = None
1562 1562 if mergeable_file:
1563 1563 fn = "mf"
1564 1564 p1 = repo[ps[0]]
1565 1565 if len(ps) > 1:
1566 1566 p2 = repo[ps[1]]
1567 1567 pa = p1.ancestor(p2)
1568 1568 base, local, other = [x[fn].data() for x in (pa, p1,
1569 1569 p2)]
1570 1570 m3 = simplemerge.Merge3Text(base, local, other)
1571 1571 ml = [l.strip() for l in m3.merge_lines()]
1572 1572 ml.append("")
1573 1573 elif at > 0:
1574 1574 ml = p1[fn].data().split("\n")
1575 1575 else:
1576 1576 ml = initialmergedlines
1577 1577 ml[id * linesperrev] += " r%i" % id
1578 1578 mergedtext = "\n".join(ml)
1579 1579 files.append(fn)
1580 1580 fctxs[fn] = context.memfilectx(fn, mergedtext)
1581 1581
1582 1582 if overwritten_file:
1583 1583 fn = "of"
1584 1584 files.append(fn)
1585 1585 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1586 1586
1587 1587 if new_file:
1588 1588 fn = "nf%i" % id
1589 1589 files.append(fn)
1590 1590 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1591 1591 if len(ps) > 1:
1592 1592 if not p2:
1593 1593 p2 = repo[ps[1]]
1594 1594 for fn in p2:
1595 1595 if fn.startswith("nf"):
1596 1596 files.append(fn)
1597 1597 fctxs[fn] = p2[fn]
1598 1598
1599 1599 def fctxfn(repo, cx, path):
1600 1600 return fctxs.get(path)
1601 1601
1602 1602 if len(ps) == 0 or ps[0] < 0:
1603 1603 pars = [None, None]
1604 1604 elif len(ps) == 1:
1605 1605 pars = [nodeids[ps[0]], None]
1606 1606 else:
1607 1607 pars = [nodeids[p] for p in ps]
1608 1608 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1609 1609 date=(id, 0),
1610 1610 user="debugbuilddag",
1611 1611 extra={'branch': atbranch})
1612 1612 nodeid = repo.commitctx(cx)
1613 1613 nodeids.append(nodeid)
1614 1614 at = id
1615 1615 elif type == 'l':
1616 1616 id, name = data
1617 1617 ui.note(('tag %s\n' % name))
1618 1618 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1619 1619 elif type == 'a':
1620 1620 ui.note(('branch %s\n' % data))
1621 1621 atbranch = data
1622 1622 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1623 1623 tr.close()
1624 1624
1625 1625 if tags:
1626 1626 repo.opener.write("localtags", "".join(tags))
1627 1627 finally:
1628 1628 ui.progress(_('building'), None)
1629 1629 release(tr, lock)
1630 1630
1631 1631 @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE'))
1632 1632 def debugbundle(ui, bundlepath, all=None, **opts):
1633 1633 """lists the contents of a bundle"""
1634 1634 f = hg.openpath(ui, bundlepath)
1635 1635 try:
1636 1636 gen = changegroup.readbundle(f, bundlepath)
1637 1637 if all:
1638 1638 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1639 1639
1640 1640 def showchunks(named):
1641 1641 ui.write("\n%s\n" % named)
1642 1642 chain = None
1643 1643 while True:
1644 1644 chunkdata = gen.deltachunk(chain)
1645 1645 if not chunkdata:
1646 1646 break
1647 1647 node = chunkdata['node']
1648 1648 p1 = chunkdata['p1']
1649 1649 p2 = chunkdata['p2']
1650 1650 cs = chunkdata['cs']
1651 1651 deltabase = chunkdata['deltabase']
1652 1652 delta = chunkdata['delta']
1653 1653 ui.write("%s %s %s %s %s %s\n" %
1654 1654 (hex(node), hex(p1), hex(p2),
1655 1655 hex(cs), hex(deltabase), len(delta)))
1656 1656 chain = node
1657 1657
1658 1658 chunkdata = gen.changelogheader()
1659 1659 showchunks("changelog")
1660 1660 chunkdata = gen.manifestheader()
1661 1661 showchunks("manifest")
1662 1662 while True:
1663 1663 chunkdata = gen.filelogheader()
1664 1664 if not chunkdata:
1665 1665 break
1666 1666 fname = chunkdata['filename']
1667 1667 showchunks(fname)
1668 1668 else:
1669 1669 chunkdata = gen.changelogheader()
1670 1670 chain = None
1671 1671 while True:
1672 1672 chunkdata = gen.deltachunk(chain)
1673 1673 if not chunkdata:
1674 1674 break
1675 1675 node = chunkdata['node']
1676 1676 ui.write("%s\n" % hex(node))
1677 1677 chain = node
1678 1678 finally:
1679 1679 f.close()
1680 1680
1681 1681 @command('debugcheckstate', [], '')
1682 1682 def debugcheckstate(ui, repo):
1683 1683 """validate the correctness of the current dirstate"""
1684 1684 parent1, parent2 = repo.dirstate.parents()
1685 1685 m1 = repo[parent1].manifest()
1686 1686 m2 = repo[parent2].manifest()
1687 1687 errors = 0
1688 1688 for f in repo.dirstate:
1689 1689 state = repo.dirstate[f]
1690 1690 if state in "nr" and f not in m1:
1691 1691 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1692 1692 errors += 1
1693 1693 if state in "a" and f in m1:
1694 1694 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1695 1695 errors += 1
1696 1696 if state in "m" and f not in m1 and f not in m2:
1697 1697 ui.warn(_("%s in state %s, but not in either manifest\n") %
1698 1698 (f, state))
1699 1699 errors += 1
1700 1700 for f in m1:
1701 1701 state = repo.dirstate[f]
1702 1702 if state not in "nrm":
1703 1703 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1704 1704 errors += 1
1705 1705 if errors:
1706 1706 error = _(".hg/dirstate inconsistent with current parent's manifest")
1707 1707 raise util.Abort(error)
1708 1708
1709 1709 @command('debugcommands', [], _('[COMMAND]'))
1710 1710 def debugcommands(ui, cmd='', *args):
1711 1711 """list all available commands and options"""
1712 1712 for cmd, vals in sorted(table.iteritems()):
1713 1713 cmd = cmd.split('|')[0].strip('^')
1714 1714 opts = ', '.join([i[1] for i in vals[1]])
1715 1715 ui.write('%s: %s\n' % (cmd, opts))
1716 1716
1717 1717 @command('debugcomplete',
1718 1718 [('o', 'options', None, _('show the command options'))],
1719 1719 _('[-o] CMD'))
1720 1720 def debugcomplete(ui, cmd='', **opts):
1721 1721 """returns the completion list associated with the given command"""
1722 1722
1723 1723 if opts.get('options'):
1724 1724 options = []
1725 1725 otables = [globalopts]
1726 1726 if cmd:
1727 1727 aliases, entry = cmdutil.findcmd(cmd, table, False)
1728 1728 otables.append(entry[1])
1729 1729 for t in otables:
1730 1730 for o in t:
1731 1731 if "(DEPRECATED)" in o[3]:
1732 1732 continue
1733 1733 if o[0]:
1734 1734 options.append('-%s' % o[0])
1735 1735 options.append('--%s' % o[1])
1736 1736 ui.write("%s\n" % "\n".join(options))
1737 1737 return
1738 1738
1739 1739 cmdlist = cmdutil.findpossible(cmd, table)
1740 1740 if ui.verbose:
1741 1741 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1742 1742 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1743 1743
1744 1744 @command('debugdag',
1745 1745 [('t', 'tags', None, _('use tags as labels')),
1746 1746 ('b', 'branches', None, _('annotate with branch names')),
1747 1747 ('', 'dots', None, _('use dots for runs')),
1748 1748 ('s', 'spaces', None, _('separate elements by spaces'))],
1749 1749 _('[OPTION]... [FILE [REV]...]'))
1750 1750 def debugdag(ui, repo, file_=None, *revs, **opts):
1751 1751 """format the changelog or an index DAG as a concise textual description
1752 1752
1753 1753 If you pass a revlog index, the revlog's DAG is emitted. If you list
1754 1754 revision numbers, they get labeled in the output as rN.
1755 1755
1756 1756 Otherwise, the changelog DAG of the current repo is emitted.
1757 1757 """
1758 1758 spaces = opts.get('spaces')
1759 1759 dots = opts.get('dots')
1760 1760 if file_:
1761 1761 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1762 1762 revs = set((int(r) for r in revs))
1763 1763 def events():
1764 1764 for r in rlog:
1765 1765 yield 'n', (r, list(set(p for p in rlog.parentrevs(r)
1766 1766 if p != -1)))
1767 1767 if r in revs:
1768 1768 yield 'l', (r, "r%i" % r)
1769 1769 elif repo:
1770 1770 cl = repo.changelog
1771 1771 tags = opts.get('tags')
1772 1772 branches = opts.get('branches')
1773 1773 if tags:
1774 1774 labels = {}
1775 1775 for l, n in repo.tags().items():
1776 1776 labels.setdefault(cl.rev(n), []).append(l)
1777 1777 def events():
1778 1778 b = "default"
1779 1779 for r in cl:
1780 1780 if branches:
1781 1781 newb = cl.read(cl.node(r))[5]['branch']
1782 1782 if newb != b:
1783 1783 yield 'a', newb
1784 1784 b = newb
1785 1785 yield 'n', (r, list(set(p for p in cl.parentrevs(r)
1786 1786 if p != -1)))
1787 1787 if tags:
1788 1788 ls = labels.get(r)
1789 1789 if ls:
1790 1790 for l in ls:
1791 1791 yield 'l', (r, l)
1792 1792 else:
1793 1793 raise util.Abort(_('need repo for changelog dag'))
1794 1794
1795 1795 for line in dagparser.dagtextlines(events(),
1796 1796 addspaces=spaces,
1797 1797 wraplabels=True,
1798 1798 wrapannotations=True,
1799 1799 wrapnonlinear=dots,
1800 1800 usedots=dots,
1801 1801 maxlinewidth=70):
1802 1802 ui.write(line)
1803 1803 ui.write("\n")
1804 1804
1805 1805 @command('debugdata',
1806 1806 [('c', 'changelog', False, _('open changelog')),
1807 1807 ('m', 'manifest', False, _('open manifest'))],
1808 1808 _('-c|-m|FILE REV'))
1809 1809 def debugdata(ui, repo, file_, rev = None, **opts):
1810 1810 """dump the contents of a data file revision"""
1811 1811 if opts.get('changelog') or opts.get('manifest'):
1812 1812 file_, rev = None, file_
1813 1813 elif rev is None:
1814 1814 raise error.CommandError('debugdata', _('invalid arguments'))
1815 1815 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
1816 1816 try:
1817 1817 ui.write(r.revision(r.lookup(rev)))
1818 1818 except KeyError:
1819 1819 raise util.Abort(_('invalid revision identifier %s') % rev)
1820 1820
1821 1821 @command('debugdate',
1822 1822 [('e', 'extended', None, _('try extended date formats'))],
1823 1823 _('[-e] DATE [RANGE]'))
1824 1824 def debugdate(ui, date, range=None, **opts):
1825 1825 """parse and display a date"""
1826 1826 if opts["extended"]:
1827 1827 d = util.parsedate(date, util.extendeddateformats)
1828 1828 else:
1829 1829 d = util.parsedate(date)
1830 1830 ui.write(("internal: %s %s\n") % d)
1831 1831 ui.write(("standard: %s\n") % util.datestr(d))
1832 1832 if range:
1833 1833 m = util.matchdate(range)
1834 1834 ui.write(("match: %s\n") % m(d[0]))
1835 1835
1836 1836 @command('debugdiscovery',
1837 1837 [('', 'old', None, _('use old-style discovery')),
1838 1838 ('', 'nonheads', None,
1839 1839 _('use old-style discovery with non-heads included')),
1840 1840 ] + remoteopts,
1841 1841 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
1842 1842 def debugdiscovery(ui, repo, remoteurl="default", **opts):
1843 1843 """runs the changeset discovery protocol in isolation"""
1844 1844 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
1845 1845 opts.get('branch'))
1846 1846 remote = hg.peer(repo, opts, remoteurl)
1847 1847 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
1848 1848
1849 1849 # make sure tests are repeatable
1850 1850 random.seed(12323)
1851 1851
1852 1852 def doit(localheads, remoteheads, remote=remote):
1853 1853 if opts.get('old'):
1854 1854 if localheads:
1855 1855 raise util.Abort('cannot use localheads with old style '
1856 1856 'discovery')
1857 1857 if not util.safehasattr(remote, 'branches'):
1858 1858 # enable in-client legacy support
1859 1859 remote = localrepo.locallegacypeer(remote.local())
1860 1860 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
1861 1861 force=True)
1862 1862 common = set(common)
1863 1863 if not opts.get('nonheads'):
1864 1864 ui.write(("unpruned common: %s\n") %
1865 1865 " ".join(sorted(short(n) for n in common)))
1866 1866 dag = dagutil.revlogdag(repo.changelog)
1867 1867 all = dag.ancestorset(dag.internalizeall(common))
1868 1868 common = dag.externalizeall(dag.headsetofconnecteds(all))
1869 1869 else:
1870 1870 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
1871 1871 common = set(common)
1872 1872 rheads = set(hds)
1873 1873 lheads = set(repo.heads())
1874 1874 ui.write(("common heads: %s\n") %
1875 1875 " ".join(sorted(short(n) for n in common)))
1876 1876 if lheads <= common:
1877 1877 ui.write(("local is subset\n"))
1878 1878 elif rheads <= common:
1879 1879 ui.write(("remote is subset\n"))
1880 1880
1881 1881 serverlogs = opts.get('serverlog')
1882 1882 if serverlogs:
1883 1883 for filename in serverlogs:
1884 1884 logfile = open(filename, 'r')
1885 1885 try:
1886 1886 line = logfile.readline()
1887 1887 while line:
1888 1888 parts = line.strip().split(';')
1889 1889 op = parts[1]
1890 1890 if op == 'cg':
1891 1891 pass
1892 1892 elif op == 'cgss':
1893 1893 doit(parts[2].split(' '), parts[3].split(' '))
1894 1894 elif op == 'unb':
1895 1895 doit(parts[3].split(' '), parts[2].split(' '))
1896 1896 line = logfile.readline()
1897 1897 finally:
1898 1898 logfile.close()
1899 1899
1900 1900 else:
1901 1901 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
1902 1902 opts.get('remote_head'))
1903 1903 localrevs = opts.get('local_head')
1904 1904 doit(localrevs, remoterevs)
1905 1905
1906 1906 @command('debugfileset',
1907 1907 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
1908 1908 _('[-r REV] FILESPEC'))
1909 1909 def debugfileset(ui, repo, expr, **opts):
1910 1910 '''parse and apply a fileset specification'''
1911 1911 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
1912 1912 if ui.verbose:
1913 1913 tree = fileset.parse(expr)[0]
1914 1914 ui.note(tree, "\n")
1915 1915
1916 1916 for f in fileset.getfileset(ctx, expr):
1917 1917 ui.write("%s\n" % f)
1918 1918
1919 1919 @command('debugfsinfo', [], _('[PATH]'))
1920 1920 def debugfsinfo(ui, path = "."):
1921 1921 """show information detected about current filesystem"""
1922 1922 util.writefile('.debugfsinfo', '')
1923 1923 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
1924 1924 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
1925 1925 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
1926 1926 and 'yes' or 'no'))
1927 1927 os.unlink('.debugfsinfo')
1928 1928
1929 1929 @command('debuggetbundle',
1930 1930 [('H', 'head', [], _('id of head node'), _('ID')),
1931 1931 ('C', 'common', [], _('id of common node'), _('ID')),
1932 1932 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
1933 1933 _('REPO FILE [-H|-C ID]...'))
1934 1934 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
1935 1935 """retrieves a bundle from a repo
1936 1936
1937 1937 Every ID must be a full-length hex node id string. Saves the bundle to the
1938 1938 given file.
1939 1939 """
1940 1940 repo = hg.peer(ui, opts, repopath)
1941 1941 if not repo.capable('getbundle'):
1942 1942 raise util.Abort("getbundle() not supported by target repository")
1943 1943 args = {}
1944 1944 if common:
1945 1945 args['common'] = [bin(s) for s in common]
1946 1946 if head:
1947 1947 args['heads'] = [bin(s) for s in head]
1948 1948 # TODO: get desired bundlecaps from command line.
1949 1949 args['bundlecaps'] = None
1950 1950 bundle = repo.getbundle('debug', **args)
1951 1951
1952 1952 bundletype = opts.get('type', 'bzip2').lower()
1953 1953 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1954 1954 bundletype = btypes.get(bundletype)
1955 1955 if bundletype not in changegroup.bundletypes:
1956 1956 raise util.Abort(_('unknown bundle type specified with --type'))
1957 1957 changegroup.writebundle(bundle, bundlepath, bundletype)
1958 1958
1959 1959 @command('debugignore', [], '')
1960 1960 def debugignore(ui, repo, *values, **opts):
1961 1961 """display the combined ignore pattern"""
1962 1962 ignore = repo.dirstate._ignore
1963 1963 includepat = getattr(ignore, 'includepat', None)
1964 1964 if includepat is not None:
1965 1965 ui.write("%s\n" % includepat)
1966 1966 else:
1967 1967 raise util.Abort(_("no ignore patterns found"))
1968 1968
1969 1969 @command('debugindex',
1970 1970 [('c', 'changelog', False, _('open changelog')),
1971 1971 ('m', 'manifest', False, _('open manifest')),
1972 1972 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
1973 1973 _('[-f FORMAT] -c|-m|FILE'))
1974 1974 def debugindex(ui, repo, file_ = None, **opts):
1975 1975 """dump the contents of an index file"""
1976 1976 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
1977 1977 format = opts.get('format', 0)
1978 1978 if format not in (0, 1):
1979 1979 raise util.Abort(_("unknown format %d") % format)
1980 1980
1981 1981 generaldelta = r.version & revlog.REVLOGGENERALDELTA
1982 1982 if generaldelta:
1983 1983 basehdr = ' delta'
1984 1984 else:
1985 1985 basehdr = ' base'
1986 1986
1987 1987 if format == 0:
1988 1988 ui.write(" rev offset length " + basehdr + " linkrev"
1989 1989 " nodeid p1 p2\n")
1990 1990 elif format == 1:
1991 1991 ui.write(" rev flag offset length"
1992 1992 " size " + basehdr + " link p1 p2"
1993 1993 " nodeid\n")
1994 1994
1995 1995 for i in r:
1996 1996 node = r.node(i)
1997 1997 if generaldelta:
1998 1998 base = r.deltaparent(i)
1999 1999 else:
2000 2000 base = r.chainbase(i)
2001 2001 if format == 0:
2002 2002 try:
2003 2003 pp = r.parents(node)
2004 2004 except Exception:
2005 2005 pp = [nullid, nullid]
2006 2006 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2007 2007 i, r.start(i), r.length(i), base, r.linkrev(i),
2008 2008 short(node), short(pp[0]), short(pp[1])))
2009 2009 elif format == 1:
2010 2010 pr = r.parentrevs(i)
2011 2011 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2012 2012 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2013 2013 base, r.linkrev(i), pr[0], pr[1], short(node)))
2014 2014
2015 2015 @command('debugindexdot', [], _('FILE'))
2016 2016 def debugindexdot(ui, repo, file_):
2017 2017 """dump an index DAG as a graphviz dot file"""
2018 2018 r = None
2019 2019 if repo:
2020 2020 filelog = repo.file(file_)
2021 2021 if len(filelog):
2022 2022 r = filelog
2023 2023 if not r:
2024 2024 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2025 2025 ui.write(("digraph G {\n"))
2026 2026 for i in r:
2027 2027 node = r.node(i)
2028 2028 pp = r.parents(node)
2029 2029 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2030 2030 if pp[1] != nullid:
2031 2031 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2032 2032 ui.write("}\n")
2033 2033
2034 2034 @command('debuginstall', [], '')
2035 2035 def debuginstall(ui):
2036 2036 '''test Mercurial installation
2037 2037
2038 2038 Returns 0 on success.
2039 2039 '''
2040 2040
2041 2041 def writetemp(contents):
2042 2042 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2043 2043 f = os.fdopen(fd, "wb")
2044 2044 f.write(contents)
2045 2045 f.close()
2046 2046 return name
2047 2047
2048 2048 problems = 0
2049 2049
2050 2050 # encoding
2051 2051 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2052 2052 try:
2053 2053 encoding.fromlocal("test")
2054 2054 except util.Abort, inst:
2055 2055 ui.write(" %s\n" % inst)
2056 2056 ui.write(_(" (check that your locale is properly set)\n"))
2057 2057 problems += 1
2058 2058
2059 2059 # Python lib
2060 2060 ui.status(_("checking Python lib (%s)...\n")
2061 2061 % os.path.dirname(os.__file__))
2062 2062
2063 2063 # compiled modules
2064 2064 ui.status(_("checking installed modules (%s)...\n")
2065 2065 % os.path.dirname(__file__))
2066 2066 try:
2067 2067 import bdiff, mpatch, base85, osutil
2068 2068 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2069 2069 except Exception, inst:
2070 2070 ui.write(" %s\n" % inst)
2071 2071 ui.write(_(" One or more extensions could not be found"))
2072 2072 ui.write(_(" (check that you compiled the extensions)\n"))
2073 2073 problems += 1
2074 2074
2075 2075 # templates
2076 2076 import templater
2077 2077 p = templater.templatepath()
2078 2078 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2079 2079 try:
2080 2080 templater.templater(templater.templatepath("map-cmdline.default"))
2081 2081 except Exception, inst:
2082 2082 ui.write(" %s\n" % inst)
2083 2083 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2084 2084 problems += 1
2085 2085
2086 2086 # editor
2087 2087 ui.status(_("checking commit editor...\n"))
2088 2088 editor = ui.geteditor()
2089 2089 cmdpath = util.findexe(editor) or util.findexe(editor.split()[0])
2090 2090 if not cmdpath:
2091 2091 if editor == 'vi':
2092 2092 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2093 2093 ui.write(_(" (specify a commit editor in your configuration"
2094 2094 " file)\n"))
2095 2095 else:
2096 2096 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2097 2097 ui.write(_(" (specify a commit editor in your configuration"
2098 2098 " file)\n"))
2099 2099 problems += 1
2100 2100
2101 2101 # check username
2102 2102 ui.status(_("checking username...\n"))
2103 2103 try:
2104 2104 ui.username()
2105 2105 except util.Abort, e:
2106 2106 ui.write(" %s\n" % e)
2107 2107 ui.write(_(" (specify a username in your configuration file)\n"))
2108 2108 problems += 1
2109 2109
2110 2110 if not problems:
2111 2111 ui.status(_("no problems detected\n"))
2112 2112 else:
2113 2113 ui.write(_("%s problems detected,"
2114 2114 " please check your install!\n") % problems)
2115 2115
2116 2116 return problems
2117 2117
2118 2118 @command('debugknown', [], _('REPO ID...'))
2119 2119 def debugknown(ui, repopath, *ids, **opts):
2120 2120 """test whether node ids are known to a repo
2121 2121
2122 2122 Every ID must be a full-length hex node id string. Returns a list of 0s
2123 2123 and 1s indicating unknown/known.
2124 2124 """
2125 2125 repo = hg.peer(ui, opts, repopath)
2126 2126 if not repo.capable('known'):
2127 2127 raise util.Abort("known() not supported by target repository")
2128 2128 flags = repo.known([bin(s) for s in ids])
2129 2129 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2130 2130
2131 2131 @command('debuglabelcomplete', [], _('LABEL...'))
2132 2132 def debuglabelcomplete(ui, repo, *args):
2133 2133 '''complete "labels" - tags, open branch names, bookmark names'''
2134 2134
2135 2135 labels = set()
2136 2136 labels.update(t[0] for t in repo.tagslist())
2137 2137 labels.update(repo._bookmarks.keys())
2138 2138 for heads in repo.branchmap().itervalues():
2139 2139 for h in heads:
2140 2140 ctx = repo[h]
2141 2141 if not ctx.closesbranch():
2142 2142 labels.add(ctx.branch())
2143 2143 completions = set()
2144 2144 if not args:
2145 2145 args = ['']
2146 2146 for a in args:
2147 2147 completions.update(l for l in labels if l.startswith(a))
2148 2148 ui.write('\n'.join(sorted(completions)))
2149 2149 ui.write('\n')
2150 2150
2151 2151 @command('debugobsolete',
2152 2152 [('', 'flags', 0, _('markers flag')),
2153 2153 ] + commitopts2,
2154 2154 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2155 2155 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2156 2156 """create arbitrary obsolete marker
2157 2157
2158 2158 With no arguments, displays the list of obsolescence markers."""
2159 2159 def parsenodeid(s):
2160 2160 try:
2161 2161 # We do not use revsingle/revrange functions here to accept
2162 2162 # arbitrary node identifiers, possibly not present in the
2163 2163 # local repository.
2164 2164 n = bin(s)
2165 2165 if len(n) != len(nullid):
2166 2166 raise TypeError()
2167 2167 return n
2168 2168 except TypeError:
2169 2169 raise util.Abort('changeset references must be full hexadecimal '
2170 2170 'node identifiers')
2171 2171
2172 2172 if precursor is not None:
2173 2173 metadata = {}
2174 2174 if 'date' in opts:
2175 2175 metadata['date'] = opts['date']
2176 2176 metadata['user'] = opts['user'] or ui.username()
2177 2177 succs = tuple(parsenodeid(succ) for succ in successors)
2178 2178 l = repo.lock()
2179 2179 try:
2180 2180 tr = repo.transaction('debugobsolete')
2181 2181 try:
2182 2182 repo.obsstore.create(tr, parsenodeid(precursor), succs,
2183 2183 opts['flags'], metadata)
2184 2184 tr.close()
2185 2185 finally:
2186 2186 tr.release()
2187 2187 finally:
2188 2188 l.release()
2189 2189 else:
2190 2190 for m in obsolete.allmarkers(repo):
2191 2191 ui.write(hex(m.precnode()))
2192 2192 for repl in m.succnodes():
2193 2193 ui.write(' ')
2194 2194 ui.write(hex(repl))
2195 2195 ui.write(' %X ' % m._data[2])
2196 2196 ui.write('{%s}' % (', '.join('%r: %r' % t for t in
2197 2197 sorted(m.metadata().items()))))
2198 2198 ui.write('\n')
2199 2199
2200 2200 @command('debugpathcomplete',
2201 2201 [('f', 'full', None, _('complete an entire path')),
2202 2202 ('n', 'normal', None, _('show only normal files')),
2203 2203 ('a', 'added', None, _('show only added files')),
2204 2204 ('r', 'removed', None, _('show only removed files'))],
2205 2205 _('FILESPEC...'))
2206 2206 def debugpathcomplete(ui, repo, *specs, **opts):
2207 2207 '''complete part or all of a tracked path
2208 2208
2209 2209 This command supports shells that offer path name completion. It
2210 2210 currently completes only files already known to the dirstate.
2211 2211
2212 2212 Completion extends only to the next path segment unless
2213 2213 --full is specified, in which case entire paths are used.'''
2214 2214
2215 2215 def complete(path, acceptable):
2216 2216 dirstate = repo.dirstate
2217 2217 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2218 2218 rootdir = repo.root + os.sep
2219 2219 if spec != repo.root and not spec.startswith(rootdir):
2220 2220 return [], []
2221 2221 if os.path.isdir(spec):
2222 2222 spec += '/'
2223 2223 spec = spec[len(rootdir):]
2224 2224 fixpaths = os.sep != '/'
2225 2225 if fixpaths:
2226 2226 spec = spec.replace(os.sep, '/')
2227 2227 speclen = len(spec)
2228 2228 fullpaths = opts['full']
2229 2229 files, dirs = set(), set()
2230 2230 adddir, addfile = dirs.add, files.add
2231 2231 for f, st in dirstate.iteritems():
2232 2232 if f.startswith(spec) and st[0] in acceptable:
2233 2233 if fixpaths:
2234 2234 f = f.replace('/', os.sep)
2235 2235 if fullpaths:
2236 2236 addfile(f)
2237 2237 continue
2238 2238 s = f.find(os.sep, speclen)
2239 2239 if s >= 0:
2240 2240 adddir(f[:s + 1])
2241 2241 else:
2242 2242 addfile(f)
2243 2243 return files, dirs
2244 2244
2245 2245 acceptable = ''
2246 2246 if opts['normal']:
2247 2247 acceptable += 'nm'
2248 2248 if opts['added']:
2249 2249 acceptable += 'a'
2250 2250 if opts['removed']:
2251 2251 acceptable += 'r'
2252 2252 cwd = repo.getcwd()
2253 2253 if not specs:
2254 2254 specs = ['.']
2255 2255
2256 2256 files, dirs = set(), set()
2257 2257 for spec in specs:
2258 2258 f, d = complete(spec, acceptable or 'nmar')
2259 2259 files.update(f)
2260 2260 dirs.update(d)
2261 2261 if not files and len(dirs) == 1:
2262 2262 # force the shell to consider a completion that matches one
2263 2263 # directory and zero files to be ambiguous
2264 2264 dirs.add(iter(dirs).next() + '.')
2265 2265 files.update(dirs)
2266 2266 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2267 2267 ui.write('\n')
2268 2268
2269 2269 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'))
2270 2270 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2271 2271 '''access the pushkey key/value protocol
2272 2272
2273 2273 With two args, list the keys in the given namespace.
2274 2274
2275 2275 With five args, set a key to new if it currently is set to old.
2276 2276 Reports success or failure.
2277 2277 '''
2278 2278
2279 2279 target = hg.peer(ui, {}, repopath)
2280 2280 if keyinfo:
2281 2281 key, old, new = keyinfo
2282 2282 r = target.pushkey(namespace, key, old, new)
2283 2283 ui.status(str(r) + '\n')
2284 2284 return not r
2285 2285 else:
2286 2286 for k, v in sorted(target.listkeys(namespace).iteritems()):
2287 2287 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2288 2288 v.encode('string-escape')))
2289 2289
2290 2290 @command('debugpvec', [], _('A B'))
2291 2291 def debugpvec(ui, repo, a, b=None):
2292 2292 ca = scmutil.revsingle(repo, a)
2293 2293 cb = scmutil.revsingle(repo, b)
2294 2294 pa = pvec.ctxpvec(ca)
2295 2295 pb = pvec.ctxpvec(cb)
2296 2296 if pa == pb:
2297 2297 rel = "="
2298 2298 elif pa > pb:
2299 2299 rel = ">"
2300 2300 elif pa < pb:
2301 2301 rel = "<"
2302 2302 elif pa | pb:
2303 2303 rel = "|"
2304 2304 ui.write(_("a: %s\n") % pa)
2305 2305 ui.write(_("b: %s\n") % pb)
2306 2306 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2307 2307 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2308 2308 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2309 2309 pa.distance(pb), rel))
2310 2310
2311 2311 @command('debugrebuilddirstate|debugrebuildstate',
2312 2312 [('r', 'rev', '', _('revision to rebuild to'), _('REV'))],
2313 2313 _('[-r REV]'))
2314 2314 def debugrebuilddirstate(ui, repo, rev):
2315 2315 """rebuild the dirstate as it would look like for the given revision
2316 2316
2317 2317 If no revision is specified the first current parent will be used.
2318 2318
2319 2319 The dirstate will be set to the files of the given revision.
2320 2320 The actual working directory content or existing dirstate
2321 2321 information such as adds or removes is not considered.
2322 2322
2323 2323 One use of this command is to make the next :hg:`status` invocation
2324 2324 check the actual file content.
2325 2325 """
2326 2326 ctx = scmutil.revsingle(repo, rev)
2327 2327 wlock = repo.wlock()
2328 2328 try:
2329 2329 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
2330 2330 finally:
2331 2331 wlock.release()
2332 2332
2333 2333 @command('debugrename',
2334 2334 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2335 2335 _('[-r REV] FILE'))
2336 2336 def debugrename(ui, repo, file1, *pats, **opts):
2337 2337 """dump rename information"""
2338 2338
2339 2339 ctx = scmutil.revsingle(repo, opts.get('rev'))
2340 2340 m = scmutil.match(ctx, (file1,) + pats, opts)
2341 2341 for abs in ctx.walk(m):
2342 2342 fctx = ctx[abs]
2343 2343 o = fctx.filelog().renamed(fctx.filenode())
2344 2344 rel = m.rel(abs)
2345 2345 if o:
2346 2346 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2347 2347 else:
2348 2348 ui.write(_("%s not renamed\n") % rel)
2349 2349
2350 2350 @command('debugrevlog',
2351 2351 [('c', 'changelog', False, _('open changelog')),
2352 2352 ('m', 'manifest', False, _('open manifest')),
2353 2353 ('d', 'dump', False, _('dump index data'))],
2354 2354 _('-c|-m|FILE'))
2355 2355 def debugrevlog(ui, repo, file_ = None, **opts):
2356 2356 """show data and statistics about a revlog"""
2357 2357 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2358 2358
2359 2359 if opts.get("dump"):
2360 2360 numrevs = len(r)
2361 2361 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2362 2362 " rawsize totalsize compression heads\n")
2363 2363 ts = 0
2364 2364 heads = set()
2365 2365 for rev in xrange(numrevs):
2366 2366 dbase = r.deltaparent(rev)
2367 2367 if dbase == -1:
2368 2368 dbase = rev
2369 2369 cbase = r.chainbase(rev)
2370 2370 p1, p2 = r.parentrevs(rev)
2371 2371 rs = r.rawsize(rev)
2372 2372 ts = ts + rs
2373 2373 heads -= set(r.parentrevs(rev))
2374 2374 heads.add(rev)
2375 2375 ui.write("%d %d %d %d %d %d %d %d %d %d %d %d %d\n" %
2376 2376 (rev, p1, p2, r.start(rev), r.end(rev),
2377 2377 r.start(dbase), r.start(cbase),
2378 2378 r.start(p1), r.start(p2),
2379 2379 rs, ts, ts / r.end(rev), len(heads)))
2380 2380 return 0
2381 2381
2382 2382 v = r.version
2383 2383 format = v & 0xFFFF
2384 2384 flags = []
2385 2385 gdelta = False
2386 2386 if v & revlog.REVLOGNGINLINEDATA:
2387 2387 flags.append('inline')
2388 2388 if v & revlog.REVLOGGENERALDELTA:
2389 2389 gdelta = True
2390 2390 flags.append('generaldelta')
2391 2391 if not flags:
2392 2392 flags = ['(none)']
2393 2393
2394 2394 nummerges = 0
2395 2395 numfull = 0
2396 2396 numprev = 0
2397 2397 nump1 = 0
2398 2398 nump2 = 0
2399 2399 numother = 0
2400 2400 nump1prev = 0
2401 2401 nump2prev = 0
2402 2402 chainlengths = []
2403 2403
2404 2404 datasize = [None, 0, 0L]
2405 2405 fullsize = [None, 0, 0L]
2406 2406 deltasize = [None, 0, 0L]
2407 2407
2408 2408 def addsize(size, l):
2409 2409 if l[0] is None or size < l[0]:
2410 2410 l[0] = size
2411 2411 if size > l[1]:
2412 2412 l[1] = size
2413 2413 l[2] += size
2414 2414
2415 2415 numrevs = len(r)
2416 2416 for rev in xrange(numrevs):
2417 2417 p1, p2 = r.parentrevs(rev)
2418 2418 delta = r.deltaparent(rev)
2419 2419 if format > 0:
2420 2420 addsize(r.rawsize(rev), datasize)
2421 2421 if p2 != nullrev:
2422 2422 nummerges += 1
2423 2423 size = r.length(rev)
2424 2424 if delta == nullrev:
2425 2425 chainlengths.append(0)
2426 2426 numfull += 1
2427 2427 addsize(size, fullsize)
2428 2428 else:
2429 2429 chainlengths.append(chainlengths[delta] + 1)
2430 2430 addsize(size, deltasize)
2431 2431 if delta == rev - 1:
2432 2432 numprev += 1
2433 2433 if delta == p1:
2434 2434 nump1prev += 1
2435 2435 elif delta == p2:
2436 2436 nump2prev += 1
2437 2437 elif delta == p1:
2438 2438 nump1 += 1
2439 2439 elif delta == p2:
2440 2440 nump2 += 1
2441 2441 elif delta != nullrev:
2442 2442 numother += 1
2443 2443
2444 2444 # Adjust size min value for empty cases
2445 2445 for size in (datasize, fullsize, deltasize):
2446 2446 if size[0] is None:
2447 2447 size[0] = 0
2448 2448
2449 2449 numdeltas = numrevs - numfull
2450 2450 numoprev = numprev - nump1prev - nump2prev
2451 2451 totalrawsize = datasize[2]
2452 2452 datasize[2] /= numrevs
2453 2453 fulltotal = fullsize[2]
2454 2454 fullsize[2] /= numfull
2455 2455 deltatotal = deltasize[2]
2456 2456 if numrevs - numfull > 0:
2457 2457 deltasize[2] /= numrevs - numfull
2458 2458 totalsize = fulltotal + deltatotal
2459 2459 avgchainlen = sum(chainlengths) / numrevs
2460 2460 compratio = totalrawsize / totalsize
2461 2461
2462 2462 basedfmtstr = '%%%dd\n'
2463 2463 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2464 2464
2465 2465 def dfmtstr(max):
2466 2466 return basedfmtstr % len(str(max))
2467 2467 def pcfmtstr(max, padding=0):
2468 2468 return basepcfmtstr % (len(str(max)), ' ' * padding)
2469 2469
2470 2470 def pcfmt(value, total):
2471 2471 return (value, 100 * float(value) / total)
2472 2472
2473 2473 ui.write(('format : %d\n') % format)
2474 2474 ui.write(('flags : %s\n') % ', '.join(flags))
2475 2475
2476 2476 ui.write('\n')
2477 2477 fmt = pcfmtstr(totalsize)
2478 2478 fmt2 = dfmtstr(totalsize)
2479 2479 ui.write(('revisions : ') + fmt2 % numrevs)
2480 2480 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2481 2481 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2482 2482 ui.write(('revisions : ') + fmt2 % numrevs)
2483 2483 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2484 2484 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2485 2485 ui.write(('revision size : ') + fmt2 % totalsize)
2486 2486 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2487 2487 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2488 2488
2489 2489 ui.write('\n')
2490 2490 fmt = dfmtstr(max(avgchainlen, compratio))
2491 2491 ui.write(('avg chain length : ') + fmt % avgchainlen)
2492 2492 ui.write(('compression ratio : ') + fmt % compratio)
2493 2493
2494 2494 if format > 0:
2495 2495 ui.write('\n')
2496 2496 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2497 2497 % tuple(datasize))
2498 2498 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2499 2499 % tuple(fullsize))
2500 2500 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2501 2501 % tuple(deltasize))
2502 2502
2503 2503 if numdeltas > 0:
2504 2504 ui.write('\n')
2505 2505 fmt = pcfmtstr(numdeltas)
2506 2506 fmt2 = pcfmtstr(numdeltas, 4)
2507 2507 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2508 2508 if numprev > 0:
2509 2509 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2510 2510 numprev))
2511 2511 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2512 2512 numprev))
2513 2513 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2514 2514 numprev))
2515 2515 if gdelta:
2516 2516 ui.write(('deltas against p1 : ')
2517 2517 + fmt % pcfmt(nump1, numdeltas))
2518 2518 ui.write(('deltas against p2 : ')
2519 2519 + fmt % pcfmt(nump2, numdeltas))
2520 2520 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2521 2521 numdeltas))
2522 2522
2523 2523 @command('debugrevspec', [], ('REVSPEC'))
2524 2524 def debugrevspec(ui, repo, expr):
2525 2525 """parse and apply a revision specification
2526 2526
2527 2527 Use --verbose to print the parsed tree before and after aliases
2528 2528 expansion.
2529 2529 """
2530 2530 if ui.verbose:
2531 2531 tree = revset.parse(expr)[0]
2532 2532 ui.note(revset.prettyformat(tree), "\n")
2533 2533 newtree = revset.findaliases(ui, tree)
2534 2534 if newtree != tree:
2535 2535 ui.note(revset.prettyformat(newtree), "\n")
2536 2536 func = revset.match(ui, expr)
2537 2537 for c in func(repo, range(len(repo))):
2538 2538 ui.write("%s\n" % c)
2539 2539
2540 2540 @command('debugsetparents', [], _('REV1 [REV2]'))
2541 2541 def debugsetparents(ui, repo, rev1, rev2=None):
2542 2542 """manually set the parents of the current working directory
2543 2543
2544 2544 This is useful for writing repository conversion tools, but should
2545 2545 be used with care.
2546 2546
2547 2547 Returns 0 on success.
2548 2548 """
2549 2549
2550 2550 r1 = scmutil.revsingle(repo, rev1).node()
2551 2551 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2552 2552
2553 2553 wlock = repo.wlock()
2554 2554 try:
2555 2555 repo.setparents(r1, r2)
2556 2556 finally:
2557 2557 wlock.release()
2558 2558
2559 2559 @command('debugdirstate|debugstate',
2560 2560 [('', 'nodates', None, _('do not display the saved mtime')),
2561 2561 ('', 'datesort', None, _('sort by saved mtime'))],
2562 2562 _('[OPTION]...'))
2563 2563 def debugstate(ui, repo, nodates=None, datesort=None):
2564 2564 """show the contents of the current dirstate"""
2565 2565 timestr = ""
2566 2566 showdate = not nodates
2567 2567 if datesort:
2568 2568 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
2569 2569 else:
2570 2570 keyfunc = None # sort by filename
2571 2571 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
2572 2572 if showdate:
2573 2573 if ent[3] == -1:
2574 2574 # Pad or slice to locale representation
2575 2575 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
2576 2576 time.localtime(0)))
2577 2577 timestr = 'unset'
2578 2578 timestr = (timestr[:locale_len] +
2579 2579 ' ' * (locale_len - len(timestr)))
2580 2580 else:
2581 2581 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
2582 2582 time.localtime(ent[3]))
2583 2583 if ent[1] & 020000:
2584 2584 mode = 'lnk'
2585 2585 else:
2586 2586 mode = '%3o' % (ent[1] & 0777 & ~util.umask)
2587 2587 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
2588 2588 for f in repo.dirstate.copies():
2589 2589 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
2590 2590
2591 2591 @command('debugsub',
2592 2592 [('r', 'rev', '',
2593 2593 _('revision to check'), _('REV'))],
2594 2594 _('[-r REV] [REV]'))
2595 2595 def debugsub(ui, repo, rev=None):
2596 2596 ctx = scmutil.revsingle(repo, rev, None)
2597 2597 for k, v in sorted(ctx.substate.items()):
2598 2598 ui.write(('path %s\n') % k)
2599 2599 ui.write((' source %s\n') % v[0])
2600 2600 ui.write((' revision %s\n') % v[1])
2601 2601
2602 2602 @command('debugsuccessorssets',
2603 2603 [],
2604 2604 _('[REV]'))
2605 2605 def debugsuccessorssets(ui, repo, *revs):
2606 2606 """show set of successors for revision
2607 2607
2608 2608 A successors set of changeset A is a consistent group of revisions that
2609 2609 succeed A. It contains non-obsolete changesets only.
2610 2610
2611 2611 In most cases a changeset A has a single successors set containing a single
2612 2612 successor (changeset A replaced by A').
2613 2613
2614 2614 A changeset that is made obsolete with no successors are called "pruned".
2615 2615 Such changesets have no successors sets at all.
2616 2616
2617 2617 A changeset that has been "split" will have a successors set containing
2618 2618 more than one successor.
2619 2619
2620 2620 A changeset that has been rewritten in multiple different ways is called
2621 2621 "divergent". Such changesets have multiple successor sets (each of which
2622 2622 may also be split, i.e. have multiple successors).
2623 2623
2624 2624 Results are displayed as follows::
2625 2625
2626 2626 <rev1>
2627 2627 <successors-1A>
2628 2628 <rev2>
2629 2629 <successors-2A>
2630 2630 <successors-2B1> <successors-2B2> <successors-2B3>
2631 2631
2632 2632 Here rev2 has two possible (i.e. divergent) successors sets. The first
2633 2633 holds one element, whereas the second holds three (i.e. the changeset has
2634 2634 been split).
2635 2635 """
2636 2636 # passed to successorssets caching computation from one call to another
2637 2637 cache = {}
2638 2638 ctx2str = str
2639 2639 node2str = short
2640 2640 if ui.debug():
2641 2641 def ctx2str(ctx):
2642 2642 return ctx.hex()
2643 2643 node2str = hex
2644 2644 for rev in scmutil.revrange(repo, revs):
2645 2645 ctx = repo[rev]
2646 2646 ui.write('%s\n'% ctx2str(ctx))
2647 2647 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
2648 2648 if succsset:
2649 2649 ui.write(' ')
2650 2650 ui.write(node2str(succsset[0]))
2651 2651 for node in succsset[1:]:
2652 2652 ui.write(' ')
2653 2653 ui.write(node2str(node))
2654 2654 ui.write('\n')
2655 2655
2656 2656 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'))
2657 2657 def debugwalk(ui, repo, *pats, **opts):
2658 2658 """show how files match on given patterns"""
2659 2659 m = scmutil.match(repo[None], pats, opts)
2660 2660 items = list(repo.walk(m))
2661 2661 if not items:
2662 2662 return
2663 2663 f = lambda fn: fn
2664 2664 if ui.configbool('ui', 'slash') and os.sep != '/':
2665 2665 f = lambda fn: util.normpath(fn)
2666 2666 fmt = 'f %%-%ds %%-%ds %%s' % (
2667 2667 max([len(abs) for abs in items]),
2668 2668 max([len(m.rel(abs)) for abs in items]))
2669 2669 for abs in items:
2670 2670 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
2671 2671 ui.write("%s\n" % line.rstrip())
2672 2672
2673 2673 @command('debugwireargs',
2674 2674 [('', 'three', '', 'three'),
2675 2675 ('', 'four', '', 'four'),
2676 2676 ('', 'five', '', 'five'),
2677 2677 ] + remoteopts,
2678 2678 _('REPO [OPTIONS]... [ONE [TWO]]'))
2679 2679 def debugwireargs(ui, repopath, *vals, **opts):
2680 2680 repo = hg.peer(ui, opts, repopath)
2681 2681 for opt in remoteopts:
2682 2682 del opts[opt[1]]
2683 2683 args = {}
2684 2684 for k, v in opts.iteritems():
2685 2685 if v:
2686 2686 args[k] = v
2687 2687 # run twice to check that we don't mess up the stream for the next command
2688 2688 res1 = repo.debugwireargs(*vals, **args)
2689 2689 res2 = repo.debugwireargs(*vals, **args)
2690 2690 ui.write("%s\n" % res1)
2691 2691 if res1 != res2:
2692 2692 ui.warn("%s\n" % res2)
2693 2693
2694 2694 @command('^diff',
2695 2695 [('r', 'rev', [], _('revision'), _('REV')),
2696 2696 ('c', 'change', '', _('change made by revision'), _('REV'))
2697 2697 ] + diffopts + diffopts2 + walkopts + subrepoopts,
2698 2698 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'))
2699 2699 def diff(ui, repo, *pats, **opts):
2700 2700 """diff repository (or selected files)
2701 2701
2702 2702 Show differences between revisions for the specified files.
2703 2703
2704 2704 Differences between files are shown using the unified diff format.
2705 2705
2706 2706 .. note::
2707 2707 diff may generate unexpected results for merges, as it will
2708 2708 default to comparing against the working directory's first
2709 2709 parent changeset if no revisions are specified.
2710 2710
2711 2711 When two revision arguments are given, then changes are shown
2712 2712 between those revisions. If only one revision is specified then
2713 2713 that revision is compared to the working directory, and, when no
2714 2714 revisions are specified, the working directory files are compared
2715 2715 to its parent.
2716 2716
2717 2717 Alternatively you can specify -c/--change with a revision to see
2718 2718 the changes in that changeset relative to its first parent.
2719 2719
2720 2720 Without the -a/--text option, diff will avoid generating diffs of
2721 2721 files it detects as binary. With -a, diff will generate a diff
2722 2722 anyway, probably with undesirable results.
2723 2723
2724 2724 Use the -g/--git option to generate diffs in the git extended diff
2725 2725 format. For more information, read :hg:`help diffs`.
2726 2726
2727 2727 .. container:: verbose
2728 2728
2729 2729 Examples:
2730 2730
2731 2731 - compare a file in the current working directory to its parent::
2732 2732
2733 2733 hg diff foo.c
2734 2734
2735 2735 - compare two historical versions of a directory, with rename info::
2736 2736
2737 2737 hg diff --git -r 1.0:1.2 lib/
2738 2738
2739 2739 - get change stats relative to the last change on some date::
2740 2740
2741 2741 hg diff --stat -r "date('may 2')"
2742 2742
2743 2743 - diff all newly-added files that contain a keyword::
2744 2744
2745 2745 hg diff "set:added() and grep(GNU)"
2746 2746
2747 2747 - compare a revision and its parents::
2748 2748
2749 2749 hg diff -c 9353 # compare against first parent
2750 2750 hg diff -r 9353^:9353 # same using revset syntax
2751 2751 hg diff -r 9353^2:9353 # compare against the second parent
2752 2752
2753 2753 Returns 0 on success.
2754 2754 """
2755 2755
2756 2756 revs = opts.get('rev')
2757 2757 change = opts.get('change')
2758 2758 stat = opts.get('stat')
2759 2759 reverse = opts.get('reverse')
2760 2760
2761 2761 if revs and change:
2762 2762 msg = _('cannot specify --rev and --change at the same time')
2763 2763 raise util.Abort(msg)
2764 2764 elif change:
2765 2765 node2 = scmutil.revsingle(repo, change, None).node()
2766 2766 node1 = repo[node2].p1().node()
2767 2767 else:
2768 2768 node1, node2 = scmutil.revpair(repo, revs)
2769 2769
2770 2770 if reverse:
2771 2771 node1, node2 = node2, node1
2772 2772
2773 2773 diffopts = patch.diffopts(ui, opts)
2774 2774 m = scmutil.match(repo[node2], pats, opts)
2775 2775 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
2776 2776 listsubrepos=opts.get('subrepos'))
2777 2777
2778 2778 @command('^export',
2779 2779 [('o', 'output', '',
2780 2780 _('print output to file with formatted name'), _('FORMAT')),
2781 2781 ('', 'switch-parent', None, _('diff against the second parent')),
2782 2782 ('r', 'rev', [], _('revisions to export'), _('REV')),
2783 2783 ] + diffopts,
2784 2784 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
2785 2785 def export(ui, repo, *changesets, **opts):
2786 2786 """dump the header and diffs for one or more changesets
2787 2787
2788 2788 Print the changeset header and diffs for one or more revisions.
2789 2789 If no revision is given, the parent of the working directory is used.
2790 2790
2791 2791 The information shown in the changeset header is: author, date,
2792 2792 branch name (if non-default), changeset hash, parent(s) and commit
2793 2793 comment.
2794 2794
2795 2795 .. note::
2796 2796 export may generate unexpected diff output for merge
2797 2797 changesets, as it will compare the merge changeset against its
2798 2798 first parent only.
2799 2799
2800 2800 Output may be to a file, in which case the name of the file is
2801 2801 given using a format string. The formatting rules are as follows:
2802 2802
2803 2803 :``%%``: literal "%" character
2804 2804 :``%H``: changeset hash (40 hexadecimal digits)
2805 2805 :``%N``: number of patches being generated
2806 2806 :``%R``: changeset revision number
2807 2807 :``%b``: basename of the exporting repository
2808 2808 :``%h``: short-form changeset hash (12 hexadecimal digits)
2809 2809 :``%m``: first line of the commit message (only alphanumeric characters)
2810 2810 :``%n``: zero-padded sequence number, starting at 1
2811 2811 :``%r``: zero-padded changeset revision number
2812 2812
2813 2813 Without the -a/--text option, export will avoid generating diffs
2814 2814 of files it detects as binary. With -a, export will generate a
2815 2815 diff anyway, probably with undesirable results.
2816 2816
2817 2817 Use the -g/--git option to generate diffs in the git extended diff
2818 2818 format. See :hg:`help diffs` for more information.
2819 2819
2820 2820 With the --switch-parent option, the diff will be against the
2821 2821 second parent. It can be useful to review a merge.
2822 2822
2823 2823 .. container:: verbose
2824 2824
2825 2825 Examples:
2826 2826
2827 2827 - use export and import to transplant a bugfix to the current
2828 2828 branch::
2829 2829
2830 2830 hg export -r 9353 | hg import -
2831 2831
2832 2832 - export all the changesets between two revisions to a file with
2833 2833 rename information::
2834 2834
2835 2835 hg export --git -r 123:150 > changes.txt
2836 2836
2837 2837 - split outgoing changes into a series of patches with
2838 2838 descriptive names::
2839 2839
2840 2840 hg export -r "outgoing()" -o "%n-%m.patch"
2841 2841
2842 2842 Returns 0 on success.
2843 2843 """
2844 2844 changesets += tuple(opts.get('rev', []))
2845 2845 if not changesets:
2846 2846 changesets = ['.']
2847 2847 revs = scmutil.revrange(repo, changesets)
2848 2848 if not revs:
2849 2849 raise util.Abort(_("export requires at least one changeset"))
2850 2850 if len(revs) > 1:
2851 2851 ui.note(_('exporting patches:\n'))
2852 2852 else:
2853 2853 ui.note(_('exporting patch:\n'))
2854 2854 cmdutil.export(repo, revs, template=opts.get('output'),
2855 2855 switch_parent=opts.get('switch_parent'),
2856 2856 opts=patch.diffopts(ui, opts))
2857 2857
2858 2858 @command('^forget', walkopts, _('[OPTION]... FILE...'))
2859 2859 def forget(ui, repo, *pats, **opts):
2860 2860 """forget the specified files on the next commit
2861 2861
2862 2862 Mark the specified files so they will no longer be tracked
2863 2863 after the next commit.
2864 2864
2865 2865 This only removes files from the current branch, not from the
2866 2866 entire project history, and it does not delete them from the
2867 2867 working directory.
2868 2868
2869 2869 To undo a forget before the next commit, see :hg:`add`.
2870 2870
2871 2871 .. container:: verbose
2872 2872
2873 2873 Examples:
2874 2874
2875 2875 - forget newly-added binary files::
2876 2876
2877 2877 hg forget "set:added() and binary()"
2878 2878
2879 2879 - forget files that would be excluded by .hgignore::
2880 2880
2881 2881 hg forget "set:hgignore()"
2882 2882
2883 2883 Returns 0 on success.
2884 2884 """
2885 2885
2886 2886 if not pats:
2887 2887 raise util.Abort(_('no files specified'))
2888 2888
2889 2889 m = scmutil.match(repo[None], pats, opts)
2890 2890 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
2891 2891 return rejected and 1 or 0
2892 2892
2893 2893 @command(
2894 2894 'graft',
2895 2895 [('r', 'rev', [], _('revisions to graft'), _('REV')),
2896 2896 ('c', 'continue', False, _('resume interrupted graft')),
2897 2897 ('e', 'edit', False, _('invoke editor on commit messages')),
2898 2898 ('', 'log', None, _('append graft info to log message')),
2899 2899 ('D', 'currentdate', False,
2900 2900 _('record the current date as commit date')),
2901 2901 ('U', 'currentuser', False,
2902 2902 _('record the current user as committer'), _('DATE'))]
2903 2903 + commitopts2 + mergetoolopts + dryrunopts,
2904 2904 _('[OPTION]... [-r] REV...'))
2905 2905 def graft(ui, repo, *revs, **opts):
2906 2906 '''copy changes from other branches onto the current branch
2907 2907
2908 2908 This command uses Mercurial's merge logic to copy individual
2909 2909 changes from other branches without merging branches in the
2910 2910 history graph. This is sometimes known as 'backporting' or
2911 2911 'cherry-picking'. By default, graft will copy user, date, and
2912 2912 description from the source changesets.
2913 2913
2914 2914 Changesets that are ancestors of the current revision, that have
2915 2915 already been grafted, or that are merges will be skipped.
2916 2916
2917 2917 If --log is specified, log messages will have a comment appended
2918 2918 of the form::
2919 2919
2920 2920 (grafted from CHANGESETHASH)
2921 2921
2922 2922 If a graft merge results in conflicts, the graft process is
2923 2923 interrupted so that the current merge can be manually resolved.
2924 2924 Once all conflicts are addressed, the graft process can be
2925 2925 continued with the -c/--continue option.
2926 2926
2927 2927 .. note::
2928 2928 The -c/--continue option does not reapply earlier options.
2929 2929
2930 2930 .. container:: verbose
2931 2931
2932 2932 Examples:
2933 2933
2934 2934 - copy a single change to the stable branch and edit its description::
2935 2935
2936 2936 hg update stable
2937 2937 hg graft --edit 9393
2938 2938
2939 2939 - graft a range of changesets with one exception, updating dates::
2940 2940
2941 2941 hg graft -D "2085::2093 and not 2091"
2942 2942
2943 2943 - continue a graft after resolving conflicts::
2944 2944
2945 2945 hg graft -c
2946 2946
2947 2947 - show the source of a grafted changeset::
2948 2948
2949 2949 hg log --debug -r .
2950 2950
2951 2951 Returns 0 on successful completion.
2952 2952 '''
2953 2953
2954 2954 revs = list(revs)
2955 2955 revs.extend(opts['rev'])
2956 2956
2957 2957 if not opts.get('user') and opts.get('currentuser'):
2958 2958 opts['user'] = ui.username()
2959 2959 if not opts.get('date') and opts.get('currentdate'):
2960 2960 opts['date'] = "%d %d" % util.makedate()
2961 2961
2962 2962 editor = None
2963 2963 if opts.get('edit'):
2964 2964 editor = cmdutil.commitforceeditor
2965 2965
2966 2966 cont = False
2967 2967 if opts['continue']:
2968 2968 cont = True
2969 2969 if revs:
2970 2970 raise util.Abort(_("can't specify --continue and revisions"))
2971 2971 # read in unfinished revisions
2972 2972 try:
2973 2973 nodes = repo.opener.read('graftstate').splitlines()
2974 2974 revs = [repo[node].rev() for node in nodes]
2975 2975 except IOError, inst:
2976 2976 if inst.errno != errno.ENOENT:
2977 2977 raise
2978 2978 raise util.Abort(_("no graft state found, can't continue"))
2979 2979 else:
2980 2980 cmdutil.bailifchanged(repo)
2981 2981 if not revs:
2982 2982 raise util.Abort(_('no revisions specified'))
2983 2983 revs = scmutil.revrange(repo, revs)
2984 2984
2985 2985 # check for merges
2986 2986 for rev in repo.revs('%ld and merge()', revs):
2987 2987 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
2988 2988 revs.remove(rev)
2989 2989 if not revs:
2990 2990 return -1
2991 2991
2992 2992 # check for ancestors of dest branch
2993 2993 crev = repo['.'].rev()
2994 2994 ancestors = repo.changelog.ancestors([crev], inclusive=True)
2995 2995 # don't mutate while iterating, create a copy
2996 2996 for rev in list(revs):
2997 2997 if rev in ancestors:
2998 2998 ui.warn(_('skipping ancestor revision %s\n') % rev)
2999 2999 revs.remove(rev)
3000 3000 if not revs:
3001 3001 return -1
3002 3002
3003 3003 # analyze revs for earlier grafts
3004 3004 ids = {}
3005 3005 for ctx in repo.set("%ld", revs):
3006 3006 ids[ctx.hex()] = ctx.rev()
3007 3007 n = ctx.extra().get('source')
3008 3008 if n:
3009 3009 ids[n] = ctx.rev()
3010 3010
3011 3011 # check ancestors for earlier grafts
3012 3012 ui.debug('scanning for duplicate grafts\n')
3013 3013
3014 3014 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3015 3015 ctx = repo[rev]
3016 3016 n = ctx.extra().get('source')
3017 3017 if n in ids:
3018 3018 r = repo[n].rev()
3019 3019 if r in revs:
3020 3020 ui.warn(_('skipping already grafted revision %s\n') % r)
3021 3021 revs.remove(r)
3022 3022 elif ids[n] in revs:
3023 3023 ui.warn(_('skipping already grafted revision %s '
3024 3024 '(same origin %d)\n') % (ids[n], r))
3025 3025 revs.remove(ids[n])
3026 3026 elif ctx.hex() in ids:
3027 3027 r = ids[ctx.hex()]
3028 3028 ui.warn(_('skipping already grafted revision %s '
3029 3029 '(was grafted from %d)\n') % (r, rev))
3030 3030 revs.remove(r)
3031 3031 if not revs:
3032 3032 return -1
3033 3033
3034 3034 wlock = repo.wlock()
3035 3035 try:
3036 3036 current = repo['.']
3037 3037 for pos, ctx in enumerate(repo.set("%ld", revs)):
3038 3038
3039 3039 ui.status(_('grafting revision %s\n') % ctx.rev())
3040 3040 if opts.get('dry_run'):
3041 3041 continue
3042 3042
3043 3043 source = ctx.extra().get('source')
3044 3044 if not source:
3045 3045 source = ctx.hex()
3046 3046 extra = {'source': source}
3047 3047 user = ctx.user()
3048 3048 if opts.get('user'):
3049 3049 user = opts['user']
3050 3050 date = ctx.date()
3051 3051 if opts.get('date'):
3052 3052 date = opts['date']
3053 3053 message = ctx.description()
3054 3054 if opts.get('log'):
3055 3055 message += '\n(grafted from %s)' % ctx.hex()
3056 3056
3057 3057 # we don't merge the first commit when continuing
3058 3058 if not cont:
3059 3059 # perform the graft merge with p1(rev) as 'ancestor'
3060 3060 try:
3061 3061 # ui.forcemerge is an internal variable, do not document
3062 3062 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
3063 3063 stats = mergemod.update(repo, ctx.node(), True, True, False,
3064 3064 ctx.p1().node())
3065 3065 finally:
3066 3066 repo.ui.setconfig('ui', 'forcemerge', '')
3067 3067 # report any conflicts
3068 3068 if stats and stats[3] > 0:
3069 3069 # write out state for --continue
3070 3070 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3071 3071 repo.opener.write('graftstate', ''.join(nodelines))
3072 3072 raise util.Abort(
3073 3073 _("unresolved conflicts, can't continue"),
3074 3074 hint=_('use hg resolve and hg graft --continue'))
3075 3075 else:
3076 3076 cont = False
3077 3077
3078 3078 # drop the second merge parent
3079 3079 repo.setparents(current.node(), nullid)
3080 3080 repo.dirstate.write()
3081 3081 # fix up dirstate for copies and renames
3082 3082 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
3083 3083
3084 3084 # commit
3085 3085 node = repo.commit(text=message, user=user,
3086 3086 date=date, extra=extra, editor=editor)
3087 3087 if node is None:
3088 3088 ui.status(_('graft for revision %s is empty\n') % ctx.rev())
3089 3089 else:
3090 3090 current = repo[node]
3091 3091 finally:
3092 3092 wlock.release()
3093 3093
3094 3094 # remove state when we complete successfully
3095 3095 if not opts.get('dry_run'):
3096 3096 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3097 3097
3098 3098 return 0
3099 3099
3100 3100 @command('grep',
3101 3101 [('0', 'print0', None, _('end fields with NUL')),
3102 3102 ('', 'all', None, _('print all revisions that match')),
3103 3103 ('a', 'text', None, _('treat all files as text')),
3104 3104 ('f', 'follow', None,
3105 3105 _('follow changeset history,'
3106 3106 ' or file history across copies and renames')),
3107 3107 ('i', 'ignore-case', None, _('ignore case when matching')),
3108 3108 ('l', 'files-with-matches', None,
3109 3109 _('print only filenames and revisions that match')),
3110 3110 ('n', 'line-number', None, _('print matching line numbers')),
3111 3111 ('r', 'rev', [],
3112 3112 _('only search files changed within revision range'), _('REV')),
3113 3113 ('u', 'user', None, _('list the author (long with -v)')),
3114 3114 ('d', 'date', None, _('list the date (short with -q)')),
3115 3115 ] + walkopts,
3116 3116 _('[OPTION]... PATTERN [FILE]...'))
3117 3117 def grep(ui, repo, pattern, *pats, **opts):
3118 3118 """search for a pattern in specified files and revisions
3119 3119
3120 3120 Search revisions of files for a regular expression.
3121 3121
3122 3122 This command behaves differently than Unix grep. It only accepts
3123 3123 Python/Perl regexps. It searches repository history, not the
3124 3124 working directory. It always prints the revision number in which a
3125 3125 match appears.
3126 3126
3127 3127 By default, grep only prints output for the first revision of a
3128 3128 file in which it finds a match. To get it to print every revision
3129 3129 that contains a change in match status ("-" for a match that
3130 3130 becomes a non-match, or "+" for a non-match that becomes a match),
3131 3131 use the --all flag.
3132 3132
3133 3133 Returns 0 if a match is found, 1 otherwise.
3134 3134 """
3135 3135 reflags = re.M
3136 3136 if opts.get('ignore_case'):
3137 3137 reflags |= re.I
3138 3138 try:
3139 3139 regexp = util.compilere(pattern, reflags)
3140 3140 except re.error, inst:
3141 3141 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3142 3142 return 1
3143 3143 sep, eol = ':', '\n'
3144 3144 if opts.get('print0'):
3145 3145 sep = eol = '\0'
3146 3146
3147 3147 getfile = util.lrucachefunc(repo.file)
3148 3148
3149 3149 def matchlines(body):
3150 3150 begin = 0
3151 3151 linenum = 0
3152 3152 while begin < len(body):
3153 3153 match = regexp.search(body, begin)
3154 3154 if not match:
3155 3155 break
3156 3156 mstart, mend = match.span()
3157 3157 linenum += body.count('\n', begin, mstart) + 1
3158 3158 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3159 3159 begin = body.find('\n', mend) + 1 or len(body) + 1
3160 3160 lend = begin - 1
3161 3161 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3162 3162
3163 3163 class linestate(object):
3164 3164 def __init__(self, line, linenum, colstart, colend):
3165 3165 self.line = line
3166 3166 self.linenum = linenum
3167 3167 self.colstart = colstart
3168 3168 self.colend = colend
3169 3169
3170 3170 def __hash__(self):
3171 3171 return hash((self.linenum, self.line))
3172 3172
3173 3173 def __eq__(self, other):
3174 3174 return self.line == other.line
3175 3175
3176 3176 matches = {}
3177 3177 copies = {}
3178 3178 def grepbody(fn, rev, body):
3179 3179 matches[rev].setdefault(fn, [])
3180 3180 m = matches[rev][fn]
3181 3181 for lnum, cstart, cend, line in matchlines(body):
3182 3182 s = linestate(line, lnum, cstart, cend)
3183 3183 m.append(s)
3184 3184
3185 3185 def difflinestates(a, b):
3186 3186 sm = difflib.SequenceMatcher(None, a, b)
3187 3187 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3188 3188 if tag == 'insert':
3189 3189 for i in xrange(blo, bhi):
3190 3190 yield ('+', b[i])
3191 3191 elif tag == 'delete':
3192 3192 for i in xrange(alo, ahi):
3193 3193 yield ('-', a[i])
3194 3194 elif tag == 'replace':
3195 3195 for i in xrange(alo, ahi):
3196 3196 yield ('-', a[i])
3197 3197 for i in xrange(blo, bhi):
3198 3198 yield ('+', b[i])
3199 3199
3200 3200 def display(fn, ctx, pstates, states):
3201 3201 rev = ctx.rev()
3202 3202 datefunc = ui.quiet and util.shortdate or util.datestr
3203 3203 found = False
3204 3204 filerevmatches = {}
3205 3205 def binary():
3206 3206 flog = getfile(fn)
3207 3207 return util.binary(flog.read(ctx.filenode(fn)))
3208 3208
3209 3209 if opts.get('all'):
3210 3210 iter = difflinestates(pstates, states)
3211 3211 else:
3212 3212 iter = [('', l) for l in states]
3213 3213 for change, l in iter:
3214 3214 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3215 3215 before, match, after = None, None, None
3216 3216
3217 3217 if opts.get('line_number'):
3218 3218 cols.append((str(l.linenum), 'grep.linenumber'))
3219 3219 if opts.get('all'):
3220 3220 cols.append((change, 'grep.change'))
3221 3221 if opts.get('user'):
3222 3222 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3223 3223 if opts.get('date'):
3224 3224 cols.append((datefunc(ctx.date()), 'grep.date'))
3225 3225 if opts.get('files_with_matches'):
3226 3226 c = (fn, rev)
3227 3227 if c in filerevmatches:
3228 3228 continue
3229 3229 filerevmatches[c] = 1
3230 3230 else:
3231 3231 before = l.line[:l.colstart]
3232 3232 match = l.line[l.colstart:l.colend]
3233 3233 after = l.line[l.colend:]
3234 3234 for col, label in cols[:-1]:
3235 3235 ui.write(col, label=label)
3236 3236 ui.write(sep, label='grep.sep')
3237 3237 ui.write(cols[-1][0], label=cols[-1][1])
3238 3238 if before is not None:
3239 3239 ui.write(sep, label='grep.sep')
3240 3240 if not opts.get('text') and binary():
3241 3241 ui.write(" Binary file matches")
3242 3242 else:
3243 3243 ui.write(before)
3244 3244 ui.write(match, label='grep.match')
3245 3245 ui.write(after)
3246 3246 ui.write(eol)
3247 3247 found = True
3248 3248 return found
3249 3249
3250 3250 skip = {}
3251 3251 revfiles = {}
3252 3252 matchfn = scmutil.match(repo[None], pats, opts)
3253 3253 found = False
3254 3254 follow = opts.get('follow')
3255 3255
3256 3256 def prep(ctx, fns):
3257 3257 rev = ctx.rev()
3258 3258 pctx = ctx.p1()
3259 3259 parent = pctx.rev()
3260 3260 matches.setdefault(rev, {})
3261 3261 matches.setdefault(parent, {})
3262 3262 files = revfiles.setdefault(rev, [])
3263 3263 for fn in fns:
3264 3264 flog = getfile(fn)
3265 3265 try:
3266 3266 fnode = ctx.filenode(fn)
3267 3267 except error.LookupError:
3268 3268 continue
3269 3269
3270 3270 copied = flog.renamed(fnode)
3271 3271 copy = follow and copied and copied[0]
3272 3272 if copy:
3273 3273 copies.setdefault(rev, {})[fn] = copy
3274 3274 if fn in skip:
3275 3275 if copy:
3276 3276 skip[copy] = True
3277 3277 continue
3278 3278 files.append(fn)
3279 3279
3280 3280 if fn not in matches[rev]:
3281 3281 grepbody(fn, rev, flog.read(fnode))
3282 3282
3283 3283 pfn = copy or fn
3284 3284 if pfn not in matches[parent]:
3285 3285 try:
3286 3286 fnode = pctx.filenode(pfn)
3287 3287 grepbody(pfn, parent, flog.read(fnode))
3288 3288 except error.LookupError:
3289 3289 pass
3290 3290
3291 3291 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3292 3292 rev = ctx.rev()
3293 3293 parent = ctx.p1().rev()
3294 3294 for fn in sorted(revfiles.get(rev, [])):
3295 3295 states = matches[rev][fn]
3296 3296 copy = copies.get(rev, {}).get(fn)
3297 3297 if fn in skip:
3298 3298 if copy:
3299 3299 skip[copy] = True
3300 3300 continue
3301 3301 pstates = matches.get(parent, {}).get(copy or fn, [])
3302 3302 if pstates or states:
3303 3303 r = display(fn, ctx, pstates, states)
3304 3304 found = found or r
3305 3305 if r and not opts.get('all'):
3306 3306 skip[fn] = True
3307 3307 if copy:
3308 3308 skip[copy] = True
3309 3309 del matches[rev]
3310 3310 del revfiles[rev]
3311 3311
3312 3312 return not found
3313 3313
3314 3314 @command('heads',
3315 3315 [('r', 'rev', '',
3316 3316 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3317 3317 ('t', 'topo', False, _('show topological heads only')),
3318 3318 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3319 3319 ('c', 'closed', False, _('show normal and closed branch heads')),
3320 3320 ] + templateopts,
3321 3321 _('[-ct] [-r STARTREV] [REV]...'))
3322 3322 def heads(ui, repo, *branchrevs, **opts):
3323 """show current repository heads or show branch heads
3324
3325 With no arguments, show all repository branch heads.
3326
3327 Repository "heads" are changesets with no child changesets. They are
3328 where development generally takes place and are the usual targets
3329 for update and merge operations. Branch heads are changesets that have
3330 no child changeset on the same branch.
3331
3332 If one or more REVs are given, only branch heads on the branches
3333 associated with the specified changesets are shown. This means
3334 that you can use :hg:`heads foo` to see the heads on a branch
3335 named ``foo``.
3323 """show branch heads
3324
3325 With no arguments, show all open branch heads in the repository.
3326 Branch heads are changesets that have no child changesets on the
3327 same branch. They are where development generally takes place and
3328 are the usual targets for update and merge operations.
3329
3330 If one or more REVs are given, only open branch heads on the
3331 branches associated with the specified changesets are shown. This
3332 means that you can use :hg:`heads .` to see the heads on the
3333 currently checked-out branch.
3336 3334
3337 3335 If -c/--closed is specified, also show branch heads marked closed
3338 3336 (see :hg:`commit --close-branch`).
3339 3337
3340 3338 If STARTREV is specified, only those heads that are descendants of
3341 3339 STARTREV will be displayed.
3342 3340
3343 3341 If -t/--topo is specified, named branch mechanics will be ignored and only
3344 changesets without children will be shown.
3342 topological heads (changesets with no children) will be shown.
3345 3343
3346 3344 Returns 0 if matching heads are found, 1 if not.
3347 3345 """
3348 3346
3349 3347 start = None
3350 3348 if 'rev' in opts:
3351 3349 start = scmutil.revsingle(repo, opts['rev'], None).node()
3352 3350
3353 3351 if opts.get('topo'):
3354 3352 heads = [repo[h] for h in repo.heads(start)]
3355 3353 else:
3356 3354 heads = []
3357 3355 for branch in repo.branchmap():
3358 3356 heads += repo.branchheads(branch, start, opts.get('closed'))
3359 3357 heads = [repo[h] for h in heads]
3360 3358
3361 3359 if branchrevs:
3362 3360 branches = set(repo[br].branch() for br in branchrevs)
3363 3361 heads = [h for h in heads if h.branch() in branches]
3364 3362
3365 3363 if opts.get('active') and branchrevs:
3366 3364 dagheads = repo.heads(start)
3367 3365 heads = [h for h in heads if h.node() in dagheads]
3368 3366
3369 3367 if branchrevs:
3370 3368 haveheads = set(h.branch() for h in heads)
3371 3369 if branches - haveheads:
3372 3370 headless = ', '.join(b for b in branches - haveheads)
3373 3371 msg = _('no open branch heads found on branches %s')
3374 3372 if opts.get('rev'):
3375 3373 msg += _(' (started at %s)') % opts['rev']
3376 3374 ui.warn((msg + '\n') % headless)
3377 3375
3378 3376 if not heads:
3379 3377 return 1
3380 3378
3381 3379 heads = sorted(heads, key=lambda x: -x.rev())
3382 3380 displayer = cmdutil.show_changeset(ui, repo, opts)
3383 3381 for ctx in heads:
3384 3382 displayer.show(ctx)
3385 3383 displayer.close()
3386 3384
3387 3385 @command('help',
3388 3386 [('e', 'extension', None, _('show only help for extensions')),
3389 3387 ('c', 'command', None, _('show only help for commands')),
3390 3388 ('k', 'keyword', '', _('show topics matching keyword')),
3391 3389 ],
3392 3390 _('[-ec] [TOPIC]'))
3393 3391 def help_(ui, name=None, **opts):
3394 3392 """show help for a given topic or a help overview
3395 3393
3396 3394 With no arguments, print a list of commands with short help messages.
3397 3395
3398 3396 Given a topic, extension, or command name, print help for that
3399 3397 topic.
3400 3398
3401 3399 Returns 0 if successful.
3402 3400 """
3403 3401
3404 3402 textwidth = min(ui.termwidth(), 80) - 2
3405 3403
3406 3404 keep = ui.verbose and ['verbose'] or []
3407 3405 text = help.help_(ui, name, **opts)
3408 3406
3409 3407 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3410 3408 if 'verbose' in pruned:
3411 3409 keep.append('omitted')
3412 3410 else:
3413 3411 keep.append('notomitted')
3414 3412 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3415 3413 ui.write(formatted)
3416 3414
3417 3415
3418 3416 @command('identify|id',
3419 3417 [('r', 'rev', '',
3420 3418 _('identify the specified revision'), _('REV')),
3421 3419 ('n', 'num', None, _('show local revision number')),
3422 3420 ('i', 'id', None, _('show global revision id')),
3423 3421 ('b', 'branch', None, _('show branch')),
3424 3422 ('t', 'tags', None, _('show tags')),
3425 3423 ('B', 'bookmarks', None, _('show bookmarks')),
3426 3424 ] + remoteopts,
3427 3425 _('[-nibtB] [-r REV] [SOURCE]'))
3428 3426 def identify(ui, repo, source=None, rev=None,
3429 3427 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
3430 3428 """identify the working copy or specified revision
3431 3429
3432 3430 Print a summary identifying the repository state at REV using one or
3433 3431 two parent hash identifiers, followed by a "+" if the working
3434 3432 directory has uncommitted changes, the branch name (if not default),
3435 3433 a list of tags, and a list of bookmarks.
3436 3434
3437 3435 When REV is not given, print a summary of the current state of the
3438 3436 repository.
3439 3437
3440 3438 Specifying a path to a repository root or Mercurial bundle will
3441 3439 cause lookup to operate on that repository/bundle.
3442 3440
3443 3441 .. container:: verbose
3444 3442
3445 3443 Examples:
3446 3444
3447 3445 - generate a build identifier for the working directory::
3448 3446
3449 3447 hg id --id > build-id.dat
3450 3448
3451 3449 - find the revision corresponding to a tag::
3452 3450
3453 3451 hg id -n -r 1.3
3454 3452
3455 3453 - check the most recent revision of a remote repository::
3456 3454
3457 3455 hg id -r tip http://selenic.com/hg/
3458 3456
3459 3457 Returns 0 if successful.
3460 3458 """
3461 3459
3462 3460 if not repo and not source:
3463 3461 raise util.Abort(_("there is no Mercurial repository here "
3464 3462 "(.hg not found)"))
3465 3463
3466 3464 hexfunc = ui.debugflag and hex or short
3467 3465 default = not (num or id or branch or tags or bookmarks)
3468 3466 output = []
3469 3467 revs = []
3470 3468
3471 3469 if source:
3472 3470 source, branches = hg.parseurl(ui.expandpath(source))
3473 3471 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3474 3472 repo = peer.local()
3475 3473 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3476 3474
3477 3475 if not repo:
3478 3476 if num or branch or tags:
3479 3477 raise util.Abort(
3480 3478 _("can't query remote revision number, branch, or tags"))
3481 3479 if not rev and revs:
3482 3480 rev = revs[0]
3483 3481 if not rev:
3484 3482 rev = "tip"
3485 3483
3486 3484 remoterev = peer.lookup(rev)
3487 3485 if default or id:
3488 3486 output = [hexfunc(remoterev)]
3489 3487
3490 3488 def getbms():
3491 3489 bms = []
3492 3490
3493 3491 if 'bookmarks' in peer.listkeys('namespaces'):
3494 3492 hexremoterev = hex(remoterev)
3495 3493 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
3496 3494 if bmr == hexremoterev]
3497 3495
3498 3496 return sorted(bms)
3499 3497
3500 3498 if bookmarks:
3501 3499 output.extend(getbms())
3502 3500 elif default and not ui.quiet:
3503 3501 # multiple bookmarks for a single parent separated by '/'
3504 3502 bm = '/'.join(getbms())
3505 3503 if bm:
3506 3504 output.append(bm)
3507 3505 else:
3508 3506 if not rev:
3509 3507 ctx = repo[None]
3510 3508 parents = ctx.parents()
3511 3509 changed = ""
3512 3510 if default or id or num:
3513 3511 if (util.any(repo.status())
3514 3512 or util.any(ctx.sub(s).dirty() for s in ctx.substate)):
3515 3513 changed = '+'
3516 3514 if default or id:
3517 3515 output = ["%s%s" %
3518 3516 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
3519 3517 if num:
3520 3518 output.append("%s%s" %
3521 3519 ('+'.join([str(p.rev()) for p in parents]), changed))
3522 3520 else:
3523 3521 ctx = scmutil.revsingle(repo, rev)
3524 3522 if default or id:
3525 3523 output = [hexfunc(ctx.node())]
3526 3524 if num:
3527 3525 output.append(str(ctx.rev()))
3528 3526
3529 3527 if default and not ui.quiet:
3530 3528 b = ctx.branch()
3531 3529 if b != 'default':
3532 3530 output.append("(%s)" % b)
3533 3531
3534 3532 # multiple tags for a single parent separated by '/'
3535 3533 t = '/'.join(ctx.tags())
3536 3534 if t:
3537 3535 output.append(t)
3538 3536
3539 3537 # multiple bookmarks for a single parent separated by '/'
3540 3538 bm = '/'.join(ctx.bookmarks())
3541 3539 if bm:
3542 3540 output.append(bm)
3543 3541 else:
3544 3542 if branch:
3545 3543 output.append(ctx.branch())
3546 3544
3547 3545 if tags:
3548 3546 output.extend(ctx.tags())
3549 3547
3550 3548 if bookmarks:
3551 3549 output.extend(ctx.bookmarks())
3552 3550
3553 3551 ui.write("%s\n" % ' '.join(output))
3554 3552
3555 3553 @command('import|patch',
3556 3554 [('p', 'strip', 1,
3557 3555 _('directory strip option for patch. This has the same '
3558 3556 'meaning as the corresponding patch option'), _('NUM')),
3559 3557 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
3560 3558 ('e', 'edit', False, _('invoke editor on commit messages')),
3561 3559 ('f', 'force', None,
3562 3560 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
3563 3561 ('', 'no-commit', None,
3564 3562 _("don't commit, just update the working directory")),
3565 3563 ('', 'bypass', None,
3566 3564 _("apply patch without touching the working directory")),
3567 3565 ('', 'exact', None,
3568 3566 _('apply patch to the nodes from which it was generated')),
3569 3567 ('', 'import-branch', None,
3570 3568 _('use any branch information in patch (implied by --exact)'))] +
3571 3569 commitopts + commitopts2 + similarityopts,
3572 3570 _('[OPTION]... PATCH...'))
3573 3571 def import_(ui, repo, patch1=None, *patches, **opts):
3574 3572 """import an ordered set of patches
3575 3573
3576 3574 Import a list of patches and commit them individually (unless
3577 3575 --no-commit is specified).
3578 3576
3579 3577 Because import first applies changes to the working directory,
3580 3578 import will abort if there are outstanding changes.
3581 3579
3582 3580 You can import a patch straight from a mail message. Even patches
3583 3581 as attachments work (to use the body part, it must have type
3584 3582 text/plain or text/x-patch). From and Subject headers of email
3585 3583 message are used as default committer and commit message. All
3586 3584 text/plain body parts before first diff are added to commit
3587 3585 message.
3588 3586
3589 3587 If the imported patch was generated by :hg:`export`, user and
3590 3588 description from patch override values from message headers and
3591 3589 body. Values given on command line with -m/--message and -u/--user
3592 3590 override these.
3593 3591
3594 3592 If --exact is specified, import will set the working directory to
3595 3593 the parent of each patch before applying it, and will abort if the
3596 3594 resulting changeset has a different ID than the one recorded in
3597 3595 the patch. This may happen due to character set problems or other
3598 3596 deficiencies in the text patch format.
3599 3597
3600 3598 Use --bypass to apply and commit patches directly to the
3601 3599 repository, not touching the working directory. Without --exact,
3602 3600 patches will be applied on top of the working directory parent
3603 3601 revision.
3604 3602
3605 3603 With -s/--similarity, hg will attempt to discover renames and
3606 3604 copies in the patch in the same way as :hg:`addremove`.
3607 3605
3608 3606 To read a patch from standard input, use "-" as the patch name. If
3609 3607 a URL is specified, the patch will be downloaded from it.
3610 3608 See :hg:`help dates` for a list of formats valid for -d/--date.
3611 3609
3612 3610 .. container:: verbose
3613 3611
3614 3612 Examples:
3615 3613
3616 3614 - import a traditional patch from a website and detect renames::
3617 3615
3618 3616 hg import -s 80 http://example.com/bugfix.patch
3619 3617
3620 3618 - import a changeset from an hgweb server::
3621 3619
3622 3620 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
3623 3621
3624 3622 - import all the patches in an Unix-style mbox::
3625 3623
3626 3624 hg import incoming-patches.mbox
3627 3625
3628 3626 - attempt to exactly restore an exported changeset (not always
3629 3627 possible)::
3630 3628
3631 3629 hg import --exact proposed-fix.patch
3632 3630
3633 3631 Returns 0 on success.
3634 3632 """
3635 3633
3636 3634 if not patch1:
3637 3635 raise util.Abort(_('need at least one patch to import'))
3638 3636
3639 3637 patches = (patch1,) + patches
3640 3638
3641 3639 date = opts.get('date')
3642 3640 if date:
3643 3641 opts['date'] = util.parsedate(date)
3644 3642
3645 3643 editor = cmdutil.commiteditor
3646 3644 if opts.get('edit'):
3647 3645 editor = cmdutil.commitforceeditor
3648 3646
3649 3647 update = not opts.get('bypass')
3650 3648 if not update and opts.get('no_commit'):
3651 3649 raise util.Abort(_('cannot use --no-commit with --bypass'))
3652 3650 try:
3653 3651 sim = float(opts.get('similarity') or 0)
3654 3652 except ValueError:
3655 3653 raise util.Abort(_('similarity must be a number'))
3656 3654 if sim < 0 or sim > 100:
3657 3655 raise util.Abort(_('similarity must be between 0 and 100'))
3658 3656 if sim and not update:
3659 3657 raise util.Abort(_('cannot use --similarity with --bypass'))
3660 3658
3661 3659 if (opts.get('exact') or not opts.get('force')) and update:
3662 3660 cmdutil.bailifchanged(repo)
3663 3661
3664 3662 base = opts["base"]
3665 3663 strip = opts["strip"]
3666 3664 wlock = lock = tr = None
3667 3665 msgs = []
3668 3666
3669 3667 def tryone(ui, hunk, parents):
3670 3668 tmpname, message, user, date, branch, nodeid, p1, p2 = \
3671 3669 patch.extract(ui, hunk)
3672 3670
3673 3671 if not tmpname:
3674 3672 return (None, None)
3675 3673 msg = _('applied to working directory')
3676 3674
3677 3675 try:
3678 3676 cmdline_message = cmdutil.logmessage(ui, opts)
3679 3677 if cmdline_message:
3680 3678 # pickup the cmdline msg
3681 3679 message = cmdline_message
3682 3680 elif message:
3683 3681 # pickup the patch msg
3684 3682 message = message.strip()
3685 3683 else:
3686 3684 # launch the editor
3687 3685 message = None
3688 3686 ui.debug('message:\n%s\n' % message)
3689 3687
3690 3688 if len(parents) == 1:
3691 3689 parents.append(repo[nullid])
3692 3690 if opts.get('exact'):
3693 3691 if not nodeid or not p1:
3694 3692 raise util.Abort(_('not a Mercurial patch'))
3695 3693 p1 = repo[p1]
3696 3694 p2 = repo[p2 or nullid]
3697 3695 elif p2:
3698 3696 try:
3699 3697 p1 = repo[p1]
3700 3698 p2 = repo[p2]
3701 3699 # Without any options, consider p2 only if the
3702 3700 # patch is being applied on top of the recorded
3703 3701 # first parent.
3704 3702 if p1 != parents[0]:
3705 3703 p1 = parents[0]
3706 3704 p2 = repo[nullid]
3707 3705 except error.RepoError:
3708 3706 p1, p2 = parents
3709 3707 else:
3710 3708 p1, p2 = parents
3711 3709
3712 3710 n = None
3713 3711 if update:
3714 3712 if p1 != parents[0]:
3715 3713 hg.clean(repo, p1.node())
3716 3714 if p2 != parents[1]:
3717 3715 repo.setparents(p1.node(), p2.node())
3718 3716
3719 3717 if opts.get('exact') or opts.get('import_branch'):
3720 3718 repo.dirstate.setbranch(branch or 'default')
3721 3719
3722 3720 files = set()
3723 3721 patch.patch(ui, repo, tmpname, strip=strip, files=files,
3724 3722 eolmode=None, similarity=sim / 100.0)
3725 3723 files = list(files)
3726 3724 if opts.get('no_commit'):
3727 3725 if message:
3728 3726 msgs.append(message)
3729 3727 else:
3730 3728 if opts.get('exact') or p2:
3731 3729 # If you got here, you either use --force and know what
3732 3730 # you are doing or used --exact or a merge patch while
3733 3731 # being updated to its first parent.
3734 3732 m = None
3735 3733 else:
3736 3734 m = scmutil.matchfiles(repo, files or [])
3737 3735 n = repo.commit(message, opts.get('user') or user,
3738 3736 opts.get('date') or date, match=m,
3739 3737 editor=editor)
3740 3738 else:
3741 3739 if opts.get('exact') or opts.get('import_branch'):
3742 3740 branch = branch or 'default'
3743 3741 else:
3744 3742 branch = p1.branch()
3745 3743 store = patch.filestore()
3746 3744 try:
3747 3745 files = set()
3748 3746 try:
3749 3747 patch.patchrepo(ui, repo, p1, store, tmpname, strip,
3750 3748 files, eolmode=None)
3751 3749 except patch.PatchError, e:
3752 3750 raise util.Abort(str(e))
3753 3751 memctx = patch.makememctx(repo, (p1.node(), p2.node()),
3754 3752 message,
3755 3753 opts.get('user') or user,
3756 3754 opts.get('date') or date,
3757 3755 branch, files, store,
3758 3756 editor=cmdutil.commiteditor)
3759 3757 repo.savecommitmessage(memctx.description())
3760 3758 n = memctx.commit()
3761 3759 finally:
3762 3760 store.close()
3763 3761 if opts.get('exact') and hex(n) != nodeid:
3764 3762 raise util.Abort(_('patch is damaged or loses information'))
3765 3763 if n:
3766 3764 # i18n: refers to a short changeset id
3767 3765 msg = _('created %s') % short(n)
3768 3766 return (msg, n)
3769 3767 finally:
3770 3768 os.unlink(tmpname)
3771 3769
3772 3770 try:
3773 3771 try:
3774 3772 wlock = repo.wlock()
3775 3773 if not opts.get('no_commit'):
3776 3774 lock = repo.lock()
3777 3775 tr = repo.transaction('import')
3778 3776 parents = repo.parents()
3779 3777 for patchurl in patches:
3780 3778 if patchurl == '-':
3781 3779 ui.status(_('applying patch from stdin\n'))
3782 3780 patchfile = ui.fin
3783 3781 patchurl = 'stdin' # for error message
3784 3782 else:
3785 3783 patchurl = os.path.join(base, patchurl)
3786 3784 ui.status(_('applying %s\n') % patchurl)
3787 3785 patchfile = hg.openpath(ui, patchurl)
3788 3786
3789 3787 haspatch = False
3790 3788 for hunk in patch.split(patchfile):
3791 3789 (msg, node) = tryone(ui, hunk, parents)
3792 3790 if msg:
3793 3791 haspatch = True
3794 3792 ui.note(msg + '\n')
3795 3793 if update or opts.get('exact'):
3796 3794 parents = repo.parents()
3797 3795 else:
3798 3796 parents = [repo[node]]
3799 3797
3800 3798 if not haspatch:
3801 3799 raise util.Abort(_('%s: no diffs found') % patchurl)
3802 3800
3803 3801 if tr:
3804 3802 tr.close()
3805 3803 if msgs:
3806 3804 repo.savecommitmessage('\n* * *\n'.join(msgs))
3807 3805 except: # re-raises
3808 3806 # wlock.release() indirectly calls dirstate.write(): since
3809 3807 # we're crashing, we do not want to change the working dir
3810 3808 # parent after all, so make sure it writes nothing
3811 3809 repo.dirstate.invalidate()
3812 3810 raise
3813 3811 finally:
3814 3812 if tr:
3815 3813 tr.release()
3816 3814 release(lock, wlock)
3817 3815
3818 3816 @command('incoming|in',
3819 3817 [('f', 'force', None,
3820 3818 _('run even if remote repository is unrelated')),
3821 3819 ('n', 'newest-first', None, _('show newest record first')),
3822 3820 ('', 'bundle', '',
3823 3821 _('file to store the bundles into'), _('FILE')),
3824 3822 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3825 3823 ('B', 'bookmarks', False, _("compare bookmarks")),
3826 3824 ('b', 'branch', [],
3827 3825 _('a specific branch you would like to pull'), _('BRANCH')),
3828 3826 ] + logopts + remoteopts + subrepoopts,
3829 3827 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3830 3828 def incoming(ui, repo, source="default", **opts):
3831 3829 """show new changesets found in source
3832 3830
3833 3831 Show new changesets found in the specified path/URL or the default
3834 3832 pull location. These are the changesets that would have been pulled
3835 3833 if a pull at the time you issued this command.
3836 3834
3837 3835 For remote repository, using --bundle avoids downloading the
3838 3836 changesets twice if the incoming is followed by a pull.
3839 3837
3840 3838 See pull for valid source format details.
3841 3839
3842 3840 Returns 0 if there are incoming changes, 1 otherwise.
3843 3841 """
3844 3842 if opts.get('graph'):
3845 3843 cmdutil.checkunsupportedgraphflags([], opts)
3846 3844 def display(other, chlist, displayer):
3847 3845 revdag = cmdutil.graphrevs(other, chlist, opts)
3848 3846 showparents = [ctx.node() for ctx in repo[None].parents()]
3849 3847 cmdutil.displaygraph(ui, revdag, displayer, showparents,
3850 3848 graphmod.asciiedges)
3851 3849
3852 3850 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3853 3851 return 0
3854 3852
3855 3853 if opts.get('bundle') and opts.get('subrepos'):
3856 3854 raise util.Abort(_('cannot combine --bundle and --subrepos'))
3857 3855
3858 3856 if opts.get('bookmarks'):
3859 3857 source, branches = hg.parseurl(ui.expandpath(source),
3860 3858 opts.get('branch'))
3861 3859 other = hg.peer(repo, opts, source)
3862 3860 if 'bookmarks' not in other.listkeys('namespaces'):
3863 3861 ui.warn(_("remote doesn't support bookmarks\n"))
3864 3862 return 0
3865 3863 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3866 3864 return bookmarks.diff(ui, repo, other)
3867 3865
3868 3866 repo._subtoppath = ui.expandpath(source)
3869 3867 try:
3870 3868 return hg.incoming(ui, repo, source, opts)
3871 3869 finally:
3872 3870 del repo._subtoppath
3873 3871
3874 3872
3875 3873 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'))
3876 3874 def init(ui, dest=".", **opts):
3877 3875 """create a new repository in the given directory
3878 3876
3879 3877 Initialize a new repository in the given directory. If the given
3880 3878 directory does not exist, it will be created.
3881 3879
3882 3880 If no directory is given, the current directory is used.
3883 3881
3884 3882 It is possible to specify an ``ssh://`` URL as the destination.
3885 3883 See :hg:`help urls` for more information.
3886 3884
3887 3885 Returns 0 on success.
3888 3886 """
3889 3887 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3890 3888
3891 3889 @command('locate',
3892 3890 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3893 3891 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3894 3892 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3895 3893 ] + walkopts,
3896 3894 _('[OPTION]... [PATTERN]...'))
3897 3895 def locate(ui, repo, *pats, **opts):
3898 3896 """locate files matching specific patterns
3899 3897
3900 3898 Print files under Mercurial control in the working directory whose
3901 3899 names match the given patterns.
3902 3900
3903 3901 By default, this command searches all directories in the working
3904 3902 directory. To search just the current directory and its
3905 3903 subdirectories, use "--include .".
3906 3904
3907 3905 If no patterns are given to match, this command prints the names
3908 3906 of all files under Mercurial control in the working directory.
3909 3907
3910 3908 If you want to feed the output of this command into the "xargs"
3911 3909 command, use the -0 option to both this command and "xargs". This
3912 3910 will avoid the problem of "xargs" treating single filenames that
3913 3911 contain whitespace as multiple filenames.
3914 3912
3915 3913 Returns 0 if a match is found, 1 otherwise.
3916 3914 """
3917 3915 end = opts.get('print0') and '\0' or '\n'
3918 3916 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
3919 3917
3920 3918 ret = 1
3921 3919 m = scmutil.match(repo[rev], pats, opts, default='relglob')
3922 3920 m.bad = lambda x, y: False
3923 3921 for abs in repo[rev].walk(m):
3924 3922 if not rev and abs not in repo.dirstate:
3925 3923 continue
3926 3924 if opts.get('fullpath'):
3927 3925 ui.write(repo.wjoin(abs), end)
3928 3926 else:
3929 3927 ui.write(((pats and m.rel(abs)) or abs), end)
3930 3928 ret = 0
3931 3929
3932 3930 return ret
3933 3931
3934 3932 @command('^log|history',
3935 3933 [('f', 'follow', None,
3936 3934 _('follow changeset history, or file history across copies and renames')),
3937 3935 ('', 'follow-first', None,
3938 3936 _('only follow the first parent of merge changesets (DEPRECATED)')),
3939 3937 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3940 3938 ('C', 'copies', None, _('show copied files')),
3941 3939 ('k', 'keyword', [],
3942 3940 _('do case-insensitive search for a given text'), _('TEXT')),
3943 3941 ('r', 'rev', [], _('show the specified revision or range'), _('REV')),
3944 3942 ('', 'removed', None, _('include revisions where files were removed')),
3945 3943 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3946 3944 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3947 3945 ('', 'only-branch', [],
3948 3946 _('show only changesets within the given named branch (DEPRECATED)'),
3949 3947 _('BRANCH')),
3950 3948 ('b', 'branch', [],
3951 3949 _('show changesets within the given named branch'), _('BRANCH')),
3952 3950 ('P', 'prune', [],
3953 3951 _('do not display revision or any of its ancestors'), _('REV')),
3954 3952 ] + logopts + walkopts,
3955 3953 _('[OPTION]... [FILE]'))
3956 3954 def log(ui, repo, *pats, **opts):
3957 3955 """show revision history of entire repository or files
3958 3956
3959 3957 Print the revision history of the specified files or the entire
3960 3958 project.
3961 3959
3962 3960 If no revision range is specified, the default is ``tip:0`` unless
3963 3961 --follow is set, in which case the working directory parent is
3964 3962 used as the starting revision.
3965 3963
3966 3964 File history is shown without following rename or copy history of
3967 3965 files. Use -f/--follow with a filename to follow history across
3968 3966 renames and copies. --follow without a filename will only show
3969 3967 ancestors or descendants of the starting revision.
3970 3968
3971 3969 By default this command prints revision number and changeset id,
3972 3970 tags, non-trivial parents, user, date and time, and a summary for
3973 3971 each commit. When the -v/--verbose switch is used, the list of
3974 3972 changed files and full commit message are shown.
3975 3973
3976 3974 .. note::
3977 3975 log -p/--patch may generate unexpected diff output for merge
3978 3976 changesets, as it will only compare the merge changeset against
3979 3977 its first parent. Also, only files different from BOTH parents
3980 3978 will appear in files:.
3981 3979
3982 3980 .. note::
3983 3981 for performance reasons, log FILE may omit duplicate changes
3984 3982 made on branches and will not show deletions. To see all
3985 3983 changes including duplicates and deletions, use the --removed
3986 3984 switch.
3987 3985
3988 3986 .. container:: verbose
3989 3987
3990 3988 Some examples:
3991 3989
3992 3990 - changesets with full descriptions and file lists::
3993 3991
3994 3992 hg log -v
3995 3993
3996 3994 - changesets ancestral to the working directory::
3997 3995
3998 3996 hg log -f
3999 3997
4000 3998 - last 10 commits on the current branch::
4001 3999
4002 4000 hg log -l 10 -b .
4003 4001
4004 4002 - changesets showing all modifications of a file, including removals::
4005 4003
4006 4004 hg log --removed file.c
4007 4005
4008 4006 - all changesets that touch a directory, with diffs, excluding merges::
4009 4007
4010 4008 hg log -Mp lib/
4011 4009
4012 4010 - all revision numbers that match a keyword::
4013 4011
4014 4012 hg log -k bug --template "{rev}\\n"
4015 4013
4016 4014 - check if a given changeset is included is a tagged release::
4017 4015
4018 4016 hg log -r "a21ccf and ancestor(1.9)"
4019 4017
4020 4018 - find all changesets by some user in a date range::
4021 4019
4022 4020 hg log -k alice -d "may 2008 to jul 2008"
4023 4021
4024 4022 - summary of all changesets after the last tag::
4025 4023
4026 4024 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4027 4025
4028 4026 See :hg:`help dates` for a list of formats valid for -d/--date.
4029 4027
4030 4028 See :hg:`help revisions` and :hg:`help revsets` for more about
4031 4029 specifying revisions.
4032 4030
4033 4031 See :hg:`help templates` for more about pre-packaged styles and
4034 4032 specifying custom templates.
4035 4033
4036 4034 Returns 0 on success.
4037 4035 """
4038 4036 if opts.get('graph'):
4039 4037 return cmdutil.graphlog(ui, repo, *pats, **opts)
4040 4038
4041 4039 matchfn = scmutil.match(repo[None], pats, opts)
4042 4040 limit = cmdutil.loglimit(opts)
4043 4041 count = 0
4044 4042
4045 4043 getrenamed, endrev = None, None
4046 4044 if opts.get('copies'):
4047 4045 if opts.get('rev'):
4048 4046 endrev = max(scmutil.revrange(repo, opts.get('rev'))) + 1
4049 4047 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4050 4048
4051 4049 df = False
4052 4050 if opts.get("date"):
4053 4051 df = util.matchdate(opts["date"])
4054 4052
4055 4053 branches = opts.get('branch', []) + opts.get('only_branch', [])
4056 4054 opts['branch'] = [repo.lookupbranch(b) for b in branches]
4057 4055
4058 4056 displayer = cmdutil.show_changeset(ui, repo, opts, True)
4059 4057 def prep(ctx, fns):
4060 4058 rev = ctx.rev()
4061 4059 parents = [p for p in repo.changelog.parentrevs(rev)
4062 4060 if p != nullrev]
4063 4061 if opts.get('no_merges') and len(parents) == 2:
4064 4062 return
4065 4063 if opts.get('only_merges') and len(parents) != 2:
4066 4064 return
4067 4065 if opts.get('branch') and ctx.branch() not in opts['branch']:
4068 4066 return
4069 4067 if df and not df(ctx.date()[0]):
4070 4068 return
4071 4069
4072 4070 lower = encoding.lower
4073 4071 if opts.get('user'):
4074 4072 luser = lower(ctx.user())
4075 4073 for k in [lower(x) for x in opts['user']]:
4076 4074 if (k in luser):
4077 4075 break
4078 4076 else:
4079 4077 return
4080 4078 if opts.get('keyword'):
4081 4079 luser = lower(ctx.user())
4082 4080 ldesc = lower(ctx.description())
4083 4081 lfiles = lower(" ".join(ctx.files()))
4084 4082 for k in [lower(x) for x in opts['keyword']]:
4085 4083 if (k in luser or k in ldesc or k in lfiles):
4086 4084 break
4087 4085 else:
4088 4086 return
4089 4087
4090 4088 copies = None
4091 4089 if getrenamed is not None and rev:
4092 4090 copies = []
4093 4091 for fn in ctx.files():
4094 4092 rename = getrenamed(fn, rev)
4095 4093 if rename:
4096 4094 copies.append((fn, rename[0]))
4097 4095
4098 4096 revmatchfn = None
4099 4097 if opts.get('patch') or opts.get('stat'):
4100 4098 if opts.get('follow') or opts.get('follow_first'):
4101 4099 # note: this might be wrong when following through merges
4102 4100 revmatchfn = scmutil.match(repo[None], fns, default='path')
4103 4101 else:
4104 4102 revmatchfn = matchfn
4105 4103
4106 4104 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4107 4105
4108 4106 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
4109 4107 if displayer.flush(ctx.rev()):
4110 4108 count += 1
4111 4109 if count == limit:
4112 4110 break
4113 4111 displayer.close()
4114 4112
4115 4113 @command('manifest',
4116 4114 [('r', 'rev', '', _('revision to display'), _('REV')),
4117 4115 ('', 'all', False, _("list files from all revisions"))],
4118 4116 _('[-r REV]'))
4119 4117 def manifest(ui, repo, node=None, rev=None, **opts):
4120 4118 """output the current or given revision of the project manifest
4121 4119
4122 4120 Print a list of version controlled files for the given revision.
4123 4121 If no revision is given, the first parent of the working directory
4124 4122 is used, or the null revision if no revision is checked out.
4125 4123
4126 4124 With -v, print file permissions, symlink and executable bits.
4127 4125 With --debug, print file revision hashes.
4128 4126
4129 4127 If option --all is specified, the list of all files from all revisions
4130 4128 is printed. This includes deleted and renamed files.
4131 4129
4132 4130 Returns 0 on success.
4133 4131 """
4134 4132
4135 4133 fm = ui.formatter('manifest', opts)
4136 4134
4137 4135 if opts.get('all'):
4138 4136 if rev or node:
4139 4137 raise util.Abort(_("can't specify a revision with --all"))
4140 4138
4141 4139 res = []
4142 4140 prefix = "data/"
4143 4141 suffix = ".i"
4144 4142 plen = len(prefix)
4145 4143 slen = len(suffix)
4146 4144 lock = repo.lock()
4147 4145 try:
4148 4146 for fn, b, size in repo.store.datafiles():
4149 4147 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4150 4148 res.append(fn[plen:-slen])
4151 4149 finally:
4152 4150 lock.release()
4153 4151 for f in res:
4154 4152 fm.startitem()
4155 4153 fm.write("path", '%s\n', f)
4156 4154 fm.end()
4157 4155 return
4158 4156
4159 4157 if rev and node:
4160 4158 raise util.Abort(_("please specify just one revision"))
4161 4159
4162 4160 if not node:
4163 4161 node = rev
4164 4162
4165 4163 char = {'l': '@', 'x': '*', '': ''}
4166 4164 mode = {'l': '644', 'x': '755', '': '644'}
4167 4165 ctx = scmutil.revsingle(repo, node)
4168 4166 mf = ctx.manifest()
4169 4167 for f in ctx:
4170 4168 fm.startitem()
4171 4169 fl = ctx[f].flags()
4172 4170 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4173 4171 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4174 4172 fm.write('path', '%s\n', f)
4175 4173 fm.end()
4176 4174
4177 4175 @command('^merge',
4178 4176 [('f', 'force', None,
4179 4177 _('force a merge including outstanding changes (DEPRECATED)')),
4180 4178 ('r', 'rev', '', _('revision to merge'), _('REV')),
4181 4179 ('P', 'preview', None,
4182 4180 _('review revisions to merge (no merge is performed)'))
4183 4181 ] + mergetoolopts,
4184 4182 _('[-P] [-f] [[-r] REV]'))
4185 4183 def merge(ui, repo, node=None, **opts):
4186 4184 """merge working directory with another revision
4187 4185
4188 4186 The current working directory is updated with all changes made in
4189 4187 the requested revision since the last common predecessor revision.
4190 4188
4191 4189 Files that changed between either parent are marked as changed for
4192 4190 the next commit and a commit must be performed before any further
4193 4191 updates to the repository are allowed. The next commit will have
4194 4192 two parents.
4195 4193
4196 4194 ``--tool`` can be used to specify the merge tool used for file
4197 4195 merges. It overrides the HGMERGE environment variable and your
4198 4196 configuration files. See :hg:`help merge-tools` for options.
4199 4197
4200 4198 If no revision is specified, the working directory's parent is a
4201 4199 head revision, and the current branch contains exactly one other
4202 4200 head, the other head is merged with by default. Otherwise, an
4203 4201 explicit revision with which to merge with must be provided.
4204 4202
4205 4203 :hg:`resolve` must be used to resolve unresolved files.
4206 4204
4207 4205 To undo an uncommitted merge, use :hg:`update --clean .` which
4208 4206 will check out a clean copy of the original merge parent, losing
4209 4207 all changes.
4210 4208
4211 4209 Returns 0 on success, 1 if there are unresolved files.
4212 4210 """
4213 4211
4214 4212 if opts.get('rev') and node:
4215 4213 raise util.Abort(_("please specify just one revision"))
4216 4214 if not node:
4217 4215 node = opts.get('rev')
4218 4216
4219 4217 if node:
4220 4218 node = scmutil.revsingle(repo, node).node()
4221 4219
4222 4220 if not node and repo._bookmarkcurrent:
4223 4221 bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
4224 4222 curhead = repo[repo._bookmarkcurrent].node()
4225 4223 if len(bmheads) == 2:
4226 4224 if curhead == bmheads[0]:
4227 4225 node = bmheads[1]
4228 4226 else:
4229 4227 node = bmheads[0]
4230 4228 elif len(bmheads) > 2:
4231 4229 raise util.Abort(_("multiple matching bookmarks to merge - "
4232 4230 "please merge with an explicit rev or bookmark"),
4233 4231 hint=_("run 'hg heads' to see all heads"))
4234 4232 elif len(bmheads) <= 1:
4235 4233 raise util.Abort(_("no matching bookmark to merge - "
4236 4234 "please merge with an explicit rev or bookmark"),
4237 4235 hint=_("run 'hg heads' to see all heads"))
4238 4236
4239 4237 if not node and not repo._bookmarkcurrent:
4240 4238 branch = repo[None].branch()
4241 4239 bheads = repo.branchheads(branch)
4242 4240 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
4243 4241
4244 4242 if len(nbhs) > 2:
4245 4243 raise util.Abort(_("branch '%s' has %d heads - "
4246 4244 "please merge with an explicit rev")
4247 4245 % (branch, len(bheads)),
4248 4246 hint=_("run 'hg heads .' to see heads"))
4249 4247
4250 4248 parent = repo.dirstate.p1()
4251 4249 if len(nbhs) <= 1:
4252 4250 if len(bheads) > 1:
4253 4251 raise util.Abort(_("heads are bookmarked - "
4254 4252 "please merge with an explicit rev"),
4255 4253 hint=_("run 'hg heads' to see all heads"))
4256 4254 if len(repo.heads()) > 1:
4257 4255 raise util.Abort(_("branch '%s' has one head - "
4258 4256 "please merge with an explicit rev")
4259 4257 % branch,
4260 4258 hint=_("run 'hg heads' to see all heads"))
4261 4259 msg, hint = _('nothing to merge'), None
4262 4260 if parent != repo.lookup(branch):
4263 4261 hint = _("use 'hg update' instead")
4264 4262 raise util.Abort(msg, hint=hint)
4265 4263
4266 4264 if parent not in bheads:
4267 4265 raise util.Abort(_('working directory not at a head revision'),
4268 4266 hint=_("use 'hg update' or merge with an "
4269 4267 "explicit revision"))
4270 4268 if parent == nbhs[0]:
4271 4269 node = nbhs[-1]
4272 4270 else:
4273 4271 node = nbhs[0]
4274 4272
4275 4273 if opts.get('preview'):
4276 4274 # find nodes that are ancestors of p2 but not of p1
4277 4275 p1 = repo.lookup('.')
4278 4276 p2 = repo.lookup(node)
4279 4277 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4280 4278
4281 4279 displayer = cmdutil.show_changeset(ui, repo, opts)
4282 4280 for node in nodes:
4283 4281 displayer.show(repo[node])
4284 4282 displayer.close()
4285 4283 return 0
4286 4284
4287 4285 try:
4288 4286 # ui.forcemerge is an internal variable, do not document
4289 4287 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
4290 4288 return hg.merge(repo, node, force=opts.get('force'))
4291 4289 finally:
4292 4290 ui.setconfig('ui', 'forcemerge', '')
4293 4291
4294 4292 @command('outgoing|out',
4295 4293 [('f', 'force', None, _('run even when the destination is unrelated')),
4296 4294 ('r', 'rev', [],
4297 4295 _('a changeset intended to be included in the destination'), _('REV')),
4298 4296 ('n', 'newest-first', None, _('show newest record first')),
4299 4297 ('B', 'bookmarks', False, _('compare bookmarks')),
4300 4298 ('b', 'branch', [], _('a specific branch you would like to push'),
4301 4299 _('BRANCH')),
4302 4300 ] + logopts + remoteopts + subrepoopts,
4303 4301 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4304 4302 def outgoing(ui, repo, dest=None, **opts):
4305 4303 """show changesets not found in the destination
4306 4304
4307 4305 Show changesets not found in the specified destination repository
4308 4306 or the default push location. These are the changesets that would
4309 4307 be pushed if a push was requested.
4310 4308
4311 4309 See pull for details of valid destination formats.
4312 4310
4313 4311 Returns 0 if there are outgoing changes, 1 otherwise.
4314 4312 """
4315 4313 if opts.get('graph'):
4316 4314 cmdutil.checkunsupportedgraphflags([], opts)
4317 4315 o = hg._outgoing(ui, repo, dest, opts)
4318 4316 if o is None:
4319 4317 return
4320 4318
4321 4319 revdag = cmdutil.graphrevs(repo, o, opts)
4322 4320 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4323 4321 showparents = [ctx.node() for ctx in repo[None].parents()]
4324 4322 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4325 4323 graphmod.asciiedges)
4326 4324 return 0
4327 4325
4328 4326 if opts.get('bookmarks'):
4329 4327 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4330 4328 dest, branches = hg.parseurl(dest, opts.get('branch'))
4331 4329 other = hg.peer(repo, opts, dest)
4332 4330 if 'bookmarks' not in other.listkeys('namespaces'):
4333 4331 ui.warn(_("remote doesn't support bookmarks\n"))
4334 4332 return 0
4335 4333 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4336 4334 return bookmarks.diff(ui, other, repo)
4337 4335
4338 4336 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4339 4337 try:
4340 4338 return hg.outgoing(ui, repo, dest, opts)
4341 4339 finally:
4342 4340 del repo._subtoppath
4343 4341
4344 4342 @command('parents',
4345 4343 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4346 4344 ] + templateopts,
4347 4345 _('[-r REV] [FILE]'))
4348 4346 def parents(ui, repo, file_=None, **opts):
4349 4347 """show the parents of the working directory or revision
4350 4348
4351 4349 Print the working directory's parent revisions. If a revision is
4352 4350 given via -r/--rev, the parent of that revision will be printed.
4353 4351 If a file argument is given, the revision in which the file was
4354 4352 last changed (before the working directory revision or the
4355 4353 argument to --rev if given) is printed.
4356 4354
4357 4355 Returns 0 on success.
4358 4356 """
4359 4357
4360 4358 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
4361 4359
4362 4360 if file_:
4363 4361 m = scmutil.match(ctx, (file_,), opts)
4364 4362 if m.anypats() or len(m.files()) != 1:
4365 4363 raise util.Abort(_('can only specify an explicit filename'))
4366 4364 file_ = m.files()[0]
4367 4365 filenodes = []
4368 4366 for cp in ctx.parents():
4369 4367 if not cp:
4370 4368 continue
4371 4369 try:
4372 4370 filenodes.append(cp.filenode(file_))
4373 4371 except error.LookupError:
4374 4372 pass
4375 4373 if not filenodes:
4376 4374 raise util.Abort(_("'%s' not found in manifest!") % file_)
4377 4375 p = []
4378 4376 for fn in filenodes:
4379 4377 fctx = repo.filectx(file_, fileid=fn)
4380 4378 p.append(fctx.node())
4381 4379 else:
4382 4380 p = [cp.node() for cp in ctx.parents()]
4383 4381
4384 4382 displayer = cmdutil.show_changeset(ui, repo, opts)
4385 4383 for n in p:
4386 4384 if n != nullid:
4387 4385 displayer.show(repo[n])
4388 4386 displayer.close()
4389 4387
4390 4388 @command('paths', [], _('[NAME]'))
4391 4389 def paths(ui, repo, search=None):
4392 4390 """show aliases for remote repositories
4393 4391
4394 4392 Show definition of symbolic path name NAME. If no name is given,
4395 4393 show definition of all available names.
4396 4394
4397 4395 Option -q/--quiet suppresses all output when searching for NAME
4398 4396 and shows only the path names when listing all definitions.
4399 4397
4400 4398 Path names are defined in the [paths] section of your
4401 4399 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
4402 4400 repository, ``.hg/hgrc`` is used, too.
4403 4401
4404 4402 The path names ``default`` and ``default-push`` have a special
4405 4403 meaning. When performing a push or pull operation, they are used
4406 4404 as fallbacks if no location is specified on the command-line.
4407 4405 When ``default-push`` is set, it will be used for push and
4408 4406 ``default`` will be used for pull; otherwise ``default`` is used
4409 4407 as the fallback for both. When cloning a repository, the clone
4410 4408 source is written as ``default`` in ``.hg/hgrc``. Note that
4411 4409 ``default`` and ``default-push`` apply to all inbound (e.g.
4412 4410 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
4413 4411 :hg:`bundle`) operations.
4414 4412
4415 4413 See :hg:`help urls` for more information.
4416 4414
4417 4415 Returns 0 on success.
4418 4416 """
4419 4417 if search:
4420 4418 for name, path in ui.configitems("paths"):
4421 4419 if name == search:
4422 4420 ui.status("%s\n" % util.hidepassword(path))
4423 4421 return
4424 4422 if not ui.quiet:
4425 4423 ui.warn(_("not found!\n"))
4426 4424 return 1
4427 4425 else:
4428 4426 for name, path in ui.configitems("paths"):
4429 4427 if ui.quiet:
4430 4428 ui.write("%s\n" % name)
4431 4429 else:
4432 4430 ui.write("%s = %s\n" % (name, util.hidepassword(path)))
4433 4431
4434 4432 @command('phase',
4435 4433 [('p', 'public', False, _('set changeset phase to public')),
4436 4434 ('d', 'draft', False, _('set changeset phase to draft')),
4437 4435 ('s', 'secret', False, _('set changeset phase to secret')),
4438 4436 ('f', 'force', False, _('allow to move boundary backward')),
4439 4437 ('r', 'rev', [], _('target revision'), _('REV')),
4440 4438 ],
4441 4439 _('[-p|-d|-s] [-f] [-r] REV...'))
4442 4440 def phase(ui, repo, *revs, **opts):
4443 4441 """set or show the current phase name
4444 4442
4445 4443 With no argument, show the phase name of specified revisions.
4446 4444
4447 4445 With one of -p/--public, -d/--draft or -s/--secret, change the
4448 4446 phase value of the specified revisions.
4449 4447
4450 4448 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
4451 4449 lower phase to an higher phase. Phases are ordered as follows::
4452 4450
4453 4451 public < draft < secret
4454 4452
4455 4453 Return 0 on success, 1 if no phases were changed or some could not
4456 4454 be changed.
4457 4455 """
4458 4456 # search for a unique phase argument
4459 4457 targetphase = None
4460 4458 for idx, name in enumerate(phases.phasenames):
4461 4459 if opts[name]:
4462 4460 if targetphase is not None:
4463 4461 raise util.Abort(_('only one phase can be specified'))
4464 4462 targetphase = idx
4465 4463
4466 4464 # look for specified revision
4467 4465 revs = list(revs)
4468 4466 revs.extend(opts['rev'])
4469 4467 if not revs:
4470 4468 raise util.Abort(_('no revisions specified'))
4471 4469
4472 4470 revs = scmutil.revrange(repo, revs)
4473 4471
4474 4472 lock = None
4475 4473 ret = 0
4476 4474 if targetphase is None:
4477 4475 # display
4478 4476 for r in revs:
4479 4477 ctx = repo[r]
4480 4478 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
4481 4479 else:
4482 4480 lock = repo.lock()
4483 4481 try:
4484 4482 # set phase
4485 4483 if not revs:
4486 4484 raise util.Abort(_('empty revision set'))
4487 4485 nodes = [repo[r].node() for r in revs]
4488 4486 olddata = repo._phasecache.getphaserevs(repo)[:]
4489 4487 phases.advanceboundary(repo, targetphase, nodes)
4490 4488 if opts['force']:
4491 4489 phases.retractboundary(repo, targetphase, nodes)
4492 4490 finally:
4493 4491 lock.release()
4494 4492 # moving revision from public to draft may hide them
4495 4493 # We have to check result on an unfiltered repository
4496 4494 unfi = repo.unfiltered()
4497 4495 newdata = repo._phasecache.getphaserevs(unfi)
4498 4496 changes = sum(o != newdata[i] for i, o in enumerate(olddata))
4499 4497 cl = unfi.changelog
4500 4498 rejected = [n for n in nodes
4501 4499 if newdata[cl.rev(n)] < targetphase]
4502 4500 if rejected:
4503 4501 ui.warn(_('cannot move %i changesets to a more permissive '
4504 4502 'phase, use --force\n') % len(rejected))
4505 4503 ret = 1
4506 4504 if changes:
4507 4505 msg = _('phase changed for %i changesets\n') % changes
4508 4506 if ret:
4509 4507 ui.status(msg)
4510 4508 else:
4511 4509 ui.note(msg)
4512 4510 else:
4513 4511 ui.warn(_('no phases changed\n'))
4514 4512 ret = 1
4515 4513 return ret
4516 4514
4517 4515 def postincoming(ui, repo, modheads, optupdate, checkout):
4518 4516 if modheads == 0:
4519 4517 return
4520 4518 if optupdate:
4521 4519 movemarkfrom = repo['.'].node()
4522 4520 try:
4523 4521 ret = hg.update(repo, checkout)
4524 4522 except util.Abort, inst:
4525 4523 ui.warn(_("not updating: %s\n") % str(inst))
4526 4524 return 0
4527 4525 if not ret and not checkout:
4528 4526 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
4529 4527 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
4530 4528 return ret
4531 4529 if modheads > 1:
4532 4530 currentbranchheads = len(repo.branchheads())
4533 4531 if currentbranchheads == modheads:
4534 4532 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
4535 4533 elif currentbranchheads > 1:
4536 4534 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
4537 4535 "merge)\n"))
4538 4536 else:
4539 4537 ui.status(_("(run 'hg heads' to see heads)\n"))
4540 4538 else:
4541 4539 ui.status(_("(run 'hg update' to get a working copy)\n"))
4542 4540
4543 4541 @command('^pull',
4544 4542 [('u', 'update', None,
4545 4543 _('update to new branch head if changesets were pulled')),
4546 4544 ('f', 'force', None, _('run even when remote repository is unrelated')),
4547 4545 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4548 4546 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
4549 4547 ('b', 'branch', [], _('a specific branch you would like to pull'),
4550 4548 _('BRANCH')),
4551 4549 ] + remoteopts,
4552 4550 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
4553 4551 def pull(ui, repo, source="default", **opts):
4554 4552 """pull changes from the specified source
4555 4553
4556 4554 Pull changes from a remote repository to a local one.
4557 4555
4558 4556 This finds all changes from the repository at the specified path
4559 4557 or URL and adds them to a local repository (the current one unless
4560 4558 -R is specified). By default, this does not update the copy of the
4561 4559 project in the working directory.
4562 4560
4563 4561 Use :hg:`incoming` if you want to see what would have been added
4564 4562 by a pull at the time you issued this command. If you then decide
4565 4563 to add those changes to the repository, you should use :hg:`pull
4566 4564 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
4567 4565
4568 4566 If SOURCE is omitted, the 'default' path will be used.
4569 4567 See :hg:`help urls` for more information.
4570 4568
4571 4569 Returns 0 on success, 1 if an update had unresolved files.
4572 4570 """
4573 4571 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4574 4572 other = hg.peer(repo, opts, source)
4575 4573 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4576 4574 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
4577 4575
4578 4576 remotebookmarks = other.listkeys('bookmarks')
4579 4577
4580 4578 if opts.get('bookmark'):
4581 4579 if not revs:
4582 4580 revs = []
4583 4581 for b in opts['bookmark']:
4584 4582 if b not in remotebookmarks:
4585 4583 raise util.Abort(_('remote bookmark %s not found!') % b)
4586 4584 revs.append(remotebookmarks[b])
4587 4585
4588 4586 if revs:
4589 4587 try:
4590 4588 revs = [other.lookup(rev) for rev in revs]
4591 4589 except error.CapabilityError:
4592 4590 err = _("other repository doesn't support revision lookup, "
4593 4591 "so a rev cannot be specified.")
4594 4592 raise util.Abort(err)
4595 4593
4596 4594 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
4597 4595 bookmarks.updatefromremote(ui, repo, remotebookmarks, source)
4598 4596 if checkout:
4599 4597 checkout = str(repo.changelog.rev(other.lookup(checkout)))
4600 4598 repo._subtoppath = source
4601 4599 try:
4602 4600 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
4603 4601
4604 4602 finally:
4605 4603 del repo._subtoppath
4606 4604
4607 4605 # update specified bookmarks
4608 4606 if opts.get('bookmark'):
4609 4607 marks = repo._bookmarks
4610 4608 for b in opts['bookmark']:
4611 4609 # explicit pull overrides local bookmark if any
4612 4610 ui.status(_("importing bookmark %s\n") % b)
4613 4611 marks[b] = repo[remotebookmarks[b]].node()
4614 4612 marks.write()
4615 4613
4616 4614 return ret
4617 4615
4618 4616 @command('^push',
4619 4617 [('f', 'force', None, _('force push')),
4620 4618 ('r', 'rev', [],
4621 4619 _('a changeset intended to be included in the destination'),
4622 4620 _('REV')),
4623 4621 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4624 4622 ('b', 'branch', [],
4625 4623 _('a specific branch you would like to push'), _('BRANCH')),
4626 4624 ('', 'new-branch', False, _('allow pushing a new branch')),
4627 4625 ] + remoteopts,
4628 4626 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4629 4627 def push(ui, repo, dest=None, **opts):
4630 4628 """push changes to the specified destination
4631 4629
4632 4630 Push changesets from the local repository to the specified
4633 4631 destination.
4634 4632
4635 4633 This operation is symmetrical to pull: it is identical to a pull
4636 4634 in the destination repository from the current one.
4637 4635
4638 4636 By default, push will not allow creation of new heads at the
4639 4637 destination, since multiple heads would make it unclear which head
4640 4638 to use. In this situation, it is recommended to pull and merge
4641 4639 before pushing.
4642 4640
4643 4641 Use --new-branch if you want to allow push to create a new named
4644 4642 branch that is not present at the destination. This allows you to
4645 4643 only create a new branch without forcing other changes.
4646 4644
4647 4645 Use -f/--force to override the default behavior and push all
4648 4646 changesets on all branches.
4649 4647
4650 4648 If -r/--rev is used, the specified revision and all its ancestors
4651 4649 will be pushed to the remote repository.
4652 4650
4653 4651 If -B/--bookmark is used, the specified bookmarked revision, its
4654 4652 ancestors, and the bookmark will be pushed to the remote
4655 4653 repository.
4656 4654
4657 4655 Please see :hg:`help urls` for important details about ``ssh://``
4658 4656 URLs. If DESTINATION is omitted, a default path will be used.
4659 4657
4660 4658 Returns 0 if push was successful, 1 if nothing to push.
4661 4659 """
4662 4660
4663 4661 if opts.get('bookmark'):
4664 4662 for b in opts['bookmark']:
4665 4663 # translate -B options to -r so changesets get pushed
4666 4664 if b in repo._bookmarks:
4667 4665 opts.setdefault('rev', []).append(b)
4668 4666 else:
4669 4667 # if we try to push a deleted bookmark, translate it to null
4670 4668 # this lets simultaneous -r, -b options continue working
4671 4669 opts.setdefault('rev', []).append("null")
4672 4670
4673 4671 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4674 4672 dest, branches = hg.parseurl(dest, opts.get('branch'))
4675 4673 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4676 4674 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4677 4675 other = hg.peer(repo, opts, dest)
4678 4676 if revs:
4679 4677 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
4680 4678
4681 4679 repo._subtoppath = dest
4682 4680 try:
4683 4681 # push subrepos depth-first for coherent ordering
4684 4682 c = repo['']
4685 4683 subs = c.substate # only repos that are committed
4686 4684 for s in sorted(subs):
4687 4685 if c.sub(s).push(opts) == 0:
4688 4686 return False
4689 4687 finally:
4690 4688 del repo._subtoppath
4691 4689 result = repo.push(other, opts.get('force'), revs=revs,
4692 4690 newbranch=opts.get('new_branch'))
4693 4691
4694 4692 result = not result
4695 4693
4696 4694 if opts.get('bookmark'):
4697 4695 rb = other.listkeys('bookmarks')
4698 4696 for b in opts['bookmark']:
4699 4697 # explicit push overrides remote bookmark if any
4700 4698 if b in repo._bookmarks:
4701 4699 ui.status(_("exporting bookmark %s\n") % b)
4702 4700 new = repo[b].hex()
4703 4701 elif b in rb:
4704 4702 ui.status(_("deleting remote bookmark %s\n") % b)
4705 4703 new = '' # delete
4706 4704 else:
4707 4705 ui.warn(_('bookmark %s does not exist on the local '
4708 4706 'or remote repository!\n') % b)
4709 4707 return 2
4710 4708 old = rb.get(b, '')
4711 4709 r = other.pushkey('bookmarks', b, old, new)
4712 4710 if not r:
4713 4711 ui.warn(_('updating bookmark %s failed!\n') % b)
4714 4712 if not result:
4715 4713 result = 2
4716 4714
4717 4715 return result
4718 4716
4719 4717 @command('recover', [])
4720 4718 def recover(ui, repo):
4721 4719 """roll back an interrupted transaction
4722 4720
4723 4721 Recover from an interrupted commit or pull.
4724 4722
4725 4723 This command tries to fix the repository status after an
4726 4724 interrupted operation. It should only be necessary when Mercurial
4727 4725 suggests it.
4728 4726
4729 4727 Returns 0 if successful, 1 if nothing to recover or verify fails.
4730 4728 """
4731 4729 if repo.recover():
4732 4730 return hg.verify(repo)
4733 4731 return 1
4734 4732
4735 4733 @command('^remove|rm',
4736 4734 [('A', 'after', None, _('record delete for missing files')),
4737 4735 ('f', 'force', None,
4738 4736 _('remove (and delete) file even if added or modified')),
4739 4737 ] + walkopts,
4740 4738 _('[OPTION]... FILE...'))
4741 4739 def remove(ui, repo, *pats, **opts):
4742 4740 """remove the specified files on the next commit
4743 4741
4744 4742 Schedule the indicated files for removal from the current branch.
4745 4743
4746 4744 This command schedules the files to be removed at the next commit.
4747 4745 To undo a remove before that, see :hg:`revert`. To undo added
4748 4746 files, see :hg:`forget`.
4749 4747
4750 4748 .. container:: verbose
4751 4749
4752 4750 -A/--after can be used to remove only files that have already
4753 4751 been deleted, -f/--force can be used to force deletion, and -Af
4754 4752 can be used to remove files from the next revision without
4755 4753 deleting them from the working directory.
4756 4754
4757 4755 The following table details the behavior of remove for different
4758 4756 file states (columns) and option combinations (rows). The file
4759 4757 states are Added [A], Clean [C], Modified [M] and Missing [!]
4760 4758 (as reported by :hg:`status`). The actions are Warn, Remove
4761 4759 (from branch) and Delete (from disk):
4762 4760
4763 4761 ======= == == == ==
4764 4762 A C M !
4765 4763 ======= == == == ==
4766 4764 none W RD W R
4767 4765 -f R RD RD R
4768 4766 -A W W W R
4769 4767 -Af R R R R
4770 4768 ======= == == == ==
4771 4769
4772 4770 Note that remove never deletes files in Added [A] state from the
4773 4771 working directory, not even if option --force is specified.
4774 4772
4775 4773 Returns 0 on success, 1 if any warnings encountered.
4776 4774 """
4777 4775
4778 4776 ret = 0
4779 4777 after, force = opts.get('after'), opts.get('force')
4780 4778 if not pats and not after:
4781 4779 raise util.Abort(_('no files specified'))
4782 4780
4783 4781 m = scmutil.match(repo[None], pats, opts)
4784 4782 s = repo.status(match=m, clean=True)
4785 4783 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
4786 4784
4787 4785 # warn about failure to delete explicit files/dirs
4788 4786 wctx = repo[None]
4789 4787 for f in m.files():
4790 4788 if f in repo.dirstate or f in wctx.dirs():
4791 4789 continue
4792 4790 if os.path.exists(m.rel(f)):
4793 4791 if os.path.isdir(m.rel(f)):
4794 4792 ui.warn(_('not removing %s: no tracked files\n') % m.rel(f))
4795 4793 else:
4796 4794 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
4797 4795 # missing files will generate a warning elsewhere
4798 4796 ret = 1
4799 4797
4800 4798 if force:
4801 4799 list = modified + deleted + clean + added
4802 4800 elif after:
4803 4801 list = deleted
4804 4802 for f in modified + added + clean:
4805 4803 ui.warn(_('not removing %s: file still exists\n') % m.rel(f))
4806 4804 ret = 1
4807 4805 else:
4808 4806 list = deleted + clean
4809 4807 for f in modified:
4810 4808 ui.warn(_('not removing %s: file is modified (use -f'
4811 4809 ' to force removal)\n') % m.rel(f))
4812 4810 ret = 1
4813 4811 for f in added:
4814 4812 ui.warn(_('not removing %s: file has been marked for add'
4815 4813 ' (use forget to undo)\n') % m.rel(f))
4816 4814 ret = 1
4817 4815
4818 4816 for f in sorted(list):
4819 4817 if ui.verbose or not m.exact(f):
4820 4818 ui.status(_('removing %s\n') % m.rel(f))
4821 4819
4822 4820 wlock = repo.wlock()
4823 4821 try:
4824 4822 if not after:
4825 4823 for f in list:
4826 4824 if f in added:
4827 4825 continue # we never unlink added files on remove
4828 4826 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
4829 4827 repo[None].forget(list)
4830 4828 finally:
4831 4829 wlock.release()
4832 4830
4833 4831 return ret
4834 4832
4835 4833 @command('rename|move|mv',
4836 4834 [('A', 'after', None, _('record a rename that has already occurred')),
4837 4835 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4838 4836 ] + walkopts + dryrunopts,
4839 4837 _('[OPTION]... SOURCE... DEST'))
4840 4838 def rename(ui, repo, *pats, **opts):
4841 4839 """rename files; equivalent of copy + remove
4842 4840
4843 4841 Mark dest as copies of sources; mark sources for deletion. If dest
4844 4842 is a directory, copies are put in that directory. If dest is a
4845 4843 file, there can only be one source.
4846 4844
4847 4845 By default, this command copies the contents of files as they
4848 4846 exist in the working directory. If invoked with -A/--after, the
4849 4847 operation is recorded, but no copying is performed.
4850 4848
4851 4849 This command takes effect at the next commit. To undo a rename
4852 4850 before that, see :hg:`revert`.
4853 4851
4854 4852 Returns 0 on success, 1 if errors are encountered.
4855 4853 """
4856 4854 wlock = repo.wlock(False)
4857 4855 try:
4858 4856 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4859 4857 finally:
4860 4858 wlock.release()
4861 4859
4862 4860 @command('resolve',
4863 4861 [('a', 'all', None, _('select all unresolved files')),
4864 4862 ('l', 'list', None, _('list state of files needing merge')),
4865 4863 ('m', 'mark', None, _('mark files as resolved')),
4866 4864 ('u', 'unmark', None, _('mark files as unresolved')),
4867 4865 ('n', 'no-status', None, _('hide status prefix'))]
4868 4866 + mergetoolopts + walkopts,
4869 4867 _('[OPTION]... [FILE]...'))
4870 4868 def resolve(ui, repo, *pats, **opts):
4871 4869 """redo merges or set/view the merge status of files
4872 4870
4873 4871 Merges with unresolved conflicts are often the result of
4874 4872 non-interactive merging using the ``internal:merge`` configuration
4875 4873 setting, or a command-line merge tool like ``diff3``. The resolve
4876 4874 command is used to manage the files involved in a merge, after
4877 4875 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4878 4876 working directory must have two parents). See :hg:`help
4879 4877 merge-tools` for information on configuring merge tools.
4880 4878
4881 4879 The resolve command can be used in the following ways:
4882 4880
4883 4881 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4884 4882 files, discarding any previous merge attempts. Re-merging is not
4885 4883 performed for files already marked as resolved. Use ``--all/-a``
4886 4884 to select all unresolved files. ``--tool`` can be used to specify
4887 4885 the merge tool used for the given files. It overrides the HGMERGE
4888 4886 environment variable and your configuration files. Previous file
4889 4887 contents are saved with a ``.orig`` suffix.
4890 4888
4891 4889 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4892 4890 (e.g. after having manually fixed-up the files). The default is
4893 4891 to mark all unresolved files.
4894 4892
4895 4893 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4896 4894 default is to mark all resolved files.
4897 4895
4898 4896 - :hg:`resolve -l`: list files which had or still have conflicts.
4899 4897 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4900 4898
4901 4899 Note that Mercurial will not let you commit files with unresolved
4902 4900 merge conflicts. You must use :hg:`resolve -m ...` before you can
4903 4901 commit after a conflicting merge.
4904 4902
4905 4903 Returns 0 on success, 1 if any files fail a resolve attempt.
4906 4904 """
4907 4905
4908 4906 all, mark, unmark, show, nostatus = \
4909 4907 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
4910 4908
4911 4909 if (show and (mark or unmark)) or (mark and unmark):
4912 4910 raise util.Abort(_("too many options specified"))
4913 4911 if pats and all:
4914 4912 raise util.Abort(_("can't specify --all and patterns"))
4915 4913 if not (all or pats or show or mark or unmark):
4916 4914 raise util.Abort(_('no files or directories specified; '
4917 4915 'use --all to remerge all files'))
4918 4916
4919 4917 ms = mergemod.mergestate(repo)
4920 4918 m = scmutil.match(repo[None], pats, opts)
4921 4919 ret = 0
4922 4920
4923 4921 for f in ms:
4924 4922 if m(f):
4925 4923 if show:
4926 4924 if nostatus:
4927 4925 ui.write("%s\n" % f)
4928 4926 else:
4929 4927 ui.write("%s %s\n" % (ms[f].upper(), f),
4930 4928 label='resolve.' +
4931 4929 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
4932 4930 elif mark:
4933 4931 ms.mark(f, "r")
4934 4932 elif unmark:
4935 4933 ms.mark(f, "u")
4936 4934 else:
4937 4935 wctx = repo[None]
4938 4936 mctx = wctx.parents()[-1]
4939 4937
4940 4938 # backup pre-resolve (merge uses .orig for its own purposes)
4941 4939 a = repo.wjoin(f)
4942 4940 util.copyfile(a, a + ".resolve")
4943 4941
4944 4942 try:
4945 4943 # resolve file
4946 4944 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''))
4947 4945 if ms.resolve(f, wctx, mctx):
4948 4946 ret = 1
4949 4947 finally:
4950 4948 ui.setconfig('ui', 'forcemerge', '')
4951 4949 ms.commit()
4952 4950
4953 4951 # replace filemerge's .orig file with our resolve file
4954 4952 util.rename(a + ".resolve", a + ".orig")
4955 4953
4956 4954 ms.commit()
4957 4955 return ret
4958 4956
4959 4957 @command('revert',
4960 4958 [('a', 'all', None, _('revert all changes when no arguments given')),
4961 4959 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4962 4960 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4963 4961 ('C', 'no-backup', None, _('do not save backup copies of files')),
4964 4962 ] + walkopts + dryrunopts,
4965 4963 _('[OPTION]... [-r REV] [NAME]...'))
4966 4964 def revert(ui, repo, *pats, **opts):
4967 4965 """restore files to their checkout state
4968 4966
4969 4967 .. note::
4970 4968 To check out earlier revisions, you should use :hg:`update REV`.
4971 4969 To cancel an uncommitted merge (and lose your changes),
4972 4970 use :hg:`update --clean .`.
4973 4971
4974 4972 With no revision specified, revert the specified files or directories
4975 4973 to the contents they had in the parent of the working directory.
4976 4974 This restores the contents of files to an unmodified
4977 4975 state and unschedules adds, removes, copies, and renames. If the
4978 4976 working directory has two parents, you must explicitly specify a
4979 4977 revision.
4980 4978
4981 4979 Using the -r/--rev or -d/--date options, revert the given files or
4982 4980 directories to their states as of a specific revision. Because
4983 4981 revert does not change the working directory parents, this will
4984 4982 cause these files to appear modified. This can be helpful to "back
4985 4983 out" some or all of an earlier change. See :hg:`backout` for a
4986 4984 related method.
4987 4985
4988 4986 Modified files are saved with a .orig suffix before reverting.
4989 4987 To disable these backups, use --no-backup.
4990 4988
4991 4989 See :hg:`help dates` for a list of formats valid for -d/--date.
4992 4990
4993 4991 Returns 0 on success.
4994 4992 """
4995 4993
4996 4994 if opts.get("date"):
4997 4995 if opts.get("rev"):
4998 4996 raise util.Abort(_("you can't specify a revision and a date"))
4999 4997 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5000 4998
5001 4999 parent, p2 = repo.dirstate.parents()
5002 5000 if not opts.get('rev') and p2 != nullid:
5003 5001 # revert after merge is a trap for new users (issue2915)
5004 5002 raise util.Abort(_('uncommitted merge with no revision specified'),
5005 5003 hint=_('use "hg update" or see "hg help revert"'))
5006 5004
5007 5005 ctx = scmutil.revsingle(repo, opts.get('rev'))
5008 5006
5009 5007 if not pats and not opts.get('all'):
5010 5008 msg = _("no files or directories specified")
5011 5009 if p2 != nullid:
5012 5010 hint = _("uncommitted merge, use --all to discard all changes,"
5013 5011 " or 'hg update -C .' to abort the merge")
5014 5012 raise util.Abort(msg, hint=hint)
5015 5013 dirty = util.any(repo.status())
5016 5014 node = ctx.node()
5017 5015 if node != parent:
5018 5016 if dirty:
5019 5017 hint = _("uncommitted changes, use --all to discard all"
5020 5018 " changes, or 'hg update %s' to update") % ctx.rev()
5021 5019 else:
5022 5020 hint = _("use --all to revert all files,"
5023 5021 " or 'hg update %s' to update") % ctx.rev()
5024 5022 elif dirty:
5025 5023 hint = _("uncommitted changes, use --all to discard all changes")
5026 5024 else:
5027 5025 hint = _("use --all to revert all files")
5028 5026 raise util.Abort(msg, hint=hint)
5029 5027
5030 5028 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5031 5029
5032 5030 @command('rollback', dryrunopts +
5033 5031 [('f', 'force', False, _('ignore safety measures'))])
5034 5032 def rollback(ui, repo, **opts):
5035 5033 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5036 5034
5037 5035 Please use :hg:`commit --amend` instead of rollback to correct
5038 5036 mistakes in the last commit.
5039 5037
5040 5038 This command should be used with care. There is only one level of
5041 5039 rollback, and there is no way to undo a rollback. It will also
5042 5040 restore the dirstate at the time of the last transaction, losing
5043 5041 any dirstate changes since that time. This command does not alter
5044 5042 the working directory.
5045 5043
5046 5044 Transactions are used to encapsulate the effects of all commands
5047 5045 that create new changesets or propagate existing changesets into a
5048 5046 repository.
5049 5047
5050 5048 .. container:: verbose
5051 5049
5052 5050 For example, the following commands are transactional, and their
5053 5051 effects can be rolled back:
5054 5052
5055 5053 - commit
5056 5054 - import
5057 5055 - pull
5058 5056 - push (with this repository as the destination)
5059 5057 - unbundle
5060 5058
5061 5059 To avoid permanent data loss, rollback will refuse to rollback a
5062 5060 commit transaction if it isn't checked out. Use --force to
5063 5061 override this protection.
5064 5062
5065 5063 This command is not intended for use on public repositories. Once
5066 5064 changes are visible for pull by other users, rolling a transaction
5067 5065 back locally is ineffective (someone else may already have pulled
5068 5066 the changes). Furthermore, a race is possible with readers of the
5069 5067 repository; for example an in-progress pull from the repository
5070 5068 may fail if a rollback is performed.
5071 5069
5072 5070 Returns 0 on success, 1 if no rollback data is available.
5073 5071 """
5074 5072 return repo.rollback(dryrun=opts.get('dry_run'),
5075 5073 force=opts.get('force'))
5076 5074
5077 5075 @command('root', [])
5078 5076 def root(ui, repo):
5079 5077 """print the root (top) of the current working directory
5080 5078
5081 5079 Print the root directory of the current repository.
5082 5080
5083 5081 Returns 0 on success.
5084 5082 """
5085 5083 ui.write(repo.root + "\n")
5086 5084
5087 5085 @command('^serve',
5088 5086 [('A', 'accesslog', '', _('name of access log file to write to'),
5089 5087 _('FILE')),
5090 5088 ('d', 'daemon', None, _('run server in background')),
5091 5089 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('NUM')),
5092 5090 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5093 5091 # use string type, then we can check if something was passed
5094 5092 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5095 5093 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5096 5094 _('ADDR')),
5097 5095 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5098 5096 _('PREFIX')),
5099 5097 ('n', 'name', '',
5100 5098 _('name to show in web pages (default: working directory)'), _('NAME')),
5101 5099 ('', 'web-conf', '',
5102 5100 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5103 5101 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5104 5102 _('FILE')),
5105 5103 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5106 5104 ('', 'stdio', None, _('for remote clients')),
5107 5105 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5108 5106 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5109 5107 ('', 'style', '', _('template style to use'), _('STYLE')),
5110 5108 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5111 5109 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5112 5110 _('[OPTION]...'))
5113 5111 def serve(ui, repo, **opts):
5114 5112 """start stand-alone webserver
5115 5113
5116 5114 Start a local HTTP repository browser and pull server. You can use
5117 5115 this for ad-hoc sharing and browsing of repositories. It is
5118 5116 recommended to use a real web server to serve a repository for
5119 5117 longer periods of time.
5120 5118
5121 5119 Please note that the server does not implement access control.
5122 5120 This means that, by default, anybody can read from the server and
5123 5121 nobody can write to it by default. Set the ``web.allow_push``
5124 5122 option to ``*`` to allow everybody to push to the server. You
5125 5123 should use a real web server if you need to authenticate users.
5126 5124
5127 5125 By default, the server logs accesses to stdout and errors to
5128 5126 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5129 5127 files.
5130 5128
5131 5129 To have the server choose a free port number to listen on, specify
5132 5130 a port number of 0; in this case, the server will print the port
5133 5131 number it uses.
5134 5132
5135 5133 Returns 0 on success.
5136 5134 """
5137 5135
5138 5136 if opts["stdio"] and opts["cmdserver"]:
5139 5137 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5140 5138
5141 5139 def checkrepo():
5142 5140 if repo is None:
5143 5141 raise error.RepoError(_("there is no Mercurial repository here"
5144 5142 " (.hg not found)"))
5145 5143
5146 5144 if opts["stdio"]:
5147 5145 checkrepo()
5148 5146 s = sshserver.sshserver(ui, repo)
5149 5147 s.serve_forever()
5150 5148
5151 5149 if opts["cmdserver"]:
5152 5150 checkrepo()
5153 5151 s = commandserver.server(ui, repo, opts["cmdserver"])
5154 5152 return s.serve()
5155 5153
5156 5154 # this way we can check if something was given in the command-line
5157 5155 if opts.get('port'):
5158 5156 opts['port'] = util.getport(opts.get('port'))
5159 5157
5160 5158 baseui = repo and repo.baseui or ui
5161 5159 optlist = ("name templates style address port prefix ipv6"
5162 5160 " accesslog errorlog certificate encoding")
5163 5161 for o in optlist.split():
5164 5162 val = opts.get(o, '')
5165 5163 if val in (None, ''): # should check against default options instead
5166 5164 continue
5167 5165 baseui.setconfig("web", o, val)
5168 5166 if repo and repo.ui != baseui:
5169 5167 repo.ui.setconfig("web", o, val)
5170 5168
5171 5169 o = opts.get('web_conf') or opts.get('webdir_conf')
5172 5170 if not o:
5173 5171 if not repo:
5174 5172 raise error.RepoError(_("there is no Mercurial repository"
5175 5173 " here (.hg not found)"))
5176 5174 o = repo
5177 5175
5178 5176 app = hgweb.hgweb(o, baseui=baseui)
5179 5177
5180 5178 class service(object):
5181 5179 def init(self):
5182 5180 util.setsignalhandler()
5183 5181 self.httpd = hgweb.server.create_server(ui, app)
5184 5182
5185 5183 if opts['port'] and not ui.verbose:
5186 5184 return
5187 5185
5188 5186 if self.httpd.prefix:
5189 5187 prefix = self.httpd.prefix.strip('/') + '/'
5190 5188 else:
5191 5189 prefix = ''
5192 5190
5193 5191 port = ':%d' % self.httpd.port
5194 5192 if port == ':80':
5195 5193 port = ''
5196 5194
5197 5195 bindaddr = self.httpd.addr
5198 5196 if bindaddr == '0.0.0.0':
5199 5197 bindaddr = '*'
5200 5198 elif ':' in bindaddr: # IPv6
5201 5199 bindaddr = '[%s]' % bindaddr
5202 5200
5203 5201 fqaddr = self.httpd.fqaddr
5204 5202 if ':' in fqaddr:
5205 5203 fqaddr = '[%s]' % fqaddr
5206 5204 if opts['port']:
5207 5205 write = ui.status
5208 5206 else:
5209 5207 write = ui.write
5210 5208 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5211 5209 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5212 5210
5213 5211 def run(self):
5214 5212 self.httpd.serve_forever()
5215 5213
5216 5214 service = service()
5217 5215
5218 5216 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5219 5217
5220 5218 @command('showconfig|debugconfig',
5221 5219 [('u', 'untrusted', None, _('show untrusted configuration options'))],
5222 5220 _('[-u] [NAME]...'))
5223 5221 def showconfig(ui, repo, *values, **opts):
5224 5222 """show combined config settings from all hgrc files
5225 5223
5226 5224 With no arguments, print names and values of all config items.
5227 5225
5228 5226 With one argument of the form section.name, print just the value
5229 5227 of that config item.
5230 5228
5231 5229 With multiple arguments, print names and values of all config
5232 5230 items with matching section names.
5233 5231
5234 5232 With --debug, the source (filename and line number) is printed
5235 5233 for each config item.
5236 5234
5237 5235 Returns 0 on success.
5238 5236 """
5239 5237
5240 5238 for f in scmutil.rcpath():
5241 5239 ui.debug('read config from: %s\n' % f)
5242 5240 untrusted = bool(opts.get('untrusted'))
5243 5241 if values:
5244 5242 sections = [v for v in values if '.' not in v]
5245 5243 items = [v for v in values if '.' in v]
5246 5244 if len(items) > 1 or items and sections:
5247 5245 raise util.Abort(_('only one config item permitted'))
5248 5246 for section, name, value in ui.walkconfig(untrusted=untrusted):
5249 5247 value = str(value).replace('\n', '\\n')
5250 5248 sectname = section + '.' + name
5251 5249 if values:
5252 5250 for v in values:
5253 5251 if v == section:
5254 5252 ui.debug('%s: ' %
5255 5253 ui.configsource(section, name, untrusted))
5256 5254 ui.write('%s=%s\n' % (sectname, value))
5257 5255 elif v == sectname:
5258 5256 ui.debug('%s: ' %
5259 5257 ui.configsource(section, name, untrusted))
5260 5258 ui.write(value, '\n')
5261 5259 else:
5262 5260 ui.debug('%s: ' %
5263 5261 ui.configsource(section, name, untrusted))
5264 5262 ui.write('%s=%s\n' % (sectname, value))
5265 5263
5266 5264 @command('^status|st',
5267 5265 [('A', 'all', None, _('show status of all files')),
5268 5266 ('m', 'modified', None, _('show only modified files')),
5269 5267 ('a', 'added', None, _('show only added files')),
5270 5268 ('r', 'removed', None, _('show only removed files')),
5271 5269 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5272 5270 ('c', 'clean', None, _('show only files without changes')),
5273 5271 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5274 5272 ('i', 'ignored', None, _('show only ignored files')),
5275 5273 ('n', 'no-status', None, _('hide status prefix')),
5276 5274 ('C', 'copies', None, _('show source of copied files')),
5277 5275 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5278 5276 ('', 'rev', [], _('show difference from revision'), _('REV')),
5279 5277 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5280 5278 ] + walkopts + subrepoopts,
5281 5279 _('[OPTION]... [FILE]...'))
5282 5280 def status(ui, repo, *pats, **opts):
5283 5281 """show changed files in the working directory
5284 5282
5285 5283 Show status of files in the repository. If names are given, only
5286 5284 files that match are shown. Files that are clean or ignored or
5287 5285 the source of a copy/move operation, are not listed unless
5288 5286 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5289 5287 Unless options described with "show only ..." are given, the
5290 5288 options -mardu are used.
5291 5289
5292 5290 Option -q/--quiet hides untracked (unknown and ignored) files
5293 5291 unless explicitly requested with -u/--unknown or -i/--ignored.
5294 5292
5295 5293 .. note::
5296 5294 status may appear to disagree with diff if permissions have
5297 5295 changed or a merge has occurred. The standard diff format does
5298 5296 not report permission changes and diff only reports changes
5299 5297 relative to one merge parent.
5300 5298
5301 5299 If one revision is given, it is used as the base revision.
5302 5300 If two revisions are given, the differences between them are
5303 5301 shown. The --change option can also be used as a shortcut to list
5304 5302 the changed files of a revision from its first parent.
5305 5303
5306 5304 The codes used to show the status of files are::
5307 5305
5308 5306 M = modified
5309 5307 A = added
5310 5308 R = removed
5311 5309 C = clean
5312 5310 ! = missing (deleted by non-hg command, but still tracked)
5313 5311 ? = not tracked
5314 5312 I = ignored
5315 5313 = origin of the previous file listed as A (added)
5316 5314
5317 5315 .. container:: verbose
5318 5316
5319 5317 Examples:
5320 5318
5321 5319 - show changes in the working directory relative to a
5322 5320 changeset::
5323 5321
5324 5322 hg status --rev 9353
5325 5323
5326 5324 - show all changes including copies in an existing changeset::
5327 5325
5328 5326 hg status --copies --change 9353
5329 5327
5330 5328 - get a NUL separated list of added files, suitable for xargs::
5331 5329
5332 5330 hg status -an0
5333 5331
5334 5332 Returns 0 on success.
5335 5333 """
5336 5334
5337 5335 revs = opts.get('rev')
5338 5336 change = opts.get('change')
5339 5337
5340 5338 if revs and change:
5341 5339 msg = _('cannot specify --rev and --change at the same time')
5342 5340 raise util.Abort(msg)
5343 5341 elif change:
5344 5342 node2 = scmutil.revsingle(repo, change, None).node()
5345 5343 node1 = repo[node2].p1().node()
5346 5344 else:
5347 5345 node1, node2 = scmutil.revpair(repo, revs)
5348 5346
5349 5347 cwd = (pats and repo.getcwd()) or ''
5350 5348 end = opts.get('print0') and '\0' or '\n'
5351 5349 copy = {}
5352 5350 states = 'modified added removed deleted unknown ignored clean'.split()
5353 5351 show = [k for k in states if opts.get(k)]
5354 5352 if opts.get('all'):
5355 5353 show += ui.quiet and (states[:4] + ['clean']) or states
5356 5354 if not show:
5357 5355 show = ui.quiet and states[:4] or states[:5]
5358 5356
5359 5357 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
5360 5358 'ignored' in show, 'clean' in show, 'unknown' in show,
5361 5359 opts.get('subrepos'))
5362 5360 changestates = zip(states, 'MAR!?IC', stat)
5363 5361
5364 5362 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
5365 5363 copy = copies.pathcopies(repo[node1], repo[node2])
5366 5364
5367 5365 fm = ui.formatter('status', opts)
5368 5366 fmt = '%s' + end
5369 5367 showchar = not opts.get('no_status')
5370 5368
5371 5369 for state, char, files in changestates:
5372 5370 if state in show:
5373 5371 label = 'status.' + state
5374 5372 for f in files:
5375 5373 fm.startitem()
5376 5374 fm.condwrite(showchar, 'status', '%s ', char, label=label)
5377 5375 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
5378 5376 if f in copy:
5379 5377 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
5380 5378 label='status.copied')
5381 5379 fm.end()
5382 5380
5383 5381 @command('^summary|sum',
5384 5382 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
5385 5383 def summary(ui, repo, **opts):
5386 5384 """summarize working directory state
5387 5385
5388 5386 This generates a brief summary of the working directory state,
5389 5387 including parents, branch, commit status, and available updates.
5390 5388
5391 5389 With the --remote option, this will check the default paths for
5392 5390 incoming and outgoing changes. This can be time-consuming.
5393 5391
5394 5392 Returns 0 on success.
5395 5393 """
5396 5394
5397 5395 ctx = repo[None]
5398 5396 parents = ctx.parents()
5399 5397 pnode = parents[0].node()
5400 5398 marks = []
5401 5399
5402 5400 for p in parents:
5403 5401 # label with log.changeset (instead of log.parent) since this
5404 5402 # shows a working directory parent *changeset*:
5405 5403 # i18n: column positioning for "hg summary"
5406 5404 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
5407 5405 label='log.changeset changeset.%s' % p.phasestr())
5408 5406 ui.write(' '.join(p.tags()), label='log.tag')
5409 5407 if p.bookmarks():
5410 5408 marks.extend(p.bookmarks())
5411 5409 if p.rev() == -1:
5412 5410 if not len(repo):
5413 5411 ui.write(_(' (empty repository)'))
5414 5412 else:
5415 5413 ui.write(_(' (no revision checked out)'))
5416 5414 ui.write('\n')
5417 5415 if p.description():
5418 5416 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5419 5417 label='log.summary')
5420 5418
5421 5419 branch = ctx.branch()
5422 5420 bheads = repo.branchheads(branch)
5423 5421 # i18n: column positioning for "hg summary"
5424 5422 m = _('branch: %s\n') % branch
5425 5423 if branch != 'default':
5426 5424 ui.write(m, label='log.branch')
5427 5425 else:
5428 5426 ui.status(m, label='log.branch')
5429 5427
5430 5428 if marks:
5431 5429 current = repo._bookmarkcurrent
5432 5430 # i18n: column positioning for "hg summary"
5433 5431 ui.write(_('bookmarks:'), label='log.bookmark')
5434 5432 if current is not None:
5435 5433 if current in marks:
5436 5434 ui.write(' *' + current, label='bookmarks.current')
5437 5435 marks.remove(current)
5438 5436 else:
5439 5437 ui.write(' [%s]' % current, label='bookmarks.current')
5440 5438 for m in marks:
5441 5439 ui.write(' ' + m, label='log.bookmark')
5442 5440 ui.write('\n', label='log.bookmark')
5443 5441
5444 5442 st = list(repo.status(unknown=True))[:6]
5445 5443
5446 5444 c = repo.dirstate.copies()
5447 5445 copied, renamed = [], []
5448 5446 for d, s in c.iteritems():
5449 5447 if s in st[2]:
5450 5448 st[2].remove(s)
5451 5449 renamed.append(d)
5452 5450 else:
5453 5451 copied.append(d)
5454 5452 if d in st[1]:
5455 5453 st[1].remove(d)
5456 5454 st.insert(3, renamed)
5457 5455 st.insert(4, copied)
5458 5456
5459 5457 ms = mergemod.mergestate(repo)
5460 5458 st.append([f for f in ms if ms[f] == 'u'])
5461 5459
5462 5460 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5463 5461 st.append(subs)
5464 5462
5465 5463 labels = [ui.label(_('%d modified'), 'status.modified'),
5466 5464 ui.label(_('%d added'), 'status.added'),
5467 5465 ui.label(_('%d removed'), 'status.removed'),
5468 5466 ui.label(_('%d renamed'), 'status.copied'),
5469 5467 ui.label(_('%d copied'), 'status.copied'),
5470 5468 ui.label(_('%d deleted'), 'status.deleted'),
5471 5469 ui.label(_('%d unknown'), 'status.unknown'),
5472 5470 ui.label(_('%d ignored'), 'status.ignored'),
5473 5471 ui.label(_('%d unresolved'), 'resolve.unresolved'),
5474 5472 ui.label(_('%d subrepos'), 'status.modified')]
5475 5473 t = []
5476 5474 for s, l in zip(st, labels):
5477 5475 if s:
5478 5476 t.append(l % len(s))
5479 5477
5480 5478 t = ', '.join(t)
5481 5479 cleanworkdir = False
5482 5480
5483 5481 if len(parents) > 1:
5484 5482 t += _(' (merge)')
5485 5483 elif branch != parents[0].branch():
5486 5484 t += _(' (new branch)')
5487 5485 elif (parents[0].closesbranch() and
5488 5486 pnode in repo.branchheads(branch, closed=True)):
5489 5487 t += _(' (head closed)')
5490 5488 elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
5491 5489 t += _(' (clean)')
5492 5490 cleanworkdir = True
5493 5491 elif pnode not in bheads:
5494 5492 t += _(' (new branch head)')
5495 5493
5496 5494 if cleanworkdir:
5497 5495 # i18n: column positioning for "hg summary"
5498 5496 ui.status(_('commit: %s\n') % t.strip())
5499 5497 else:
5500 5498 # i18n: column positioning for "hg summary"
5501 5499 ui.write(_('commit: %s\n') % t.strip())
5502 5500
5503 5501 # all ancestors of branch heads - all ancestors of parent = new csets
5504 5502 new = len(repo.changelog.findmissing([ctx.node() for ctx in parents],
5505 5503 bheads))
5506 5504
5507 5505 if new == 0:
5508 5506 # i18n: column positioning for "hg summary"
5509 5507 ui.status(_('update: (current)\n'))
5510 5508 elif pnode not in bheads:
5511 5509 # i18n: column positioning for "hg summary"
5512 5510 ui.write(_('update: %d new changesets (update)\n') % new)
5513 5511 else:
5514 5512 # i18n: column positioning for "hg summary"
5515 5513 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5516 5514 (new, len(bheads)))
5517 5515
5518 5516 cmdutil.summaryhooks(ui, repo)
5519 5517
5520 5518 if opts.get('remote'):
5521 5519 t = []
5522 5520 source, branches = hg.parseurl(ui.expandpath('default'))
5523 5521 sbranch = branches[0]
5524 5522 other = hg.peer(repo, {}, source)
5525 5523 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5526 5524 if revs:
5527 5525 revs = [other.lookup(rev) for rev in revs]
5528 5526 ui.debug('comparing with %s\n' % util.hidepassword(source))
5529 5527 repo.ui.pushbuffer()
5530 5528 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5531 5529 _common, incoming, _rheads = commoninc
5532 5530 repo.ui.popbuffer()
5533 5531 if incoming:
5534 5532 t.append(_('1 or more incoming'))
5535 5533
5536 5534 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5537 5535 dbranch = branches[0]
5538 5536 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5539 5537 if source != dest:
5540 5538 other = hg.peer(repo, {}, dest)
5541 5539 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5542 5540 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5543 5541 commoninc = None
5544 5542 if revs:
5545 5543 revs = [repo.lookup(rev) for rev in revs]
5546 5544 repo.ui.pushbuffer()
5547 5545 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs,
5548 5546 commoninc=commoninc)
5549 5547 repo.ui.popbuffer()
5550 5548 o = outgoing.missing
5551 5549 if o:
5552 5550 t.append(_('%d outgoing') % len(o))
5553 5551 if 'bookmarks' in other.listkeys('namespaces'):
5554 5552 lmarks = repo.listkeys('bookmarks')
5555 5553 rmarks = other.listkeys('bookmarks')
5556 5554 diff = set(rmarks) - set(lmarks)
5557 5555 if len(diff) > 0:
5558 5556 t.append(_('%d incoming bookmarks') % len(diff))
5559 5557 diff = set(lmarks) - set(rmarks)
5560 5558 if len(diff) > 0:
5561 5559 t.append(_('%d outgoing bookmarks') % len(diff))
5562 5560
5563 5561 if t:
5564 5562 # i18n: column positioning for "hg summary"
5565 5563 ui.write(_('remote: %s\n') % (', '.join(t)))
5566 5564 else:
5567 5565 # i18n: column positioning for "hg summary"
5568 5566 ui.status(_('remote: (synced)\n'))
5569 5567
5570 5568 @command('tag',
5571 5569 [('f', 'force', None, _('force tag')),
5572 5570 ('l', 'local', None, _('make the tag local')),
5573 5571 ('r', 'rev', '', _('revision to tag'), _('REV')),
5574 5572 ('', 'remove', None, _('remove a tag')),
5575 5573 # -l/--local is already there, commitopts cannot be used
5576 5574 ('e', 'edit', None, _('edit commit message')),
5577 5575 ('m', 'message', '', _('use <text> as commit message'), _('TEXT')),
5578 5576 ] + commitopts2,
5579 5577 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5580 5578 def tag(ui, repo, name1, *names, **opts):
5581 5579 """add one or more tags for the current or given revision
5582 5580
5583 5581 Name a particular revision using <name>.
5584 5582
5585 5583 Tags are used to name particular revisions of the repository and are
5586 5584 very useful to compare different revisions, to go back to significant
5587 5585 earlier versions or to mark branch points as releases, etc. Changing
5588 5586 an existing tag is normally disallowed; use -f/--force to override.
5589 5587
5590 5588 If no revision is given, the parent of the working directory is
5591 5589 used.
5592 5590
5593 5591 To facilitate version control, distribution, and merging of tags,
5594 5592 they are stored as a file named ".hgtags" which is managed similarly
5595 5593 to other project files and can be hand-edited if necessary. This
5596 5594 also means that tagging creates a new commit. The file
5597 5595 ".hg/localtags" is used for local tags (not shared among
5598 5596 repositories).
5599 5597
5600 5598 Tag commits are usually made at the head of a branch. If the parent
5601 5599 of the working directory is not a branch head, :hg:`tag` aborts; use
5602 5600 -f/--force to force the tag commit to be based on a non-head
5603 5601 changeset.
5604 5602
5605 5603 See :hg:`help dates` for a list of formats valid for -d/--date.
5606 5604
5607 5605 Since tag names have priority over branch names during revision
5608 5606 lookup, using an existing branch name as a tag name is discouraged.
5609 5607
5610 5608 Returns 0 on success.
5611 5609 """
5612 5610 wlock = lock = None
5613 5611 try:
5614 5612 wlock = repo.wlock()
5615 5613 lock = repo.lock()
5616 5614 rev_ = "."
5617 5615 names = [t.strip() for t in (name1,) + names]
5618 5616 if len(names) != len(set(names)):
5619 5617 raise util.Abort(_('tag names must be unique'))
5620 5618 for n in names:
5621 5619 scmutil.checknewlabel(repo, n, 'tag')
5622 5620 if not n:
5623 5621 raise util.Abort(_('tag names cannot consist entirely of '
5624 5622 'whitespace'))
5625 5623 if opts.get('rev') and opts.get('remove'):
5626 5624 raise util.Abort(_("--rev and --remove are incompatible"))
5627 5625 if opts.get('rev'):
5628 5626 rev_ = opts['rev']
5629 5627 message = opts.get('message')
5630 5628 if opts.get('remove'):
5631 5629 expectedtype = opts.get('local') and 'local' or 'global'
5632 5630 for n in names:
5633 5631 if not repo.tagtype(n):
5634 5632 raise util.Abort(_("tag '%s' does not exist") % n)
5635 5633 if repo.tagtype(n) != expectedtype:
5636 5634 if expectedtype == 'global':
5637 5635 raise util.Abort(_("tag '%s' is not a global tag") % n)
5638 5636 else:
5639 5637 raise util.Abort(_("tag '%s' is not a local tag") % n)
5640 5638 rev_ = nullid
5641 5639 if not message:
5642 5640 # we don't translate commit messages
5643 5641 message = 'Removed tag %s' % ', '.join(names)
5644 5642 elif not opts.get('force'):
5645 5643 for n in names:
5646 5644 if n in repo.tags():
5647 5645 raise util.Abort(_("tag '%s' already exists "
5648 5646 "(use -f to force)") % n)
5649 5647 if not opts.get('local'):
5650 5648 p1, p2 = repo.dirstate.parents()
5651 5649 if p2 != nullid:
5652 5650 raise util.Abort(_('uncommitted merge'))
5653 5651 bheads = repo.branchheads()
5654 5652 if not opts.get('force') and bheads and p1 not in bheads:
5655 5653 raise util.Abort(_('not at a branch head (use -f to force)'))
5656 5654 r = scmutil.revsingle(repo, rev_).node()
5657 5655
5658 5656 if not message:
5659 5657 # we don't translate commit messages
5660 5658 message = ('Added tag %s for changeset %s' %
5661 5659 (', '.join(names), short(r)))
5662 5660
5663 5661 date = opts.get('date')
5664 5662 if date:
5665 5663 date = util.parsedate(date)
5666 5664
5667 5665 if opts.get('edit'):
5668 5666 message = ui.edit(message, ui.username())
5669 5667
5670 5668 # don't allow tagging the null rev
5671 5669 if (not opts.get('remove') and
5672 5670 scmutil.revsingle(repo, rev_).rev() == nullrev):
5673 5671 raise util.Abort(_("cannot tag null revision"))
5674 5672
5675 5673 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
5676 5674 finally:
5677 5675 release(lock, wlock)
5678 5676
5679 5677 @command('tags', [], '')
5680 5678 def tags(ui, repo, **opts):
5681 5679 """list repository tags
5682 5680
5683 5681 This lists both regular and local tags. When the -v/--verbose
5684 5682 switch is used, a third column "local" is printed for local tags.
5685 5683
5686 5684 Returns 0 on success.
5687 5685 """
5688 5686
5689 5687 fm = ui.formatter('tags', opts)
5690 5688 hexfunc = ui.debugflag and hex or short
5691 5689 tagtype = ""
5692 5690
5693 5691 for t, n in reversed(repo.tagslist()):
5694 5692 hn = hexfunc(n)
5695 5693 label = 'tags.normal'
5696 5694 tagtype = ''
5697 5695 if repo.tagtype(t) == 'local':
5698 5696 label = 'tags.local'
5699 5697 tagtype = 'local'
5700 5698
5701 5699 fm.startitem()
5702 5700 fm.write('tag', '%s', t, label=label)
5703 5701 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5704 5702 fm.condwrite(not ui.quiet, 'rev id', fmt,
5705 5703 repo.changelog.rev(n), hn, label=label)
5706 5704 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5707 5705 tagtype, label=label)
5708 5706 fm.plain('\n')
5709 5707 fm.end()
5710 5708
5711 5709 @command('tip',
5712 5710 [('p', 'patch', None, _('show patch')),
5713 5711 ('g', 'git', None, _('use git extended diff format')),
5714 5712 ] + templateopts,
5715 5713 _('[-p] [-g]'))
5716 5714 def tip(ui, repo, **opts):
5717 5715 """show the tip revision (DEPRECATED)
5718 5716
5719 5717 The tip revision (usually just called the tip) is the changeset
5720 5718 most recently added to the repository (and therefore the most
5721 5719 recently changed head).
5722 5720
5723 5721 If you have just made a commit, that commit will be the tip. If
5724 5722 you have just pulled changes from another repository, the tip of
5725 5723 that repository becomes the current tip. The "tip" tag is special
5726 5724 and cannot be renamed or assigned to a different changeset.
5727 5725
5728 5726 This command is deprecated, please use :hg:`heads` instead.
5729 5727
5730 5728 Returns 0 on success.
5731 5729 """
5732 5730 displayer = cmdutil.show_changeset(ui, repo, opts)
5733 5731 displayer.show(repo['tip'])
5734 5732 displayer.close()
5735 5733
5736 5734 @command('unbundle',
5737 5735 [('u', 'update', None,
5738 5736 _('update to new branch head if changesets were unbundled'))],
5739 5737 _('[-u] FILE...'))
5740 5738 def unbundle(ui, repo, fname1, *fnames, **opts):
5741 5739 """apply one or more changegroup files
5742 5740
5743 5741 Apply one or more compressed changegroup files generated by the
5744 5742 bundle command.
5745 5743
5746 5744 Returns 0 on success, 1 if an update has unresolved files.
5747 5745 """
5748 5746 fnames = (fname1,) + fnames
5749 5747
5750 5748 lock = repo.lock()
5751 5749 wc = repo['.']
5752 5750 try:
5753 5751 for fname in fnames:
5754 5752 f = hg.openpath(ui, fname)
5755 5753 gen = changegroup.readbundle(f, fname)
5756 5754 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
5757 5755 finally:
5758 5756 lock.release()
5759 5757 bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch())
5760 5758 return postincoming(ui, repo, modheads, opts.get('update'), None)
5761 5759
5762 5760 @command('^update|up|checkout|co',
5763 5761 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5764 5762 ('c', 'check', None,
5765 5763 _('update across branches if no uncommitted changes')),
5766 5764 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5767 5765 ('r', 'rev', '', _('revision'), _('REV'))],
5768 5766 _('[-c] [-C] [-d DATE] [[-r] REV]'))
5769 5767 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
5770 5768 """update working directory (or switch revisions)
5771 5769
5772 5770 Update the repository's working directory to the specified
5773 5771 changeset. If no changeset is specified, update to the tip of the
5774 5772 current named branch and move the current bookmark (see :hg:`help
5775 5773 bookmarks`).
5776 5774
5777 5775 Update sets the working directory's parent revision to the specified
5778 5776 changeset (see :hg:`help parents`).
5779 5777
5780 5778 If the changeset is not a descendant or ancestor of the working
5781 5779 directory's parent, the update is aborted. With the -c/--check
5782 5780 option, the working directory is checked for uncommitted changes; if
5783 5781 none are found, the working directory is updated to the specified
5784 5782 changeset.
5785 5783
5786 5784 .. container:: verbose
5787 5785
5788 5786 The following rules apply when the working directory contains
5789 5787 uncommitted changes:
5790 5788
5791 5789 1. If neither -c/--check nor -C/--clean is specified, and if
5792 5790 the requested changeset is an ancestor or descendant of
5793 5791 the working directory's parent, the uncommitted changes
5794 5792 are merged into the requested changeset and the merged
5795 5793 result is left uncommitted. If the requested changeset is
5796 5794 not an ancestor or descendant (that is, it is on another
5797 5795 branch), the update is aborted and the uncommitted changes
5798 5796 are preserved.
5799 5797
5800 5798 2. With the -c/--check option, the update is aborted and the
5801 5799 uncommitted changes are preserved.
5802 5800
5803 5801 3. With the -C/--clean option, uncommitted changes are discarded and
5804 5802 the working directory is updated to the requested changeset.
5805 5803
5806 5804 To cancel an uncommitted merge (and lose your changes), use
5807 5805 :hg:`update --clean .`.
5808 5806
5809 5807 Use null as the changeset to remove the working directory (like
5810 5808 :hg:`clone -U`).
5811 5809
5812 5810 If you want to revert just one file to an older revision, use
5813 5811 :hg:`revert [-r REV] NAME`.
5814 5812
5815 5813 See :hg:`help dates` for a list of formats valid for -d/--date.
5816 5814
5817 5815 Returns 0 on success, 1 if there are unresolved files.
5818 5816 """
5819 5817 if rev and node:
5820 5818 raise util.Abort(_("please specify just one revision"))
5821 5819
5822 5820 if rev is None or rev == '':
5823 5821 rev = node
5824 5822
5825 5823 # with no argument, we also move the current bookmark, if any
5826 5824 movemarkfrom = None
5827 5825 if rev is None:
5828 5826 curmark = repo._bookmarkcurrent
5829 5827 if bookmarks.iscurrent(repo):
5830 5828 movemarkfrom = repo['.'].node()
5831 5829 elif curmark:
5832 5830 ui.status(_("updating to active bookmark %s\n") % curmark)
5833 5831 rev = curmark
5834 5832
5835 5833 # if we defined a bookmark, we have to remember the original bookmark name
5836 5834 brev = rev
5837 5835 rev = scmutil.revsingle(repo, rev, rev).rev()
5838 5836
5839 5837 if check and clean:
5840 5838 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
5841 5839
5842 5840 if date:
5843 5841 if rev is not None:
5844 5842 raise util.Abort(_("you can't specify a revision and a date"))
5845 5843 rev = cmdutil.finddate(ui, repo, date)
5846 5844
5847 5845 if check:
5848 5846 c = repo[None]
5849 5847 if c.dirty(merge=False, branch=False, missing=True):
5850 5848 raise util.Abort(_("uncommitted local changes"))
5851 5849 if rev is None:
5852 5850 rev = repo[repo[None].branch()].rev()
5853 5851 mergemod._checkunknown(repo, repo[None], repo[rev])
5854 5852
5855 5853 if clean:
5856 5854 ret = hg.clean(repo, rev)
5857 5855 else:
5858 5856 ret = hg.update(repo, rev)
5859 5857
5860 5858 if not ret and movemarkfrom:
5861 5859 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5862 5860 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
5863 5861 elif brev in repo._bookmarks:
5864 5862 bookmarks.setcurrent(repo, brev)
5865 5863 elif brev:
5866 5864 bookmarks.unsetcurrent(repo)
5867 5865
5868 5866 return ret
5869 5867
5870 5868 @command('verify', [])
5871 5869 def verify(ui, repo):
5872 5870 """verify the integrity of the repository
5873 5871
5874 5872 Verify the integrity of the current repository.
5875 5873
5876 5874 This will perform an extensive check of the repository's
5877 5875 integrity, validating the hashes and checksums of each entry in
5878 5876 the changelog, manifest, and tracked files, as well as the
5879 5877 integrity of their crosslinks and indices.
5880 5878
5881 5879 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption
5882 5880 for more information about recovery from corruption of the
5883 5881 repository.
5884 5882
5885 5883 Returns 0 on success, 1 if errors are encountered.
5886 5884 """
5887 5885 return hg.verify(repo)
5888 5886
5889 5887 @command('version', [])
5890 5888 def version_(ui):
5891 5889 """output version and copyright information"""
5892 5890 ui.write(_("Mercurial Distributed SCM (version %s)\n")
5893 5891 % util.version())
5894 5892 ui.status(_(
5895 5893 "(see http://mercurial.selenic.com for more information)\n"
5896 5894 "\nCopyright (C) 2005-2013 Matt Mackall and others\n"
5897 5895 "This is free software; see the source for copying conditions. "
5898 5896 "There is NO\nwarranty; "
5899 5897 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5900 5898 ))
5901 5899
5902 5900 norepo = ("clone init version help debugcommands debugcomplete"
5903 5901 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
5904 5902 " debugknown debuggetbundle debugbundle")
5905 5903 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
5906 5904 " debugdata debugindex debugindexdot debugrevlog")
5907 5905 inferrepo = ("add addremove annotate cat commit diff grep forget log parents"
5908 5906 " remove resolve status debugwalk")
@@ -1,445 +1,445 b''
1 1 $ hg init a
2 2 $ cd a
3 3 $ echo a > a
4 4 $ hg ci -A -d'1 0' -m a
5 5 adding a
6 6
7 7 $ cd ..
8 8
9 9 $ hg init b
10 10 $ cd b
11 11 $ echo b > b
12 12 $ hg ci -A -d'1 0' -m b
13 13 adding b
14 14
15 15 $ cd ..
16 16
17 17 $ hg clone a c
18 18 updating to branch default
19 19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
20 20 $ cd c
21 21 $ cat >> .hg/hgrc <<EOF
22 22 > [paths]
23 23 > relative = ../a
24 24 > EOF
25 25 $ hg pull -f ../b
26 26 pulling from ../b
27 27 searching for changes
28 28 warning: repository is unrelated
29 29 requesting all changes
30 30 adding changesets
31 31 adding manifests
32 32 adding file changes
33 33 added 1 changesets with 1 changes to 1 files (+1 heads)
34 34 (run 'hg heads' to see heads, 'hg merge' to merge)
35 35 $ hg merge
36 36 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
37 37 (branch merge, don't forget to commit)
38 38
39 39 $ cd ..
40 40
41 41 Testing -R/--repository:
42 42
43 43 $ hg -R a tip
44 44 changeset: 0:8580ff50825a
45 45 tag: tip
46 46 user: test
47 47 date: Thu Jan 01 00:00:01 1970 +0000
48 48 summary: a
49 49
50 50 $ hg --repository b tip
51 51 changeset: 0:b6c483daf290
52 52 tag: tip
53 53 user: test
54 54 date: Thu Jan 01 00:00:01 1970 +0000
55 55 summary: b
56 56
57 57
58 58 -R with a URL:
59 59
60 60 $ hg -R file:a identify
61 61 8580ff50825a tip
62 62 $ hg -R file://localhost/`pwd`/a/ identify
63 63 8580ff50825a tip
64 64
65 65 -R with path aliases:
66 66
67 67 $ cd c
68 68 $ hg -R default identify
69 69 8580ff50825a tip
70 70 $ hg -R relative identify
71 71 8580ff50825a tip
72 72 $ echo '[paths]' >> $HGRCPATH
73 73 $ echo 'relativetohome = a' >> $HGRCPATH
74 74 $ HOME=`pwd`/../ hg -R relativetohome identify
75 75 8580ff50825a tip
76 76 $ cd ..
77 77
78 78 #if no-outer-repo
79 79
80 80 Implicit -R:
81 81
82 82 $ hg ann a/a
83 83 0: a
84 84 $ hg ann a/a a/a
85 85 0: a
86 86 $ hg ann a/a b/b
87 87 abort: no repository found in '$TESTTMP' (.hg not found)!
88 88 [255]
89 89 $ hg -R b ann a/a
90 90 abort: a/a not under root '$TESTTMP/b' (glob)
91 91 [255]
92 92 $ hg log
93 93 abort: no repository found in '$TESTTMP' (.hg not found)!
94 94 [255]
95 95
96 96 #endif
97 97
98 98 Abbreviation of long option:
99 99
100 100 $ hg --repo c tip
101 101 changeset: 1:b6c483daf290
102 102 tag: tip
103 103 parent: -1:000000000000
104 104 user: test
105 105 date: Thu Jan 01 00:00:01 1970 +0000
106 106 summary: b
107 107
108 108
109 109 earlygetopt with duplicate options (36d23de02da1):
110 110
111 111 $ hg --cwd a --cwd b --cwd c tip
112 112 changeset: 1:b6c483daf290
113 113 tag: tip
114 114 parent: -1:000000000000
115 115 user: test
116 116 date: Thu Jan 01 00:00:01 1970 +0000
117 117 summary: b
118 118
119 119 $ hg --repo c --repository b -R a tip
120 120 changeset: 0:8580ff50825a
121 121 tag: tip
122 122 user: test
123 123 date: Thu Jan 01 00:00:01 1970 +0000
124 124 summary: a
125 125
126 126
127 127 earlygetopt short option without following space:
128 128
129 129 $ hg -q -Rb tip
130 130 0:b6c483daf290
131 131
132 132 earlygetopt with illegal abbreviations:
133 133
134 134 $ hg --confi "foo.bar=baz"
135 135 abort: option --config may not be abbreviated!
136 136 [255]
137 137 $ hg --cw a tip
138 138 abort: option --cwd may not be abbreviated!
139 139 [255]
140 140 $ hg --rep a tip
141 141 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
142 142 [255]
143 143 $ hg --repositor a tip
144 144 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
145 145 [255]
146 146 $ hg -qR a tip
147 147 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
148 148 [255]
149 149 $ hg -qRa tip
150 150 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
151 151 [255]
152 152
153 153 Testing --cwd:
154 154
155 155 $ hg --cwd a parents
156 156 changeset: 0:8580ff50825a
157 157 tag: tip
158 158 user: test
159 159 date: Thu Jan 01 00:00:01 1970 +0000
160 160 summary: a
161 161
162 162
163 163 Testing -y/--noninteractive - just be sure it is parsed:
164 164
165 165 $ hg --cwd a tip -q --noninteractive
166 166 0:8580ff50825a
167 167 $ hg --cwd a tip -q -y
168 168 0:8580ff50825a
169 169
170 170 Testing -q/--quiet:
171 171
172 172 $ hg -R a -q tip
173 173 0:8580ff50825a
174 174 $ hg -R b -q tip
175 175 0:b6c483daf290
176 176 $ hg -R c --quiet parents
177 177 0:8580ff50825a
178 178 1:b6c483daf290
179 179
180 180 Testing -v/--verbose:
181 181
182 182 $ hg --cwd c head -v
183 183 changeset: 1:b6c483daf290
184 184 tag: tip
185 185 parent: -1:000000000000
186 186 user: test
187 187 date: Thu Jan 01 00:00:01 1970 +0000
188 188 files: b
189 189 description:
190 190 b
191 191
192 192
193 193 changeset: 0:8580ff50825a
194 194 user: test
195 195 date: Thu Jan 01 00:00:01 1970 +0000
196 196 files: a
197 197 description:
198 198 a
199 199
200 200
201 201 $ hg --cwd b tip --verbose
202 202 changeset: 0:b6c483daf290
203 203 tag: tip
204 204 user: test
205 205 date: Thu Jan 01 00:00:01 1970 +0000
206 206 files: b
207 207 description:
208 208 b
209 209
210 210
211 211
212 212 Testing --config:
213 213
214 214 $ hg --cwd c --config paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
215 215 quuxfoo
216 216 $ hg --cwd c --config '' tip -q
217 217 abort: malformed --config option: '' (use --config section.name=value)
218 218 [255]
219 219 $ hg --cwd c --config a.b tip -q
220 220 abort: malformed --config option: 'a.b' (use --config section.name=value)
221 221 [255]
222 222 $ hg --cwd c --config a tip -q
223 223 abort: malformed --config option: 'a' (use --config section.name=value)
224 224 [255]
225 225 $ hg --cwd c --config a.= tip -q
226 226 abort: malformed --config option: 'a.=' (use --config section.name=value)
227 227 [255]
228 228 $ hg --cwd c --config .b= tip -q
229 229 abort: malformed --config option: '.b=' (use --config section.name=value)
230 230 [255]
231 231
232 232 Testing --debug:
233 233
234 234 $ hg --cwd c log --debug
235 235 changeset: 1:b6c483daf2907ce5825c0bb50f5716226281cc1a
236 236 tag: tip
237 237 parent: -1:0000000000000000000000000000000000000000
238 238 parent: -1:0000000000000000000000000000000000000000
239 239 manifest: 1:23226e7a252cacdc2d99e4fbdc3653441056de49
240 240 user: test
241 241 date: Thu Jan 01 00:00:01 1970 +0000
242 242 files+: b
243 243 extra: branch=default
244 244 description:
245 245 b
246 246
247 247
248 248 changeset: 0:8580ff50825a50c8f716709acdf8de0deddcd6ab
249 249 parent: -1:0000000000000000000000000000000000000000
250 250 parent: -1:0000000000000000000000000000000000000000
251 251 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
252 252 user: test
253 253 date: Thu Jan 01 00:00:01 1970 +0000
254 254 files+: a
255 255 extra: branch=default
256 256 description:
257 257 a
258 258
259 259
260 260
261 261 Testing --traceback:
262 262
263 263 $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback'
264 264 Traceback (most recent call last):
265 265
266 266 Testing --time:
267 267
268 268 $ hg --cwd a --time id
269 269 8580ff50825a tip
270 270 time: real * (glob)
271 271
272 272 Testing --version:
273 273
274 274 $ hg --version -q
275 275 Mercurial Distributed SCM * (glob)
276 276
277 277 hide outer repo
278 278 $ hg init
279 279
280 280 Testing -h/--help:
281 281
282 282 $ hg -h
283 283 Mercurial Distributed SCM
284 284
285 285 list of commands:
286 286
287 287 add add the specified files on the next commit
288 288 addremove add all new files, delete all missing files
289 289 annotate show changeset information by line for each file
290 290 archive create an unversioned archive of a repository revision
291 291 backout reverse effect of earlier changeset
292 292 bisect subdivision search of changesets
293 293 bookmarks track a line of development with movable markers
294 294 branch set or show the current branch name
295 295 branches list repository named branches
296 296 bundle create a changegroup file
297 297 cat output the current or given revision of files
298 298 clone make a copy of an existing repository
299 299 commit commit the specified files or all outstanding changes
300 300 copy mark files as copied for the next commit
301 301 diff diff repository (or selected files)
302 302 export dump the header and diffs for one or more changesets
303 303 forget forget the specified files on the next commit
304 304 graft copy changes from other branches onto the current branch
305 305 grep search for a pattern in specified files and revisions
306 heads show current repository heads or show branch heads
306 heads show branch heads
307 307 help show help for a given topic or a help overview
308 308 identify identify the working copy or specified revision
309 309 import import an ordered set of patches
310 310 incoming show new changesets found in source
311 311 init create a new repository in the given directory
312 312 locate locate files matching specific patterns
313 313 log show revision history of entire repository or files
314 314 manifest output the current or given revision of the project manifest
315 315 merge merge working directory with another revision
316 316 outgoing show changesets not found in the destination
317 317 parents show the parents of the working directory or revision
318 318 paths show aliases for remote repositories
319 319 phase set or show the current phase name
320 320 pull pull changes from the specified source
321 321 push push changes to the specified destination
322 322 recover roll back an interrupted transaction
323 323 remove remove the specified files on the next commit
324 324 rename rename files; equivalent of copy + remove
325 325 resolve redo merges or set/view the merge status of files
326 326 revert restore files to their checkout state
327 327 root print the root (top) of the current working directory
328 328 serve start stand-alone webserver
329 329 showconfig show combined config settings from all hgrc files
330 330 status show changed files in the working directory
331 331 summary summarize working directory state
332 332 tag add one or more tags for the current or given revision
333 333 tags list repository tags
334 334 unbundle apply one or more changegroup files
335 335 update update working directory (or switch revisions)
336 336 verify verify the integrity of the repository
337 337 version output version and copyright information
338 338
339 339 additional help topics:
340 340
341 341 config Configuration Files
342 342 dates Date Formats
343 343 diffs Diff Formats
344 344 environment Environment Variables
345 345 extensions Using Additional Features
346 346 filesets Specifying File Sets
347 347 glossary Glossary
348 348 hgignore Syntax for Mercurial Ignore Files
349 349 hgweb Configuring hgweb
350 350 merge-tools Merge Tools
351 351 multirevs Specifying Multiple Revisions
352 352 patterns File Name Patterns
353 353 phases Working with Phases
354 354 revisions Specifying Single Revisions
355 355 revsets Specifying Revision Sets
356 356 subrepos Subrepositories
357 357 templating Template Usage
358 358 urls URL Paths
359 359
360 360 use "hg -v help" to show builtin aliases and global options
361 361
362 362
363 363
364 364 $ hg --help
365 365 Mercurial Distributed SCM
366 366
367 367 list of commands:
368 368
369 369 add add the specified files on the next commit
370 370 addremove add all new files, delete all missing files
371 371 annotate show changeset information by line for each file
372 372 archive create an unversioned archive of a repository revision
373 373 backout reverse effect of earlier changeset
374 374 bisect subdivision search of changesets
375 375 bookmarks track a line of development with movable markers
376 376 branch set or show the current branch name
377 377 branches list repository named branches
378 378 bundle create a changegroup file
379 379 cat output the current or given revision of files
380 380 clone make a copy of an existing repository
381 381 commit commit the specified files or all outstanding changes
382 382 copy mark files as copied for the next commit
383 383 diff diff repository (or selected files)
384 384 export dump the header and diffs for one or more changesets
385 385 forget forget the specified files on the next commit
386 386 graft copy changes from other branches onto the current branch
387 387 grep search for a pattern in specified files and revisions
388 heads show current repository heads or show branch heads
388 heads show branch heads
389 389 help show help for a given topic or a help overview
390 390 identify identify the working copy or specified revision
391 391 import import an ordered set of patches
392 392 incoming show new changesets found in source
393 393 init create a new repository in the given directory
394 394 locate locate files matching specific patterns
395 395 log show revision history of entire repository or files
396 396 manifest output the current or given revision of the project manifest
397 397 merge merge working directory with another revision
398 398 outgoing show changesets not found in the destination
399 399 parents show the parents of the working directory or revision
400 400 paths show aliases for remote repositories
401 401 phase set or show the current phase name
402 402 pull pull changes from the specified source
403 403 push push changes to the specified destination
404 404 recover roll back an interrupted transaction
405 405 remove remove the specified files on the next commit
406 406 rename rename files; equivalent of copy + remove
407 407 resolve redo merges or set/view the merge status of files
408 408 revert restore files to their checkout state
409 409 root print the root (top) of the current working directory
410 410 serve start stand-alone webserver
411 411 showconfig show combined config settings from all hgrc files
412 412 status show changed files in the working directory
413 413 summary summarize working directory state
414 414 tag add one or more tags for the current or given revision
415 415 tags list repository tags
416 416 unbundle apply one or more changegroup files
417 417 update update working directory (or switch revisions)
418 418 verify verify the integrity of the repository
419 419 version output version and copyright information
420 420
421 421 additional help topics:
422 422
423 423 config Configuration Files
424 424 dates Date Formats
425 425 diffs Diff Formats
426 426 environment Environment Variables
427 427 extensions Using Additional Features
428 428 filesets Specifying File Sets
429 429 glossary Glossary
430 430 hgignore Syntax for Mercurial Ignore Files
431 431 hgweb Configuring hgweb
432 432 merge-tools Merge Tools
433 433 multirevs Specifying Multiple Revisions
434 434 patterns File Name Patterns
435 435 phases Working with Phases
436 436 revisions Specifying Single Revisions
437 437 revsets Specifying Revision Sets
438 438 subrepos Subrepositories
439 439 templating Template Usage
440 440 urls URL Paths
441 441
442 442 use "hg -v help" to show builtin aliases and global options
443 443
444 444 Not tested: --debugger
445 445
@@ -1,1905 +1,1905 b''
1 1 Short help:
2 2
3 3 $ hg
4 4 Mercurial Distributed SCM
5 5
6 6 basic commands:
7 7
8 8 add add the specified files on the next commit
9 9 annotate show changeset information by line for each file
10 10 clone make a copy of an existing repository
11 11 commit commit the specified files or all outstanding changes
12 12 diff diff repository (or selected files)
13 13 export dump the header and diffs for one or more changesets
14 14 forget forget the specified files on the next commit
15 15 init create a new repository in the given directory
16 16 log show revision history of entire repository or files
17 17 merge merge working directory with another revision
18 18 pull pull changes from the specified source
19 19 push push changes to the specified destination
20 20 remove remove the specified files on the next commit
21 21 serve start stand-alone webserver
22 22 status show changed files in the working directory
23 23 summary summarize working directory state
24 24 update update working directory (or switch revisions)
25 25
26 26 use "hg help" for the full list of commands or "hg -v" for details
27 27
28 28 $ hg -q
29 29 add add the specified files on the next commit
30 30 annotate show changeset information by line for each file
31 31 clone make a copy of an existing repository
32 32 commit commit the specified files or all outstanding changes
33 33 diff diff repository (or selected files)
34 34 export dump the header and diffs for one or more changesets
35 35 forget forget the specified files on the next commit
36 36 init create a new repository in the given directory
37 37 log show revision history of entire repository or files
38 38 merge merge working directory with another revision
39 39 pull pull changes from the specified source
40 40 push push changes to the specified destination
41 41 remove remove the specified files on the next commit
42 42 serve start stand-alone webserver
43 43 status show changed files in the working directory
44 44 summary summarize working directory state
45 45 update update working directory (or switch revisions)
46 46
47 47 $ hg help
48 48 Mercurial Distributed SCM
49 49
50 50 list of commands:
51 51
52 52 add add the specified files on the next commit
53 53 addremove add all new files, delete all missing files
54 54 annotate show changeset information by line for each file
55 55 archive create an unversioned archive of a repository revision
56 56 backout reverse effect of earlier changeset
57 57 bisect subdivision search of changesets
58 58 bookmarks track a line of development with movable markers
59 59 branch set or show the current branch name
60 60 branches list repository named branches
61 61 bundle create a changegroup file
62 62 cat output the current or given revision of files
63 63 clone make a copy of an existing repository
64 64 commit commit the specified files or all outstanding changes
65 65 copy mark files as copied for the next commit
66 66 diff diff repository (or selected files)
67 67 export dump the header and diffs for one or more changesets
68 68 forget forget the specified files on the next commit
69 69 graft copy changes from other branches onto the current branch
70 70 grep search for a pattern in specified files and revisions
71 heads show current repository heads or show branch heads
71 heads show branch heads
72 72 help show help for a given topic or a help overview
73 73 identify identify the working copy or specified revision
74 74 import import an ordered set of patches
75 75 incoming show new changesets found in source
76 76 init create a new repository in the given directory
77 77 locate locate files matching specific patterns
78 78 log show revision history of entire repository or files
79 79 manifest output the current or given revision of the project manifest
80 80 merge merge working directory with another revision
81 81 outgoing show changesets not found in the destination
82 82 parents show the parents of the working directory or revision
83 83 paths show aliases for remote repositories
84 84 phase set or show the current phase name
85 85 pull pull changes from the specified source
86 86 push push changes to the specified destination
87 87 recover roll back an interrupted transaction
88 88 remove remove the specified files on the next commit
89 89 rename rename files; equivalent of copy + remove
90 90 resolve redo merges or set/view the merge status of files
91 91 revert restore files to their checkout state
92 92 root print the root (top) of the current working directory
93 93 serve start stand-alone webserver
94 94 showconfig show combined config settings from all hgrc files
95 95 status show changed files in the working directory
96 96 summary summarize working directory state
97 97 tag add one or more tags for the current or given revision
98 98 tags list repository tags
99 99 unbundle apply one or more changegroup files
100 100 update update working directory (or switch revisions)
101 101 verify verify the integrity of the repository
102 102 version output version and copyright information
103 103
104 104 additional help topics:
105 105
106 106 config Configuration Files
107 107 dates Date Formats
108 108 diffs Diff Formats
109 109 environment Environment Variables
110 110 extensions Using Additional Features
111 111 filesets Specifying File Sets
112 112 glossary Glossary
113 113 hgignore Syntax for Mercurial Ignore Files
114 114 hgweb Configuring hgweb
115 115 merge-tools Merge Tools
116 116 multirevs Specifying Multiple Revisions
117 117 patterns File Name Patterns
118 118 phases Working with Phases
119 119 revisions Specifying Single Revisions
120 120 revsets Specifying Revision Sets
121 121 subrepos Subrepositories
122 122 templating Template Usage
123 123 urls URL Paths
124 124
125 125 use "hg -v help" to show builtin aliases and global options
126 126
127 127 $ hg -q help
128 128 add add the specified files on the next commit
129 129 addremove add all new files, delete all missing files
130 130 annotate show changeset information by line for each file
131 131 archive create an unversioned archive of a repository revision
132 132 backout reverse effect of earlier changeset
133 133 bisect subdivision search of changesets
134 134 bookmarks track a line of development with movable markers
135 135 branch set or show the current branch name
136 136 branches list repository named branches
137 137 bundle create a changegroup file
138 138 cat output the current or given revision of files
139 139 clone make a copy of an existing repository
140 140 commit commit the specified files or all outstanding changes
141 141 copy mark files as copied for the next commit
142 142 diff diff repository (or selected files)
143 143 export dump the header and diffs for one or more changesets
144 144 forget forget the specified files on the next commit
145 145 graft copy changes from other branches onto the current branch
146 146 grep search for a pattern in specified files and revisions
147 heads show current repository heads or show branch heads
147 heads show branch heads
148 148 help show help for a given topic or a help overview
149 149 identify identify the working copy or specified revision
150 150 import import an ordered set of patches
151 151 incoming show new changesets found in source
152 152 init create a new repository in the given directory
153 153 locate locate files matching specific patterns
154 154 log show revision history of entire repository or files
155 155 manifest output the current or given revision of the project manifest
156 156 merge merge working directory with another revision
157 157 outgoing show changesets not found in the destination
158 158 parents show the parents of the working directory or revision
159 159 paths show aliases for remote repositories
160 160 phase set or show the current phase name
161 161 pull pull changes from the specified source
162 162 push push changes to the specified destination
163 163 recover roll back an interrupted transaction
164 164 remove remove the specified files on the next commit
165 165 rename rename files; equivalent of copy + remove
166 166 resolve redo merges or set/view the merge status of files
167 167 revert restore files to their checkout state
168 168 root print the root (top) of the current working directory
169 169 serve start stand-alone webserver
170 170 showconfig show combined config settings from all hgrc files
171 171 status show changed files in the working directory
172 172 summary summarize working directory state
173 173 tag add one or more tags for the current or given revision
174 174 tags list repository tags
175 175 unbundle apply one or more changegroup files
176 176 update update working directory (or switch revisions)
177 177 verify verify the integrity of the repository
178 178 version output version and copyright information
179 179
180 180 additional help topics:
181 181
182 182 config Configuration Files
183 183 dates Date Formats
184 184 diffs Diff Formats
185 185 environment Environment Variables
186 186 extensions Using Additional Features
187 187 filesets Specifying File Sets
188 188 glossary Glossary
189 189 hgignore Syntax for Mercurial Ignore Files
190 190 hgweb Configuring hgweb
191 191 merge-tools Merge Tools
192 192 multirevs Specifying Multiple Revisions
193 193 patterns File Name Patterns
194 194 phases Working with Phases
195 195 revisions Specifying Single Revisions
196 196 revsets Specifying Revision Sets
197 197 subrepos Subrepositories
198 198 templating Template Usage
199 199 urls URL Paths
200 200
201 201 Test short command list with verbose option
202 202
203 203 $ hg -v help shortlist
204 204 Mercurial Distributed SCM
205 205
206 206 basic commands:
207 207
208 208 add add the specified files on the next commit
209 209 annotate, blame
210 210 show changeset information by line for each file
211 211 clone make a copy of an existing repository
212 212 commit, ci commit the specified files or all outstanding changes
213 213 diff diff repository (or selected files)
214 214 export dump the header and diffs for one or more changesets
215 215 forget forget the specified files on the next commit
216 216 init create a new repository in the given directory
217 217 log, history show revision history of entire repository or files
218 218 merge merge working directory with another revision
219 219 pull pull changes from the specified source
220 220 push push changes to the specified destination
221 221 remove, rm remove the specified files on the next commit
222 222 serve start stand-alone webserver
223 223 status, st show changed files in the working directory
224 224 summary, sum summarize working directory state
225 225 update, up, checkout, co
226 226 update working directory (or switch revisions)
227 227
228 228 global options:
229 229
230 230 -R --repository REPO repository root directory or name of overlay bundle
231 231 file
232 232 --cwd DIR change working directory
233 233 -y --noninteractive do not prompt, automatically pick the first choice for
234 234 all prompts
235 235 -q --quiet suppress output
236 236 -v --verbose enable additional output
237 237 --config CONFIG [+] set/override config option (use 'section.name=value')
238 238 --debug enable debugging output
239 239 --debugger start debugger
240 240 --encoding ENCODE set the charset encoding (default: ascii)
241 241 --encodingmode MODE set the charset encoding mode (default: strict)
242 242 --traceback always print a traceback on exception
243 243 --time time how long the command takes
244 244 --profile print command execution profile
245 245 --version output version information and exit
246 246 -h --help display help and exit
247 247 --hidden consider hidden changesets
248 248
249 249 [+] marked option can be specified multiple times
250 250
251 251 use "hg help" for the full list of commands
252 252
253 253 $ hg add -h
254 254 hg add [OPTION]... [FILE]...
255 255
256 256 add the specified files on the next commit
257 257
258 258 Schedule files to be version controlled and added to the repository.
259 259
260 260 The files will be added to the repository at the next commit. To undo an
261 261 add before that, see "hg forget".
262 262
263 263 If no names are given, add all files to the repository.
264 264
265 265 Returns 0 if all files are successfully added.
266 266
267 267 options:
268 268
269 269 -I --include PATTERN [+] include names matching the given patterns
270 270 -X --exclude PATTERN [+] exclude names matching the given patterns
271 271 -S --subrepos recurse into subrepositories
272 272 -n --dry-run do not perform actions, just print output
273 273
274 274 [+] marked option can be specified multiple times
275 275
276 276 use "hg -v help add" to show more complete help and the global options
277 277
278 278 Verbose help for add
279 279
280 280 $ hg add -hv
281 281 hg add [OPTION]... [FILE]...
282 282
283 283 add the specified files on the next commit
284 284
285 285 Schedule files to be version controlled and added to the repository.
286 286
287 287 The files will be added to the repository at the next commit. To undo an
288 288 add before that, see "hg forget".
289 289
290 290 If no names are given, add all files to the repository.
291 291
292 292 An example showing how new (unknown) files are added automatically by "hg
293 293 add":
294 294
295 295 $ ls
296 296 foo.c
297 297 $ hg status
298 298 ? foo.c
299 299 $ hg add
300 300 adding foo.c
301 301 $ hg status
302 302 A foo.c
303 303
304 304 Returns 0 if all files are successfully added.
305 305
306 306 options:
307 307
308 308 -I --include PATTERN [+] include names matching the given patterns
309 309 -X --exclude PATTERN [+] exclude names matching the given patterns
310 310 -S --subrepos recurse into subrepositories
311 311 -n --dry-run do not perform actions, just print output
312 312
313 313 [+] marked option can be specified multiple times
314 314
315 315 global options:
316 316
317 317 -R --repository REPO repository root directory or name of overlay bundle
318 318 file
319 319 --cwd DIR change working directory
320 320 -y --noninteractive do not prompt, automatically pick the first choice for
321 321 all prompts
322 322 -q --quiet suppress output
323 323 -v --verbose enable additional output
324 324 --config CONFIG [+] set/override config option (use 'section.name=value')
325 325 --debug enable debugging output
326 326 --debugger start debugger
327 327 --encoding ENCODE set the charset encoding (default: ascii)
328 328 --encodingmode MODE set the charset encoding mode (default: strict)
329 329 --traceback always print a traceback on exception
330 330 --time time how long the command takes
331 331 --profile print command execution profile
332 332 --version output version information and exit
333 333 -h --help display help and exit
334 334 --hidden consider hidden changesets
335 335
336 336 [+] marked option can be specified multiple times
337 337
338 338 Test help option with version option
339 339
340 340 $ hg add -h --version
341 341 Mercurial Distributed SCM (version *) (glob)
342 342 (see http://mercurial.selenic.com for more information)
343 343
344 344 Copyright (C) 2005-2013 Matt Mackall and others
345 345 This is free software; see the source for copying conditions. There is NO
346 346 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
347 347
348 348 $ hg add --skjdfks
349 349 hg add: option --skjdfks not recognized
350 350 hg add [OPTION]... [FILE]...
351 351
352 352 add the specified files on the next commit
353 353
354 354 options:
355 355
356 356 -I --include PATTERN [+] include names matching the given patterns
357 357 -X --exclude PATTERN [+] exclude names matching the given patterns
358 358 -S --subrepos recurse into subrepositories
359 359 -n --dry-run do not perform actions, just print output
360 360
361 361 [+] marked option can be specified multiple times
362 362
363 363 use "hg help add" to show the full help text
364 364 [255]
365 365
366 366 Test ambiguous command help
367 367
368 368 $ hg help ad
369 369 list of commands:
370 370
371 371 add add the specified files on the next commit
372 372 addremove add all new files, delete all missing files
373 373
374 374 use "hg -v help ad" to show builtin aliases and global options
375 375
376 376 Test command without options
377 377
378 378 $ hg help verify
379 379 hg verify
380 380
381 381 verify the integrity of the repository
382 382
383 383 Verify the integrity of the current repository.
384 384
385 385 This will perform an extensive check of the repository's integrity,
386 386 validating the hashes and checksums of each entry in the changelog,
387 387 manifest, and tracked files, as well as the integrity of their crosslinks
388 388 and indices.
389 389
390 390 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption for more
391 391 information about recovery from corruption of the repository.
392 392
393 393 Returns 0 on success, 1 if errors are encountered.
394 394
395 395 use "hg -v help verify" to show the global options
396 396
397 397 $ hg help diff
398 398 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
399 399
400 400 diff repository (or selected files)
401 401
402 402 Show differences between revisions for the specified files.
403 403
404 404 Differences between files are shown using the unified diff format.
405 405
406 406 Note:
407 407 diff may generate unexpected results for merges, as it will default to
408 408 comparing against the working directory's first parent changeset if no
409 409 revisions are specified.
410 410
411 411 When two revision arguments are given, then changes are shown between
412 412 those revisions. If only one revision is specified then that revision is
413 413 compared to the working directory, and, when no revisions are specified,
414 414 the working directory files are compared to its parent.
415 415
416 416 Alternatively you can specify -c/--change with a revision to see the
417 417 changes in that changeset relative to its first parent.
418 418
419 419 Without the -a/--text option, diff will avoid generating diffs of files it
420 420 detects as binary. With -a, diff will generate a diff anyway, probably
421 421 with undesirable results.
422 422
423 423 Use the -g/--git option to generate diffs in the git extended diff format.
424 424 For more information, read "hg help diffs".
425 425
426 426 Returns 0 on success.
427 427
428 428 options:
429 429
430 430 -r --rev REV [+] revision
431 431 -c --change REV change made by revision
432 432 -a --text treat all files as text
433 433 -g --git use git extended diff format
434 434 --nodates omit dates from diff headers
435 435 -p --show-function show which function each change is in
436 436 --reverse produce a diff that undoes the changes
437 437 -w --ignore-all-space ignore white space when comparing lines
438 438 -b --ignore-space-change ignore changes in the amount of white space
439 439 -B --ignore-blank-lines ignore changes whose lines are all blank
440 440 -U --unified NUM number of lines of context to show
441 441 --stat output diffstat-style summary of changes
442 442 -I --include PATTERN [+] include names matching the given patterns
443 443 -X --exclude PATTERN [+] exclude names matching the given patterns
444 444 -S --subrepos recurse into subrepositories
445 445
446 446 [+] marked option can be specified multiple times
447 447
448 448 use "hg -v help diff" to show more complete help and the global options
449 449
450 450 $ hg help status
451 451 hg status [OPTION]... [FILE]...
452 452
453 453 aliases: st
454 454
455 455 show changed files in the working directory
456 456
457 457 Show status of files in the repository. If names are given, only files
458 458 that match are shown. Files that are clean or ignored or the source of a
459 459 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
460 460 -C/--copies or -A/--all are given. Unless options described with "show
461 461 only ..." are given, the options -mardu are used.
462 462
463 463 Option -q/--quiet hides untracked (unknown and ignored) files unless
464 464 explicitly requested with -u/--unknown or -i/--ignored.
465 465
466 466 Note:
467 467 status may appear to disagree with diff if permissions have changed or
468 468 a merge has occurred. The standard diff format does not report
469 469 permission changes and diff only reports changes relative to one merge
470 470 parent.
471 471
472 472 If one revision is given, it is used as the base revision. If two
473 473 revisions are given, the differences between them are shown. The --change
474 474 option can also be used as a shortcut to list the changed files of a
475 475 revision from its first parent.
476 476
477 477 The codes used to show the status of files are:
478 478
479 479 M = modified
480 480 A = added
481 481 R = removed
482 482 C = clean
483 483 ! = missing (deleted by non-hg command, but still tracked)
484 484 ? = not tracked
485 485 I = ignored
486 486 = origin of the previous file listed as A (added)
487 487
488 488 Returns 0 on success.
489 489
490 490 options:
491 491
492 492 -A --all show status of all files
493 493 -m --modified show only modified files
494 494 -a --added show only added files
495 495 -r --removed show only removed files
496 496 -d --deleted show only deleted (but tracked) files
497 497 -c --clean show only files without changes
498 498 -u --unknown show only unknown (not tracked) files
499 499 -i --ignored show only ignored files
500 500 -n --no-status hide status prefix
501 501 -C --copies show source of copied files
502 502 -0 --print0 end filenames with NUL, for use with xargs
503 503 --rev REV [+] show difference from revision
504 504 --change REV list the changed files of a revision
505 505 -I --include PATTERN [+] include names matching the given patterns
506 506 -X --exclude PATTERN [+] exclude names matching the given patterns
507 507 -S --subrepos recurse into subrepositories
508 508
509 509 [+] marked option can be specified multiple times
510 510
511 511 use "hg -v help status" to show more complete help and the global options
512 512
513 513 $ hg -q help status
514 514 hg status [OPTION]... [FILE]...
515 515
516 516 show changed files in the working directory
517 517
518 518 $ hg help foo
519 519 hg: unknown command 'foo'
520 520 Mercurial Distributed SCM
521 521
522 522 basic commands:
523 523
524 524 add add the specified files on the next commit
525 525 annotate show changeset information by line for each file
526 526 clone make a copy of an existing repository
527 527 commit commit the specified files or all outstanding changes
528 528 diff diff repository (or selected files)
529 529 export dump the header and diffs for one or more changesets
530 530 forget forget the specified files on the next commit
531 531 init create a new repository in the given directory
532 532 log show revision history of entire repository or files
533 533 merge merge working directory with another revision
534 534 pull pull changes from the specified source
535 535 push push changes to the specified destination
536 536 remove remove the specified files on the next commit
537 537 serve start stand-alone webserver
538 538 status show changed files in the working directory
539 539 summary summarize working directory state
540 540 update update working directory (or switch revisions)
541 541
542 542 use "hg help" for the full list of commands or "hg -v" for details
543 543 [255]
544 544
545 545 $ hg skjdfks
546 546 hg: unknown command 'skjdfks'
547 547 Mercurial Distributed SCM
548 548
549 549 basic commands:
550 550
551 551 add add the specified files on the next commit
552 552 annotate show changeset information by line for each file
553 553 clone make a copy of an existing repository
554 554 commit commit the specified files or all outstanding changes
555 555 diff diff repository (or selected files)
556 556 export dump the header and diffs for one or more changesets
557 557 forget forget the specified files on the next commit
558 558 init create a new repository in the given directory
559 559 log show revision history of entire repository or files
560 560 merge merge working directory with another revision
561 561 pull pull changes from the specified source
562 562 push push changes to the specified destination
563 563 remove remove the specified files on the next commit
564 564 serve start stand-alone webserver
565 565 status show changed files in the working directory
566 566 summary summarize working directory state
567 567 update update working directory (or switch revisions)
568 568
569 569 use "hg help" for the full list of commands or "hg -v" for details
570 570 [255]
571 571
572 572 $ cat > helpext.py <<EOF
573 573 > import os
574 574 > from mercurial import commands
575 575 >
576 576 > def nohelp(ui, *args, **kwargs):
577 577 > pass
578 578 >
579 579 > cmdtable = {
580 580 > "nohelp": (nohelp, [], "hg nohelp"),
581 581 > }
582 582 >
583 583 > commands.norepo += ' nohelp'
584 584 > EOF
585 585 $ echo '[extensions]' >> $HGRCPATH
586 586 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
587 587
588 588 Test command with no help text
589 589
590 590 $ hg help nohelp
591 591 hg nohelp
592 592
593 593 (no help text available)
594 594
595 595 use "hg -v help nohelp" to show the global options
596 596
597 597 $ hg help -k nohelp
598 598 Commands:
599 599
600 600 nohelp hg nohelp
601 601
602 602 Extension Commands:
603 603
604 604 nohelp (no help text available)
605 605
606 606 Test that default list of commands omits extension commands
607 607
608 608 $ hg help
609 609 Mercurial Distributed SCM
610 610
611 611 list of commands:
612 612
613 613 add add the specified files on the next commit
614 614 addremove add all new files, delete all missing files
615 615 annotate show changeset information by line for each file
616 616 archive create an unversioned archive of a repository revision
617 617 backout reverse effect of earlier changeset
618 618 bisect subdivision search of changesets
619 619 bookmarks track a line of development with movable markers
620 620 branch set or show the current branch name
621 621 branches list repository named branches
622 622 bundle create a changegroup file
623 623 cat output the current or given revision of files
624 624 clone make a copy of an existing repository
625 625 commit commit the specified files or all outstanding changes
626 626 copy mark files as copied for the next commit
627 627 diff diff repository (or selected files)
628 628 export dump the header and diffs for one or more changesets
629 629 forget forget the specified files on the next commit
630 630 graft copy changes from other branches onto the current branch
631 631 grep search for a pattern in specified files and revisions
632 heads show current repository heads or show branch heads
632 heads show branch heads
633 633 help show help for a given topic or a help overview
634 634 identify identify the working copy or specified revision
635 635 import import an ordered set of patches
636 636 incoming show new changesets found in source
637 637 init create a new repository in the given directory
638 638 locate locate files matching specific patterns
639 639 log show revision history of entire repository or files
640 640 manifest output the current or given revision of the project manifest
641 641 merge merge working directory with another revision
642 642 outgoing show changesets not found in the destination
643 643 parents show the parents of the working directory or revision
644 644 paths show aliases for remote repositories
645 645 phase set or show the current phase name
646 646 pull pull changes from the specified source
647 647 push push changes to the specified destination
648 648 recover roll back an interrupted transaction
649 649 remove remove the specified files on the next commit
650 650 rename rename files; equivalent of copy + remove
651 651 resolve redo merges or set/view the merge status of files
652 652 revert restore files to their checkout state
653 653 root print the root (top) of the current working directory
654 654 serve start stand-alone webserver
655 655 showconfig show combined config settings from all hgrc files
656 656 status show changed files in the working directory
657 657 summary summarize working directory state
658 658 tag add one or more tags for the current or given revision
659 659 tags list repository tags
660 660 unbundle apply one or more changegroup files
661 661 update update working directory (or switch revisions)
662 662 verify verify the integrity of the repository
663 663 version output version and copyright information
664 664
665 665 enabled extensions:
666 666
667 667 helpext (no help text available)
668 668
669 669 additional help topics:
670 670
671 671 config Configuration Files
672 672 dates Date Formats
673 673 diffs Diff Formats
674 674 environment Environment Variables
675 675 extensions Using Additional Features
676 676 filesets Specifying File Sets
677 677 glossary Glossary
678 678 hgignore Syntax for Mercurial Ignore Files
679 679 hgweb Configuring hgweb
680 680 merge-tools Merge Tools
681 681 multirevs Specifying Multiple Revisions
682 682 patterns File Name Patterns
683 683 phases Working with Phases
684 684 revisions Specifying Single Revisions
685 685 revsets Specifying Revision Sets
686 686 subrepos Subrepositories
687 687 templating Template Usage
688 688 urls URL Paths
689 689
690 690 use "hg -v help" to show builtin aliases and global options
691 691
692 692
693 693
694 694 Test list of commands with command with no help text
695 695
696 696 $ hg help helpext
697 697 helpext extension - no help text available
698 698
699 699 list of commands:
700 700
701 701 nohelp (no help text available)
702 702
703 703 use "hg -v help helpext" to show builtin aliases and global options
704 704
705 705 Test a help topic
706 706
707 707 $ hg help revs
708 708 Specifying Single Revisions
709 709 """""""""""""""""""""""""""
710 710
711 711 Mercurial supports several ways to specify individual revisions.
712 712
713 713 A plain integer is treated as a revision number. Negative integers are
714 714 treated as sequential offsets from the tip, with -1 denoting the tip, -2
715 715 denoting the revision prior to the tip, and so forth.
716 716
717 717 A 40-digit hexadecimal string is treated as a unique revision identifier.
718 718
719 719 A hexadecimal string less than 40 characters long is treated as a unique
720 720 revision identifier and is referred to as a short-form identifier. A
721 721 short-form identifier is only valid if it is the prefix of exactly one
722 722 full-length identifier.
723 723
724 724 Any other string is treated as a bookmark, tag, or branch name. A bookmark
725 725 is a movable pointer to a revision. A tag is a permanent name associated
726 726 with a revision. A branch name denotes the tipmost revision of that
727 727 branch. Bookmark, tag, and branch names must not contain the ":"
728 728 character.
729 729
730 730 The reserved name "tip" always identifies the most recent revision.
731 731
732 732 The reserved name "null" indicates the null revision. This is the revision
733 733 of an empty repository, and the parent of revision 0.
734 734
735 735 The reserved name "." indicates the working directory parent. If no
736 736 working directory is checked out, it is equivalent to null. If an
737 737 uncommitted merge is in progress, "." is the revision of the first parent.
738 738
739 739 Test templating help
740 740
741 741 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
742 742 desc String. The text of the changeset description.
743 743 diffstat String. Statistics of changes with the following format:
744 744 firstline Any text. Returns the first line of text.
745 745 nonempty Any text. Returns '(none)' if the string is empty.
746 746
747 747 Test help hooks
748 748
749 749 $ cat > helphook1.py <<EOF
750 750 > from mercurial import help
751 751 >
752 752 > def rewrite(topic, doc):
753 753 > return doc + '\nhelphook1\n'
754 754 >
755 755 > def extsetup(ui):
756 756 > help.addtopichook('revsets', rewrite)
757 757 > EOF
758 758 $ cat > helphook2.py <<EOF
759 759 > from mercurial import help
760 760 >
761 761 > def rewrite(topic, doc):
762 762 > return doc + '\nhelphook2\n'
763 763 >
764 764 > def extsetup(ui):
765 765 > help.addtopichook('revsets', rewrite)
766 766 > EOF
767 767 $ echo '[extensions]' >> $HGRCPATH
768 768 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
769 769 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
770 770 $ hg help revsets | grep helphook
771 771 helphook1
772 772 helphook2
773 773
774 774 Test keyword search help
775 775
776 776 $ hg help -k clone
777 777 Topics:
778 778
779 779 config Configuration Files
780 780 extensions Using Additional Features
781 781 glossary Glossary
782 782 phases Working with Phases
783 783 subrepos Subrepositories
784 784 urls URL Paths
785 785
786 786 Commands:
787 787
788 788 bookmarks track a line of development with movable markers
789 789 clone make a copy of an existing repository
790 790 paths show aliases for remote repositories
791 791 update update working directory (or switch revisions)
792 792
793 793 Extensions:
794 794
795 795 relink recreates hardlinks between repository clones
796 796
797 797 Extension Commands:
798 798
799 799 qclone clone main and patch repository at same time
800 800
801 801 Test omit indicating for help
802 802
803 803 $ cat > addverboseitems.py <<EOF
804 804 > '''extension to test omit indicating.
805 805 >
806 806 > This paragraph is never omitted (for extension)
807 807 >
808 808 > .. container:: verbose
809 809 >
810 810 > This paragraph is omitted,
811 811 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for extension)
812 812 >
813 813 > This paragraph is never omitted, too (for extension)
814 814 > '''
815 815 >
816 816 > from mercurial import help, commands
817 817 > testtopic = """This paragraph is never omitted (for topic).
818 818 >
819 819 > .. container:: verbose
820 820 >
821 821 > This paragraph is omitted,
822 822 > if :hg:\`help\` is invoked witout \`\`-v\`\` (for topic)
823 823 >
824 824 > This paragraph is never omitted, too (for topic)
825 825 > """
826 826 > def extsetup(ui):
827 827 > help.helptable.append((["topic-containing-verbose"],
828 828 > "This is the topic to test omit indicating.",
829 829 > lambda : testtopic))
830 830 > EOF
831 831 $ echo '[extensions]' >> $HGRCPATH
832 832 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
833 833 $ hg help addverboseitems
834 834 addverboseitems extension - extension to test omit indicating.
835 835
836 836 This paragraph is never omitted (for extension)
837 837
838 838 This paragraph is never omitted, too (for extension)
839 839
840 840 use "hg help -v addverboseitems" to show more complete help
841 841
842 842 no commands defined
843 843 $ hg help -v addverboseitems
844 844 addverboseitems extension - extension to test omit indicating.
845 845
846 846 This paragraph is never omitted (for extension)
847 847
848 848 This paragraph is omitted, if "hg help" is invoked witout "-v" (for extension)
849 849
850 850 This paragraph is never omitted, too (for extension)
851 851
852 852 no commands defined
853 853 $ hg help topic-containing-verbose
854 854 This is the topic to test omit indicating.
855 855 """"""""""""""""""""""""""""""""""""""""""
856 856
857 857 This paragraph is never omitted (for topic).
858 858
859 859 This paragraph is never omitted, too (for topic)
860 860
861 861 use "hg help -v topic-containing-verbose" to show more complete help
862 862 $ hg help -v topic-containing-verbose
863 863 This is the topic to test omit indicating.
864 864 """"""""""""""""""""""""""""""""""""""""""
865 865
866 866 This paragraph is never omitted (for topic).
867 867
868 868 This paragraph is omitted, if "hg help" is invoked witout "-v" (for topic)
869 869
870 870 This paragraph is never omitted, too (for topic)
871 871
872 872 Test usage of section marks in help documents
873 873
874 874 $ cd "$TESTDIR"/../doc
875 875 $ python check-seclevel.py
876 876 $ cd $TESTTMP
877 877
878 878 #if serve
879 879
880 880 Test the help pages in hgweb.
881 881
882 882 Dish up an empty repo; serve it cold.
883 883
884 884 $ hg init "$TESTTMP/test"
885 885 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
886 886 $ cat hg.pid >> $DAEMON_PIDS
887 887
888 888 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help"
889 889 200 Script output follows
890 890
891 891 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
892 892 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
893 893 <head>
894 894 <link rel="icon" href="/static/hgicon.png" type="image/png" />
895 895 <meta name="robots" content="index, nofollow" />
896 896 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
897 897 <script type="text/javascript" src="/static/mercurial.js"></script>
898 898
899 899 <title>Help: Index</title>
900 900 </head>
901 901 <body>
902 902
903 903 <div class="container">
904 904 <div class="menu">
905 905 <div class="logo">
906 906 <a href="http://mercurial.selenic.com/">
907 907 <img src="/static/hglogo.png" alt="mercurial" /></a>
908 908 </div>
909 909 <ul>
910 910 <li><a href="/shortlog">log</a></li>
911 911 <li><a href="/graph">graph</a></li>
912 912 <li><a href="/tags">tags</a></li>
913 913 <li><a href="/bookmarks">bookmarks</a></li>
914 914 <li><a href="/branches">branches</a></li>
915 915 </ul>
916 916 <ul>
917 917 <li class="active">help</li>
918 918 </ul>
919 919 </div>
920 920
921 921 <div class="main">
922 922 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
923 923 <form class="search" action="/log">
924 924
925 925 <p><input name="rev" id="search1" type="text" size="30" /></p>
926 926 <div id="hint">find changesets by author, revision,
927 927 files, or words in the commit message</div>
928 928 </form>
929 929 <table class="bigtable">
930 930 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
931 931
932 932 <tr><td>
933 933 <a href="/help/config">
934 934 config
935 935 </a>
936 936 </td><td>
937 937 Configuration Files
938 938 </td></tr>
939 939 <tr><td>
940 940 <a href="/help/dates">
941 941 dates
942 942 </a>
943 943 </td><td>
944 944 Date Formats
945 945 </td></tr>
946 946 <tr><td>
947 947 <a href="/help/diffs">
948 948 diffs
949 949 </a>
950 950 </td><td>
951 951 Diff Formats
952 952 </td></tr>
953 953 <tr><td>
954 954 <a href="/help/environment">
955 955 environment
956 956 </a>
957 957 </td><td>
958 958 Environment Variables
959 959 </td></tr>
960 960 <tr><td>
961 961 <a href="/help/extensions">
962 962 extensions
963 963 </a>
964 964 </td><td>
965 965 Using Additional Features
966 966 </td></tr>
967 967 <tr><td>
968 968 <a href="/help/filesets">
969 969 filesets
970 970 </a>
971 971 </td><td>
972 972 Specifying File Sets
973 973 </td></tr>
974 974 <tr><td>
975 975 <a href="/help/glossary">
976 976 glossary
977 977 </a>
978 978 </td><td>
979 979 Glossary
980 980 </td></tr>
981 981 <tr><td>
982 982 <a href="/help/hgignore">
983 983 hgignore
984 984 </a>
985 985 </td><td>
986 986 Syntax for Mercurial Ignore Files
987 987 </td></tr>
988 988 <tr><td>
989 989 <a href="/help/hgweb">
990 990 hgweb
991 991 </a>
992 992 </td><td>
993 993 Configuring hgweb
994 994 </td></tr>
995 995 <tr><td>
996 996 <a href="/help/merge-tools">
997 997 merge-tools
998 998 </a>
999 999 </td><td>
1000 1000 Merge Tools
1001 1001 </td></tr>
1002 1002 <tr><td>
1003 1003 <a href="/help/multirevs">
1004 1004 multirevs
1005 1005 </a>
1006 1006 </td><td>
1007 1007 Specifying Multiple Revisions
1008 1008 </td></tr>
1009 1009 <tr><td>
1010 1010 <a href="/help/patterns">
1011 1011 patterns
1012 1012 </a>
1013 1013 </td><td>
1014 1014 File Name Patterns
1015 1015 </td></tr>
1016 1016 <tr><td>
1017 1017 <a href="/help/phases">
1018 1018 phases
1019 1019 </a>
1020 1020 </td><td>
1021 1021 Working with Phases
1022 1022 </td></tr>
1023 1023 <tr><td>
1024 1024 <a href="/help/revisions">
1025 1025 revisions
1026 1026 </a>
1027 1027 </td><td>
1028 1028 Specifying Single Revisions
1029 1029 </td></tr>
1030 1030 <tr><td>
1031 1031 <a href="/help/revsets">
1032 1032 revsets
1033 1033 </a>
1034 1034 </td><td>
1035 1035 Specifying Revision Sets
1036 1036 </td></tr>
1037 1037 <tr><td>
1038 1038 <a href="/help/subrepos">
1039 1039 subrepos
1040 1040 </a>
1041 1041 </td><td>
1042 1042 Subrepositories
1043 1043 </td></tr>
1044 1044 <tr><td>
1045 1045 <a href="/help/templating">
1046 1046 templating
1047 1047 </a>
1048 1048 </td><td>
1049 1049 Template Usage
1050 1050 </td></tr>
1051 1051 <tr><td>
1052 1052 <a href="/help/urls">
1053 1053 urls
1054 1054 </a>
1055 1055 </td><td>
1056 1056 URL Paths
1057 1057 </td></tr>
1058 1058 <tr><td>
1059 1059 <a href="/help/topic-containing-verbose">
1060 1060 topic-containing-verbose
1061 1061 </a>
1062 1062 </td><td>
1063 1063 This is the topic to test omit indicating.
1064 1064 </td></tr>
1065 1065
1066 1066 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1067 1067
1068 1068 <tr><td>
1069 1069 <a href="/help/add">
1070 1070 add
1071 1071 </a>
1072 1072 </td><td>
1073 1073 add the specified files on the next commit
1074 1074 </td></tr>
1075 1075 <tr><td>
1076 1076 <a href="/help/annotate">
1077 1077 annotate
1078 1078 </a>
1079 1079 </td><td>
1080 1080 show changeset information by line for each file
1081 1081 </td></tr>
1082 1082 <tr><td>
1083 1083 <a href="/help/clone">
1084 1084 clone
1085 1085 </a>
1086 1086 </td><td>
1087 1087 make a copy of an existing repository
1088 1088 </td></tr>
1089 1089 <tr><td>
1090 1090 <a href="/help/commit">
1091 1091 commit
1092 1092 </a>
1093 1093 </td><td>
1094 1094 commit the specified files or all outstanding changes
1095 1095 </td></tr>
1096 1096 <tr><td>
1097 1097 <a href="/help/diff">
1098 1098 diff
1099 1099 </a>
1100 1100 </td><td>
1101 1101 diff repository (or selected files)
1102 1102 </td></tr>
1103 1103 <tr><td>
1104 1104 <a href="/help/export">
1105 1105 export
1106 1106 </a>
1107 1107 </td><td>
1108 1108 dump the header and diffs for one or more changesets
1109 1109 </td></tr>
1110 1110 <tr><td>
1111 1111 <a href="/help/forget">
1112 1112 forget
1113 1113 </a>
1114 1114 </td><td>
1115 1115 forget the specified files on the next commit
1116 1116 </td></tr>
1117 1117 <tr><td>
1118 1118 <a href="/help/init">
1119 1119 init
1120 1120 </a>
1121 1121 </td><td>
1122 1122 create a new repository in the given directory
1123 1123 </td></tr>
1124 1124 <tr><td>
1125 1125 <a href="/help/log">
1126 1126 log
1127 1127 </a>
1128 1128 </td><td>
1129 1129 show revision history of entire repository or files
1130 1130 </td></tr>
1131 1131 <tr><td>
1132 1132 <a href="/help/merge">
1133 1133 merge
1134 1134 </a>
1135 1135 </td><td>
1136 1136 merge working directory with another revision
1137 1137 </td></tr>
1138 1138 <tr><td>
1139 1139 <a href="/help/pull">
1140 1140 pull
1141 1141 </a>
1142 1142 </td><td>
1143 1143 pull changes from the specified source
1144 1144 </td></tr>
1145 1145 <tr><td>
1146 1146 <a href="/help/push">
1147 1147 push
1148 1148 </a>
1149 1149 </td><td>
1150 1150 push changes to the specified destination
1151 1151 </td></tr>
1152 1152 <tr><td>
1153 1153 <a href="/help/remove">
1154 1154 remove
1155 1155 </a>
1156 1156 </td><td>
1157 1157 remove the specified files on the next commit
1158 1158 </td></tr>
1159 1159 <tr><td>
1160 1160 <a href="/help/serve">
1161 1161 serve
1162 1162 </a>
1163 1163 </td><td>
1164 1164 start stand-alone webserver
1165 1165 </td></tr>
1166 1166 <tr><td>
1167 1167 <a href="/help/status">
1168 1168 status
1169 1169 </a>
1170 1170 </td><td>
1171 1171 show changed files in the working directory
1172 1172 </td></tr>
1173 1173 <tr><td>
1174 1174 <a href="/help/summary">
1175 1175 summary
1176 1176 </a>
1177 1177 </td><td>
1178 1178 summarize working directory state
1179 1179 </td></tr>
1180 1180 <tr><td>
1181 1181 <a href="/help/update">
1182 1182 update
1183 1183 </a>
1184 1184 </td><td>
1185 1185 update working directory (or switch revisions)
1186 1186 </td></tr>
1187 1187
1188 1188 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1189 1189
1190 1190 <tr><td>
1191 1191 <a href="/help/addremove">
1192 1192 addremove
1193 1193 </a>
1194 1194 </td><td>
1195 1195 add all new files, delete all missing files
1196 1196 </td></tr>
1197 1197 <tr><td>
1198 1198 <a href="/help/archive">
1199 1199 archive
1200 1200 </a>
1201 1201 </td><td>
1202 1202 create an unversioned archive of a repository revision
1203 1203 </td></tr>
1204 1204 <tr><td>
1205 1205 <a href="/help/backout">
1206 1206 backout
1207 1207 </a>
1208 1208 </td><td>
1209 1209 reverse effect of earlier changeset
1210 1210 </td></tr>
1211 1211 <tr><td>
1212 1212 <a href="/help/bisect">
1213 1213 bisect
1214 1214 </a>
1215 1215 </td><td>
1216 1216 subdivision search of changesets
1217 1217 </td></tr>
1218 1218 <tr><td>
1219 1219 <a href="/help/bookmarks">
1220 1220 bookmarks
1221 1221 </a>
1222 1222 </td><td>
1223 1223 track a line of development with movable markers
1224 1224 </td></tr>
1225 1225 <tr><td>
1226 1226 <a href="/help/branch">
1227 1227 branch
1228 1228 </a>
1229 1229 </td><td>
1230 1230 set or show the current branch name
1231 1231 </td></tr>
1232 1232 <tr><td>
1233 1233 <a href="/help/branches">
1234 1234 branches
1235 1235 </a>
1236 1236 </td><td>
1237 1237 list repository named branches
1238 1238 </td></tr>
1239 1239 <tr><td>
1240 1240 <a href="/help/bundle">
1241 1241 bundle
1242 1242 </a>
1243 1243 </td><td>
1244 1244 create a changegroup file
1245 1245 </td></tr>
1246 1246 <tr><td>
1247 1247 <a href="/help/cat">
1248 1248 cat
1249 1249 </a>
1250 1250 </td><td>
1251 1251 output the current or given revision of files
1252 1252 </td></tr>
1253 1253 <tr><td>
1254 1254 <a href="/help/copy">
1255 1255 copy
1256 1256 </a>
1257 1257 </td><td>
1258 1258 mark files as copied for the next commit
1259 1259 </td></tr>
1260 1260 <tr><td>
1261 1261 <a href="/help/graft">
1262 1262 graft
1263 1263 </a>
1264 1264 </td><td>
1265 1265 copy changes from other branches onto the current branch
1266 1266 </td></tr>
1267 1267 <tr><td>
1268 1268 <a href="/help/grep">
1269 1269 grep
1270 1270 </a>
1271 1271 </td><td>
1272 1272 search for a pattern in specified files and revisions
1273 1273 </td></tr>
1274 1274 <tr><td>
1275 1275 <a href="/help/heads">
1276 1276 heads
1277 1277 </a>
1278 1278 </td><td>
1279 show current repository heads or show branch heads
1279 show branch heads
1280 1280 </td></tr>
1281 1281 <tr><td>
1282 1282 <a href="/help/help">
1283 1283 help
1284 1284 </a>
1285 1285 </td><td>
1286 1286 show help for a given topic or a help overview
1287 1287 </td></tr>
1288 1288 <tr><td>
1289 1289 <a href="/help/identify">
1290 1290 identify
1291 1291 </a>
1292 1292 </td><td>
1293 1293 identify the working copy or specified revision
1294 1294 </td></tr>
1295 1295 <tr><td>
1296 1296 <a href="/help/import">
1297 1297 import
1298 1298 </a>
1299 1299 </td><td>
1300 1300 import an ordered set of patches
1301 1301 </td></tr>
1302 1302 <tr><td>
1303 1303 <a href="/help/incoming">
1304 1304 incoming
1305 1305 </a>
1306 1306 </td><td>
1307 1307 show new changesets found in source
1308 1308 </td></tr>
1309 1309 <tr><td>
1310 1310 <a href="/help/locate">
1311 1311 locate
1312 1312 </a>
1313 1313 </td><td>
1314 1314 locate files matching specific patterns
1315 1315 </td></tr>
1316 1316 <tr><td>
1317 1317 <a href="/help/manifest">
1318 1318 manifest
1319 1319 </a>
1320 1320 </td><td>
1321 1321 output the current or given revision of the project manifest
1322 1322 </td></tr>
1323 1323 <tr><td>
1324 1324 <a href="/help/nohelp">
1325 1325 nohelp
1326 1326 </a>
1327 1327 </td><td>
1328 1328 (no help text available)
1329 1329 </td></tr>
1330 1330 <tr><td>
1331 1331 <a href="/help/outgoing">
1332 1332 outgoing
1333 1333 </a>
1334 1334 </td><td>
1335 1335 show changesets not found in the destination
1336 1336 </td></tr>
1337 1337 <tr><td>
1338 1338 <a href="/help/parents">
1339 1339 parents
1340 1340 </a>
1341 1341 </td><td>
1342 1342 show the parents of the working directory or revision
1343 1343 </td></tr>
1344 1344 <tr><td>
1345 1345 <a href="/help/paths">
1346 1346 paths
1347 1347 </a>
1348 1348 </td><td>
1349 1349 show aliases for remote repositories
1350 1350 </td></tr>
1351 1351 <tr><td>
1352 1352 <a href="/help/phase">
1353 1353 phase
1354 1354 </a>
1355 1355 </td><td>
1356 1356 set or show the current phase name
1357 1357 </td></tr>
1358 1358 <tr><td>
1359 1359 <a href="/help/recover">
1360 1360 recover
1361 1361 </a>
1362 1362 </td><td>
1363 1363 roll back an interrupted transaction
1364 1364 </td></tr>
1365 1365 <tr><td>
1366 1366 <a href="/help/rename">
1367 1367 rename
1368 1368 </a>
1369 1369 </td><td>
1370 1370 rename files; equivalent of copy + remove
1371 1371 </td></tr>
1372 1372 <tr><td>
1373 1373 <a href="/help/resolve">
1374 1374 resolve
1375 1375 </a>
1376 1376 </td><td>
1377 1377 redo merges or set/view the merge status of files
1378 1378 </td></tr>
1379 1379 <tr><td>
1380 1380 <a href="/help/revert">
1381 1381 revert
1382 1382 </a>
1383 1383 </td><td>
1384 1384 restore files to their checkout state
1385 1385 </td></tr>
1386 1386 <tr><td>
1387 1387 <a href="/help/root">
1388 1388 root
1389 1389 </a>
1390 1390 </td><td>
1391 1391 print the root (top) of the current working directory
1392 1392 </td></tr>
1393 1393 <tr><td>
1394 1394 <a href="/help/showconfig">
1395 1395 showconfig
1396 1396 </a>
1397 1397 </td><td>
1398 1398 show combined config settings from all hgrc files
1399 1399 </td></tr>
1400 1400 <tr><td>
1401 1401 <a href="/help/tag">
1402 1402 tag
1403 1403 </a>
1404 1404 </td><td>
1405 1405 add one or more tags for the current or given revision
1406 1406 </td></tr>
1407 1407 <tr><td>
1408 1408 <a href="/help/tags">
1409 1409 tags
1410 1410 </a>
1411 1411 </td><td>
1412 1412 list repository tags
1413 1413 </td></tr>
1414 1414 <tr><td>
1415 1415 <a href="/help/unbundle">
1416 1416 unbundle
1417 1417 </a>
1418 1418 </td><td>
1419 1419 apply one or more changegroup files
1420 1420 </td></tr>
1421 1421 <tr><td>
1422 1422 <a href="/help/verify">
1423 1423 verify
1424 1424 </a>
1425 1425 </td><td>
1426 1426 verify the integrity of the repository
1427 1427 </td></tr>
1428 1428 <tr><td>
1429 1429 <a href="/help/version">
1430 1430 version
1431 1431 </a>
1432 1432 </td><td>
1433 1433 output version and copyright information
1434 1434 </td></tr>
1435 1435 </table>
1436 1436 </div>
1437 1437 </div>
1438 1438
1439 1439 <script type="text/javascript">process_dates()</script>
1440 1440
1441 1441
1442 1442 </body>
1443 1443 </html>
1444 1444
1445 1445
1446 1446 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/add"
1447 1447 200 Script output follows
1448 1448
1449 1449 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1450 1450 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1451 1451 <head>
1452 1452 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1453 1453 <meta name="robots" content="index, nofollow" />
1454 1454 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1455 1455 <script type="text/javascript" src="/static/mercurial.js"></script>
1456 1456
1457 1457 <title>Help: add</title>
1458 1458 </head>
1459 1459 <body>
1460 1460
1461 1461 <div class="container">
1462 1462 <div class="menu">
1463 1463 <div class="logo">
1464 1464 <a href="http://mercurial.selenic.com/">
1465 1465 <img src="/static/hglogo.png" alt="mercurial" /></a>
1466 1466 </div>
1467 1467 <ul>
1468 1468 <li><a href="/shortlog">log</a></li>
1469 1469 <li><a href="/graph">graph</a></li>
1470 1470 <li><a href="/tags">tags</a></li>
1471 1471 <li><a href="/bookmarks">bookmarks</a></li>
1472 1472 <li><a href="/branches">branches</a></li>
1473 1473 </ul>
1474 1474 <ul>
1475 1475 <li class="active"><a href="/help">help</a></li>
1476 1476 </ul>
1477 1477 </div>
1478 1478
1479 1479 <div class="main">
1480 1480 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1481 1481 <h3>Help: add</h3>
1482 1482
1483 1483 <form class="search" action="/log">
1484 1484
1485 1485 <p><input name="rev" id="search1" type="text" size="30" /></p>
1486 1486 <div id="hint">find changesets by author, revision,
1487 1487 files, or words in the commit message</div>
1488 1488 </form>
1489 1489 <div id="doc">
1490 1490 <p>
1491 1491 hg add [OPTION]... [FILE]...
1492 1492 </p>
1493 1493 <p>
1494 1494 add the specified files on the next commit
1495 1495 </p>
1496 1496 <p>
1497 1497 Schedule files to be version controlled and added to the
1498 1498 repository.
1499 1499 </p>
1500 1500 <p>
1501 1501 The files will be added to the repository at the next commit. To
1502 1502 undo an add before that, see &quot;hg forget&quot;.
1503 1503 </p>
1504 1504 <p>
1505 1505 If no names are given, add all files to the repository.
1506 1506 </p>
1507 1507 <p>
1508 1508 An example showing how new (unknown) files are added
1509 1509 automatically by &quot;hg add&quot;:
1510 1510 </p>
1511 1511 <pre>
1512 1512 \$ ls (re)
1513 1513 foo.c
1514 1514 \$ hg status (re)
1515 1515 ? foo.c
1516 1516 \$ hg add (re)
1517 1517 adding foo.c
1518 1518 \$ hg status (re)
1519 1519 A foo.c
1520 1520 </pre>
1521 1521 <p>
1522 1522 Returns 0 if all files are successfully added.
1523 1523 </p>
1524 1524 <p>
1525 1525 options:
1526 1526 </p>
1527 1527 <table>
1528 1528 <tr><td>-I</td>
1529 1529 <td>--include PATTERN [+]</td>
1530 1530 <td>include names matching the given patterns</td></tr>
1531 1531 <tr><td>-X</td>
1532 1532 <td>--exclude PATTERN [+]</td>
1533 1533 <td>exclude names matching the given patterns</td></tr>
1534 1534 <tr><td>-S</td>
1535 1535 <td>--subrepos</td>
1536 1536 <td>recurse into subrepositories</td></tr>
1537 1537 <tr><td>-n</td>
1538 1538 <td>--dry-run</td>
1539 1539 <td>do not perform actions, just print output</td></tr>
1540 1540 </table>
1541 1541 <p>
1542 1542 [+] marked option can be specified multiple times
1543 1543 </p>
1544 1544 <p>
1545 1545 global options:
1546 1546 </p>
1547 1547 <table>
1548 1548 <tr><td>-R</td>
1549 1549 <td>--repository REPO</td>
1550 1550 <td>repository root directory or name of overlay bundle file</td></tr>
1551 1551 <tr><td></td>
1552 1552 <td>--cwd DIR</td>
1553 1553 <td>change working directory</td></tr>
1554 1554 <tr><td>-y</td>
1555 1555 <td>--noninteractive</td>
1556 1556 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1557 1557 <tr><td>-q</td>
1558 1558 <td>--quiet</td>
1559 1559 <td>suppress output</td></tr>
1560 1560 <tr><td>-v</td>
1561 1561 <td>--verbose</td>
1562 1562 <td>enable additional output</td></tr>
1563 1563 <tr><td></td>
1564 1564 <td>--config CONFIG [+]</td>
1565 1565 <td>set/override config option (use 'section.name=value')</td></tr>
1566 1566 <tr><td></td>
1567 1567 <td>--debug</td>
1568 1568 <td>enable debugging output</td></tr>
1569 1569 <tr><td></td>
1570 1570 <td>--debugger</td>
1571 1571 <td>start debugger</td></tr>
1572 1572 <tr><td></td>
1573 1573 <td>--encoding ENCODE</td>
1574 1574 <td>set the charset encoding (default: ascii)</td></tr>
1575 1575 <tr><td></td>
1576 1576 <td>--encodingmode MODE</td>
1577 1577 <td>set the charset encoding mode (default: strict)</td></tr>
1578 1578 <tr><td></td>
1579 1579 <td>--traceback</td>
1580 1580 <td>always print a traceback on exception</td></tr>
1581 1581 <tr><td></td>
1582 1582 <td>--time</td>
1583 1583 <td>time how long the command takes</td></tr>
1584 1584 <tr><td></td>
1585 1585 <td>--profile</td>
1586 1586 <td>print command execution profile</td></tr>
1587 1587 <tr><td></td>
1588 1588 <td>--version</td>
1589 1589 <td>output version information and exit</td></tr>
1590 1590 <tr><td>-h</td>
1591 1591 <td>--help</td>
1592 1592 <td>display help and exit</td></tr>
1593 1593 <tr><td></td>
1594 1594 <td>--hidden</td>
1595 1595 <td>consider hidden changesets</td></tr>
1596 1596 </table>
1597 1597 <p>
1598 1598 [+] marked option can be specified multiple times
1599 1599 </p>
1600 1600
1601 1601 </div>
1602 1602 </div>
1603 1603 </div>
1604 1604
1605 1605 <script type="text/javascript">process_dates()</script>
1606 1606
1607 1607
1608 1608 </body>
1609 1609 </html>
1610 1610
1611 1611
1612 1612 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/remove"
1613 1613 200 Script output follows
1614 1614
1615 1615 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1616 1616 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1617 1617 <head>
1618 1618 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1619 1619 <meta name="robots" content="index, nofollow" />
1620 1620 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1621 1621 <script type="text/javascript" src="/static/mercurial.js"></script>
1622 1622
1623 1623 <title>Help: remove</title>
1624 1624 </head>
1625 1625 <body>
1626 1626
1627 1627 <div class="container">
1628 1628 <div class="menu">
1629 1629 <div class="logo">
1630 1630 <a href="http://mercurial.selenic.com/">
1631 1631 <img src="/static/hglogo.png" alt="mercurial" /></a>
1632 1632 </div>
1633 1633 <ul>
1634 1634 <li><a href="/shortlog">log</a></li>
1635 1635 <li><a href="/graph">graph</a></li>
1636 1636 <li><a href="/tags">tags</a></li>
1637 1637 <li><a href="/bookmarks">bookmarks</a></li>
1638 1638 <li><a href="/branches">branches</a></li>
1639 1639 </ul>
1640 1640 <ul>
1641 1641 <li class="active"><a href="/help">help</a></li>
1642 1642 </ul>
1643 1643 </div>
1644 1644
1645 1645 <div class="main">
1646 1646 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1647 1647 <h3>Help: remove</h3>
1648 1648
1649 1649 <form class="search" action="/log">
1650 1650
1651 1651 <p><input name="rev" id="search1" type="text" size="30" /></p>
1652 1652 <div id="hint">find changesets by author, revision,
1653 1653 files, or words in the commit message</div>
1654 1654 </form>
1655 1655 <div id="doc">
1656 1656 <p>
1657 1657 hg remove [OPTION]... FILE...
1658 1658 </p>
1659 1659 <p>
1660 1660 aliases: rm
1661 1661 </p>
1662 1662 <p>
1663 1663 remove the specified files on the next commit
1664 1664 </p>
1665 1665 <p>
1666 1666 Schedule the indicated files for removal from the current branch.
1667 1667 </p>
1668 1668 <p>
1669 1669 This command schedules the files to be removed at the next commit.
1670 1670 To undo a remove before that, see &quot;hg revert&quot;. To undo added
1671 1671 files, see &quot;hg forget&quot;.
1672 1672 </p>
1673 1673 <p>
1674 1674 -A/--after can be used to remove only files that have already
1675 1675 been deleted, -f/--force can be used to force deletion, and -Af
1676 1676 can be used to remove files from the next revision without
1677 1677 deleting them from the working directory.
1678 1678 </p>
1679 1679 <p>
1680 1680 The following table details the behavior of remove for different
1681 1681 file states (columns) and option combinations (rows). The file
1682 1682 states are Added [A], Clean [C], Modified [M] and Missing [!]
1683 1683 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
1684 1684 (from branch) and Delete (from disk):
1685 1685 </p>
1686 1686 <table>
1687 1687 <tr><td></td>
1688 1688 <td>A</td>
1689 1689 <td>C</td>
1690 1690 <td>M</td>
1691 1691 <td>!</td></tr>
1692 1692 <tr><td>none</td>
1693 1693 <td>W</td>
1694 1694 <td>RD</td>
1695 1695 <td>W</td>
1696 1696 <td>R</td></tr>
1697 1697 <tr><td>-f</td>
1698 1698 <td>R</td>
1699 1699 <td>RD</td>
1700 1700 <td>RD</td>
1701 1701 <td>R</td></tr>
1702 1702 <tr><td>-A</td>
1703 1703 <td>W</td>
1704 1704 <td>W</td>
1705 1705 <td>W</td>
1706 1706 <td>R</td></tr>
1707 1707 <tr><td>-Af</td>
1708 1708 <td>R</td>
1709 1709 <td>R</td>
1710 1710 <td>R</td>
1711 1711 <td>R</td></tr>
1712 1712 </table>
1713 1713 <p>
1714 1714 Note that remove never deletes files in Added [A] state from the
1715 1715 working directory, not even if option --force is specified.
1716 1716 </p>
1717 1717 <p>
1718 1718 Returns 0 on success, 1 if any warnings encountered.
1719 1719 </p>
1720 1720 <p>
1721 1721 options:
1722 1722 </p>
1723 1723 <table>
1724 1724 <tr><td>-A</td>
1725 1725 <td>--after</td>
1726 1726 <td>record delete for missing files</td></tr>
1727 1727 <tr><td>-f</td>
1728 1728 <td>--force</td>
1729 1729 <td>remove (and delete) file even if added or modified</td></tr>
1730 1730 <tr><td>-I</td>
1731 1731 <td>--include PATTERN [+]</td>
1732 1732 <td>include names matching the given patterns</td></tr>
1733 1733 <tr><td>-X</td>
1734 1734 <td>--exclude PATTERN [+]</td>
1735 1735 <td>exclude names matching the given patterns</td></tr>
1736 1736 </table>
1737 1737 <p>
1738 1738 [+] marked option can be specified multiple times
1739 1739 </p>
1740 1740 <p>
1741 1741 global options:
1742 1742 </p>
1743 1743 <table>
1744 1744 <tr><td>-R</td>
1745 1745 <td>--repository REPO</td>
1746 1746 <td>repository root directory or name of overlay bundle file</td></tr>
1747 1747 <tr><td></td>
1748 1748 <td>--cwd DIR</td>
1749 1749 <td>change working directory</td></tr>
1750 1750 <tr><td>-y</td>
1751 1751 <td>--noninteractive</td>
1752 1752 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
1753 1753 <tr><td>-q</td>
1754 1754 <td>--quiet</td>
1755 1755 <td>suppress output</td></tr>
1756 1756 <tr><td>-v</td>
1757 1757 <td>--verbose</td>
1758 1758 <td>enable additional output</td></tr>
1759 1759 <tr><td></td>
1760 1760 <td>--config CONFIG [+]</td>
1761 1761 <td>set/override config option (use 'section.name=value')</td></tr>
1762 1762 <tr><td></td>
1763 1763 <td>--debug</td>
1764 1764 <td>enable debugging output</td></tr>
1765 1765 <tr><td></td>
1766 1766 <td>--debugger</td>
1767 1767 <td>start debugger</td></tr>
1768 1768 <tr><td></td>
1769 1769 <td>--encoding ENCODE</td>
1770 1770 <td>set the charset encoding (default: ascii)</td></tr>
1771 1771 <tr><td></td>
1772 1772 <td>--encodingmode MODE</td>
1773 1773 <td>set the charset encoding mode (default: strict)</td></tr>
1774 1774 <tr><td></td>
1775 1775 <td>--traceback</td>
1776 1776 <td>always print a traceback on exception</td></tr>
1777 1777 <tr><td></td>
1778 1778 <td>--time</td>
1779 1779 <td>time how long the command takes</td></tr>
1780 1780 <tr><td></td>
1781 1781 <td>--profile</td>
1782 1782 <td>print command execution profile</td></tr>
1783 1783 <tr><td></td>
1784 1784 <td>--version</td>
1785 1785 <td>output version information and exit</td></tr>
1786 1786 <tr><td>-h</td>
1787 1787 <td>--help</td>
1788 1788 <td>display help and exit</td></tr>
1789 1789 <tr><td></td>
1790 1790 <td>--hidden</td>
1791 1791 <td>consider hidden changesets</td></tr>
1792 1792 </table>
1793 1793 <p>
1794 1794 [+] marked option can be specified multiple times
1795 1795 </p>
1796 1796
1797 1797 </div>
1798 1798 </div>
1799 1799 </div>
1800 1800
1801 1801 <script type="text/javascript">process_dates()</script>
1802 1802
1803 1803
1804 1804 </body>
1805 1805 </html>
1806 1806
1807 1807
1808 1808 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT "help/revisions"
1809 1809 200 Script output follows
1810 1810
1811 1811 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1812 1812 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1813 1813 <head>
1814 1814 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1815 1815 <meta name="robots" content="index, nofollow" />
1816 1816 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1817 1817 <script type="text/javascript" src="/static/mercurial.js"></script>
1818 1818
1819 1819 <title>Help: revisions</title>
1820 1820 </head>
1821 1821 <body>
1822 1822
1823 1823 <div class="container">
1824 1824 <div class="menu">
1825 1825 <div class="logo">
1826 1826 <a href="http://mercurial.selenic.com/">
1827 1827 <img src="/static/hglogo.png" alt="mercurial" /></a>
1828 1828 </div>
1829 1829 <ul>
1830 1830 <li><a href="/shortlog">log</a></li>
1831 1831 <li><a href="/graph">graph</a></li>
1832 1832 <li><a href="/tags">tags</a></li>
1833 1833 <li><a href="/bookmarks">bookmarks</a></li>
1834 1834 <li><a href="/branches">branches</a></li>
1835 1835 </ul>
1836 1836 <ul>
1837 1837 <li class="active"><a href="/help">help</a></li>
1838 1838 </ul>
1839 1839 </div>
1840 1840
1841 1841 <div class="main">
1842 1842 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1843 1843 <h3>Help: revisions</h3>
1844 1844
1845 1845 <form class="search" action="/log">
1846 1846
1847 1847 <p><input name="rev" id="search1" type="text" size="30" /></p>
1848 1848 <div id="hint">find changesets by author, revision,
1849 1849 files, or words in the commit message</div>
1850 1850 </form>
1851 1851 <div id="doc">
1852 1852 <h1>Specifying Single Revisions</h1>
1853 1853 <p>
1854 1854 Mercurial supports several ways to specify individual revisions.
1855 1855 </p>
1856 1856 <p>
1857 1857 A plain integer is treated as a revision number. Negative integers are
1858 1858 treated as sequential offsets from the tip, with -1 denoting the tip,
1859 1859 -2 denoting the revision prior to the tip, and so forth.
1860 1860 </p>
1861 1861 <p>
1862 1862 A 40-digit hexadecimal string is treated as a unique revision
1863 1863 identifier.
1864 1864 </p>
1865 1865 <p>
1866 1866 A hexadecimal string less than 40 characters long is treated as a
1867 1867 unique revision identifier and is referred to as a short-form
1868 1868 identifier. A short-form identifier is only valid if it is the prefix
1869 1869 of exactly one full-length identifier.
1870 1870 </p>
1871 1871 <p>
1872 1872 Any other string is treated as a bookmark, tag, or branch name. A
1873 1873 bookmark is a movable pointer to a revision. A tag is a permanent name
1874 1874 associated with a revision. A branch name denotes the tipmost revision
1875 1875 of that branch. Bookmark, tag, and branch names must not contain the &quot;:&quot;
1876 1876 character.
1877 1877 </p>
1878 1878 <p>
1879 1879 The reserved name &quot;tip&quot; always identifies the most recent revision.
1880 1880 </p>
1881 1881 <p>
1882 1882 The reserved name &quot;null&quot; indicates the null revision. This is the
1883 1883 revision of an empty repository, and the parent of revision 0.
1884 1884 </p>
1885 1885 <p>
1886 1886 The reserved name &quot;.&quot; indicates the working directory parent. If no
1887 1887 working directory is checked out, it is equivalent to null. If an
1888 1888 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
1889 1889 parent.
1890 1890 </p>
1891 1891
1892 1892 </div>
1893 1893 </div>
1894 1894 </div>
1895 1895
1896 1896 <script type="text/javascript">process_dates()</script>
1897 1897
1898 1898
1899 1899 </body>
1900 1900 </html>
1901 1901
1902 1902
1903 1903 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
1904 1904
1905 1905 #endif
General Comments 0
You need to be logged in to leave comments. Login now