##// END OF EJS Templates
commands: support creating stream clone bundles...
Gregory Szorc -
r26757:43708f92 default
parent child Browse files
Show More
@@ -1,6686 +1,6704
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, shlex
12 12 import sys, socket
13 13 import hg, scmutil, util, revlog, copies, error, bookmarks
14 14 import patch, help, encoding, templatekw, discovery
15 15 import archival, changegroup, cmdutil, hbisect
16 16 import sshserver, hgweb
17 17 import extensions
18 18 from hgweb import server as hgweb_server
19 19 import merge as mergemod
20 20 import minirst, revset, fileset
21 21 import dagparser, context, simplemerge, graphmod, copies
22 22 import random, operator
23 23 import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil
24 24 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
25 25 import ui as uimod
26 import streamclone
26 27
27 28 table = {}
28 29
29 30 command = cmdutil.command(table)
30 31
31 32 # Space delimited list of commands that don't require local repositories.
32 33 # This should be populated by passing norepo=True into the @command decorator.
33 34 norepo = ''
34 35 # Space delimited list of commands that optionally require local repositories.
35 36 # This should be populated by passing optionalrepo=True into the @command
36 37 # decorator.
37 38 optionalrepo = ''
38 39 # Space delimited list of commands that will examine arguments looking for
39 40 # a repository. This should be populated by passing inferrepo=True into the
40 41 # @command decorator.
41 42 inferrepo = ''
42 43
43 44 # label constants
44 45 # until 3.5, bookmarks.current was the advertised name, not
45 46 # bookmarks.active, so we must use both to avoid breaking old
46 47 # custom styles
47 48 activebookmarklabel = 'bookmarks.active bookmarks.current'
48 49
49 50 # common command options
50 51
51 52 globalopts = [
52 53 ('R', 'repository', '',
53 54 _('repository root directory or name of overlay bundle file'),
54 55 _('REPO')),
55 56 ('', 'cwd', '',
56 57 _('change working directory'), _('DIR')),
57 58 ('y', 'noninteractive', None,
58 59 _('do not prompt, automatically pick the first choice for all prompts')),
59 60 ('q', 'quiet', None, _('suppress output')),
60 61 ('v', 'verbose', None, _('enable additional output')),
61 62 ('', 'config', [],
62 63 _('set/override config option (use \'section.name=value\')'),
63 64 _('CONFIG')),
64 65 ('', 'debug', None, _('enable debugging output')),
65 66 ('', 'debugger', None, _('start debugger')),
66 67 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
67 68 _('ENCODE')),
68 69 ('', 'encodingmode', encoding.encodingmode,
69 70 _('set the charset encoding mode'), _('MODE')),
70 71 ('', 'traceback', None, _('always print a traceback on exception')),
71 72 ('', 'time', None, _('time how long the command takes')),
72 73 ('', 'profile', None, _('print command execution profile')),
73 74 ('', 'version', None, _('output version information and exit')),
74 75 ('h', 'help', None, _('display help and exit')),
75 76 ('', 'hidden', False, _('consider hidden changesets')),
76 77 ]
77 78
78 79 dryrunopts = [('n', 'dry-run', None,
79 80 _('do not perform actions, just print output'))]
80 81
81 82 remoteopts = [
82 83 ('e', 'ssh', '',
83 84 _('specify ssh command to use'), _('CMD')),
84 85 ('', 'remotecmd', '',
85 86 _('specify hg command to run on the remote side'), _('CMD')),
86 87 ('', 'insecure', None,
87 88 _('do not verify server certificate (ignoring web.cacerts config)')),
88 89 ]
89 90
90 91 walkopts = [
91 92 ('I', 'include', [],
92 93 _('include names matching the given patterns'), _('PATTERN')),
93 94 ('X', 'exclude', [],
94 95 _('exclude names matching the given patterns'), _('PATTERN')),
95 96 ]
96 97
97 98 commitopts = [
98 99 ('m', 'message', '',
99 100 _('use text as commit message'), _('TEXT')),
100 101 ('l', 'logfile', '',
101 102 _('read commit message from file'), _('FILE')),
102 103 ]
103 104
104 105 commitopts2 = [
105 106 ('d', 'date', '',
106 107 _('record the specified date as commit date'), _('DATE')),
107 108 ('u', 'user', '',
108 109 _('record the specified user as committer'), _('USER')),
109 110 ]
110 111
111 112 # hidden for now
112 113 formatteropts = [
113 114 ('T', 'template', '',
114 115 _('display with template (EXPERIMENTAL)'), _('TEMPLATE')),
115 116 ]
116 117
117 118 templateopts = [
118 119 ('', 'style', '',
119 120 _('display using template map file (DEPRECATED)'), _('STYLE')),
120 121 ('T', 'template', '',
121 122 _('display with template'), _('TEMPLATE')),
122 123 ]
123 124
124 125 logopts = [
125 126 ('p', 'patch', None, _('show patch')),
126 127 ('g', 'git', None, _('use git extended diff format')),
127 128 ('l', 'limit', '',
128 129 _('limit number of changes displayed'), _('NUM')),
129 130 ('M', 'no-merges', None, _('do not show merges')),
130 131 ('', 'stat', None, _('output diffstat-style summary of changes')),
131 132 ('G', 'graph', None, _("show the revision DAG")),
132 133 ] + templateopts
133 134
134 135 diffopts = [
135 136 ('a', 'text', None, _('treat all files as text')),
136 137 ('g', 'git', None, _('use git extended diff format')),
137 138 ('', 'nodates', None, _('omit dates from diff headers'))
138 139 ]
139 140
140 141 diffwsopts = [
141 142 ('w', 'ignore-all-space', None,
142 143 _('ignore white space when comparing lines')),
143 144 ('b', 'ignore-space-change', None,
144 145 _('ignore changes in the amount of white space')),
145 146 ('B', 'ignore-blank-lines', None,
146 147 _('ignore changes whose lines are all blank')),
147 148 ]
148 149
149 150 diffopts2 = [
150 151 ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
151 152 ('p', 'show-function', None, _('show which function each change is in')),
152 153 ('', 'reverse', None, _('produce a diff that undoes the changes')),
153 154 ] + diffwsopts + [
154 155 ('U', 'unified', '',
155 156 _('number of lines of context to show'), _('NUM')),
156 157 ('', 'stat', None, _('output diffstat-style summary of changes')),
157 158 ('', 'root', '', _('produce diffs relative to subdirectory'), _('DIR')),
158 159 ]
159 160
160 161 mergetoolopts = [
161 162 ('t', 'tool', '', _('specify merge tool')),
162 163 ]
163 164
164 165 similarityopts = [
165 166 ('s', 'similarity', '',
166 167 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
167 168 ]
168 169
169 170 subrepoopts = [
170 171 ('S', 'subrepos', None,
171 172 _('recurse into subrepositories'))
172 173 ]
173 174
174 175 # Commands start here, listed alphabetically
175 176
176 177 @command('^add',
177 178 walkopts + subrepoopts + dryrunopts,
178 179 _('[OPTION]... [FILE]...'),
179 180 inferrepo=True)
180 181 def add(ui, repo, *pats, **opts):
181 182 """add the specified files on the next commit
182 183
183 184 Schedule files to be version controlled and added to the
184 185 repository.
185 186
186 187 The files will be added to the repository at the next commit. To
187 188 undo an add before that, see :hg:`forget`.
188 189
189 190 If no names are given, add all files to the repository.
190 191
191 192 .. container:: verbose
192 193
193 194 An example showing how new (unknown) files are added
194 195 automatically by :hg:`add`::
195 196
196 197 $ ls
197 198 foo.c
198 199 $ hg status
199 200 ? foo.c
200 201 $ hg add
201 202 adding foo.c
202 203 $ hg status
203 204 A foo.c
204 205
205 206 Returns 0 if all files are successfully added.
206 207 """
207 208
208 209 m = scmutil.match(repo[None], pats, opts)
209 210 rejected = cmdutil.add(ui, repo, m, "", False, **opts)
210 211 return rejected and 1 or 0
211 212
212 213 @command('addremove',
213 214 similarityopts + subrepoopts + walkopts + dryrunopts,
214 215 _('[OPTION]... [FILE]...'),
215 216 inferrepo=True)
216 217 def addremove(ui, repo, *pats, **opts):
217 218 """add all new files, delete all missing files
218 219
219 220 Add all new files and remove all missing files from the
220 221 repository.
221 222
222 223 New files are ignored if they match any of the patterns in
223 224 ``.hgignore``. As with add, these changes take effect at the next
224 225 commit.
225 226
226 227 Use the -s/--similarity option to detect renamed files. This
227 228 option takes a percentage between 0 (disabled) and 100 (files must
228 229 be identical) as its parameter. With a parameter greater than 0,
229 230 this compares every removed file with every added file and records
230 231 those similar enough as renames. Detecting renamed files this way
231 232 can be expensive. After using this option, :hg:`status -C` can be
232 233 used to check which files were identified as moved or renamed. If
233 234 not specified, -s/--similarity defaults to 100 and only renames of
234 235 identical files are detected.
235 236
236 237 Returns 0 if all files are successfully added.
237 238 """
238 239 try:
239 240 sim = float(opts.get('similarity') or 100)
240 241 except ValueError:
241 242 raise error.Abort(_('similarity must be a number'))
242 243 if sim < 0 or sim > 100:
243 244 raise error.Abort(_('similarity must be between 0 and 100'))
244 245 matcher = scmutil.match(repo[None], pats, opts)
245 246 return scmutil.addremove(repo, matcher, "", opts, similarity=sim / 100.0)
246 247
247 248 @command('^annotate|blame',
248 249 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
249 250 ('', 'follow', None,
250 251 _('follow copies/renames and list the filename (DEPRECATED)')),
251 252 ('', 'no-follow', None, _("don't follow copies and renames")),
252 253 ('a', 'text', None, _('treat all files as text')),
253 254 ('u', 'user', None, _('list the author (long with -v)')),
254 255 ('f', 'file', None, _('list the filename')),
255 256 ('d', 'date', None, _('list the date (short with -q)')),
256 257 ('n', 'number', None, _('list the revision number (default)')),
257 258 ('c', 'changeset', None, _('list the changeset')),
258 259 ('l', 'line-number', None, _('show line number at the first appearance'))
259 260 ] + diffwsopts + walkopts + formatteropts,
260 261 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'),
261 262 inferrepo=True)
262 263 def annotate(ui, repo, *pats, **opts):
263 264 """show changeset information by line for each file
264 265
265 266 List changes in files, showing the revision id responsible for
266 267 each line
267 268
268 269 This command is useful for discovering when a change was made and
269 270 by whom.
270 271
271 272 Without the -a/--text option, annotate will avoid processing files
272 273 it detects as binary. With -a, annotate will annotate the file
273 274 anyway, although the results will probably be neither useful
274 275 nor desirable.
275 276
276 277 Returns 0 on success.
277 278 """
278 279 if not pats:
279 280 raise error.Abort(_('at least one filename or pattern is required'))
280 281
281 282 if opts.get('follow'):
282 283 # --follow is deprecated and now just an alias for -f/--file
283 284 # to mimic the behavior of Mercurial before version 1.5
284 285 opts['file'] = True
285 286
286 287 ctx = scmutil.revsingle(repo, opts.get('rev'))
287 288
288 289 fm = ui.formatter('annotate', opts)
289 290 if ui.quiet:
290 291 datefunc = util.shortdate
291 292 else:
292 293 datefunc = util.datestr
293 294 if ctx.rev() is None:
294 295 def hexfn(node):
295 296 if node is None:
296 297 return None
297 298 else:
298 299 return fm.hexfunc(node)
299 300 if opts.get('changeset'):
300 301 # omit "+" suffix which is appended to node hex
301 302 def formatrev(rev):
302 303 if rev is None:
303 304 return '%d' % ctx.p1().rev()
304 305 else:
305 306 return '%d' % rev
306 307 else:
307 308 def formatrev(rev):
308 309 if rev is None:
309 310 return '%d+' % ctx.p1().rev()
310 311 else:
311 312 return '%d ' % rev
312 313 def formathex(hex):
313 314 if hex is None:
314 315 return '%s+' % fm.hexfunc(ctx.p1().node())
315 316 else:
316 317 return '%s ' % hex
317 318 else:
318 319 hexfn = fm.hexfunc
319 320 formatrev = formathex = str
320 321
321 322 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
322 323 ('number', ' ', lambda x: x[0].rev(), formatrev),
323 324 ('changeset', ' ', lambda x: hexfn(x[0].node()), formathex),
324 325 ('date', ' ', lambda x: x[0].date(), util.cachefunc(datefunc)),
325 326 ('file', ' ', lambda x: x[0].path(), str),
326 327 ('line_number', ':', lambda x: x[1], str),
327 328 ]
328 329 fieldnamemap = {'number': 'rev', 'changeset': 'node'}
329 330
330 331 if (not opts.get('user') and not opts.get('changeset')
331 332 and not opts.get('date') and not opts.get('file')):
332 333 opts['number'] = True
333 334
334 335 linenumber = opts.get('line_number') is not None
335 336 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
336 337 raise error.Abort(_('at least one of -n/-c is required for -l'))
337 338
338 339 if fm:
339 340 def makefunc(get, fmt):
340 341 return get
341 342 else:
342 343 def makefunc(get, fmt):
343 344 return lambda x: fmt(get(x))
344 345 funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap
345 346 if opts.get(op)]
346 347 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
347 348 fields = ' '.join(fieldnamemap.get(op, op) for op, sep, get, fmt in opmap
348 349 if opts.get(op))
349 350
350 351 def bad(x, y):
351 352 raise error.Abort("%s: %s" % (x, y))
352 353
353 354 m = scmutil.match(ctx, pats, opts, badfn=bad)
354 355
355 356 follow = not opts.get('no_follow')
356 357 diffopts = patch.difffeatureopts(ui, opts, section='annotate',
357 358 whitespace=True)
358 359 for abs in ctx.walk(m):
359 360 fctx = ctx[abs]
360 361 if not opts.get('text') and util.binary(fctx.data()):
361 362 fm.plain(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
362 363 continue
363 364
364 365 lines = fctx.annotate(follow=follow, linenumber=linenumber,
365 366 diffopts=diffopts)
366 367 formats = []
367 368 pieces = []
368 369
369 370 for f, sep in funcmap:
370 371 l = [f(n) for n, dummy in lines]
371 372 if l:
372 373 if fm:
373 374 formats.append(['%s' for x in l])
374 375 else:
375 376 sizes = [encoding.colwidth(x) for x in l]
376 377 ml = max(sizes)
377 378 formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes])
378 379 pieces.append(l)
379 380
380 381 for f, p, l in zip(zip(*formats), zip(*pieces), lines):
381 382 fm.startitem()
382 383 fm.write(fields, "".join(f), *p)
383 384 fm.write('line', ": %s", l[1])
384 385
385 386 if lines and not lines[-1][1].endswith('\n'):
386 387 fm.plain('\n')
387 388
388 389 fm.end()
389 390
390 391 @command('archive',
391 392 [('', 'no-decode', None, _('do not pass files through decoders')),
392 393 ('p', 'prefix', '', _('directory prefix for files in archive'),
393 394 _('PREFIX')),
394 395 ('r', 'rev', '', _('revision to distribute'), _('REV')),
395 396 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
396 397 ] + subrepoopts + walkopts,
397 398 _('[OPTION]... DEST'))
398 399 def archive(ui, repo, dest, **opts):
399 400 '''create an unversioned archive of a repository revision
400 401
401 402 By default, the revision used is the parent of the working
402 403 directory; use -r/--rev to specify a different revision.
403 404
404 405 The archive type is automatically detected based on file
405 406 extension (or override using -t/--type).
406 407
407 408 .. container:: verbose
408 409
409 410 Examples:
410 411
411 412 - create a zip file containing the 1.0 release::
412 413
413 414 hg archive -r 1.0 project-1.0.zip
414 415
415 416 - create a tarball excluding .hg files::
416 417
417 418 hg archive project.tar.gz -X ".hg*"
418 419
419 420 Valid types are:
420 421
421 422 :``files``: a directory full of files (default)
422 423 :``tar``: tar archive, uncompressed
423 424 :``tbz2``: tar archive, compressed using bzip2
424 425 :``tgz``: tar archive, compressed using gzip
425 426 :``uzip``: zip archive, uncompressed
426 427 :``zip``: zip archive, compressed using deflate
427 428
428 429 The exact name of the destination archive or directory is given
429 430 using a format string; see :hg:`help export` for details.
430 431
431 432 Each member added to an archive file has a directory prefix
432 433 prepended. Use -p/--prefix to specify a format string for the
433 434 prefix. The default is the basename of the archive, with suffixes
434 435 removed.
435 436
436 437 Returns 0 on success.
437 438 '''
438 439
439 440 ctx = scmutil.revsingle(repo, opts.get('rev'))
440 441 if not ctx:
441 442 raise error.Abort(_('no working directory: please specify a revision'))
442 443 node = ctx.node()
443 444 dest = cmdutil.makefilename(repo, dest, node)
444 445 if os.path.realpath(dest) == repo.root:
445 446 raise error.Abort(_('repository root cannot be destination'))
446 447
447 448 kind = opts.get('type') or archival.guesskind(dest) or 'files'
448 449 prefix = opts.get('prefix')
449 450
450 451 if dest == '-':
451 452 if kind == 'files':
452 453 raise error.Abort(_('cannot archive plain files to stdout'))
453 454 dest = cmdutil.makefileobj(repo, dest)
454 455 if not prefix:
455 456 prefix = os.path.basename(repo.root) + '-%h'
456 457
457 458 prefix = cmdutil.makefilename(repo, prefix, node)
458 459 matchfn = scmutil.match(ctx, [], opts)
459 460 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
460 461 matchfn, prefix, subrepos=opts.get('subrepos'))
461 462
462 463 @command('backout',
463 464 [('', 'merge', None, _('merge with old dirstate parent after backout')),
464 465 ('', 'commit', None, _('commit if no conflicts were encountered')),
465 466 ('', 'parent', '',
466 467 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
467 468 ('r', 'rev', '', _('revision to backout'), _('REV')),
468 469 ('e', 'edit', False, _('invoke editor on commit messages')),
469 470 ] + mergetoolopts + walkopts + commitopts + commitopts2,
470 471 _('[OPTION]... [-r] REV'))
471 472 def backout(ui, repo, node=None, rev=None, commit=False, **opts):
472 473 '''reverse effect of earlier changeset
473 474
474 475 Prepare a new changeset with the effect of REV undone in the
475 476 current working directory.
476 477
477 478 If REV is the parent of the working directory, then this new changeset
478 479 is committed automatically. Otherwise, hg needs to merge the
479 480 changes and the merged result is left uncommitted.
480 481
481 482 .. note::
482 483
483 484 backout cannot be used to fix either an unwanted or
484 485 incorrect merge.
485 486
486 487 .. container:: verbose
487 488
488 489 By default, the pending changeset will have one parent,
489 490 maintaining a linear history. With --merge, the pending
490 491 changeset will instead have two parents: the old parent of the
491 492 working directory and a new child of REV that simply undoes REV.
492 493
493 494 Before version 1.7, the behavior without --merge was equivalent
494 495 to specifying --merge followed by :hg:`update --clean .` to
495 496 cancel the merge and leave the child of REV as a head to be
496 497 merged separately.
497 498
498 499 See :hg:`help dates` for a list of formats valid for -d/--date.
499 500
500 501 See :hg:`help revert` for a way to restore files to the state
501 502 of another revision.
502 503
503 504 Returns 0 on success, 1 if nothing to backout or there are unresolved
504 505 files.
505 506 '''
506 507 if rev and node:
507 508 raise error.Abort(_("please specify just one revision"))
508 509
509 510 if not rev:
510 511 rev = node
511 512
512 513 if not rev:
513 514 raise error.Abort(_("please specify a revision to backout"))
514 515
515 516 date = opts.get('date')
516 517 if date:
517 518 opts['date'] = util.parsedate(date)
518 519
519 520 cmdutil.checkunfinished(repo)
520 521 cmdutil.bailifchanged(repo)
521 522 node = scmutil.revsingle(repo, rev).node()
522 523
523 524 op1, op2 = repo.dirstate.parents()
524 525 if not repo.changelog.isancestor(node, op1):
525 526 raise error.Abort(_('cannot backout change that is not an ancestor'))
526 527
527 528 p1, p2 = repo.changelog.parents(node)
528 529 if p1 == nullid:
529 530 raise error.Abort(_('cannot backout a change with no parents'))
530 531 if p2 != nullid:
531 532 if not opts.get('parent'):
532 533 raise error.Abort(_('cannot backout a merge changeset'))
533 534 p = repo.lookup(opts['parent'])
534 535 if p not in (p1, p2):
535 536 raise error.Abort(_('%s is not a parent of %s') %
536 537 (short(p), short(node)))
537 538 parent = p
538 539 else:
539 540 if opts.get('parent'):
540 541 raise error.Abort(_('cannot use --parent on non-merge changeset'))
541 542 parent = p1
542 543
543 544 # the backout should appear on the same branch
544 545 wlock = repo.wlock()
545 546 try:
546 547 branch = repo.dirstate.branch()
547 548 bheads = repo.branchheads(branch)
548 549 rctx = scmutil.revsingle(repo, hex(parent))
549 550 if not opts.get('merge') and op1 != node:
550 551 dsguard = cmdutil.dirstateguard(repo, 'backout')
551 552 try:
552 553 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
553 554 'backout')
554 555 stats = mergemod.update(repo, parent, True, True, False,
555 556 node, False)
556 557 repo.setparents(op1, op2)
557 558 dsguard.close()
558 559 hg._showstats(repo, stats)
559 560 if stats[3]:
560 561 repo.ui.status(_("use 'hg resolve' to retry unresolved "
561 562 "file merges\n"))
562 563 return 1
563 564 elif not commit:
564 565 msg = _("changeset %s backed out, "
565 566 "don't forget to commit.\n")
566 567 ui.status(msg % short(node))
567 568 return 0
568 569 finally:
569 570 ui.setconfig('ui', 'forcemerge', '', '')
570 571 lockmod.release(dsguard)
571 572 else:
572 573 hg.clean(repo, node, show_stats=False)
573 574 repo.dirstate.setbranch(branch)
574 575 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
575 576
576 577
577 578 def commitfunc(ui, repo, message, match, opts):
578 579 editform = 'backout'
579 580 e = cmdutil.getcommiteditor(editform=editform, **opts)
580 581 if not message:
581 582 # we don't translate commit messages
582 583 message = "Backed out changeset %s" % short(node)
583 584 e = cmdutil.getcommiteditor(edit=True, editform=editform)
584 585 return repo.commit(message, opts.get('user'), opts.get('date'),
585 586 match, editor=e)
586 587 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
587 588 if not newnode:
588 589 ui.status(_("nothing changed\n"))
589 590 return 1
590 591 cmdutil.commitstatus(repo, newnode, branch, bheads)
591 592
592 593 def nice(node):
593 594 return '%d:%s' % (repo.changelog.rev(node), short(node))
594 595 ui.status(_('changeset %s backs out changeset %s\n') %
595 596 (nice(repo.changelog.tip()), nice(node)))
596 597 if opts.get('merge') and op1 != node:
597 598 hg.clean(repo, op1, show_stats=False)
598 599 ui.status(_('merging with changeset %s\n')
599 600 % nice(repo.changelog.tip()))
600 601 try:
601 602 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
602 603 'backout')
603 604 return hg.merge(repo, hex(repo.changelog.tip()))
604 605 finally:
605 606 ui.setconfig('ui', 'forcemerge', '', '')
606 607 finally:
607 608 wlock.release()
608 609 return 0
609 610
610 611 @command('bisect',
611 612 [('r', 'reset', False, _('reset bisect state')),
612 613 ('g', 'good', False, _('mark changeset good')),
613 614 ('b', 'bad', False, _('mark changeset bad')),
614 615 ('s', 'skip', False, _('skip testing changeset')),
615 616 ('e', 'extend', False, _('extend the bisect range')),
616 617 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
617 618 ('U', 'noupdate', False, _('do not update to target'))],
618 619 _("[-gbsr] [-U] [-c CMD] [REV]"))
619 620 def bisect(ui, repo, rev=None, extra=None, command=None,
620 621 reset=None, good=None, bad=None, skip=None, extend=None,
621 622 noupdate=None):
622 623 """subdivision search of changesets
623 624
624 625 This command helps to find changesets which introduce problems. To
625 626 use, mark the earliest changeset you know exhibits the problem as
626 627 bad, then mark the latest changeset which is free from the problem
627 628 as good. Bisect will update your working directory to a revision
628 629 for testing (unless the -U/--noupdate option is specified). Once
629 630 you have performed tests, mark the working directory as good or
630 631 bad, and bisect will either update to another candidate changeset
631 632 or announce that it has found the bad revision.
632 633
633 634 As a shortcut, you can also use the revision argument to mark a
634 635 revision as good or bad without checking it out first.
635 636
636 637 If you supply a command, it will be used for automatic bisection.
637 638 The environment variable HG_NODE will contain the ID of the
638 639 changeset being tested. The exit status of the command will be
639 640 used to mark revisions as good or bad: status 0 means good, 125
640 641 means to skip the revision, 127 (command not found) will abort the
641 642 bisection, and any other non-zero exit status means the revision
642 643 is bad.
643 644
644 645 .. container:: verbose
645 646
646 647 Some examples:
647 648
648 649 - start a bisection with known bad revision 34, and good revision 12::
649 650
650 651 hg bisect --bad 34
651 652 hg bisect --good 12
652 653
653 654 - advance the current bisection by marking current revision as good or
654 655 bad::
655 656
656 657 hg bisect --good
657 658 hg bisect --bad
658 659
659 660 - mark the current revision, or a known revision, to be skipped (e.g. if
660 661 that revision is not usable because of another issue)::
661 662
662 663 hg bisect --skip
663 664 hg bisect --skip 23
664 665
665 666 - skip all revisions that do not touch directories ``foo`` or ``bar``::
666 667
667 668 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
668 669
669 670 - forget the current bisection::
670 671
671 672 hg bisect --reset
672 673
673 674 - use 'make && make tests' to automatically find the first broken
674 675 revision::
675 676
676 677 hg bisect --reset
677 678 hg bisect --bad 34
678 679 hg bisect --good 12
679 680 hg bisect --command "make && make tests"
680 681
681 682 - see all changesets whose states are already known in the current
682 683 bisection::
683 684
684 685 hg log -r "bisect(pruned)"
685 686
686 687 - see the changeset currently being bisected (especially useful
687 688 if running with -U/--noupdate)::
688 689
689 690 hg log -r "bisect(current)"
690 691
691 692 - see all changesets that took part in the current bisection::
692 693
693 694 hg log -r "bisect(range)"
694 695
695 696 - you can even get a nice graph::
696 697
697 698 hg log --graph -r "bisect(range)"
698 699
699 700 See :hg:`help revsets` for more about the `bisect()` keyword.
700 701
701 702 Returns 0 on success.
702 703 """
703 704 def extendbisectrange(nodes, good):
704 705 # bisect is incomplete when it ends on a merge node and
705 706 # one of the parent was not checked.
706 707 parents = repo[nodes[0]].parents()
707 708 if len(parents) > 1:
708 709 if good:
709 710 side = state['bad']
710 711 else:
711 712 side = state['good']
712 713 num = len(set(i.node() for i in parents) & set(side))
713 714 if num == 1:
714 715 return parents[0].ancestor(parents[1])
715 716 return None
716 717
717 718 def print_result(nodes, good):
718 719 displayer = cmdutil.show_changeset(ui, repo, {})
719 720 if len(nodes) == 1:
720 721 # narrowed it down to a single revision
721 722 if good:
722 723 ui.write(_("The first good revision is:\n"))
723 724 else:
724 725 ui.write(_("The first bad revision is:\n"))
725 726 displayer.show(repo[nodes[0]])
726 727 extendnode = extendbisectrange(nodes, good)
727 728 if extendnode is not None:
728 729 ui.write(_('Not all ancestors of this changeset have been'
729 730 ' checked.\nUse bisect --extend to continue the '
730 731 'bisection from\nthe common ancestor, %s.\n')
731 732 % extendnode)
732 733 else:
733 734 # multiple possible revisions
734 735 if good:
735 736 ui.write(_("Due to skipped revisions, the first "
736 737 "good revision could be any of:\n"))
737 738 else:
738 739 ui.write(_("Due to skipped revisions, the first "
739 740 "bad revision could be any of:\n"))
740 741 for n in nodes:
741 742 displayer.show(repo[n])
742 743 displayer.close()
743 744
744 745 def check_state(state, interactive=True):
745 746 if not state['good'] or not state['bad']:
746 747 if (good or bad or skip or reset) and interactive:
747 748 return
748 749 if not state['good']:
749 750 raise error.Abort(_('cannot bisect (no known good revisions)'))
750 751 else:
751 752 raise error.Abort(_('cannot bisect (no known bad revisions)'))
752 753 return True
753 754
754 755 # backward compatibility
755 756 if rev in "good bad reset init".split():
756 757 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
757 758 cmd, rev, extra = rev, extra, None
758 759 if cmd == "good":
759 760 good = True
760 761 elif cmd == "bad":
761 762 bad = True
762 763 else:
763 764 reset = True
764 765 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
765 766 raise error.Abort(_('incompatible arguments'))
766 767
767 768 cmdutil.checkunfinished(repo)
768 769
769 770 if reset:
770 771 p = repo.join("bisect.state")
771 772 if os.path.exists(p):
772 773 os.unlink(p)
773 774 return
774 775
775 776 state = hbisect.load_state(repo)
776 777
777 778 if command:
778 779 changesets = 1
779 780 if noupdate:
780 781 try:
781 782 node = state['current'][0]
782 783 except LookupError:
783 784 raise error.Abort(_('current bisect revision is unknown - '
784 785 'start a new bisect to fix'))
785 786 else:
786 787 node, p2 = repo.dirstate.parents()
787 788 if p2 != nullid:
788 789 raise error.Abort(_('current bisect revision is a merge'))
789 790 try:
790 791 while changesets:
791 792 # update state
792 793 state['current'] = [node]
793 794 hbisect.save_state(repo, state)
794 795 status = ui.system(command, environ={'HG_NODE': hex(node)})
795 796 if status == 125:
796 797 transition = "skip"
797 798 elif status == 0:
798 799 transition = "good"
799 800 # status < 0 means process was killed
800 801 elif status == 127:
801 802 raise error.Abort(_("failed to execute %s") % command)
802 803 elif status < 0:
803 804 raise error.Abort(_("%s killed") % command)
804 805 else:
805 806 transition = "bad"
806 807 ctx = scmutil.revsingle(repo, rev, node)
807 808 rev = None # clear for future iterations
808 809 state[transition].append(ctx.node())
809 810 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
810 811 check_state(state, interactive=False)
811 812 # bisect
812 813 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
813 814 # update to next check
814 815 node = nodes[0]
815 816 if not noupdate:
816 817 cmdutil.bailifchanged(repo)
817 818 hg.clean(repo, node, show_stats=False)
818 819 finally:
819 820 state['current'] = [node]
820 821 hbisect.save_state(repo, state)
821 822 print_result(nodes, bgood)
822 823 return
823 824
824 825 # update state
825 826
826 827 if rev:
827 828 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
828 829 else:
829 830 nodes = [repo.lookup('.')]
830 831
831 832 if good or bad or skip:
832 833 if good:
833 834 state['good'] += nodes
834 835 elif bad:
835 836 state['bad'] += nodes
836 837 elif skip:
837 838 state['skip'] += nodes
838 839 hbisect.save_state(repo, state)
839 840
840 841 if not check_state(state):
841 842 return
842 843
843 844 # actually bisect
844 845 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
845 846 if extend:
846 847 if not changesets:
847 848 extendnode = extendbisectrange(nodes, good)
848 849 if extendnode is not None:
849 850 ui.write(_("Extending search to changeset %d:%s\n")
850 851 % (extendnode.rev(), extendnode))
851 852 state['current'] = [extendnode.node()]
852 853 hbisect.save_state(repo, state)
853 854 if noupdate:
854 855 return
855 856 cmdutil.bailifchanged(repo)
856 857 return hg.clean(repo, extendnode.node())
857 858 raise error.Abort(_("nothing to extend"))
858 859
859 860 if changesets == 0:
860 861 print_result(nodes, good)
861 862 else:
862 863 assert len(nodes) == 1 # only a single node can be tested next
863 864 node = nodes[0]
864 865 # compute the approximate number of remaining tests
865 866 tests, size = 0, 2
866 867 while size <= changesets:
867 868 tests, size = tests + 1, size * 2
868 869 rev = repo.changelog.rev(node)
869 870 ui.write(_("Testing changeset %d:%s "
870 871 "(%d changesets remaining, ~%d tests)\n")
871 872 % (rev, short(node), changesets, tests))
872 873 state['current'] = [node]
873 874 hbisect.save_state(repo, state)
874 875 if not noupdate:
875 876 cmdutil.bailifchanged(repo)
876 877 return hg.clean(repo, node)
877 878
878 879 @command('bookmarks|bookmark',
879 880 [('f', 'force', False, _('force')),
880 881 ('r', 'rev', '', _('revision'), _('REV')),
881 882 ('d', 'delete', False, _('delete a given bookmark')),
882 883 ('m', 'rename', '', _('rename a given bookmark'), _('OLD')),
883 884 ('i', 'inactive', False, _('mark a bookmark inactive')),
884 885 ] + formatteropts,
885 886 _('hg bookmarks [OPTIONS]... [NAME]...'))
886 887 def bookmark(ui, repo, *names, **opts):
887 888 '''create a new bookmark or list existing bookmarks
888 889
889 890 Bookmarks are labels on changesets to help track lines of development.
890 891 Bookmarks are unversioned and can be moved, renamed and deleted.
891 892 Deleting or moving a bookmark has no effect on the associated changesets.
892 893
893 894 Creating or updating to a bookmark causes it to be marked as 'active'.
894 895 The active bookmark is indicated with a '*'.
895 896 When a commit is made, the active bookmark will advance to the new commit.
896 897 A plain :hg:`update` will also advance an active bookmark, if possible.
897 898 Updating away from a bookmark will cause it to be deactivated.
898 899
899 900 Bookmarks can be pushed and pulled between repositories (see
900 901 :hg:`help push` and :hg:`help pull`). If a shared bookmark has
901 902 diverged, a new 'divergent bookmark' of the form 'name@path' will
902 903 be created. Using :hg:`merge` will resolve the divergence.
903 904
904 905 A bookmark named '@' has the special property that :hg:`clone` will
905 906 check it out by default if it exists.
906 907
907 908 .. container:: verbose
908 909
909 910 Examples:
910 911
911 912 - create an active bookmark for a new line of development::
912 913
913 914 hg book new-feature
914 915
915 916 - create an inactive bookmark as a place marker::
916 917
917 918 hg book -i reviewed
918 919
919 920 - create an inactive bookmark on another changeset::
920 921
921 922 hg book -r .^ tested
922 923
923 924 - rename bookmark turkey to dinner::
924 925
925 926 hg book -m turkey dinner
926 927
927 928 - move the '@' bookmark from another branch::
928 929
929 930 hg book -f @
930 931 '''
931 932 force = opts.get('force')
932 933 rev = opts.get('rev')
933 934 delete = opts.get('delete')
934 935 rename = opts.get('rename')
935 936 inactive = opts.get('inactive')
936 937
937 938 def checkformat(mark):
938 939 mark = mark.strip()
939 940 if not mark:
940 941 raise error.Abort(_("bookmark names cannot consist entirely of "
941 942 "whitespace"))
942 943 scmutil.checknewlabel(repo, mark, 'bookmark')
943 944 return mark
944 945
945 946 def checkconflict(repo, mark, cur, force=False, target=None):
946 947 if mark in marks and not force:
947 948 if target:
948 949 if marks[mark] == target and target == cur:
949 950 # re-activating a bookmark
950 951 return
951 952 anc = repo.changelog.ancestors([repo[target].rev()])
952 953 bmctx = repo[marks[mark]]
953 954 divs = [repo[b].node() for b in marks
954 955 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
955 956
956 957 # allow resolving a single divergent bookmark even if moving
957 958 # the bookmark across branches when a revision is specified
958 959 # that contains a divergent bookmark
959 960 if bmctx.rev() not in anc and target in divs:
960 961 bookmarks.deletedivergent(repo, [target], mark)
961 962 return
962 963
963 964 deletefrom = [b for b in divs
964 965 if repo[b].rev() in anc or b == target]
965 966 bookmarks.deletedivergent(repo, deletefrom, mark)
966 967 if bookmarks.validdest(repo, bmctx, repo[target]):
967 968 ui.status(_("moving bookmark '%s' forward from %s\n") %
968 969 (mark, short(bmctx.node())))
969 970 return
970 971 raise error.Abort(_("bookmark '%s' already exists "
971 972 "(use -f to force)") % mark)
972 973 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
973 974 and not force):
974 975 raise error.Abort(
975 976 _("a bookmark cannot have the name of an existing branch"))
976 977
977 978 if delete and rename:
978 979 raise error.Abort(_("--delete and --rename are incompatible"))
979 980 if delete and rev:
980 981 raise error.Abort(_("--rev is incompatible with --delete"))
981 982 if rename and rev:
982 983 raise error.Abort(_("--rev is incompatible with --rename"))
983 984 if not names and (delete or rev):
984 985 raise error.Abort(_("bookmark name required"))
985 986
986 987 if delete or rename or names or inactive:
987 988 wlock = lock = tr = None
988 989 try:
989 990 wlock = repo.wlock()
990 991 lock = repo.lock()
991 992 cur = repo.changectx('.').node()
992 993 marks = repo._bookmarks
993 994 if delete:
994 995 tr = repo.transaction('bookmark')
995 996 for mark in names:
996 997 if mark not in marks:
997 998 raise error.Abort(_("bookmark '%s' does not exist") %
998 999 mark)
999 1000 if mark == repo._activebookmark:
1000 1001 bookmarks.deactivate(repo)
1001 1002 del marks[mark]
1002 1003
1003 1004 elif rename:
1004 1005 tr = repo.transaction('bookmark')
1005 1006 if not names:
1006 1007 raise error.Abort(_("new bookmark name required"))
1007 1008 elif len(names) > 1:
1008 1009 raise error.Abort(_("only one new bookmark name allowed"))
1009 1010 mark = checkformat(names[0])
1010 1011 if rename not in marks:
1011 1012 raise error.Abort(_("bookmark '%s' does not exist")
1012 1013 % rename)
1013 1014 checkconflict(repo, mark, cur, force)
1014 1015 marks[mark] = marks[rename]
1015 1016 if repo._activebookmark == rename and not inactive:
1016 1017 bookmarks.activate(repo, mark)
1017 1018 del marks[rename]
1018 1019 elif names:
1019 1020 tr = repo.transaction('bookmark')
1020 1021 newact = None
1021 1022 for mark in names:
1022 1023 mark = checkformat(mark)
1023 1024 if newact is None:
1024 1025 newact = mark
1025 1026 if inactive and mark == repo._activebookmark:
1026 1027 bookmarks.deactivate(repo)
1027 1028 return
1028 1029 tgt = cur
1029 1030 if rev:
1030 1031 tgt = scmutil.revsingle(repo, rev).node()
1031 1032 checkconflict(repo, mark, cur, force, tgt)
1032 1033 marks[mark] = tgt
1033 1034 if not inactive and cur == marks[newact] and not rev:
1034 1035 bookmarks.activate(repo, newact)
1035 1036 elif cur != tgt and newact == repo._activebookmark:
1036 1037 bookmarks.deactivate(repo)
1037 1038 elif inactive:
1038 1039 if len(marks) == 0:
1039 1040 ui.status(_("no bookmarks set\n"))
1040 1041 elif not repo._activebookmark:
1041 1042 ui.status(_("no active bookmark\n"))
1042 1043 else:
1043 1044 bookmarks.deactivate(repo)
1044 1045 if tr is not None:
1045 1046 marks.recordchange(tr)
1046 1047 tr.close()
1047 1048 finally:
1048 1049 lockmod.release(tr, lock, wlock)
1049 1050 else: # show bookmarks
1050 1051 fm = ui.formatter('bookmarks', opts)
1051 1052 hexfn = fm.hexfunc
1052 1053 marks = repo._bookmarks
1053 1054 if len(marks) == 0 and not fm:
1054 1055 ui.status(_("no bookmarks set\n"))
1055 1056 for bmark, n in sorted(marks.iteritems()):
1056 1057 active = repo._activebookmark
1057 1058 if bmark == active:
1058 1059 prefix, label = '*', activebookmarklabel
1059 1060 else:
1060 1061 prefix, label = ' ', ''
1061 1062
1062 1063 fm.startitem()
1063 1064 if not ui.quiet:
1064 1065 fm.plain(' %s ' % prefix, label=label)
1065 1066 fm.write('bookmark', '%s', bmark, label=label)
1066 1067 pad = " " * (25 - encoding.colwidth(bmark))
1067 1068 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
1068 1069 repo.changelog.rev(n), hexfn(n), label=label)
1069 1070 fm.data(active=(bmark == active))
1070 1071 fm.plain('\n')
1071 1072 fm.end()
1072 1073
1073 1074 @command('branch',
1074 1075 [('f', 'force', None,
1075 1076 _('set branch name even if it shadows an existing branch')),
1076 1077 ('C', 'clean', None, _('reset branch name to parent branch name'))],
1077 1078 _('[-fC] [NAME]'))
1078 1079 def branch(ui, repo, label=None, **opts):
1079 1080 """set or show the current branch name
1080 1081
1081 1082 .. note::
1082 1083
1083 1084 Branch names are permanent and global. Use :hg:`bookmark` to create a
1084 1085 light-weight bookmark instead. See :hg:`help glossary` for more
1085 1086 information about named branches and bookmarks.
1086 1087
1087 1088 With no argument, show the current branch name. With one argument,
1088 1089 set the working directory branch name (the branch will not exist
1089 1090 in the repository until the next commit). Standard practice
1090 1091 recommends that primary development take place on the 'default'
1091 1092 branch.
1092 1093
1093 1094 Unless -f/--force is specified, branch will not let you set a
1094 1095 branch name that already exists.
1095 1096
1096 1097 Use -C/--clean to reset the working directory branch to that of
1097 1098 the parent of the working directory, negating a previous branch
1098 1099 change.
1099 1100
1100 1101 Use the command :hg:`update` to switch to an existing branch. Use
1101 1102 :hg:`commit --close-branch` to mark this branch head as closed.
1102 1103 When all heads of the branch are closed, the branch will be
1103 1104 considered closed.
1104 1105
1105 1106 Returns 0 on success.
1106 1107 """
1107 1108 if label:
1108 1109 label = label.strip()
1109 1110
1110 1111 if not opts.get('clean') and not label:
1111 1112 ui.write("%s\n" % repo.dirstate.branch())
1112 1113 return
1113 1114
1114 1115 wlock = repo.wlock()
1115 1116 try:
1116 1117 if opts.get('clean'):
1117 1118 label = repo[None].p1().branch()
1118 1119 repo.dirstate.setbranch(label)
1119 1120 ui.status(_('reset working directory to branch %s\n') % label)
1120 1121 elif label:
1121 1122 if not opts.get('force') and label in repo.branchmap():
1122 1123 if label not in [p.branch() for p in repo.parents()]:
1123 1124 raise error.Abort(_('a branch of the same name already'
1124 1125 ' exists'),
1125 1126 # i18n: "it" refers to an existing branch
1126 1127 hint=_("use 'hg update' to switch to it"))
1127 1128 scmutil.checknewlabel(repo, label, 'branch')
1128 1129 repo.dirstate.setbranch(label)
1129 1130 ui.status(_('marked working directory as branch %s\n') % label)
1130 1131
1131 1132 # find any open named branches aside from default
1132 1133 others = [n for n, h, t, c in repo.branchmap().iterbranches()
1133 1134 if n != "default" and not c]
1134 1135 if not others:
1135 1136 ui.status(_('(branches are permanent and global, '
1136 1137 'did you want a bookmark?)\n'))
1137 1138 finally:
1138 1139 wlock.release()
1139 1140
1140 1141 @command('branches',
1141 1142 [('a', 'active', False,
1142 1143 _('show only branches that have unmerged heads (DEPRECATED)')),
1143 1144 ('c', 'closed', False, _('show normal and closed branches')),
1144 1145 ] + formatteropts,
1145 1146 _('[-ac]'))
1146 1147 def branches(ui, repo, active=False, closed=False, **opts):
1147 1148 """list repository named branches
1148 1149
1149 1150 List the repository's named branches, indicating which ones are
1150 1151 inactive. If -c/--closed is specified, also list branches which have
1151 1152 been marked closed (see :hg:`commit --close-branch`).
1152 1153
1153 1154 Use the command :hg:`update` to switch to an existing branch.
1154 1155
1155 1156 Returns 0.
1156 1157 """
1157 1158
1158 1159 fm = ui.formatter('branches', opts)
1159 1160 hexfunc = fm.hexfunc
1160 1161
1161 1162 allheads = set(repo.heads())
1162 1163 branches = []
1163 1164 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1164 1165 isactive = not isclosed and bool(set(heads) & allheads)
1165 1166 branches.append((tag, repo[tip], isactive, not isclosed))
1166 1167 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1167 1168 reverse=True)
1168 1169
1169 1170 for tag, ctx, isactive, isopen in branches:
1170 1171 if active and not isactive:
1171 1172 continue
1172 1173 if isactive:
1173 1174 label = 'branches.active'
1174 1175 notice = ''
1175 1176 elif not isopen:
1176 1177 if not closed:
1177 1178 continue
1178 1179 label = 'branches.closed'
1179 1180 notice = _(' (closed)')
1180 1181 else:
1181 1182 label = 'branches.inactive'
1182 1183 notice = _(' (inactive)')
1183 1184 current = (tag == repo.dirstate.branch())
1184 1185 if current:
1185 1186 label = 'branches.current'
1186 1187
1187 1188 fm.startitem()
1188 1189 fm.write('branch', '%s', tag, label=label)
1189 1190 rev = ctx.rev()
1190 1191 padsize = max(31 - len(str(rev)) - encoding.colwidth(tag), 0)
1191 1192 fmt = ' ' * padsize + ' %d:%s'
1192 1193 fm.condwrite(not ui.quiet, 'rev node', fmt, rev, hexfunc(ctx.node()),
1193 1194 label='log.changeset changeset.%s' % ctx.phasestr())
1194 1195 fm.data(active=isactive, closed=not isopen, current=current)
1195 1196 if not ui.quiet:
1196 1197 fm.plain(notice)
1197 1198 fm.plain('\n')
1198 1199 fm.end()
1199 1200
1200 1201 @command('bundle',
1201 1202 [('f', 'force', None, _('run even when the destination is unrelated')),
1202 1203 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1203 1204 _('REV')),
1204 1205 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1205 1206 _('BRANCH')),
1206 1207 ('', 'base', [],
1207 1208 _('a base changeset assumed to be available at the destination'),
1208 1209 _('REV')),
1209 1210 ('a', 'all', None, _('bundle all changesets in the repository')),
1210 1211 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1211 1212 ] + remoteopts,
1212 1213 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1213 1214 def bundle(ui, repo, fname, dest=None, **opts):
1214 1215 """create a changegroup file
1215 1216
1216 1217 Generate a compressed changegroup file collecting changesets not
1217 1218 known to be in another repository.
1218 1219
1219 1220 If you omit the destination repository, then hg assumes the
1220 1221 destination will have all the nodes you specify with --base
1221 1222 parameters. To create a bundle containing all changesets, use
1222 1223 -a/--all (or --base null).
1223 1224
1224 1225 You can change bundle format with the -t/--type option. You can
1225 1226 specify a compression, a bundle version or both using a dash
1226 1227 (comp-version). The available compression methods are: none, bzip2,
1227 1228 and gzip (by default, bundles are compressed using bzip2). The
1228 1229 available format are: v1, v2 (default to most suitable).
1229 1230
1230 1231 The bundle file can then be transferred using conventional means
1231 1232 and applied to another repository with the unbundle or pull
1232 1233 command. This is useful when direct push and pull are not
1233 1234 available or when exporting an entire repository is undesirable.
1234 1235
1235 1236 Applying bundles preserves all changeset contents including
1236 1237 permissions, copy/rename information, and revision history.
1237 1238
1238 1239 Returns 0 on success, 1 if no changes found.
1239 1240 """
1240 1241 revs = None
1241 1242 if 'rev' in opts:
1242 1243 revs = scmutil.revrange(repo, opts['rev'])
1243 1244
1244 1245 bundletype = opts.get('type', 'bzip2').lower()
1245 1246 try:
1246 1247 bcompression, cgversion = exchange.parsebundlespec(
1247 1248 repo, bundletype, strict=False)
1248 1249 except error.UnsupportedBundleSpecification as e:
1249 1250 raise error.Abort(str(e),
1250 1251 hint=_('see "hg help bundle" for supported '
1251 1252 'values for --type'))
1252 1253
1254 # Packed bundles are a pseudo bundle format for now.
1255 if cgversion == 's1':
1256 raise error.Abort(_('packed bundles cannot be produced by "hg bundle"'),
1257 hint=_('use "hg debugcreatestreamclonebundle"'))
1258
1253 1259 if opts.get('all'):
1254 1260 base = ['null']
1255 1261 else:
1256 1262 base = scmutil.revrange(repo, opts.get('base'))
1257 1263 # TODO: get desired bundlecaps from command line.
1258 1264 bundlecaps = None
1259 1265 if base:
1260 1266 if dest:
1261 1267 raise error.Abort(_("--base is incompatible with specifying "
1262 1268 "a destination"))
1263 1269 common = [repo.lookup(rev) for rev in base]
1264 1270 heads = revs and map(repo.lookup, revs) or revs
1265 1271 cg = changegroup.getchangegroup(repo, 'bundle', heads=heads,
1266 1272 common=common, bundlecaps=bundlecaps,
1267 1273 version=cgversion)
1268 1274 outgoing = None
1269 1275 else:
1270 1276 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1271 1277 dest, branches = hg.parseurl(dest, opts.get('branch'))
1272 1278 other = hg.peer(repo, opts, dest)
1273 1279 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1274 1280 heads = revs and map(repo.lookup, revs) or revs
1275 1281 outgoing = discovery.findcommonoutgoing(repo, other,
1276 1282 onlyheads=heads,
1277 1283 force=opts.get('force'),
1278 1284 portable=True)
1279 1285 cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing,
1280 1286 bundlecaps, version=cgversion)
1281 1287 if not cg:
1282 1288 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1283 1289 return 1
1284 1290
1285 1291 if cgversion == '01': #bundle1
1286 1292 if bcompression is None:
1287 1293 bcompression = 'UN'
1288 1294 bversion = 'HG10' + bcompression
1289 1295 bcompression = None
1290 1296 else:
1291 1297 assert cgversion == '02'
1292 1298 bversion = 'HG20'
1293 1299
1294 1300
1295 1301 changegroup.writebundle(ui, cg, fname, bversion, compression=bcompression)
1296 1302
1297 1303 @command('cat',
1298 1304 [('o', 'output', '',
1299 1305 _('print output to file with formatted name'), _('FORMAT')),
1300 1306 ('r', 'rev', '', _('print the given revision'), _('REV')),
1301 1307 ('', 'decode', None, _('apply any matching decode filter')),
1302 1308 ] + walkopts,
1303 1309 _('[OPTION]... FILE...'),
1304 1310 inferrepo=True)
1305 1311 def cat(ui, repo, file1, *pats, **opts):
1306 1312 """output the current or given revision of files
1307 1313
1308 1314 Print the specified files as they were at the given revision. If
1309 1315 no revision is given, the parent of the working directory is used.
1310 1316
1311 1317 Output may be to a file, in which case the name of the file is
1312 1318 given using a format string. The formatting rules as follows:
1313 1319
1314 1320 :``%%``: literal "%" character
1315 1321 :``%s``: basename of file being printed
1316 1322 :``%d``: dirname of file being printed, or '.' if in repository root
1317 1323 :``%p``: root-relative path name of file being printed
1318 1324 :``%H``: changeset hash (40 hexadecimal digits)
1319 1325 :``%R``: changeset revision number
1320 1326 :``%h``: short-form changeset hash (12 hexadecimal digits)
1321 1327 :``%r``: zero-padded changeset revision number
1322 1328 :``%b``: basename of the exporting repository
1323 1329
1324 1330 Returns 0 on success.
1325 1331 """
1326 1332 ctx = scmutil.revsingle(repo, opts.get('rev'))
1327 1333 m = scmutil.match(ctx, (file1,) + pats, opts)
1328 1334
1329 1335 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1330 1336
1331 1337 @command('^clone',
1332 1338 [('U', 'noupdate', None, _('the clone will include an empty working '
1333 1339 'directory (only a repository)')),
1334 1340 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1335 1341 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1336 1342 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1337 1343 ('', 'pull', None, _('use pull protocol to copy metadata')),
1338 1344 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1339 1345 ] + remoteopts,
1340 1346 _('[OPTION]... SOURCE [DEST]'),
1341 1347 norepo=True)
1342 1348 def clone(ui, source, dest=None, **opts):
1343 1349 """make a copy of an existing repository
1344 1350
1345 1351 Create a copy of an existing repository in a new directory.
1346 1352
1347 1353 If no destination directory name is specified, it defaults to the
1348 1354 basename of the source.
1349 1355
1350 1356 The location of the source is added to the new repository's
1351 1357 ``.hg/hgrc`` file, as the default to be used for future pulls.
1352 1358
1353 1359 Only local paths and ``ssh://`` URLs are supported as
1354 1360 destinations. For ``ssh://`` destinations, no working directory or
1355 1361 ``.hg/hgrc`` will be created on the remote side.
1356 1362
1357 1363 To pull only a subset of changesets, specify one or more revisions
1358 1364 identifiers with -r/--rev or branches with -b/--branch. The
1359 1365 resulting clone will contain only the specified changesets and
1360 1366 their ancestors. These options (or 'clone src#rev dest') imply
1361 1367 --pull, even for local source repositories. Note that specifying a
1362 1368 tag will include the tagged changeset but not the changeset
1363 1369 containing the tag.
1364 1370
1365 1371 If the source repository has a bookmark called '@' set, that
1366 1372 revision will be checked out in the new repository by default.
1367 1373
1368 1374 To check out a particular version, use -u/--update, or
1369 1375 -U/--noupdate to create a clone with no working directory.
1370 1376
1371 1377 .. container:: verbose
1372 1378
1373 1379 For efficiency, hardlinks are used for cloning whenever the
1374 1380 source and destination are on the same filesystem (note this
1375 1381 applies only to the repository data, not to the working
1376 1382 directory). Some filesystems, such as AFS, implement hardlinking
1377 1383 incorrectly, but do not report errors. In these cases, use the
1378 1384 --pull option to avoid hardlinking.
1379 1385
1380 1386 In some cases, you can clone repositories and the working
1381 1387 directory using full hardlinks with ::
1382 1388
1383 1389 $ cp -al REPO REPOCLONE
1384 1390
1385 1391 This is the fastest way to clone, but it is not always safe. The
1386 1392 operation is not atomic (making sure REPO is not modified during
1387 1393 the operation is up to you) and you have to make sure your
1388 1394 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1389 1395 so). Also, this is not compatible with certain extensions that
1390 1396 place their metadata under the .hg directory, such as mq.
1391 1397
1392 1398 Mercurial will update the working directory to the first applicable
1393 1399 revision from this list:
1394 1400
1395 1401 a) null if -U or the source repository has no changesets
1396 1402 b) if -u . and the source repository is local, the first parent of
1397 1403 the source repository's working directory
1398 1404 c) the changeset specified with -u (if a branch name, this means the
1399 1405 latest head of that branch)
1400 1406 d) the changeset specified with -r
1401 1407 e) the tipmost head specified with -b
1402 1408 f) the tipmost head specified with the url#branch source syntax
1403 1409 g) the revision marked with the '@' bookmark, if present
1404 1410 h) the tipmost head of the default branch
1405 1411 i) tip
1406 1412
1407 1413 Examples:
1408 1414
1409 1415 - clone a remote repository to a new directory named hg/::
1410 1416
1411 1417 hg clone http://selenic.com/hg
1412 1418
1413 1419 - create a lightweight local clone::
1414 1420
1415 1421 hg clone project/ project-feature/
1416 1422
1417 1423 - clone from an absolute path on an ssh server (note double-slash)::
1418 1424
1419 1425 hg clone ssh://user@server//home/projects/alpha/
1420 1426
1421 1427 - do a high-speed clone over a LAN while checking out a
1422 1428 specified version::
1423 1429
1424 1430 hg clone --uncompressed http://server/repo -u 1.5
1425 1431
1426 1432 - create a repository without changesets after a particular revision::
1427 1433
1428 1434 hg clone -r 04e544 experimental/ good/
1429 1435
1430 1436 - clone (and track) a particular named branch::
1431 1437
1432 1438 hg clone http://selenic.com/hg#stable
1433 1439
1434 1440 See :hg:`help urls` for details on specifying URLs.
1435 1441
1436 1442 Returns 0 on success.
1437 1443 """
1438 1444 if opts.get('noupdate') and opts.get('updaterev'):
1439 1445 raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
1440 1446
1441 1447 r = hg.clone(ui, opts, source, dest,
1442 1448 pull=opts.get('pull'),
1443 1449 stream=opts.get('uncompressed'),
1444 1450 rev=opts.get('rev'),
1445 1451 update=opts.get('updaterev') or not opts.get('noupdate'),
1446 1452 branch=opts.get('branch'),
1447 1453 shareopts=opts.get('shareopts'))
1448 1454
1449 1455 return r is None
1450 1456
1451 1457 @command('^commit|ci',
1452 1458 [('A', 'addremove', None,
1453 1459 _('mark new/missing files as added/removed before committing')),
1454 1460 ('', 'close-branch', None,
1455 1461 _('mark a branch head as closed')),
1456 1462 ('', 'amend', None, _('amend the parent of the working directory')),
1457 1463 ('s', 'secret', None, _('use the secret phase for committing')),
1458 1464 ('e', 'edit', None, _('invoke editor on commit messages')),
1459 1465 ('i', 'interactive', None, _('use interactive mode')),
1460 1466 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1461 1467 _('[OPTION]... [FILE]...'),
1462 1468 inferrepo=True)
1463 1469 def commit(ui, repo, *pats, **opts):
1464 1470 """commit the specified files or all outstanding changes
1465 1471
1466 1472 Commit changes to the given files into the repository. Unlike a
1467 1473 centralized SCM, this operation is a local operation. See
1468 1474 :hg:`push` for a way to actively distribute your changes.
1469 1475
1470 1476 If a list of files is omitted, all changes reported by :hg:`status`
1471 1477 will be committed.
1472 1478
1473 1479 If you are committing the result of a merge, do not provide any
1474 1480 filenames or -I/-X filters.
1475 1481
1476 1482 If no commit message is specified, Mercurial starts your
1477 1483 configured editor where you can enter a message. In case your
1478 1484 commit fails, you will find a backup of your message in
1479 1485 ``.hg/last-message.txt``.
1480 1486
1481 1487 The --close-branch flag can be used to mark the current branch
1482 1488 head closed. When all heads of a branch are closed, the branch
1483 1489 will be considered closed and no longer listed.
1484 1490
1485 1491 The --amend flag can be used to amend the parent of the
1486 1492 working directory with a new commit that contains the changes
1487 1493 in the parent in addition to those currently reported by :hg:`status`,
1488 1494 if there are any. The old commit is stored in a backup bundle in
1489 1495 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1490 1496 on how to restore it).
1491 1497
1492 1498 Message, user and date are taken from the amended commit unless
1493 1499 specified. When a message isn't specified on the command line,
1494 1500 the editor will open with the message of the amended commit.
1495 1501
1496 1502 It is not possible to amend public changesets (see :hg:`help phases`)
1497 1503 or changesets that have children.
1498 1504
1499 1505 See :hg:`help dates` for a list of formats valid for -d/--date.
1500 1506
1501 1507 Returns 0 on success, 1 if nothing changed.
1502 1508 """
1503 1509 if opts.get('interactive'):
1504 1510 opts.pop('interactive')
1505 1511 cmdutil.dorecord(ui, repo, commit, None, False,
1506 1512 cmdutil.recordfilter, *pats, **opts)
1507 1513 return
1508 1514
1509 1515 if opts.get('subrepos'):
1510 1516 if opts.get('amend'):
1511 1517 raise error.Abort(_('cannot amend with --subrepos'))
1512 1518 # Let --subrepos on the command line override config setting.
1513 1519 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1514 1520
1515 1521 cmdutil.checkunfinished(repo, commit=True)
1516 1522
1517 1523 branch = repo[None].branch()
1518 1524 bheads = repo.branchheads(branch)
1519 1525
1520 1526 extra = {}
1521 1527 if opts.get('close_branch'):
1522 1528 extra['close'] = 1
1523 1529
1524 1530 if not bheads:
1525 1531 raise error.Abort(_('can only close branch heads'))
1526 1532 elif opts.get('amend'):
1527 1533 if repo.parents()[0].p1().branch() != branch and \
1528 1534 repo.parents()[0].p2().branch() != branch:
1529 1535 raise error.Abort(_('can only close branch heads'))
1530 1536
1531 1537 if opts.get('amend'):
1532 1538 if ui.configbool('ui', 'commitsubrepos'):
1533 1539 raise error.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1534 1540
1535 1541 old = repo['.']
1536 1542 if not old.mutable():
1537 1543 raise error.Abort(_('cannot amend public changesets'))
1538 1544 if len(repo[None].parents()) > 1:
1539 1545 raise error.Abort(_('cannot amend while merging'))
1540 1546 allowunstable = obsolete.isenabled(repo, obsolete.allowunstableopt)
1541 1547 if not allowunstable and old.children():
1542 1548 raise error.Abort(_('cannot amend changeset with children'))
1543 1549
1544 1550 # commitfunc is used only for temporary amend commit by cmdutil.amend
1545 1551 def commitfunc(ui, repo, message, match, opts):
1546 1552 return repo.commit(message,
1547 1553 opts.get('user') or old.user(),
1548 1554 opts.get('date') or old.date(),
1549 1555 match,
1550 1556 extra=extra)
1551 1557
1552 1558 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1553 1559 if node == old.node():
1554 1560 ui.status(_("nothing changed\n"))
1555 1561 return 1
1556 1562 else:
1557 1563 def commitfunc(ui, repo, message, match, opts):
1558 1564 backup = ui.backupconfig('phases', 'new-commit')
1559 1565 baseui = repo.baseui
1560 1566 basebackup = baseui.backupconfig('phases', 'new-commit')
1561 1567 try:
1562 1568 if opts.get('secret'):
1563 1569 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1564 1570 # Propagate to subrepos
1565 1571 baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
1566 1572
1567 1573 editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
1568 1574 editor = cmdutil.getcommiteditor(editform=editform, **opts)
1569 1575 return repo.commit(message, opts.get('user'), opts.get('date'),
1570 1576 match,
1571 1577 editor=editor,
1572 1578 extra=extra)
1573 1579 finally:
1574 1580 ui.restoreconfig(backup)
1575 1581 repo.baseui.restoreconfig(basebackup)
1576 1582
1577 1583
1578 1584 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1579 1585
1580 1586 if not node:
1581 1587 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1582 1588 if stat[3]:
1583 1589 ui.status(_("nothing changed (%d missing files, see "
1584 1590 "'hg status')\n") % len(stat[3]))
1585 1591 else:
1586 1592 ui.status(_("nothing changed\n"))
1587 1593 return 1
1588 1594
1589 1595 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1590 1596
1591 1597 @command('config|showconfig|debugconfig',
1592 1598 [('u', 'untrusted', None, _('show untrusted configuration options')),
1593 1599 ('e', 'edit', None, _('edit user config')),
1594 1600 ('l', 'local', None, _('edit repository config')),
1595 1601 ('g', 'global', None, _('edit global config'))],
1596 1602 _('[-u] [NAME]...'),
1597 1603 optionalrepo=True)
1598 1604 def config(ui, repo, *values, **opts):
1599 1605 """show combined config settings from all hgrc files
1600 1606
1601 1607 With no arguments, print names and values of all config items.
1602 1608
1603 1609 With one argument of the form section.name, print just the value
1604 1610 of that config item.
1605 1611
1606 1612 With multiple arguments, print names and values of all config
1607 1613 items with matching section names.
1608 1614
1609 1615 With --edit, start an editor on the user-level config file. With
1610 1616 --global, edit the system-wide config file. With --local, edit the
1611 1617 repository-level config file.
1612 1618
1613 1619 With --debug, the source (filename and line number) is printed
1614 1620 for each config item.
1615 1621
1616 1622 See :hg:`help config` for more information about config files.
1617 1623
1618 1624 Returns 0 on success, 1 if NAME does not exist.
1619 1625
1620 1626 """
1621 1627
1622 1628 if opts.get('edit') or opts.get('local') or opts.get('global'):
1623 1629 if opts.get('local') and opts.get('global'):
1624 1630 raise error.Abort(_("can't use --local and --global together"))
1625 1631
1626 1632 if opts.get('local'):
1627 1633 if not repo:
1628 1634 raise error.Abort(_("can't use --local outside a repository"))
1629 1635 paths = [repo.join('hgrc')]
1630 1636 elif opts.get('global'):
1631 1637 paths = scmutil.systemrcpath()
1632 1638 else:
1633 1639 paths = scmutil.userrcpath()
1634 1640
1635 1641 for f in paths:
1636 1642 if os.path.exists(f):
1637 1643 break
1638 1644 else:
1639 1645 if opts.get('global'):
1640 1646 samplehgrc = uimod.samplehgrcs['global']
1641 1647 elif opts.get('local'):
1642 1648 samplehgrc = uimod.samplehgrcs['local']
1643 1649 else:
1644 1650 samplehgrc = uimod.samplehgrcs['user']
1645 1651
1646 1652 f = paths[0]
1647 1653 fp = open(f, "w")
1648 1654 fp.write(samplehgrc)
1649 1655 fp.close()
1650 1656
1651 1657 editor = ui.geteditor()
1652 1658 ui.system("%s \"%s\"" % (editor, f),
1653 1659 onerr=error.Abort, errprefix=_("edit failed"))
1654 1660 return
1655 1661
1656 1662 for f in scmutil.rcpath():
1657 1663 ui.debug('read config from: %s\n' % f)
1658 1664 untrusted = bool(opts.get('untrusted'))
1659 1665 if values:
1660 1666 sections = [v for v in values if '.' not in v]
1661 1667 items = [v for v in values if '.' in v]
1662 1668 if len(items) > 1 or items and sections:
1663 1669 raise error.Abort(_('only one config item permitted'))
1664 1670 matched = False
1665 1671 for section, name, value in ui.walkconfig(untrusted=untrusted):
1666 1672 value = str(value).replace('\n', '\\n')
1667 1673 sectname = section + '.' + name
1668 1674 if values:
1669 1675 for v in values:
1670 1676 if v == section:
1671 1677 ui.debug('%s: ' %
1672 1678 ui.configsource(section, name, untrusted))
1673 1679 ui.write('%s=%s\n' % (sectname, value))
1674 1680 matched = True
1675 1681 elif v == sectname:
1676 1682 ui.debug('%s: ' %
1677 1683 ui.configsource(section, name, untrusted))
1678 1684 ui.write(value, '\n')
1679 1685 matched = True
1680 1686 else:
1681 1687 ui.debug('%s: ' %
1682 1688 ui.configsource(section, name, untrusted))
1683 1689 ui.write('%s=%s\n' % (sectname, value))
1684 1690 matched = True
1685 1691 if matched:
1686 1692 return 0
1687 1693 return 1
1688 1694
1689 1695 @command('copy|cp',
1690 1696 [('A', 'after', None, _('record a copy that has already occurred')),
1691 1697 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1692 1698 ] + walkopts + dryrunopts,
1693 1699 _('[OPTION]... [SOURCE]... DEST'))
1694 1700 def copy(ui, repo, *pats, **opts):
1695 1701 """mark files as copied for the next commit
1696 1702
1697 1703 Mark dest as having copies of source files. If dest is a
1698 1704 directory, copies are put in that directory. If dest is a file,
1699 1705 the source must be a single file.
1700 1706
1701 1707 By default, this command copies the contents of files as they
1702 1708 exist in the working directory. If invoked with -A/--after, the
1703 1709 operation is recorded, but no copying is performed.
1704 1710
1705 1711 This command takes effect with the next commit. To undo a copy
1706 1712 before that, see :hg:`revert`.
1707 1713
1708 1714 Returns 0 on success, 1 if errors are encountered.
1709 1715 """
1710 1716 wlock = repo.wlock(False)
1711 1717 try:
1712 1718 return cmdutil.copy(ui, repo, pats, opts)
1713 1719 finally:
1714 1720 wlock.release()
1715 1721
1716 1722 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
1717 1723 def debugancestor(ui, repo, *args):
1718 1724 """find the ancestor revision of two revisions in a given index"""
1719 1725 if len(args) == 3:
1720 1726 index, rev1, rev2 = args
1721 1727 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1722 1728 lookup = r.lookup
1723 1729 elif len(args) == 2:
1724 1730 if not repo:
1725 1731 raise error.Abort(_("there is no Mercurial repository here "
1726 1732 "(.hg not found)"))
1727 1733 rev1, rev2 = args
1728 1734 r = repo.changelog
1729 1735 lookup = repo.lookup
1730 1736 else:
1731 1737 raise error.Abort(_('either two or three arguments required'))
1732 1738 a = r.ancestor(lookup(rev1), lookup(rev2))
1733 1739 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1734 1740
1735 1741 @command('debugbuilddag',
1736 1742 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1737 1743 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1738 1744 ('n', 'new-file', None, _('add new file at each rev'))],
1739 1745 _('[OPTION]... [TEXT]'))
1740 1746 def debugbuilddag(ui, repo, text=None,
1741 1747 mergeable_file=False,
1742 1748 overwritten_file=False,
1743 1749 new_file=False):
1744 1750 """builds a repo with a given DAG from scratch in the current empty repo
1745 1751
1746 1752 The description of the DAG is read from stdin if not given on the
1747 1753 command line.
1748 1754
1749 1755 Elements:
1750 1756
1751 1757 - "+n" is a linear run of n nodes based on the current default parent
1752 1758 - "." is a single node based on the current default parent
1753 1759 - "$" resets the default parent to null (implied at the start);
1754 1760 otherwise the default parent is always the last node created
1755 1761 - "<p" sets the default parent to the backref p
1756 1762 - "*p" is a fork at parent p, which is a backref
1757 1763 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1758 1764 - "/p2" is a merge of the preceding node and p2
1759 1765 - ":tag" defines a local tag for the preceding node
1760 1766 - "@branch" sets the named branch for subsequent nodes
1761 1767 - "#...\\n" is a comment up to the end of the line
1762 1768
1763 1769 Whitespace between the above elements is ignored.
1764 1770
1765 1771 A backref is either
1766 1772
1767 1773 - a number n, which references the node curr-n, where curr is the current
1768 1774 node, or
1769 1775 - the name of a local tag you placed earlier using ":tag", or
1770 1776 - empty to denote the default parent.
1771 1777
1772 1778 All string valued-elements are either strictly alphanumeric, or must
1773 1779 be enclosed in double quotes ("..."), with "\\" as escape character.
1774 1780 """
1775 1781
1776 1782 if text is None:
1777 1783 ui.status(_("reading DAG from stdin\n"))
1778 1784 text = ui.fin.read()
1779 1785
1780 1786 cl = repo.changelog
1781 1787 if len(cl) > 0:
1782 1788 raise error.Abort(_('repository is not empty'))
1783 1789
1784 1790 # determine number of revs in DAG
1785 1791 total = 0
1786 1792 for type, data in dagparser.parsedag(text):
1787 1793 if type == 'n':
1788 1794 total += 1
1789 1795
1790 1796 if mergeable_file:
1791 1797 linesperrev = 2
1792 1798 # make a file with k lines per rev
1793 1799 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1794 1800 initialmergedlines.append("")
1795 1801
1796 1802 tags = []
1797 1803
1798 1804 lock = tr = None
1799 1805 try:
1800 1806 lock = repo.lock()
1801 1807 tr = repo.transaction("builddag")
1802 1808
1803 1809 at = -1
1804 1810 atbranch = 'default'
1805 1811 nodeids = []
1806 1812 id = 0
1807 1813 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1808 1814 for type, data in dagparser.parsedag(text):
1809 1815 if type == 'n':
1810 1816 ui.note(('node %s\n' % str(data)))
1811 1817 id, ps = data
1812 1818
1813 1819 files = []
1814 1820 fctxs = {}
1815 1821
1816 1822 p2 = None
1817 1823 if mergeable_file:
1818 1824 fn = "mf"
1819 1825 p1 = repo[ps[0]]
1820 1826 if len(ps) > 1:
1821 1827 p2 = repo[ps[1]]
1822 1828 pa = p1.ancestor(p2)
1823 1829 base, local, other = [x[fn].data() for x in (pa, p1,
1824 1830 p2)]
1825 1831 m3 = simplemerge.Merge3Text(base, local, other)
1826 1832 ml = [l.strip() for l in m3.merge_lines()]
1827 1833 ml.append("")
1828 1834 elif at > 0:
1829 1835 ml = p1[fn].data().split("\n")
1830 1836 else:
1831 1837 ml = initialmergedlines
1832 1838 ml[id * linesperrev] += " r%i" % id
1833 1839 mergedtext = "\n".join(ml)
1834 1840 files.append(fn)
1835 1841 fctxs[fn] = context.memfilectx(repo, fn, mergedtext)
1836 1842
1837 1843 if overwritten_file:
1838 1844 fn = "of"
1839 1845 files.append(fn)
1840 1846 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1841 1847
1842 1848 if new_file:
1843 1849 fn = "nf%i" % id
1844 1850 files.append(fn)
1845 1851 fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id)
1846 1852 if len(ps) > 1:
1847 1853 if not p2:
1848 1854 p2 = repo[ps[1]]
1849 1855 for fn in p2:
1850 1856 if fn.startswith("nf"):
1851 1857 files.append(fn)
1852 1858 fctxs[fn] = p2[fn]
1853 1859
1854 1860 def fctxfn(repo, cx, path):
1855 1861 return fctxs.get(path)
1856 1862
1857 1863 if len(ps) == 0 or ps[0] < 0:
1858 1864 pars = [None, None]
1859 1865 elif len(ps) == 1:
1860 1866 pars = [nodeids[ps[0]], None]
1861 1867 else:
1862 1868 pars = [nodeids[p] for p in ps]
1863 1869 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1864 1870 date=(id, 0),
1865 1871 user="debugbuilddag",
1866 1872 extra={'branch': atbranch})
1867 1873 nodeid = repo.commitctx(cx)
1868 1874 nodeids.append(nodeid)
1869 1875 at = id
1870 1876 elif type == 'l':
1871 1877 id, name = data
1872 1878 ui.note(('tag %s\n' % name))
1873 1879 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1874 1880 elif type == 'a':
1875 1881 ui.note(('branch %s\n' % data))
1876 1882 atbranch = data
1877 1883 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1878 1884 tr.close()
1879 1885
1880 1886 if tags:
1881 1887 repo.vfs.write("localtags", "".join(tags))
1882 1888 finally:
1883 1889 ui.progress(_('building'), None)
1884 1890 release(tr, lock)
1885 1891
1886 1892 @command('debugbundle',
1887 1893 [('a', 'all', None, _('show all details'))],
1888 1894 _('FILE'),
1889 1895 norepo=True)
1890 1896 def debugbundle(ui, bundlepath, all=None, **opts):
1891 1897 """lists the contents of a bundle"""
1892 1898 f = hg.openpath(ui, bundlepath)
1893 1899 try:
1894 1900 gen = exchange.readbundle(ui, f, bundlepath)
1895 1901 if isinstance(gen, bundle2.unbundle20):
1896 1902 return _debugbundle2(ui, gen, all=all, **opts)
1897 1903 if all:
1898 1904 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1899 1905
1900 1906 def showchunks(named):
1901 1907 ui.write("\n%s\n" % named)
1902 1908 chain = None
1903 1909 while True:
1904 1910 chunkdata = gen.deltachunk(chain)
1905 1911 if not chunkdata:
1906 1912 break
1907 1913 node = chunkdata['node']
1908 1914 p1 = chunkdata['p1']
1909 1915 p2 = chunkdata['p2']
1910 1916 cs = chunkdata['cs']
1911 1917 deltabase = chunkdata['deltabase']
1912 1918 delta = chunkdata['delta']
1913 1919 ui.write("%s %s %s %s %s %s\n" %
1914 1920 (hex(node), hex(p1), hex(p2),
1915 1921 hex(cs), hex(deltabase), len(delta)))
1916 1922 chain = node
1917 1923
1918 1924 chunkdata = gen.changelogheader()
1919 1925 showchunks("changelog")
1920 1926 chunkdata = gen.manifestheader()
1921 1927 showchunks("manifest")
1922 1928 while True:
1923 1929 chunkdata = gen.filelogheader()
1924 1930 if not chunkdata:
1925 1931 break
1926 1932 fname = chunkdata['filename']
1927 1933 showchunks(fname)
1928 1934 else:
1929 1935 if isinstance(gen, bundle2.unbundle20):
1930 1936 raise error.Abort(_('use debugbundle2 for this file'))
1931 1937 chunkdata = gen.changelogheader()
1932 1938 chain = None
1933 1939 while True:
1934 1940 chunkdata = gen.deltachunk(chain)
1935 1941 if not chunkdata:
1936 1942 break
1937 1943 node = chunkdata['node']
1938 1944 ui.write("%s\n" % hex(node))
1939 1945 chain = node
1940 1946 finally:
1941 1947 f.close()
1942 1948
1943 1949 def _debugbundle2(ui, gen, **opts):
1944 1950 """lists the contents of a bundle2"""
1945 1951 if not isinstance(gen, bundle2.unbundle20):
1946 1952 raise error.Abort(_('not a bundle2 file'))
1947 1953 ui.write(('Stream params: %s\n' % repr(gen.params)))
1948 1954 for part in gen.iterparts():
1949 1955 ui.write('%s -- %r\n' % (part.type, repr(part.params)))
1950 1956 if part.type == 'changegroup':
1951 1957 version = part.params.get('version', '01')
1952 1958 cg = changegroup.packermap[version][1](part, 'UN')
1953 1959 chunkdata = cg.changelogheader()
1954 1960 chain = None
1955 1961 while True:
1956 1962 chunkdata = cg.deltachunk(chain)
1957 1963 if not chunkdata:
1958 1964 break
1959 1965 node = chunkdata['node']
1960 1966 ui.write(" %s\n" % hex(node))
1961 1967 chain = node
1962 1968
1969 @command('debugcreatestreamclonebundle', [], 'FILE')
1970 def debugcreatestreamclonebundle(ui, repo, fname):
1971 """create a stream clone bundle file
1972
1973 Stream bundles are special bundles that are essentially archives of
1974 revlog files. They are commonly used for cloning very quickly.
1975 """
1976 requirements, gen = streamclone.generatebundlev1(repo)
1977 changegroup.writechunks(ui, gen, fname)
1978
1979 ui.write(_('bundle requirements: %s\n') % ', '.join(sorted(requirements)))
1980
1963 1981 @command('debugcheckstate', [], '')
1964 1982 def debugcheckstate(ui, repo):
1965 1983 """validate the correctness of the current dirstate"""
1966 1984 parent1, parent2 = repo.dirstate.parents()
1967 1985 m1 = repo[parent1].manifest()
1968 1986 m2 = repo[parent2].manifest()
1969 1987 errors = 0
1970 1988 for f in repo.dirstate:
1971 1989 state = repo.dirstate[f]
1972 1990 if state in "nr" and f not in m1:
1973 1991 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1974 1992 errors += 1
1975 1993 if state in "a" and f in m1:
1976 1994 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1977 1995 errors += 1
1978 1996 if state in "m" and f not in m1 and f not in m2:
1979 1997 ui.warn(_("%s in state %s, but not in either manifest\n") %
1980 1998 (f, state))
1981 1999 errors += 1
1982 2000 for f in m1:
1983 2001 state = repo.dirstate[f]
1984 2002 if state not in "nrm":
1985 2003 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1986 2004 errors += 1
1987 2005 if errors:
1988 2006 error = _(".hg/dirstate inconsistent with current parent's manifest")
1989 2007 raise error.Abort(error)
1990 2008
1991 2009 @command('debugcommands', [], _('[COMMAND]'), norepo=True)
1992 2010 def debugcommands(ui, cmd='', *args):
1993 2011 """list all available commands and options"""
1994 2012 for cmd, vals in sorted(table.iteritems()):
1995 2013 cmd = cmd.split('|')[0].strip('^')
1996 2014 opts = ', '.join([i[1] for i in vals[1]])
1997 2015 ui.write('%s: %s\n' % (cmd, opts))
1998 2016
1999 2017 @command('debugcomplete',
2000 2018 [('o', 'options', None, _('show the command options'))],
2001 2019 _('[-o] CMD'),
2002 2020 norepo=True)
2003 2021 def debugcomplete(ui, cmd='', **opts):
2004 2022 """returns the completion list associated with the given command"""
2005 2023
2006 2024 if opts.get('options'):
2007 2025 options = []
2008 2026 otables = [globalopts]
2009 2027 if cmd:
2010 2028 aliases, entry = cmdutil.findcmd(cmd, table, False)
2011 2029 otables.append(entry[1])
2012 2030 for t in otables:
2013 2031 for o in t:
2014 2032 if "(DEPRECATED)" in o[3]:
2015 2033 continue
2016 2034 if o[0]:
2017 2035 options.append('-%s' % o[0])
2018 2036 options.append('--%s' % o[1])
2019 2037 ui.write("%s\n" % "\n".join(options))
2020 2038 return
2021 2039
2022 2040 cmdlist, unused_allcmds = cmdutil.findpossible(cmd, table)
2023 2041 if ui.verbose:
2024 2042 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
2025 2043 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
2026 2044
2027 2045 @command('debugdag',
2028 2046 [('t', 'tags', None, _('use tags as labels')),
2029 2047 ('b', 'branches', None, _('annotate with branch names')),
2030 2048 ('', 'dots', None, _('use dots for runs')),
2031 2049 ('s', 'spaces', None, _('separate elements by spaces'))],
2032 2050 _('[OPTION]... [FILE [REV]...]'),
2033 2051 optionalrepo=True)
2034 2052 def debugdag(ui, repo, file_=None, *revs, **opts):
2035 2053 """format the changelog or an index DAG as a concise textual description
2036 2054
2037 2055 If you pass a revlog index, the revlog's DAG is emitted. If you list
2038 2056 revision numbers, they get labeled in the output as rN.
2039 2057
2040 2058 Otherwise, the changelog DAG of the current repo is emitted.
2041 2059 """
2042 2060 spaces = opts.get('spaces')
2043 2061 dots = opts.get('dots')
2044 2062 if file_:
2045 2063 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2046 2064 revs = set((int(r) for r in revs))
2047 2065 def events():
2048 2066 for r in rlog:
2049 2067 yield 'n', (r, list(p for p in rlog.parentrevs(r)
2050 2068 if p != -1))
2051 2069 if r in revs:
2052 2070 yield 'l', (r, "r%i" % r)
2053 2071 elif repo:
2054 2072 cl = repo.changelog
2055 2073 tags = opts.get('tags')
2056 2074 branches = opts.get('branches')
2057 2075 if tags:
2058 2076 labels = {}
2059 2077 for l, n in repo.tags().items():
2060 2078 labels.setdefault(cl.rev(n), []).append(l)
2061 2079 def events():
2062 2080 b = "default"
2063 2081 for r in cl:
2064 2082 if branches:
2065 2083 newb = cl.read(cl.node(r))[5]['branch']
2066 2084 if newb != b:
2067 2085 yield 'a', newb
2068 2086 b = newb
2069 2087 yield 'n', (r, list(p for p in cl.parentrevs(r)
2070 2088 if p != -1))
2071 2089 if tags:
2072 2090 ls = labels.get(r)
2073 2091 if ls:
2074 2092 for l in ls:
2075 2093 yield 'l', (r, l)
2076 2094 else:
2077 2095 raise error.Abort(_('need repo for changelog dag'))
2078 2096
2079 2097 for line in dagparser.dagtextlines(events(),
2080 2098 addspaces=spaces,
2081 2099 wraplabels=True,
2082 2100 wrapannotations=True,
2083 2101 wrapnonlinear=dots,
2084 2102 usedots=dots,
2085 2103 maxlinewidth=70):
2086 2104 ui.write(line)
2087 2105 ui.write("\n")
2088 2106
2089 2107 @command('debugdata',
2090 2108 [('c', 'changelog', False, _('open changelog')),
2091 2109 ('m', 'manifest', False, _('open manifest')),
2092 2110 ('', 'dir', False, _('open directory manifest'))],
2093 2111 _('-c|-m|FILE REV'))
2094 2112 def debugdata(ui, repo, file_, rev=None, **opts):
2095 2113 """dump the contents of a data file revision"""
2096 2114 if opts.get('changelog') or opts.get('manifest'):
2097 2115 file_, rev = None, file_
2098 2116 elif rev is None:
2099 2117 raise error.CommandError('debugdata', _('invalid arguments'))
2100 2118 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
2101 2119 try:
2102 2120 ui.write(r.revision(r.lookup(rev)))
2103 2121 except KeyError:
2104 2122 raise error.Abort(_('invalid revision identifier %s') % rev)
2105 2123
2106 2124 @command('debugdate',
2107 2125 [('e', 'extended', None, _('try extended date formats'))],
2108 2126 _('[-e] DATE [RANGE]'),
2109 2127 norepo=True, optionalrepo=True)
2110 2128 def debugdate(ui, date, range=None, **opts):
2111 2129 """parse and display a date"""
2112 2130 if opts["extended"]:
2113 2131 d = util.parsedate(date, util.extendeddateformats)
2114 2132 else:
2115 2133 d = util.parsedate(date)
2116 2134 ui.write(("internal: %s %s\n") % d)
2117 2135 ui.write(("standard: %s\n") % util.datestr(d))
2118 2136 if range:
2119 2137 m = util.matchdate(range)
2120 2138 ui.write(("match: %s\n") % m(d[0]))
2121 2139
2122 2140 @command('debugdiscovery',
2123 2141 [('', 'old', None, _('use old-style discovery')),
2124 2142 ('', 'nonheads', None,
2125 2143 _('use old-style discovery with non-heads included')),
2126 2144 ] + remoteopts,
2127 2145 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
2128 2146 def debugdiscovery(ui, repo, remoteurl="default", **opts):
2129 2147 """runs the changeset discovery protocol in isolation"""
2130 2148 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
2131 2149 opts.get('branch'))
2132 2150 remote = hg.peer(repo, opts, remoteurl)
2133 2151 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
2134 2152
2135 2153 # make sure tests are repeatable
2136 2154 random.seed(12323)
2137 2155
2138 2156 def doit(localheads, remoteheads, remote=remote):
2139 2157 if opts.get('old'):
2140 2158 if localheads:
2141 2159 raise error.Abort('cannot use localheads with old style '
2142 2160 'discovery')
2143 2161 if not util.safehasattr(remote, 'branches'):
2144 2162 # enable in-client legacy support
2145 2163 remote = localrepo.locallegacypeer(remote.local())
2146 2164 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
2147 2165 force=True)
2148 2166 common = set(common)
2149 2167 if not opts.get('nonheads'):
2150 2168 ui.write(("unpruned common: %s\n") %
2151 2169 " ".join(sorted(short(n) for n in common)))
2152 2170 dag = dagutil.revlogdag(repo.changelog)
2153 2171 all = dag.ancestorset(dag.internalizeall(common))
2154 2172 common = dag.externalizeall(dag.headsetofconnecteds(all))
2155 2173 else:
2156 2174 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
2157 2175 common = set(common)
2158 2176 rheads = set(hds)
2159 2177 lheads = set(repo.heads())
2160 2178 ui.write(("common heads: %s\n") %
2161 2179 " ".join(sorted(short(n) for n in common)))
2162 2180 if lheads <= common:
2163 2181 ui.write(("local is subset\n"))
2164 2182 elif rheads <= common:
2165 2183 ui.write(("remote is subset\n"))
2166 2184
2167 2185 serverlogs = opts.get('serverlog')
2168 2186 if serverlogs:
2169 2187 for filename in serverlogs:
2170 2188 logfile = open(filename, 'r')
2171 2189 try:
2172 2190 line = logfile.readline()
2173 2191 while line:
2174 2192 parts = line.strip().split(';')
2175 2193 op = parts[1]
2176 2194 if op == 'cg':
2177 2195 pass
2178 2196 elif op == 'cgss':
2179 2197 doit(parts[2].split(' '), parts[3].split(' '))
2180 2198 elif op == 'unb':
2181 2199 doit(parts[3].split(' '), parts[2].split(' '))
2182 2200 line = logfile.readline()
2183 2201 finally:
2184 2202 logfile.close()
2185 2203
2186 2204 else:
2187 2205 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2188 2206 opts.get('remote_head'))
2189 2207 localrevs = opts.get('local_head')
2190 2208 doit(localrevs, remoterevs)
2191 2209
2192 2210 @command('debugextensions', formatteropts, [], norepo=True)
2193 2211 def debugextensions(ui, **opts):
2194 2212 '''show information about active extensions'''
2195 2213 exts = extensions.extensions(ui)
2196 2214 fm = ui.formatter('debugextensions', opts)
2197 2215 for extname, extmod in sorted(exts, key=operator.itemgetter(0)):
2198 2216 extsource = extmod.__file__
2199 2217 exttestedwith = getattr(extmod, 'testedwith', None)
2200 2218 if exttestedwith is not None:
2201 2219 exttestedwith = exttestedwith.split()
2202 2220 extbuglink = getattr(extmod, 'buglink', None)
2203 2221
2204 2222 fm.startitem()
2205 2223
2206 2224 if ui.quiet or ui.verbose:
2207 2225 fm.write('name', '%s\n', extname)
2208 2226 else:
2209 2227 fm.write('name', '%s', extname)
2210 2228 if not exttestedwith:
2211 2229 fm.plain(_(' (untested!)\n'))
2212 2230 else:
2213 2231 if exttestedwith == ['internal'] or \
2214 2232 util.version() in exttestedwith:
2215 2233 fm.plain('\n')
2216 2234 else:
2217 2235 lasttestedversion = exttestedwith[-1]
2218 2236 fm.plain(' (%s!)\n' % lasttestedversion)
2219 2237
2220 2238 fm.condwrite(ui.verbose and extsource, 'source',
2221 2239 _(' location: %s\n'), extsource or "")
2222 2240
2223 2241 fm.condwrite(ui.verbose and exttestedwith, 'testedwith',
2224 2242 _(' tested with: %s\n'), ' '.join(exttestedwith or []))
2225 2243
2226 2244 fm.condwrite(ui.verbose and extbuglink, 'buglink',
2227 2245 _(' bug reporting: %s\n'), extbuglink or "")
2228 2246
2229 2247 fm.end()
2230 2248
2231 2249 @command('debugfileset',
2232 2250 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2233 2251 _('[-r REV] FILESPEC'))
2234 2252 def debugfileset(ui, repo, expr, **opts):
2235 2253 '''parse and apply a fileset specification'''
2236 2254 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2237 2255 if ui.verbose:
2238 2256 tree = fileset.parse(expr)
2239 2257 ui.note(fileset.prettyformat(tree), "\n")
2240 2258
2241 2259 for f in ctx.getfileset(expr):
2242 2260 ui.write("%s\n" % f)
2243 2261
2244 2262 @command('debugfsinfo', [], _('[PATH]'), norepo=True)
2245 2263 def debugfsinfo(ui, path="."):
2246 2264 """show information detected about current filesystem"""
2247 2265 util.writefile('.debugfsinfo', '')
2248 2266 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2249 2267 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2250 2268 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2251 2269 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2252 2270 and 'yes' or 'no'))
2253 2271 os.unlink('.debugfsinfo')
2254 2272
2255 2273 @command('debuggetbundle',
2256 2274 [('H', 'head', [], _('id of head node'), _('ID')),
2257 2275 ('C', 'common', [], _('id of common node'), _('ID')),
2258 2276 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2259 2277 _('REPO FILE [-H|-C ID]...'),
2260 2278 norepo=True)
2261 2279 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2262 2280 """retrieves a bundle from a repo
2263 2281
2264 2282 Every ID must be a full-length hex node id string. Saves the bundle to the
2265 2283 given file.
2266 2284 """
2267 2285 repo = hg.peer(ui, opts, repopath)
2268 2286 if not repo.capable('getbundle'):
2269 2287 raise error.Abort("getbundle() not supported by target repository")
2270 2288 args = {}
2271 2289 if common:
2272 2290 args['common'] = [bin(s) for s in common]
2273 2291 if head:
2274 2292 args['heads'] = [bin(s) for s in head]
2275 2293 # TODO: get desired bundlecaps from command line.
2276 2294 args['bundlecaps'] = None
2277 2295 bundle = repo.getbundle('debug', **args)
2278 2296
2279 2297 bundletype = opts.get('type', 'bzip2').lower()
2280 2298 btypes = {'none': 'HG10UN',
2281 2299 'bzip2': 'HG10BZ',
2282 2300 'gzip': 'HG10GZ',
2283 2301 'bundle2': 'HG20'}
2284 2302 bundletype = btypes.get(bundletype)
2285 2303 if bundletype not in changegroup.bundletypes:
2286 2304 raise error.Abort(_('unknown bundle type specified with --type'))
2287 2305 changegroup.writebundle(ui, bundle, bundlepath, bundletype)
2288 2306
2289 2307 @command('debugignore', [], '')
2290 2308 def debugignore(ui, repo, *values, **opts):
2291 2309 """display the combined ignore pattern"""
2292 2310 ignore = repo.dirstate._ignore
2293 2311 includepat = getattr(ignore, 'includepat', None)
2294 2312 if includepat is not None:
2295 2313 ui.write("%s\n" % includepat)
2296 2314 else:
2297 2315 raise error.Abort(_("no ignore patterns found"))
2298 2316
2299 2317 @command('debugindex',
2300 2318 [('c', 'changelog', False, _('open changelog')),
2301 2319 ('m', 'manifest', False, _('open manifest')),
2302 2320 ('', 'dir', False, _('open directory manifest')),
2303 2321 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2304 2322 _('[-f FORMAT] -c|-m|FILE'),
2305 2323 optionalrepo=True)
2306 2324 def debugindex(ui, repo, file_=None, **opts):
2307 2325 """dump the contents of an index file"""
2308 2326 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2309 2327 format = opts.get('format', 0)
2310 2328 if format not in (0, 1):
2311 2329 raise error.Abort(_("unknown format %d") % format)
2312 2330
2313 2331 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2314 2332 if generaldelta:
2315 2333 basehdr = ' delta'
2316 2334 else:
2317 2335 basehdr = ' base'
2318 2336
2319 2337 if ui.debugflag:
2320 2338 shortfn = hex
2321 2339 else:
2322 2340 shortfn = short
2323 2341
2324 2342 # There might not be anything in r, so have a sane default
2325 2343 idlen = 12
2326 2344 for i in r:
2327 2345 idlen = len(shortfn(r.node(i)))
2328 2346 break
2329 2347
2330 2348 if format == 0:
2331 2349 ui.write(" rev offset length " + basehdr + " linkrev"
2332 2350 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen)))
2333 2351 elif format == 1:
2334 2352 ui.write(" rev flag offset length"
2335 2353 " size " + basehdr + " link p1 p2"
2336 2354 " %s\n" % "nodeid".rjust(idlen))
2337 2355
2338 2356 for i in r:
2339 2357 node = r.node(i)
2340 2358 if generaldelta:
2341 2359 base = r.deltaparent(i)
2342 2360 else:
2343 2361 base = r.chainbase(i)
2344 2362 if format == 0:
2345 2363 try:
2346 2364 pp = r.parents(node)
2347 2365 except Exception:
2348 2366 pp = [nullid, nullid]
2349 2367 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2350 2368 i, r.start(i), r.length(i), base, r.linkrev(i),
2351 2369 shortfn(node), shortfn(pp[0]), shortfn(pp[1])))
2352 2370 elif format == 1:
2353 2371 pr = r.parentrevs(i)
2354 2372 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2355 2373 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2356 2374 base, r.linkrev(i), pr[0], pr[1], shortfn(node)))
2357 2375
2358 2376 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
2359 2377 def debugindexdot(ui, repo, file_):
2360 2378 """dump an index DAG as a graphviz dot file"""
2361 2379 r = None
2362 2380 if repo:
2363 2381 filelog = repo.file(file_)
2364 2382 if len(filelog):
2365 2383 r = filelog
2366 2384 if not r:
2367 2385 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2368 2386 ui.write(("digraph G {\n"))
2369 2387 for i in r:
2370 2388 node = r.node(i)
2371 2389 pp = r.parents(node)
2372 2390 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2373 2391 if pp[1] != nullid:
2374 2392 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2375 2393 ui.write("}\n")
2376 2394
2377 2395 @command('debuginstall', [], '', norepo=True)
2378 2396 def debuginstall(ui):
2379 2397 '''test Mercurial installation
2380 2398
2381 2399 Returns 0 on success.
2382 2400 '''
2383 2401
2384 2402 def writetemp(contents):
2385 2403 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2386 2404 f = os.fdopen(fd, "wb")
2387 2405 f.write(contents)
2388 2406 f.close()
2389 2407 return name
2390 2408
2391 2409 problems = 0
2392 2410
2393 2411 # encoding
2394 2412 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2395 2413 try:
2396 2414 encoding.fromlocal("test")
2397 2415 except error.Abort as inst:
2398 2416 ui.write(" %s\n" % inst)
2399 2417 ui.write(_(" (check that your locale is properly set)\n"))
2400 2418 problems += 1
2401 2419
2402 2420 # Python
2403 2421 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2404 2422 ui.status(_("checking Python version (%s)\n")
2405 2423 % ("%s.%s.%s" % sys.version_info[:3]))
2406 2424 ui.status(_("checking Python lib (%s)...\n")
2407 2425 % os.path.dirname(os.__file__))
2408 2426
2409 2427 # compiled modules
2410 2428 ui.status(_("checking installed modules (%s)...\n")
2411 2429 % os.path.dirname(__file__))
2412 2430 try:
2413 2431 import bdiff, mpatch, base85, osutil
2414 2432 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2415 2433 except Exception as inst:
2416 2434 ui.write(" %s\n" % inst)
2417 2435 ui.write(_(" One or more extensions could not be found"))
2418 2436 ui.write(_(" (check that you compiled the extensions)\n"))
2419 2437 problems += 1
2420 2438
2421 2439 # templates
2422 2440 import templater
2423 2441 p = templater.templatepaths()
2424 2442 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2425 2443 if p:
2426 2444 m = templater.templatepath("map-cmdline.default")
2427 2445 if m:
2428 2446 # template found, check if it is working
2429 2447 try:
2430 2448 templater.templater(m)
2431 2449 except Exception as inst:
2432 2450 ui.write(" %s\n" % inst)
2433 2451 p = None
2434 2452 else:
2435 2453 ui.write(_(" template 'default' not found\n"))
2436 2454 p = None
2437 2455 else:
2438 2456 ui.write(_(" no template directories found\n"))
2439 2457 if not p:
2440 2458 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2441 2459 problems += 1
2442 2460
2443 2461 # editor
2444 2462 ui.status(_("checking commit editor...\n"))
2445 2463 editor = ui.geteditor()
2446 2464 editor = util.expandpath(editor)
2447 2465 cmdpath = util.findexe(shlex.split(editor)[0])
2448 2466 if not cmdpath:
2449 2467 if editor == 'vi':
2450 2468 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2451 2469 ui.write(_(" (specify a commit editor in your configuration"
2452 2470 " file)\n"))
2453 2471 else:
2454 2472 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2455 2473 ui.write(_(" (specify a commit editor in your configuration"
2456 2474 " file)\n"))
2457 2475 problems += 1
2458 2476
2459 2477 # check username
2460 2478 ui.status(_("checking username...\n"))
2461 2479 try:
2462 2480 ui.username()
2463 2481 except error.Abort as e:
2464 2482 ui.write(" %s\n" % e)
2465 2483 ui.write(_(" (specify a username in your configuration file)\n"))
2466 2484 problems += 1
2467 2485
2468 2486 if not problems:
2469 2487 ui.status(_("no problems detected\n"))
2470 2488 else:
2471 2489 ui.write(_("%s problems detected,"
2472 2490 " please check your install!\n") % problems)
2473 2491
2474 2492 return problems
2475 2493
2476 2494 @command('debugknown', [], _('REPO ID...'), norepo=True)
2477 2495 def debugknown(ui, repopath, *ids, **opts):
2478 2496 """test whether node ids are known to a repo
2479 2497
2480 2498 Every ID must be a full-length hex node id string. Returns a list of 0s
2481 2499 and 1s indicating unknown/known.
2482 2500 """
2483 2501 repo = hg.peer(ui, opts, repopath)
2484 2502 if not repo.capable('known'):
2485 2503 raise error.Abort("known() not supported by target repository")
2486 2504 flags = repo.known([bin(s) for s in ids])
2487 2505 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2488 2506
2489 2507 @command('debuglabelcomplete', [], _('LABEL...'))
2490 2508 def debuglabelcomplete(ui, repo, *args):
2491 2509 '''backwards compatibility with old bash completion scripts (DEPRECATED)'''
2492 2510 debugnamecomplete(ui, repo, *args)
2493 2511
2494 2512 @command('debugmergestate', [], '')
2495 2513 def debugmergestate(ui, repo, *args):
2496 2514 """print merge state
2497 2515
2498 2516 Use --verbose to print out information about whether v1 or v2 merge state
2499 2517 was chosen."""
2500 2518 def printrecords(version):
2501 2519 ui.write(('* version %s records\n') % version)
2502 2520 if version == 1:
2503 2521 records = v1records
2504 2522 else:
2505 2523 records = v2records
2506 2524
2507 2525 for rtype, record in records:
2508 2526 # pretty print some record types
2509 2527 if rtype == 'L':
2510 2528 ui.write(('local: %s\n') % record)
2511 2529 elif rtype == 'O':
2512 2530 ui.write(('other: %s\n') % record)
2513 2531 elif rtype == 'm':
2514 2532 driver, mdstate = record.split('\0', 1)
2515 2533 ui.write(('merge driver: %s (state "%s")\n')
2516 2534 % (driver, mdstate))
2517 2535 elif rtype in 'FD':
2518 2536 r = record.split('\0')
2519 2537 f, state, hash, lfile, afile, anode, ofile = r[0:7]
2520 2538 if version == 1:
2521 2539 onode = 'not stored in v1 format'
2522 2540 flags = r[7]
2523 2541 else:
2524 2542 onode, flags = r[7:9]
2525 2543 ui.write(('file: %s (state "%s", hash %s)\n')
2526 2544 % (f, state, hash))
2527 2545 ui.write((' local path: %s (flags "%s")\n') % (lfile, flags))
2528 2546 ui.write((' ancestor path: %s (node %s)\n') % (afile, anode))
2529 2547 ui.write((' other path: %s (node %s)\n') % (ofile, onode))
2530 2548 else:
2531 2549 ui.write(('unrecognized entry: %s\t%s\n')
2532 2550 % (rtype, record.replace('\0', '\t')))
2533 2551
2534 2552 ms = mergemod.mergestate(repo)
2535 2553
2536 2554 # sort so that reasonable information is on top
2537 2555 v1records = ms._readrecordsv1()
2538 2556 v2records = ms._readrecordsv2()
2539 2557 order = 'LOm'
2540 2558 def key(r):
2541 2559 idx = order.find(r[0])
2542 2560 if idx == -1:
2543 2561 return (1, r[1])
2544 2562 else:
2545 2563 return (0, idx)
2546 2564 v1records.sort(key=key)
2547 2565 v2records.sort(key=key)
2548 2566
2549 2567 if not v1records and not v2records:
2550 2568 ui.write(('no merge state found\n'))
2551 2569 elif not v2records:
2552 2570 ui.note(('no version 2 merge state\n'))
2553 2571 printrecords(1)
2554 2572 elif ms._v1v2match(v1records, v2records):
2555 2573 ui.note(('v1 and v2 states match: using v2\n'))
2556 2574 printrecords(2)
2557 2575 else:
2558 2576 ui.note(('v1 and v2 states mismatch: using v1\n'))
2559 2577 printrecords(1)
2560 2578 if ui.verbose:
2561 2579 printrecords(2)
2562 2580
2563 2581 @command('debugnamecomplete', [], _('NAME...'))
2564 2582 def debugnamecomplete(ui, repo, *args):
2565 2583 '''complete "names" - tags, open branch names, bookmark names'''
2566 2584
2567 2585 names = set()
2568 2586 # since we previously only listed open branches, we will handle that
2569 2587 # specially (after this for loop)
2570 2588 for name, ns in repo.names.iteritems():
2571 2589 if name != 'branches':
2572 2590 names.update(ns.listnames(repo))
2573 2591 names.update(tag for (tag, heads, tip, closed)
2574 2592 in repo.branchmap().iterbranches() if not closed)
2575 2593 completions = set()
2576 2594 if not args:
2577 2595 args = ['']
2578 2596 for a in args:
2579 2597 completions.update(n for n in names if n.startswith(a))
2580 2598 ui.write('\n'.join(sorted(completions)))
2581 2599 ui.write('\n')
2582 2600
2583 2601 @command('debuglocks',
2584 2602 [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
2585 2603 ('W', 'force-wlock', None,
2586 2604 _('free the working state lock (DANGEROUS)'))],
2587 2605 _('[OPTION]...'))
2588 2606 def debuglocks(ui, repo, **opts):
2589 2607 """show or modify state of locks
2590 2608
2591 2609 By default, this command will show which locks are held. This
2592 2610 includes the user and process holding the lock, the amount of time
2593 2611 the lock has been held, and the machine name where the process is
2594 2612 running if it's not local.
2595 2613
2596 2614 Locks protect the integrity of Mercurial's data, so should be
2597 2615 treated with care. System crashes or other interruptions may cause
2598 2616 locks to not be properly released, though Mercurial will usually
2599 2617 detect and remove such stale locks automatically.
2600 2618
2601 2619 However, detecting stale locks may not always be possible (for
2602 2620 instance, on a shared filesystem). Removing locks may also be
2603 2621 blocked by filesystem permissions.
2604 2622
2605 2623 Returns 0 if no locks are held.
2606 2624
2607 2625 """
2608 2626
2609 2627 if opts.get('force_lock'):
2610 2628 repo.svfs.unlink('lock')
2611 2629 if opts.get('force_wlock'):
2612 2630 repo.vfs.unlink('wlock')
2613 2631 if opts.get('force_lock') or opts.get('force_lock'):
2614 2632 return 0
2615 2633
2616 2634 now = time.time()
2617 2635 held = 0
2618 2636
2619 2637 def report(vfs, name, method):
2620 2638 # this causes stale locks to get reaped for more accurate reporting
2621 2639 try:
2622 2640 l = method(False)
2623 2641 except error.LockHeld:
2624 2642 l = None
2625 2643
2626 2644 if l:
2627 2645 l.release()
2628 2646 else:
2629 2647 try:
2630 2648 stat = vfs.lstat(name)
2631 2649 age = now - stat.st_mtime
2632 2650 user = util.username(stat.st_uid)
2633 2651 locker = vfs.readlock(name)
2634 2652 if ":" in locker:
2635 2653 host, pid = locker.split(':')
2636 2654 if host == socket.gethostname():
2637 2655 locker = 'user %s, process %s' % (user, pid)
2638 2656 else:
2639 2657 locker = 'user %s, process %s, host %s' \
2640 2658 % (user, pid, host)
2641 2659 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age))
2642 2660 return 1
2643 2661 except OSError as e:
2644 2662 if e.errno != errno.ENOENT:
2645 2663 raise
2646 2664
2647 2665 ui.write("%-6s free\n" % (name + ":"))
2648 2666 return 0
2649 2667
2650 2668 held += report(repo.svfs, "lock", repo.lock)
2651 2669 held += report(repo.vfs, "wlock", repo.wlock)
2652 2670
2653 2671 return held
2654 2672
2655 2673 @command('debugobsolete',
2656 2674 [('', 'flags', 0, _('markers flag')),
2657 2675 ('', 'record-parents', False,
2658 2676 _('record parent information for the precursor')),
2659 2677 ('r', 'rev', [], _('display markers relevant to REV')),
2660 2678 ] + commitopts2,
2661 2679 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2662 2680 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2663 2681 """create arbitrary obsolete marker
2664 2682
2665 2683 With no arguments, displays the list of obsolescence markers."""
2666 2684
2667 2685 def parsenodeid(s):
2668 2686 try:
2669 2687 # We do not use revsingle/revrange functions here to accept
2670 2688 # arbitrary node identifiers, possibly not present in the
2671 2689 # local repository.
2672 2690 n = bin(s)
2673 2691 if len(n) != len(nullid):
2674 2692 raise TypeError()
2675 2693 return n
2676 2694 except TypeError:
2677 2695 raise error.Abort('changeset references must be full hexadecimal '
2678 2696 'node identifiers')
2679 2697
2680 2698 if precursor is not None:
2681 2699 if opts['rev']:
2682 2700 raise error.Abort('cannot select revision when creating marker')
2683 2701 metadata = {}
2684 2702 metadata['user'] = opts['user'] or ui.username()
2685 2703 succs = tuple(parsenodeid(succ) for succ in successors)
2686 2704 l = repo.lock()
2687 2705 try:
2688 2706 tr = repo.transaction('debugobsolete')
2689 2707 try:
2690 2708 date = opts.get('date')
2691 2709 if date:
2692 2710 date = util.parsedate(date)
2693 2711 else:
2694 2712 date = None
2695 2713 prec = parsenodeid(precursor)
2696 2714 parents = None
2697 2715 if opts['record_parents']:
2698 2716 if prec not in repo.unfiltered():
2699 2717 raise error.Abort('cannot used --record-parents on '
2700 2718 'unknown changesets')
2701 2719 parents = repo.unfiltered()[prec].parents()
2702 2720 parents = tuple(p.node() for p in parents)
2703 2721 repo.obsstore.create(tr, prec, succs, opts['flags'],
2704 2722 parents=parents, date=date,
2705 2723 metadata=metadata)
2706 2724 tr.close()
2707 2725 except ValueError as exc:
2708 2726 raise error.Abort(_('bad obsmarker input: %s') % exc)
2709 2727 finally:
2710 2728 tr.release()
2711 2729 finally:
2712 2730 l.release()
2713 2731 else:
2714 2732 if opts['rev']:
2715 2733 revs = scmutil.revrange(repo, opts['rev'])
2716 2734 nodes = [repo[r].node() for r in revs]
2717 2735 markers = list(obsolete.getmarkers(repo, nodes=nodes))
2718 2736 markers.sort(key=lambda x: x._data)
2719 2737 else:
2720 2738 markers = obsolete.getmarkers(repo)
2721 2739
2722 2740 for m in markers:
2723 2741 cmdutil.showmarker(ui, m)
2724 2742
2725 2743 @command('debugpathcomplete',
2726 2744 [('f', 'full', None, _('complete an entire path')),
2727 2745 ('n', 'normal', None, _('show only normal files')),
2728 2746 ('a', 'added', None, _('show only added files')),
2729 2747 ('r', 'removed', None, _('show only removed files'))],
2730 2748 _('FILESPEC...'))
2731 2749 def debugpathcomplete(ui, repo, *specs, **opts):
2732 2750 '''complete part or all of a tracked path
2733 2751
2734 2752 This command supports shells that offer path name completion. It
2735 2753 currently completes only files already known to the dirstate.
2736 2754
2737 2755 Completion extends only to the next path segment unless
2738 2756 --full is specified, in which case entire paths are used.'''
2739 2757
2740 2758 def complete(path, acceptable):
2741 2759 dirstate = repo.dirstate
2742 2760 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2743 2761 rootdir = repo.root + os.sep
2744 2762 if spec != repo.root and not spec.startswith(rootdir):
2745 2763 return [], []
2746 2764 if os.path.isdir(spec):
2747 2765 spec += '/'
2748 2766 spec = spec[len(rootdir):]
2749 2767 fixpaths = os.sep != '/'
2750 2768 if fixpaths:
2751 2769 spec = spec.replace(os.sep, '/')
2752 2770 speclen = len(spec)
2753 2771 fullpaths = opts['full']
2754 2772 files, dirs = set(), set()
2755 2773 adddir, addfile = dirs.add, files.add
2756 2774 for f, st in dirstate.iteritems():
2757 2775 if f.startswith(spec) and st[0] in acceptable:
2758 2776 if fixpaths:
2759 2777 f = f.replace('/', os.sep)
2760 2778 if fullpaths:
2761 2779 addfile(f)
2762 2780 continue
2763 2781 s = f.find(os.sep, speclen)
2764 2782 if s >= 0:
2765 2783 adddir(f[:s])
2766 2784 else:
2767 2785 addfile(f)
2768 2786 return files, dirs
2769 2787
2770 2788 acceptable = ''
2771 2789 if opts['normal']:
2772 2790 acceptable += 'nm'
2773 2791 if opts['added']:
2774 2792 acceptable += 'a'
2775 2793 if opts['removed']:
2776 2794 acceptable += 'r'
2777 2795 cwd = repo.getcwd()
2778 2796 if not specs:
2779 2797 specs = ['.']
2780 2798
2781 2799 files, dirs = set(), set()
2782 2800 for spec in specs:
2783 2801 f, d = complete(spec, acceptable or 'nmar')
2784 2802 files.update(f)
2785 2803 dirs.update(d)
2786 2804 files.update(dirs)
2787 2805 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2788 2806 ui.write('\n')
2789 2807
2790 2808 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'), norepo=True)
2791 2809 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2792 2810 '''access the pushkey key/value protocol
2793 2811
2794 2812 With two args, list the keys in the given namespace.
2795 2813
2796 2814 With five args, set a key to new if it currently is set to old.
2797 2815 Reports success or failure.
2798 2816 '''
2799 2817
2800 2818 target = hg.peer(ui, {}, repopath)
2801 2819 if keyinfo:
2802 2820 key, old, new = keyinfo
2803 2821 r = target.pushkey(namespace, key, old, new)
2804 2822 ui.status(str(r) + '\n')
2805 2823 return not r
2806 2824 else:
2807 2825 for k, v in sorted(target.listkeys(namespace).iteritems()):
2808 2826 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2809 2827 v.encode('string-escape')))
2810 2828
2811 2829 @command('debugpvec', [], _('A B'))
2812 2830 def debugpvec(ui, repo, a, b=None):
2813 2831 ca = scmutil.revsingle(repo, a)
2814 2832 cb = scmutil.revsingle(repo, b)
2815 2833 pa = pvec.ctxpvec(ca)
2816 2834 pb = pvec.ctxpvec(cb)
2817 2835 if pa == pb:
2818 2836 rel = "="
2819 2837 elif pa > pb:
2820 2838 rel = ">"
2821 2839 elif pa < pb:
2822 2840 rel = "<"
2823 2841 elif pa | pb:
2824 2842 rel = "|"
2825 2843 ui.write(_("a: %s\n") % pa)
2826 2844 ui.write(_("b: %s\n") % pb)
2827 2845 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2828 2846 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2829 2847 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2830 2848 pa.distance(pb), rel))
2831 2849
2832 2850 @command('debugrebuilddirstate|debugrebuildstate',
2833 2851 [('r', 'rev', '', _('revision to rebuild to'), _('REV')),
2834 2852 ('', 'minimal', None, _('only rebuild files that are inconsistent with '
2835 2853 'the working copy parent')),
2836 2854 ],
2837 2855 _('[-r REV]'))
2838 2856 def debugrebuilddirstate(ui, repo, rev, **opts):
2839 2857 """rebuild the dirstate as it would look like for the given revision
2840 2858
2841 2859 If no revision is specified the first current parent will be used.
2842 2860
2843 2861 The dirstate will be set to the files of the given revision.
2844 2862 The actual working directory content or existing dirstate
2845 2863 information such as adds or removes is not considered.
2846 2864
2847 2865 ``minimal`` will only rebuild the dirstate status for files that claim to be
2848 2866 tracked but are not in the parent manifest, or that exist in the parent
2849 2867 manifest but are not in the dirstate. It will not change adds, removes, or
2850 2868 modified files that are in the working copy parent.
2851 2869
2852 2870 One use of this command is to make the next :hg:`status` invocation
2853 2871 check the actual file content.
2854 2872 """
2855 2873 ctx = scmutil.revsingle(repo, rev)
2856 2874 wlock = repo.wlock()
2857 2875 try:
2858 2876 dirstate = repo.dirstate
2859 2877
2860 2878 # See command doc for what minimal does.
2861 2879 if opts.get('minimal'):
2862 2880 dirstatefiles = set(dirstate)
2863 2881 ctxfiles = set(ctx.manifest().keys())
2864 2882 for file in (dirstatefiles | ctxfiles):
2865 2883 indirstate = file in dirstatefiles
2866 2884 inctx = file in ctxfiles
2867 2885
2868 2886 if indirstate and not inctx and dirstate[file] != 'a':
2869 2887 dirstate.drop(file)
2870 2888 elif inctx and not indirstate:
2871 2889 dirstate.normallookup(file)
2872 2890 else:
2873 2891 dirstate.rebuild(ctx.node(), ctx.manifest())
2874 2892 finally:
2875 2893 wlock.release()
2876 2894
2877 2895 @command('debugrebuildfncache', [], '')
2878 2896 def debugrebuildfncache(ui, repo):
2879 2897 """rebuild the fncache file"""
2880 2898 repair.rebuildfncache(ui, repo)
2881 2899
2882 2900 @command('debugrename',
2883 2901 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2884 2902 _('[-r REV] FILE'))
2885 2903 def debugrename(ui, repo, file1, *pats, **opts):
2886 2904 """dump rename information"""
2887 2905
2888 2906 ctx = scmutil.revsingle(repo, opts.get('rev'))
2889 2907 m = scmutil.match(ctx, (file1,) + pats, opts)
2890 2908 for abs in ctx.walk(m):
2891 2909 fctx = ctx[abs]
2892 2910 o = fctx.filelog().renamed(fctx.filenode())
2893 2911 rel = m.rel(abs)
2894 2912 if o:
2895 2913 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2896 2914 else:
2897 2915 ui.write(_("%s not renamed\n") % rel)
2898 2916
2899 2917 @command('debugrevlog',
2900 2918 [('c', 'changelog', False, _('open changelog')),
2901 2919 ('m', 'manifest', False, _('open manifest')),
2902 2920 ('', 'dir', False, _('open directory manifest')),
2903 2921 ('d', 'dump', False, _('dump index data'))],
2904 2922 _('-c|-m|FILE'),
2905 2923 optionalrepo=True)
2906 2924 def debugrevlog(ui, repo, file_=None, **opts):
2907 2925 """show data and statistics about a revlog"""
2908 2926 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2909 2927
2910 2928 if opts.get("dump"):
2911 2929 numrevs = len(r)
2912 2930 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2913 2931 " rawsize totalsize compression heads chainlen\n")
2914 2932 ts = 0
2915 2933 heads = set()
2916 2934
2917 2935 for rev in xrange(numrevs):
2918 2936 dbase = r.deltaparent(rev)
2919 2937 if dbase == -1:
2920 2938 dbase = rev
2921 2939 cbase = r.chainbase(rev)
2922 2940 clen = r.chainlen(rev)
2923 2941 p1, p2 = r.parentrevs(rev)
2924 2942 rs = r.rawsize(rev)
2925 2943 ts = ts + rs
2926 2944 heads -= set(r.parentrevs(rev))
2927 2945 heads.add(rev)
2928 2946 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d "
2929 2947 "%11d %5d %8d\n" %
2930 2948 (rev, p1, p2, r.start(rev), r.end(rev),
2931 2949 r.start(dbase), r.start(cbase),
2932 2950 r.start(p1), r.start(p2),
2933 2951 rs, ts, ts / r.end(rev), len(heads), clen))
2934 2952 return 0
2935 2953
2936 2954 v = r.version
2937 2955 format = v & 0xFFFF
2938 2956 flags = []
2939 2957 gdelta = False
2940 2958 if v & revlog.REVLOGNGINLINEDATA:
2941 2959 flags.append('inline')
2942 2960 if v & revlog.REVLOGGENERALDELTA:
2943 2961 gdelta = True
2944 2962 flags.append('generaldelta')
2945 2963 if not flags:
2946 2964 flags = ['(none)']
2947 2965
2948 2966 nummerges = 0
2949 2967 numfull = 0
2950 2968 numprev = 0
2951 2969 nump1 = 0
2952 2970 nump2 = 0
2953 2971 numother = 0
2954 2972 nump1prev = 0
2955 2973 nump2prev = 0
2956 2974 chainlengths = []
2957 2975
2958 2976 datasize = [None, 0, 0L]
2959 2977 fullsize = [None, 0, 0L]
2960 2978 deltasize = [None, 0, 0L]
2961 2979
2962 2980 def addsize(size, l):
2963 2981 if l[0] is None or size < l[0]:
2964 2982 l[0] = size
2965 2983 if size > l[1]:
2966 2984 l[1] = size
2967 2985 l[2] += size
2968 2986
2969 2987 numrevs = len(r)
2970 2988 for rev in xrange(numrevs):
2971 2989 p1, p2 = r.parentrevs(rev)
2972 2990 delta = r.deltaparent(rev)
2973 2991 if format > 0:
2974 2992 addsize(r.rawsize(rev), datasize)
2975 2993 if p2 != nullrev:
2976 2994 nummerges += 1
2977 2995 size = r.length(rev)
2978 2996 if delta == nullrev:
2979 2997 chainlengths.append(0)
2980 2998 numfull += 1
2981 2999 addsize(size, fullsize)
2982 3000 else:
2983 3001 chainlengths.append(chainlengths[delta] + 1)
2984 3002 addsize(size, deltasize)
2985 3003 if delta == rev - 1:
2986 3004 numprev += 1
2987 3005 if delta == p1:
2988 3006 nump1prev += 1
2989 3007 elif delta == p2:
2990 3008 nump2prev += 1
2991 3009 elif delta == p1:
2992 3010 nump1 += 1
2993 3011 elif delta == p2:
2994 3012 nump2 += 1
2995 3013 elif delta != nullrev:
2996 3014 numother += 1
2997 3015
2998 3016 # Adjust size min value for empty cases
2999 3017 for size in (datasize, fullsize, deltasize):
3000 3018 if size[0] is None:
3001 3019 size[0] = 0
3002 3020
3003 3021 numdeltas = numrevs - numfull
3004 3022 numoprev = numprev - nump1prev - nump2prev
3005 3023 totalrawsize = datasize[2]
3006 3024 datasize[2] /= numrevs
3007 3025 fulltotal = fullsize[2]
3008 3026 fullsize[2] /= numfull
3009 3027 deltatotal = deltasize[2]
3010 3028 if numrevs - numfull > 0:
3011 3029 deltasize[2] /= numrevs - numfull
3012 3030 totalsize = fulltotal + deltatotal
3013 3031 avgchainlen = sum(chainlengths) / numrevs
3014 3032 maxchainlen = max(chainlengths)
3015 3033 compratio = totalrawsize / totalsize
3016 3034
3017 3035 basedfmtstr = '%%%dd\n'
3018 3036 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
3019 3037
3020 3038 def dfmtstr(max):
3021 3039 return basedfmtstr % len(str(max))
3022 3040 def pcfmtstr(max, padding=0):
3023 3041 return basepcfmtstr % (len(str(max)), ' ' * padding)
3024 3042
3025 3043 def pcfmt(value, total):
3026 3044 return (value, 100 * float(value) / total)
3027 3045
3028 3046 ui.write(('format : %d\n') % format)
3029 3047 ui.write(('flags : %s\n') % ', '.join(flags))
3030 3048
3031 3049 ui.write('\n')
3032 3050 fmt = pcfmtstr(totalsize)
3033 3051 fmt2 = dfmtstr(totalsize)
3034 3052 ui.write(('revisions : ') + fmt2 % numrevs)
3035 3053 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
3036 3054 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
3037 3055 ui.write(('revisions : ') + fmt2 % numrevs)
3038 3056 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
3039 3057 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
3040 3058 ui.write(('revision size : ') + fmt2 % totalsize)
3041 3059 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
3042 3060 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
3043 3061
3044 3062 ui.write('\n')
3045 3063 fmt = dfmtstr(max(avgchainlen, compratio))
3046 3064 ui.write(('avg chain length : ') + fmt % avgchainlen)
3047 3065 ui.write(('max chain length : ') + fmt % maxchainlen)
3048 3066 ui.write(('compression ratio : ') + fmt % compratio)
3049 3067
3050 3068 if format > 0:
3051 3069 ui.write('\n')
3052 3070 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
3053 3071 % tuple(datasize))
3054 3072 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
3055 3073 % tuple(fullsize))
3056 3074 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
3057 3075 % tuple(deltasize))
3058 3076
3059 3077 if numdeltas > 0:
3060 3078 ui.write('\n')
3061 3079 fmt = pcfmtstr(numdeltas)
3062 3080 fmt2 = pcfmtstr(numdeltas, 4)
3063 3081 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
3064 3082 if numprev > 0:
3065 3083 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
3066 3084 numprev))
3067 3085 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
3068 3086 numprev))
3069 3087 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
3070 3088 numprev))
3071 3089 if gdelta:
3072 3090 ui.write(('deltas against p1 : ')
3073 3091 + fmt % pcfmt(nump1, numdeltas))
3074 3092 ui.write(('deltas against p2 : ')
3075 3093 + fmt % pcfmt(nump2, numdeltas))
3076 3094 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
3077 3095 numdeltas))
3078 3096
3079 3097 @command('debugrevspec',
3080 3098 [('', 'optimize', None, _('print parsed tree after optimizing'))],
3081 3099 ('REVSPEC'))
3082 3100 def debugrevspec(ui, repo, expr, **opts):
3083 3101 """parse and apply a revision specification
3084 3102
3085 3103 Use --verbose to print the parsed tree before and after aliases
3086 3104 expansion.
3087 3105 """
3088 3106 if ui.verbose:
3089 3107 tree = revset.parse(expr, lookup=repo.__contains__)
3090 3108 ui.note(revset.prettyformat(tree), "\n")
3091 3109 newtree = revset.findaliases(ui, tree)
3092 3110 if newtree != tree:
3093 3111 ui.note(revset.prettyformat(newtree), "\n")
3094 3112 tree = newtree
3095 3113 newtree = revset.foldconcat(tree)
3096 3114 if newtree != tree:
3097 3115 ui.note(revset.prettyformat(newtree), "\n")
3098 3116 if opts["optimize"]:
3099 3117 weight, optimizedtree = revset.optimize(newtree, True)
3100 3118 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
3101 3119 func = revset.match(ui, expr, repo)
3102 3120 revs = func(repo)
3103 3121 if ui.verbose:
3104 3122 ui.note("* set:\n", revset.prettyformatset(revs), "\n")
3105 3123 for c in revs:
3106 3124 ui.write("%s\n" % c)
3107 3125
3108 3126 @command('debugsetparents', [], _('REV1 [REV2]'))
3109 3127 def debugsetparents(ui, repo, rev1, rev2=None):
3110 3128 """manually set the parents of the current working directory
3111 3129
3112 3130 This is useful for writing repository conversion tools, but should
3113 3131 be used with care. For example, neither the working directory nor the
3114 3132 dirstate is updated, so file status may be incorrect after running this
3115 3133 command.
3116 3134
3117 3135 Returns 0 on success.
3118 3136 """
3119 3137
3120 3138 r1 = scmutil.revsingle(repo, rev1).node()
3121 3139 r2 = scmutil.revsingle(repo, rev2, 'null').node()
3122 3140
3123 3141 wlock = repo.wlock()
3124 3142 try:
3125 3143 repo.dirstate.beginparentchange()
3126 3144 repo.setparents(r1, r2)
3127 3145 repo.dirstate.endparentchange()
3128 3146 finally:
3129 3147 wlock.release()
3130 3148
3131 3149 @command('debugdirstate|debugstate',
3132 3150 [('', 'nodates', None, _('do not display the saved mtime')),
3133 3151 ('', 'datesort', None, _('sort by saved mtime'))],
3134 3152 _('[OPTION]...'))
3135 3153 def debugstate(ui, repo, nodates=None, datesort=None):
3136 3154 """show the contents of the current dirstate"""
3137 3155 timestr = ""
3138 3156 if datesort:
3139 3157 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
3140 3158 else:
3141 3159 keyfunc = None # sort by filename
3142 3160 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
3143 3161 if ent[3] == -1:
3144 3162 timestr = 'unset '
3145 3163 elif nodates:
3146 3164 timestr = 'set '
3147 3165 else:
3148 3166 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
3149 3167 time.localtime(ent[3]))
3150 3168 if ent[1] & 0o20000:
3151 3169 mode = 'lnk'
3152 3170 else:
3153 3171 mode = '%3o' % (ent[1] & 0o777 & ~util.umask)
3154 3172 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
3155 3173 for f in repo.dirstate.copies():
3156 3174 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
3157 3175
3158 3176 @command('debugsub',
3159 3177 [('r', 'rev', '',
3160 3178 _('revision to check'), _('REV'))],
3161 3179 _('[-r REV] [REV]'))
3162 3180 def debugsub(ui, repo, rev=None):
3163 3181 ctx = scmutil.revsingle(repo, rev, None)
3164 3182 for k, v in sorted(ctx.substate.items()):
3165 3183 ui.write(('path %s\n') % k)
3166 3184 ui.write((' source %s\n') % v[0])
3167 3185 ui.write((' revision %s\n') % v[1])
3168 3186
3169 3187 @command('debugsuccessorssets',
3170 3188 [],
3171 3189 _('[REV]'))
3172 3190 def debugsuccessorssets(ui, repo, *revs):
3173 3191 """show set of successors for revision
3174 3192
3175 3193 A successors set of changeset A is a consistent group of revisions that
3176 3194 succeed A. It contains non-obsolete changesets only.
3177 3195
3178 3196 In most cases a changeset A has a single successors set containing a single
3179 3197 successor (changeset A replaced by A').
3180 3198
3181 3199 A changeset that is made obsolete with no successors are called "pruned".
3182 3200 Such changesets have no successors sets at all.
3183 3201
3184 3202 A changeset that has been "split" will have a successors set containing
3185 3203 more than one successor.
3186 3204
3187 3205 A changeset that has been rewritten in multiple different ways is called
3188 3206 "divergent". Such changesets have multiple successor sets (each of which
3189 3207 may also be split, i.e. have multiple successors).
3190 3208
3191 3209 Results are displayed as follows::
3192 3210
3193 3211 <rev1>
3194 3212 <successors-1A>
3195 3213 <rev2>
3196 3214 <successors-2A>
3197 3215 <successors-2B1> <successors-2B2> <successors-2B3>
3198 3216
3199 3217 Here rev2 has two possible (i.e. divergent) successors sets. The first
3200 3218 holds one element, whereas the second holds three (i.e. the changeset has
3201 3219 been split).
3202 3220 """
3203 3221 # passed to successorssets caching computation from one call to another
3204 3222 cache = {}
3205 3223 ctx2str = str
3206 3224 node2str = short
3207 3225 if ui.debug():
3208 3226 def ctx2str(ctx):
3209 3227 return ctx.hex()
3210 3228 node2str = hex
3211 3229 for rev in scmutil.revrange(repo, revs):
3212 3230 ctx = repo[rev]
3213 3231 ui.write('%s\n'% ctx2str(ctx))
3214 3232 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
3215 3233 if succsset:
3216 3234 ui.write(' ')
3217 3235 ui.write(node2str(succsset[0]))
3218 3236 for node in succsset[1:]:
3219 3237 ui.write(' ')
3220 3238 ui.write(node2str(node))
3221 3239 ui.write('\n')
3222 3240
3223 3241 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'), inferrepo=True)
3224 3242 def debugwalk(ui, repo, *pats, **opts):
3225 3243 """show how files match on given patterns"""
3226 3244 m = scmutil.match(repo[None], pats, opts)
3227 3245 items = list(repo.walk(m))
3228 3246 if not items:
3229 3247 return
3230 3248 f = lambda fn: fn
3231 3249 if ui.configbool('ui', 'slash') and os.sep != '/':
3232 3250 f = lambda fn: util.normpath(fn)
3233 3251 fmt = 'f %%-%ds %%-%ds %%s' % (
3234 3252 max([len(abs) for abs in items]),
3235 3253 max([len(m.rel(abs)) for abs in items]))
3236 3254 for abs in items:
3237 3255 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
3238 3256 ui.write("%s\n" % line.rstrip())
3239 3257
3240 3258 @command('debugwireargs',
3241 3259 [('', 'three', '', 'three'),
3242 3260 ('', 'four', '', 'four'),
3243 3261 ('', 'five', '', 'five'),
3244 3262 ] + remoteopts,
3245 3263 _('REPO [OPTIONS]... [ONE [TWO]]'),
3246 3264 norepo=True)
3247 3265 def debugwireargs(ui, repopath, *vals, **opts):
3248 3266 repo = hg.peer(ui, opts, repopath)
3249 3267 for opt in remoteopts:
3250 3268 del opts[opt[1]]
3251 3269 args = {}
3252 3270 for k, v in opts.iteritems():
3253 3271 if v:
3254 3272 args[k] = v
3255 3273 # run twice to check that we don't mess up the stream for the next command
3256 3274 res1 = repo.debugwireargs(*vals, **args)
3257 3275 res2 = repo.debugwireargs(*vals, **args)
3258 3276 ui.write("%s\n" % res1)
3259 3277 if res1 != res2:
3260 3278 ui.warn("%s\n" % res2)
3261 3279
3262 3280 @command('^diff',
3263 3281 [('r', 'rev', [], _('revision'), _('REV')),
3264 3282 ('c', 'change', '', _('change made by revision'), _('REV'))
3265 3283 ] + diffopts + diffopts2 + walkopts + subrepoopts,
3266 3284 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'),
3267 3285 inferrepo=True)
3268 3286 def diff(ui, repo, *pats, **opts):
3269 3287 """diff repository (or selected files)
3270 3288
3271 3289 Show differences between revisions for the specified files.
3272 3290
3273 3291 Differences between files are shown using the unified diff format.
3274 3292
3275 3293 .. note::
3276 3294
3277 3295 diff may generate unexpected results for merges, as it will
3278 3296 default to comparing against the working directory's first
3279 3297 parent changeset if no revisions are specified.
3280 3298
3281 3299 When two revision arguments are given, then changes are shown
3282 3300 between those revisions. If only one revision is specified then
3283 3301 that revision is compared to the working directory, and, when no
3284 3302 revisions are specified, the working directory files are compared
3285 3303 to its parent.
3286 3304
3287 3305 Alternatively you can specify -c/--change with a revision to see
3288 3306 the changes in that changeset relative to its first parent.
3289 3307
3290 3308 Without the -a/--text option, diff will avoid generating diffs of
3291 3309 files it detects as binary. With -a, diff will generate a diff
3292 3310 anyway, probably with undesirable results.
3293 3311
3294 3312 Use the -g/--git option to generate diffs in the git extended diff
3295 3313 format. For more information, read :hg:`help diffs`.
3296 3314
3297 3315 .. container:: verbose
3298 3316
3299 3317 Examples:
3300 3318
3301 3319 - compare a file in the current working directory to its parent::
3302 3320
3303 3321 hg diff foo.c
3304 3322
3305 3323 - compare two historical versions of a directory, with rename info::
3306 3324
3307 3325 hg diff --git -r 1.0:1.2 lib/
3308 3326
3309 3327 - get change stats relative to the last change on some date::
3310 3328
3311 3329 hg diff --stat -r "date('may 2')"
3312 3330
3313 3331 - diff all newly-added files that contain a keyword::
3314 3332
3315 3333 hg diff "set:added() and grep(GNU)"
3316 3334
3317 3335 - compare a revision and its parents::
3318 3336
3319 3337 hg diff -c 9353 # compare against first parent
3320 3338 hg diff -r 9353^:9353 # same using revset syntax
3321 3339 hg diff -r 9353^2:9353 # compare against the second parent
3322 3340
3323 3341 Returns 0 on success.
3324 3342 """
3325 3343
3326 3344 revs = opts.get('rev')
3327 3345 change = opts.get('change')
3328 3346 stat = opts.get('stat')
3329 3347 reverse = opts.get('reverse')
3330 3348
3331 3349 if revs and change:
3332 3350 msg = _('cannot specify --rev and --change at the same time')
3333 3351 raise error.Abort(msg)
3334 3352 elif change:
3335 3353 node2 = scmutil.revsingle(repo, change, None).node()
3336 3354 node1 = repo[node2].p1().node()
3337 3355 else:
3338 3356 node1, node2 = scmutil.revpair(repo, revs)
3339 3357
3340 3358 if reverse:
3341 3359 node1, node2 = node2, node1
3342 3360
3343 3361 diffopts = patch.diffallopts(ui, opts)
3344 3362 m = scmutil.match(repo[node2], pats, opts)
3345 3363 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
3346 3364 listsubrepos=opts.get('subrepos'),
3347 3365 root=opts.get('root'))
3348 3366
3349 3367 @command('^export',
3350 3368 [('o', 'output', '',
3351 3369 _('print output to file with formatted name'), _('FORMAT')),
3352 3370 ('', 'switch-parent', None, _('diff against the second parent')),
3353 3371 ('r', 'rev', [], _('revisions to export'), _('REV')),
3354 3372 ] + diffopts,
3355 3373 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
3356 3374 def export(ui, repo, *changesets, **opts):
3357 3375 """dump the header and diffs for one or more changesets
3358 3376
3359 3377 Print the changeset header and diffs for one or more revisions.
3360 3378 If no revision is given, the parent of the working directory is used.
3361 3379
3362 3380 The information shown in the changeset header is: author, date,
3363 3381 branch name (if non-default), changeset hash, parent(s) and commit
3364 3382 comment.
3365 3383
3366 3384 .. note::
3367 3385
3368 3386 export may generate unexpected diff output for merge
3369 3387 changesets, as it will compare the merge changeset against its
3370 3388 first parent only.
3371 3389
3372 3390 Output may be to a file, in which case the name of the file is
3373 3391 given using a format string. The formatting rules are as follows:
3374 3392
3375 3393 :``%%``: literal "%" character
3376 3394 :``%H``: changeset hash (40 hexadecimal digits)
3377 3395 :``%N``: number of patches being generated
3378 3396 :``%R``: changeset revision number
3379 3397 :``%b``: basename of the exporting repository
3380 3398 :``%h``: short-form changeset hash (12 hexadecimal digits)
3381 3399 :``%m``: first line of the commit message (only alphanumeric characters)
3382 3400 :``%n``: zero-padded sequence number, starting at 1
3383 3401 :``%r``: zero-padded changeset revision number
3384 3402
3385 3403 Without the -a/--text option, export will avoid generating diffs
3386 3404 of files it detects as binary. With -a, export will generate a
3387 3405 diff anyway, probably with undesirable results.
3388 3406
3389 3407 Use the -g/--git option to generate diffs in the git extended diff
3390 3408 format. See :hg:`help diffs` for more information.
3391 3409
3392 3410 With the --switch-parent option, the diff will be against the
3393 3411 second parent. It can be useful to review a merge.
3394 3412
3395 3413 .. container:: verbose
3396 3414
3397 3415 Examples:
3398 3416
3399 3417 - use export and import to transplant a bugfix to the current
3400 3418 branch::
3401 3419
3402 3420 hg export -r 9353 | hg import -
3403 3421
3404 3422 - export all the changesets between two revisions to a file with
3405 3423 rename information::
3406 3424
3407 3425 hg export --git -r 123:150 > changes.txt
3408 3426
3409 3427 - split outgoing changes into a series of patches with
3410 3428 descriptive names::
3411 3429
3412 3430 hg export -r "outgoing()" -o "%n-%m.patch"
3413 3431
3414 3432 Returns 0 on success.
3415 3433 """
3416 3434 changesets += tuple(opts.get('rev', []))
3417 3435 if not changesets:
3418 3436 changesets = ['.']
3419 3437 revs = scmutil.revrange(repo, changesets)
3420 3438 if not revs:
3421 3439 raise error.Abort(_("export requires at least one changeset"))
3422 3440 if len(revs) > 1:
3423 3441 ui.note(_('exporting patches:\n'))
3424 3442 else:
3425 3443 ui.note(_('exporting patch:\n'))
3426 3444 cmdutil.export(repo, revs, template=opts.get('output'),
3427 3445 switch_parent=opts.get('switch_parent'),
3428 3446 opts=patch.diffallopts(ui, opts))
3429 3447
3430 3448 @command('files',
3431 3449 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3432 3450 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3433 3451 ] + walkopts + formatteropts + subrepoopts,
3434 3452 _('[OPTION]... [PATTERN]...'))
3435 3453 def files(ui, repo, *pats, **opts):
3436 3454 """list tracked files
3437 3455
3438 3456 Print files under Mercurial control in the working directory or
3439 3457 specified revision whose names match the given patterns (excluding
3440 3458 removed files).
3441 3459
3442 3460 If no patterns are given to match, this command prints the names
3443 3461 of all files under Mercurial control in the working directory.
3444 3462
3445 3463 .. container:: verbose
3446 3464
3447 3465 Examples:
3448 3466
3449 3467 - list all files under the current directory::
3450 3468
3451 3469 hg files .
3452 3470
3453 3471 - shows sizes and flags for current revision::
3454 3472
3455 3473 hg files -vr .
3456 3474
3457 3475 - list all files named README::
3458 3476
3459 3477 hg files -I "**/README"
3460 3478
3461 3479 - list all binary files::
3462 3480
3463 3481 hg files "set:binary()"
3464 3482
3465 3483 - find files containing a regular expression::
3466 3484
3467 3485 hg files "set:grep('bob')"
3468 3486
3469 3487 - search tracked file contents with xargs and grep::
3470 3488
3471 3489 hg files -0 | xargs -0 grep foo
3472 3490
3473 3491 See :hg:`help patterns` and :hg:`help filesets` for more information
3474 3492 on specifying file patterns.
3475 3493
3476 3494 Returns 0 if a match is found, 1 otherwise.
3477 3495
3478 3496 """
3479 3497 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
3480 3498
3481 3499 end = '\n'
3482 3500 if opts.get('print0'):
3483 3501 end = '\0'
3484 3502 fm = ui.formatter('files', opts)
3485 3503 fmt = '%s' + end
3486 3504
3487 3505 m = scmutil.match(ctx, pats, opts)
3488 3506 ret = cmdutil.files(ui, ctx, m, fm, fmt, opts.get('subrepos'))
3489 3507
3490 3508 fm.end()
3491 3509
3492 3510 return ret
3493 3511
3494 3512 @command('^forget', walkopts, _('[OPTION]... FILE...'), inferrepo=True)
3495 3513 def forget(ui, repo, *pats, **opts):
3496 3514 """forget the specified files on the next commit
3497 3515
3498 3516 Mark the specified files so they will no longer be tracked
3499 3517 after the next commit.
3500 3518
3501 3519 This only removes files from the current branch, not from the
3502 3520 entire project history, and it does not delete them from the
3503 3521 working directory.
3504 3522
3505 3523 To delete the file from the working directory, see :hg:`remove`.
3506 3524
3507 3525 To undo a forget before the next commit, see :hg:`add`.
3508 3526
3509 3527 .. container:: verbose
3510 3528
3511 3529 Examples:
3512 3530
3513 3531 - forget newly-added binary files::
3514 3532
3515 3533 hg forget "set:added() and binary()"
3516 3534
3517 3535 - forget files that would be excluded by .hgignore::
3518 3536
3519 3537 hg forget "set:hgignore()"
3520 3538
3521 3539 Returns 0 on success.
3522 3540 """
3523 3541
3524 3542 if not pats:
3525 3543 raise error.Abort(_('no files specified'))
3526 3544
3527 3545 m = scmutil.match(repo[None], pats, opts)
3528 3546 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3529 3547 return rejected and 1 or 0
3530 3548
3531 3549 @command(
3532 3550 'graft',
3533 3551 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3534 3552 ('c', 'continue', False, _('resume interrupted graft')),
3535 3553 ('e', 'edit', False, _('invoke editor on commit messages')),
3536 3554 ('', 'log', None, _('append graft info to log message')),
3537 3555 ('f', 'force', False, _('force graft')),
3538 3556 ('D', 'currentdate', False,
3539 3557 _('record the current date as commit date')),
3540 3558 ('U', 'currentuser', False,
3541 3559 _('record the current user as committer'), _('DATE'))]
3542 3560 + commitopts2 + mergetoolopts + dryrunopts,
3543 3561 _('[OPTION]... [-r] REV...'))
3544 3562 def graft(ui, repo, *revs, **opts):
3545 3563 '''copy changes from other branches onto the current branch
3546 3564
3547 3565 This command uses Mercurial's merge logic to copy individual
3548 3566 changes from other branches without merging branches in the
3549 3567 history graph. This is sometimes known as 'backporting' or
3550 3568 'cherry-picking'. By default, graft will copy user, date, and
3551 3569 description from the source changesets.
3552 3570
3553 3571 Changesets that are ancestors of the current revision, that have
3554 3572 already been grafted, or that are merges will be skipped.
3555 3573
3556 3574 If --log is specified, log messages will have a comment appended
3557 3575 of the form::
3558 3576
3559 3577 (grafted from CHANGESETHASH)
3560 3578
3561 3579 If --force is specified, revisions will be grafted even if they
3562 3580 are already ancestors of or have been grafted to the destination.
3563 3581 This is useful when the revisions have since been backed out.
3564 3582
3565 3583 If a graft merge results in conflicts, the graft process is
3566 3584 interrupted so that the current merge can be manually resolved.
3567 3585 Once all conflicts are addressed, the graft process can be
3568 3586 continued with the -c/--continue option.
3569 3587
3570 3588 .. note::
3571 3589
3572 3590 The -c/--continue option does not reapply earlier options, except
3573 3591 for --force.
3574 3592
3575 3593 .. container:: verbose
3576 3594
3577 3595 Examples:
3578 3596
3579 3597 - copy a single change to the stable branch and edit its description::
3580 3598
3581 3599 hg update stable
3582 3600 hg graft --edit 9393
3583 3601
3584 3602 - graft a range of changesets with one exception, updating dates::
3585 3603
3586 3604 hg graft -D "2085::2093 and not 2091"
3587 3605
3588 3606 - continue a graft after resolving conflicts::
3589 3607
3590 3608 hg graft -c
3591 3609
3592 3610 - show the source of a grafted changeset::
3593 3611
3594 3612 hg log --debug -r .
3595 3613
3596 3614 See :hg:`help revisions` and :hg:`help revsets` for more about
3597 3615 specifying revisions.
3598 3616
3599 3617 Returns 0 on successful completion.
3600 3618 '''
3601 3619
3602 3620 revs = list(revs)
3603 3621 revs.extend(opts['rev'])
3604 3622
3605 3623 if not opts.get('user') and opts.get('currentuser'):
3606 3624 opts['user'] = ui.username()
3607 3625 if not opts.get('date') and opts.get('currentdate'):
3608 3626 opts['date'] = "%d %d" % util.makedate()
3609 3627
3610 3628 editor = cmdutil.getcommiteditor(editform='graft', **opts)
3611 3629
3612 3630 cont = False
3613 3631 if opts['continue']:
3614 3632 cont = True
3615 3633 if revs:
3616 3634 raise error.Abort(_("can't specify --continue and revisions"))
3617 3635 # read in unfinished revisions
3618 3636 try:
3619 3637 nodes = repo.vfs.read('graftstate').splitlines()
3620 3638 revs = [repo[node].rev() for node in nodes]
3621 3639 except IOError as inst:
3622 3640 if inst.errno != errno.ENOENT:
3623 3641 raise
3624 3642 raise error.Abort(_("no graft state found, can't continue"))
3625 3643 else:
3626 3644 cmdutil.checkunfinished(repo)
3627 3645 cmdutil.bailifchanged(repo)
3628 3646 if not revs:
3629 3647 raise error.Abort(_('no revisions specified'))
3630 3648 revs = scmutil.revrange(repo, revs)
3631 3649
3632 3650 skipped = set()
3633 3651 # check for merges
3634 3652 for rev in repo.revs('%ld and merge()', revs):
3635 3653 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3636 3654 skipped.add(rev)
3637 3655 revs = [r for r in revs if r not in skipped]
3638 3656 if not revs:
3639 3657 return -1
3640 3658
3641 3659 # Don't check in the --continue case, in effect retaining --force across
3642 3660 # --continues. That's because without --force, any revisions we decided to
3643 3661 # skip would have been filtered out here, so they wouldn't have made their
3644 3662 # way to the graftstate. With --force, any revisions we would have otherwise
3645 3663 # skipped would not have been filtered out, and if they hadn't been applied
3646 3664 # already, they'd have been in the graftstate.
3647 3665 if not (cont or opts.get('force')):
3648 3666 # check for ancestors of dest branch
3649 3667 crev = repo['.'].rev()
3650 3668 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3651 3669 # Cannot use x.remove(y) on smart set, this has to be a list.
3652 3670 # XXX make this lazy in the future
3653 3671 revs = list(revs)
3654 3672 # don't mutate while iterating, create a copy
3655 3673 for rev in list(revs):
3656 3674 if rev in ancestors:
3657 3675 ui.warn(_('skipping ancestor revision %d:%s\n') %
3658 3676 (rev, repo[rev]))
3659 3677 # XXX remove on list is slow
3660 3678 revs.remove(rev)
3661 3679 if not revs:
3662 3680 return -1
3663 3681
3664 3682 # analyze revs for earlier grafts
3665 3683 ids = {}
3666 3684 for ctx in repo.set("%ld", revs):
3667 3685 ids[ctx.hex()] = ctx.rev()
3668 3686 n = ctx.extra().get('source')
3669 3687 if n:
3670 3688 ids[n] = ctx.rev()
3671 3689
3672 3690 # check ancestors for earlier grafts
3673 3691 ui.debug('scanning for duplicate grafts\n')
3674 3692
3675 3693 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3676 3694 ctx = repo[rev]
3677 3695 n = ctx.extra().get('source')
3678 3696 if n in ids:
3679 3697 try:
3680 3698 r = repo[n].rev()
3681 3699 except error.RepoLookupError:
3682 3700 r = None
3683 3701 if r in revs:
3684 3702 ui.warn(_('skipping revision %d:%s '
3685 3703 '(already grafted to %d:%s)\n')
3686 3704 % (r, repo[r], rev, ctx))
3687 3705 revs.remove(r)
3688 3706 elif ids[n] in revs:
3689 3707 if r is None:
3690 3708 ui.warn(_('skipping already grafted revision %d:%s '
3691 3709 '(%d:%s also has unknown origin %s)\n')
3692 3710 % (ids[n], repo[ids[n]], rev, ctx, n[:12]))
3693 3711 else:
3694 3712 ui.warn(_('skipping already grafted revision %d:%s '
3695 3713 '(%d:%s also has origin %d:%s)\n')
3696 3714 % (ids[n], repo[ids[n]], rev, ctx, r, n[:12]))
3697 3715 revs.remove(ids[n])
3698 3716 elif ctx.hex() in ids:
3699 3717 r = ids[ctx.hex()]
3700 3718 ui.warn(_('skipping already grafted revision %d:%s '
3701 3719 '(was grafted from %d:%s)\n') %
3702 3720 (r, repo[r], rev, ctx))
3703 3721 revs.remove(r)
3704 3722 if not revs:
3705 3723 return -1
3706 3724
3707 3725 wlock = repo.wlock()
3708 3726 try:
3709 3727 for pos, ctx in enumerate(repo.set("%ld", revs)):
3710 3728 desc = '%d:%s "%s"' % (ctx.rev(), ctx,
3711 3729 ctx.description().split('\n', 1)[0])
3712 3730 names = repo.nodetags(ctx.node()) + repo.nodebookmarks(ctx.node())
3713 3731 if names:
3714 3732 desc += ' (%s)' % ' '.join(names)
3715 3733 ui.status(_('grafting %s\n') % desc)
3716 3734 if opts.get('dry_run'):
3717 3735 continue
3718 3736
3719 3737 source = ctx.extra().get('source')
3720 3738 extra = {}
3721 3739 if source:
3722 3740 extra['source'] = source
3723 3741 extra['intermediate-source'] = ctx.hex()
3724 3742 else:
3725 3743 extra['source'] = ctx.hex()
3726 3744 user = ctx.user()
3727 3745 if opts.get('user'):
3728 3746 user = opts['user']
3729 3747 date = ctx.date()
3730 3748 if opts.get('date'):
3731 3749 date = opts['date']
3732 3750 message = ctx.description()
3733 3751 if opts.get('log'):
3734 3752 message += '\n(grafted from %s)' % ctx.hex()
3735 3753
3736 3754 # we don't merge the first commit when continuing
3737 3755 if not cont:
3738 3756 # perform the graft merge with p1(rev) as 'ancestor'
3739 3757 try:
3740 3758 # ui.forcemerge is an internal variable, do not document
3741 3759 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3742 3760 'graft')
3743 3761 stats = mergemod.graft(repo, ctx, ctx.p1(),
3744 3762 ['local', 'graft'])
3745 3763 finally:
3746 3764 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3747 3765 # report any conflicts
3748 3766 if stats and stats[3] > 0:
3749 3767 # write out state for --continue
3750 3768 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3751 3769 repo.vfs.write('graftstate', ''.join(nodelines))
3752 3770 raise error.Abort(
3753 3771 _("unresolved conflicts, can't continue"),
3754 3772 hint=_('use hg resolve and hg graft --continue'))
3755 3773 else:
3756 3774 cont = False
3757 3775
3758 3776 # commit
3759 3777 node = repo.commit(text=message, user=user,
3760 3778 date=date, extra=extra, editor=editor)
3761 3779 if node is None:
3762 3780 ui.warn(
3763 3781 _('note: graft of %d:%s created no changes to commit\n') %
3764 3782 (ctx.rev(), ctx))
3765 3783 finally:
3766 3784 wlock.release()
3767 3785
3768 3786 # remove state when we complete successfully
3769 3787 if not opts.get('dry_run'):
3770 3788 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3771 3789
3772 3790 return 0
3773 3791
3774 3792 @command('grep',
3775 3793 [('0', 'print0', None, _('end fields with NUL')),
3776 3794 ('', 'all', None, _('print all revisions that match')),
3777 3795 ('a', 'text', None, _('treat all files as text')),
3778 3796 ('f', 'follow', None,
3779 3797 _('follow changeset history,'
3780 3798 ' or file history across copies and renames')),
3781 3799 ('i', 'ignore-case', None, _('ignore case when matching')),
3782 3800 ('l', 'files-with-matches', None,
3783 3801 _('print only filenames and revisions that match')),
3784 3802 ('n', 'line-number', None, _('print matching line numbers')),
3785 3803 ('r', 'rev', [],
3786 3804 _('only search files changed within revision range'), _('REV')),
3787 3805 ('u', 'user', None, _('list the author (long with -v)')),
3788 3806 ('d', 'date', None, _('list the date (short with -q)')),
3789 3807 ] + walkopts,
3790 3808 _('[OPTION]... PATTERN [FILE]...'),
3791 3809 inferrepo=True)
3792 3810 def grep(ui, repo, pattern, *pats, **opts):
3793 3811 """search for a pattern in specified files and revisions
3794 3812
3795 3813 Search revisions of files for a regular expression.
3796 3814
3797 3815 This command behaves differently than Unix grep. It only accepts
3798 3816 Python/Perl regexps. It searches repository history, not the
3799 3817 working directory. It always prints the revision number in which a
3800 3818 match appears.
3801 3819
3802 3820 By default, grep only prints output for the first revision of a
3803 3821 file in which it finds a match. To get it to print every revision
3804 3822 that contains a change in match status ("-" for a match that
3805 3823 becomes a non-match, or "+" for a non-match that becomes a match),
3806 3824 use the --all flag.
3807 3825
3808 3826 Returns 0 if a match is found, 1 otherwise.
3809 3827 """
3810 3828 reflags = re.M
3811 3829 if opts.get('ignore_case'):
3812 3830 reflags |= re.I
3813 3831 try:
3814 3832 regexp = util.re.compile(pattern, reflags)
3815 3833 except re.error as inst:
3816 3834 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3817 3835 return 1
3818 3836 sep, eol = ':', '\n'
3819 3837 if opts.get('print0'):
3820 3838 sep = eol = '\0'
3821 3839
3822 3840 getfile = util.lrucachefunc(repo.file)
3823 3841
3824 3842 def matchlines(body):
3825 3843 begin = 0
3826 3844 linenum = 0
3827 3845 while begin < len(body):
3828 3846 match = regexp.search(body, begin)
3829 3847 if not match:
3830 3848 break
3831 3849 mstart, mend = match.span()
3832 3850 linenum += body.count('\n', begin, mstart) + 1
3833 3851 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3834 3852 begin = body.find('\n', mend) + 1 or len(body) + 1
3835 3853 lend = begin - 1
3836 3854 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3837 3855
3838 3856 class linestate(object):
3839 3857 def __init__(self, line, linenum, colstart, colend):
3840 3858 self.line = line
3841 3859 self.linenum = linenum
3842 3860 self.colstart = colstart
3843 3861 self.colend = colend
3844 3862
3845 3863 def __hash__(self):
3846 3864 return hash((self.linenum, self.line))
3847 3865
3848 3866 def __eq__(self, other):
3849 3867 return self.line == other.line
3850 3868
3851 3869 def __iter__(self):
3852 3870 yield (self.line[:self.colstart], '')
3853 3871 yield (self.line[self.colstart:self.colend], 'grep.match')
3854 3872 rest = self.line[self.colend:]
3855 3873 while rest != '':
3856 3874 match = regexp.search(rest)
3857 3875 if not match:
3858 3876 yield (rest, '')
3859 3877 break
3860 3878 mstart, mend = match.span()
3861 3879 yield (rest[:mstart], '')
3862 3880 yield (rest[mstart:mend], 'grep.match')
3863 3881 rest = rest[mend:]
3864 3882
3865 3883 matches = {}
3866 3884 copies = {}
3867 3885 def grepbody(fn, rev, body):
3868 3886 matches[rev].setdefault(fn, [])
3869 3887 m = matches[rev][fn]
3870 3888 for lnum, cstart, cend, line in matchlines(body):
3871 3889 s = linestate(line, lnum, cstart, cend)
3872 3890 m.append(s)
3873 3891
3874 3892 def difflinestates(a, b):
3875 3893 sm = difflib.SequenceMatcher(None, a, b)
3876 3894 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3877 3895 if tag == 'insert':
3878 3896 for i in xrange(blo, bhi):
3879 3897 yield ('+', b[i])
3880 3898 elif tag == 'delete':
3881 3899 for i in xrange(alo, ahi):
3882 3900 yield ('-', a[i])
3883 3901 elif tag == 'replace':
3884 3902 for i in xrange(alo, ahi):
3885 3903 yield ('-', a[i])
3886 3904 for i in xrange(blo, bhi):
3887 3905 yield ('+', b[i])
3888 3906
3889 3907 def display(fn, ctx, pstates, states):
3890 3908 rev = ctx.rev()
3891 3909 if ui.quiet:
3892 3910 datefunc = util.shortdate
3893 3911 else:
3894 3912 datefunc = util.datestr
3895 3913 found = False
3896 3914 @util.cachefunc
3897 3915 def binary():
3898 3916 flog = getfile(fn)
3899 3917 return util.binary(flog.read(ctx.filenode(fn)))
3900 3918
3901 3919 if opts.get('all'):
3902 3920 iter = difflinestates(pstates, states)
3903 3921 else:
3904 3922 iter = [('', l) for l in states]
3905 3923 for change, l in iter:
3906 3924 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3907 3925
3908 3926 if opts.get('line_number'):
3909 3927 cols.append((str(l.linenum), 'grep.linenumber'))
3910 3928 if opts.get('all'):
3911 3929 cols.append((change, 'grep.change'))
3912 3930 if opts.get('user'):
3913 3931 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3914 3932 if opts.get('date'):
3915 3933 cols.append((datefunc(ctx.date()), 'grep.date'))
3916 3934 for col, label in cols[:-1]:
3917 3935 ui.write(col, label=label)
3918 3936 ui.write(sep, label='grep.sep')
3919 3937 ui.write(cols[-1][0], label=cols[-1][1])
3920 3938 if not opts.get('files_with_matches'):
3921 3939 ui.write(sep, label='grep.sep')
3922 3940 if not opts.get('text') and binary():
3923 3941 ui.write(" Binary file matches")
3924 3942 else:
3925 3943 for s, label in l:
3926 3944 ui.write(s, label=label)
3927 3945 ui.write(eol)
3928 3946 found = True
3929 3947 if opts.get('files_with_matches'):
3930 3948 break
3931 3949 return found
3932 3950
3933 3951 skip = {}
3934 3952 revfiles = {}
3935 3953 matchfn = scmutil.match(repo[None], pats, opts)
3936 3954 found = False
3937 3955 follow = opts.get('follow')
3938 3956
3939 3957 def prep(ctx, fns):
3940 3958 rev = ctx.rev()
3941 3959 pctx = ctx.p1()
3942 3960 parent = pctx.rev()
3943 3961 matches.setdefault(rev, {})
3944 3962 matches.setdefault(parent, {})
3945 3963 files = revfiles.setdefault(rev, [])
3946 3964 for fn in fns:
3947 3965 flog = getfile(fn)
3948 3966 try:
3949 3967 fnode = ctx.filenode(fn)
3950 3968 except error.LookupError:
3951 3969 continue
3952 3970
3953 3971 copied = flog.renamed(fnode)
3954 3972 copy = follow and copied and copied[0]
3955 3973 if copy:
3956 3974 copies.setdefault(rev, {})[fn] = copy
3957 3975 if fn in skip:
3958 3976 if copy:
3959 3977 skip[copy] = True
3960 3978 continue
3961 3979 files.append(fn)
3962 3980
3963 3981 if fn not in matches[rev]:
3964 3982 grepbody(fn, rev, flog.read(fnode))
3965 3983
3966 3984 pfn = copy or fn
3967 3985 if pfn not in matches[parent]:
3968 3986 try:
3969 3987 fnode = pctx.filenode(pfn)
3970 3988 grepbody(pfn, parent, flog.read(fnode))
3971 3989 except error.LookupError:
3972 3990 pass
3973 3991
3974 3992 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3975 3993 rev = ctx.rev()
3976 3994 parent = ctx.p1().rev()
3977 3995 for fn in sorted(revfiles.get(rev, [])):
3978 3996 states = matches[rev][fn]
3979 3997 copy = copies.get(rev, {}).get(fn)
3980 3998 if fn in skip:
3981 3999 if copy:
3982 4000 skip[copy] = True
3983 4001 continue
3984 4002 pstates = matches.get(parent, {}).get(copy or fn, [])
3985 4003 if pstates or states:
3986 4004 r = display(fn, ctx, pstates, states)
3987 4005 found = found or r
3988 4006 if r and not opts.get('all'):
3989 4007 skip[fn] = True
3990 4008 if copy:
3991 4009 skip[copy] = True
3992 4010 del matches[rev]
3993 4011 del revfiles[rev]
3994 4012
3995 4013 return not found
3996 4014
3997 4015 @command('heads',
3998 4016 [('r', 'rev', '',
3999 4017 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
4000 4018 ('t', 'topo', False, _('show topological heads only')),
4001 4019 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
4002 4020 ('c', 'closed', False, _('show normal and closed branch heads')),
4003 4021 ] + templateopts,
4004 4022 _('[-ct] [-r STARTREV] [REV]...'))
4005 4023 def heads(ui, repo, *branchrevs, **opts):
4006 4024 """show branch heads
4007 4025
4008 4026 With no arguments, show all open branch heads in the repository.
4009 4027 Branch heads are changesets that have no descendants on the
4010 4028 same branch. They are where development generally takes place and
4011 4029 are the usual targets for update and merge operations.
4012 4030
4013 4031 If one or more REVs are given, only open branch heads on the
4014 4032 branches associated with the specified changesets are shown. This
4015 4033 means that you can use :hg:`heads .` to see the heads on the
4016 4034 currently checked-out branch.
4017 4035
4018 4036 If -c/--closed is specified, also show branch heads marked closed
4019 4037 (see :hg:`commit --close-branch`).
4020 4038
4021 4039 If STARTREV is specified, only those heads that are descendants of
4022 4040 STARTREV will be displayed.
4023 4041
4024 4042 If -t/--topo is specified, named branch mechanics will be ignored and only
4025 4043 topological heads (changesets with no children) will be shown.
4026 4044
4027 4045 Returns 0 if matching heads are found, 1 if not.
4028 4046 """
4029 4047
4030 4048 start = None
4031 4049 if 'rev' in opts:
4032 4050 start = scmutil.revsingle(repo, opts['rev'], None).node()
4033 4051
4034 4052 if opts.get('topo'):
4035 4053 heads = [repo[h] for h in repo.heads(start)]
4036 4054 else:
4037 4055 heads = []
4038 4056 for branch in repo.branchmap():
4039 4057 heads += repo.branchheads(branch, start, opts.get('closed'))
4040 4058 heads = [repo[h] for h in heads]
4041 4059
4042 4060 if branchrevs:
4043 4061 branches = set(repo[br].branch() for br in branchrevs)
4044 4062 heads = [h for h in heads if h.branch() in branches]
4045 4063
4046 4064 if opts.get('active') and branchrevs:
4047 4065 dagheads = repo.heads(start)
4048 4066 heads = [h for h in heads if h.node() in dagheads]
4049 4067
4050 4068 if branchrevs:
4051 4069 haveheads = set(h.branch() for h in heads)
4052 4070 if branches - haveheads:
4053 4071 headless = ', '.join(b for b in branches - haveheads)
4054 4072 msg = _('no open branch heads found on branches %s')
4055 4073 if opts.get('rev'):
4056 4074 msg += _(' (started at %s)') % opts['rev']
4057 4075 ui.warn((msg + '\n') % headless)
4058 4076
4059 4077 if not heads:
4060 4078 return 1
4061 4079
4062 4080 heads = sorted(heads, key=lambda x: -x.rev())
4063 4081 displayer = cmdutil.show_changeset(ui, repo, opts)
4064 4082 for ctx in heads:
4065 4083 displayer.show(ctx)
4066 4084 displayer.close()
4067 4085
4068 4086 @command('help',
4069 4087 [('e', 'extension', None, _('show only help for extensions')),
4070 4088 ('c', 'command', None, _('show only help for commands')),
4071 4089 ('k', 'keyword', None, _('show topics matching keyword')),
4072 4090 ],
4073 4091 _('[-eck] [TOPIC]'),
4074 4092 norepo=True)
4075 4093 def help_(ui, name=None, **opts):
4076 4094 """show help for a given topic or a help overview
4077 4095
4078 4096 With no arguments, print a list of commands with short help messages.
4079 4097
4080 4098 Given a topic, extension, or command name, print help for that
4081 4099 topic.
4082 4100
4083 4101 Returns 0 if successful.
4084 4102 """
4085 4103
4086 4104 textwidth = min(ui.termwidth(), 80) - 2
4087 4105
4088 4106 keep = []
4089 4107 if ui.verbose:
4090 4108 keep.append('verbose')
4091 4109 if sys.platform.startswith('win'):
4092 4110 keep.append('windows')
4093 4111 elif sys.platform == 'OpenVMS':
4094 4112 keep.append('vms')
4095 4113 elif sys.platform == 'plan9':
4096 4114 keep.append('plan9')
4097 4115 else:
4098 4116 keep.append('unix')
4099 4117 keep.append(sys.platform.lower())
4100 4118
4101 4119 section = None
4102 4120 if name and '.' in name:
4103 4121 name, section = name.split('.', 1)
4104 4122 section = section.lower()
4105 4123
4106 4124 text = help.help_(ui, name, **opts)
4107 4125
4108 4126 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4109 4127 section=section)
4110 4128
4111 4129 # We could have been given a weird ".foo" section without a name
4112 4130 # to look for, or we could have simply failed to found "foo.bar"
4113 4131 # because bar isn't a section of foo
4114 4132 if section and not (formatted and name):
4115 4133 raise error.Abort(_("help section not found"))
4116 4134
4117 4135 if 'verbose' in pruned:
4118 4136 keep.append('omitted')
4119 4137 else:
4120 4138 keep.append('notomitted')
4121 4139 formatted, pruned = minirst.format(text, textwidth, keep=keep,
4122 4140 section=section)
4123 4141 ui.write(formatted)
4124 4142
4125 4143
4126 4144 @command('identify|id',
4127 4145 [('r', 'rev', '',
4128 4146 _('identify the specified revision'), _('REV')),
4129 4147 ('n', 'num', None, _('show local revision number')),
4130 4148 ('i', 'id', None, _('show global revision id')),
4131 4149 ('b', 'branch', None, _('show branch')),
4132 4150 ('t', 'tags', None, _('show tags')),
4133 4151 ('B', 'bookmarks', None, _('show bookmarks')),
4134 4152 ] + remoteopts,
4135 4153 _('[-nibtB] [-r REV] [SOURCE]'),
4136 4154 optionalrepo=True)
4137 4155 def identify(ui, repo, source=None, rev=None,
4138 4156 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
4139 4157 """identify the working directory or specified revision
4140 4158
4141 4159 Print a summary identifying the repository state at REV using one or
4142 4160 two parent hash identifiers, followed by a "+" if the working
4143 4161 directory has uncommitted changes, the branch name (if not default),
4144 4162 a list of tags, and a list of bookmarks.
4145 4163
4146 4164 When REV is not given, print a summary of the current state of the
4147 4165 repository.
4148 4166
4149 4167 Specifying a path to a repository root or Mercurial bundle will
4150 4168 cause lookup to operate on that repository/bundle.
4151 4169
4152 4170 .. container:: verbose
4153 4171
4154 4172 Examples:
4155 4173
4156 4174 - generate a build identifier for the working directory::
4157 4175
4158 4176 hg id --id > build-id.dat
4159 4177
4160 4178 - find the revision corresponding to a tag::
4161 4179
4162 4180 hg id -n -r 1.3
4163 4181
4164 4182 - check the most recent revision of a remote repository::
4165 4183
4166 4184 hg id -r tip http://selenic.com/hg/
4167 4185
4168 4186 Returns 0 if successful.
4169 4187 """
4170 4188
4171 4189 if not repo and not source:
4172 4190 raise error.Abort(_("there is no Mercurial repository here "
4173 4191 "(.hg not found)"))
4174 4192
4175 4193 if ui.debugflag:
4176 4194 hexfunc = hex
4177 4195 else:
4178 4196 hexfunc = short
4179 4197 default = not (num or id or branch or tags or bookmarks)
4180 4198 output = []
4181 4199 revs = []
4182 4200
4183 4201 if source:
4184 4202 source, branches = hg.parseurl(ui.expandpath(source))
4185 4203 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
4186 4204 repo = peer.local()
4187 4205 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
4188 4206
4189 4207 if not repo:
4190 4208 if num or branch or tags:
4191 4209 raise error.Abort(
4192 4210 _("can't query remote revision number, branch, or tags"))
4193 4211 if not rev and revs:
4194 4212 rev = revs[0]
4195 4213 if not rev:
4196 4214 rev = "tip"
4197 4215
4198 4216 remoterev = peer.lookup(rev)
4199 4217 if default or id:
4200 4218 output = [hexfunc(remoterev)]
4201 4219
4202 4220 def getbms():
4203 4221 bms = []
4204 4222
4205 4223 if 'bookmarks' in peer.listkeys('namespaces'):
4206 4224 hexremoterev = hex(remoterev)
4207 4225 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
4208 4226 if bmr == hexremoterev]
4209 4227
4210 4228 return sorted(bms)
4211 4229
4212 4230 if bookmarks:
4213 4231 output.extend(getbms())
4214 4232 elif default and not ui.quiet:
4215 4233 # multiple bookmarks for a single parent separated by '/'
4216 4234 bm = '/'.join(getbms())
4217 4235 if bm:
4218 4236 output.append(bm)
4219 4237 else:
4220 4238 ctx = scmutil.revsingle(repo, rev, None)
4221 4239
4222 4240 if ctx.rev() is None:
4223 4241 ctx = repo[None]
4224 4242 parents = ctx.parents()
4225 4243 taglist = []
4226 4244 for p in parents:
4227 4245 taglist.extend(p.tags())
4228 4246
4229 4247 changed = ""
4230 4248 if default or id or num:
4231 4249 if (any(repo.status())
4232 4250 or any(ctx.sub(s).dirty() for s in ctx.substate)):
4233 4251 changed = '+'
4234 4252 if default or id:
4235 4253 output = ["%s%s" %
4236 4254 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
4237 4255 if num:
4238 4256 output.append("%s%s" %
4239 4257 ('+'.join([str(p.rev()) for p in parents]), changed))
4240 4258 else:
4241 4259 if default or id:
4242 4260 output = [hexfunc(ctx.node())]
4243 4261 if num:
4244 4262 output.append(str(ctx.rev()))
4245 4263 taglist = ctx.tags()
4246 4264
4247 4265 if default and not ui.quiet:
4248 4266 b = ctx.branch()
4249 4267 if b != 'default':
4250 4268 output.append("(%s)" % b)
4251 4269
4252 4270 # multiple tags for a single parent separated by '/'
4253 4271 t = '/'.join(taglist)
4254 4272 if t:
4255 4273 output.append(t)
4256 4274
4257 4275 # multiple bookmarks for a single parent separated by '/'
4258 4276 bm = '/'.join(ctx.bookmarks())
4259 4277 if bm:
4260 4278 output.append(bm)
4261 4279 else:
4262 4280 if branch:
4263 4281 output.append(ctx.branch())
4264 4282
4265 4283 if tags:
4266 4284 output.extend(taglist)
4267 4285
4268 4286 if bookmarks:
4269 4287 output.extend(ctx.bookmarks())
4270 4288
4271 4289 ui.write("%s\n" % ' '.join(output))
4272 4290
4273 4291 @command('import|patch',
4274 4292 [('p', 'strip', 1,
4275 4293 _('directory strip option for patch. This has the same '
4276 4294 'meaning as the corresponding patch option'), _('NUM')),
4277 4295 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
4278 4296 ('e', 'edit', False, _('invoke editor on commit messages')),
4279 4297 ('f', 'force', None,
4280 4298 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
4281 4299 ('', 'no-commit', None,
4282 4300 _("don't commit, just update the working directory")),
4283 4301 ('', 'bypass', None,
4284 4302 _("apply patch without touching the working directory")),
4285 4303 ('', 'partial', None,
4286 4304 _('commit even if some hunks fail')),
4287 4305 ('', 'exact', None,
4288 4306 _('apply patch to the nodes from which it was generated')),
4289 4307 ('', 'prefix', '',
4290 4308 _('apply patch to subdirectory'), _('DIR')),
4291 4309 ('', 'import-branch', None,
4292 4310 _('use any branch information in patch (implied by --exact)'))] +
4293 4311 commitopts + commitopts2 + similarityopts,
4294 4312 _('[OPTION]... PATCH...'))
4295 4313 def import_(ui, repo, patch1=None, *patches, **opts):
4296 4314 """import an ordered set of patches
4297 4315
4298 4316 Import a list of patches and commit them individually (unless
4299 4317 --no-commit is specified).
4300 4318
4301 4319 Because import first applies changes to the working directory,
4302 4320 import will abort if there are outstanding changes.
4303 4321
4304 4322 You can import a patch straight from a mail message. Even patches
4305 4323 as attachments work (to use the body part, it must have type
4306 4324 text/plain or text/x-patch). From and Subject headers of email
4307 4325 message are used as default committer and commit message. All
4308 4326 text/plain body parts before first diff are added to commit
4309 4327 message.
4310 4328
4311 4329 If the imported patch was generated by :hg:`export`, user and
4312 4330 description from patch override values from message headers and
4313 4331 body. Values given on command line with -m/--message and -u/--user
4314 4332 override these.
4315 4333
4316 4334 If --exact is specified, import will set the working directory to
4317 4335 the parent of each patch before applying it, and will abort if the
4318 4336 resulting changeset has a different ID than the one recorded in
4319 4337 the patch. This may happen due to character set problems or other
4320 4338 deficiencies in the text patch format.
4321 4339
4322 4340 Use --bypass to apply and commit patches directly to the
4323 4341 repository, not touching the working directory. Without --exact,
4324 4342 patches will be applied on top of the working directory parent
4325 4343 revision.
4326 4344
4327 4345 With -s/--similarity, hg will attempt to discover renames and
4328 4346 copies in the patch in the same way as :hg:`addremove`.
4329 4347
4330 4348 Use --partial to ensure a changeset will be created from the patch
4331 4349 even if some hunks fail to apply. Hunks that fail to apply will be
4332 4350 written to a <target-file>.rej file. Conflicts can then be resolved
4333 4351 by hand before :hg:`commit --amend` is run to update the created
4334 4352 changeset. This flag exists to let people import patches that
4335 4353 partially apply without losing the associated metadata (author,
4336 4354 date, description, ...). Note that when none of the hunk applies
4337 4355 cleanly, :hg:`import --partial` will create an empty changeset,
4338 4356 importing only the patch metadata.
4339 4357
4340 4358 It is possible to use external patch programs to perform the patch
4341 4359 by setting the ``ui.patch`` configuration option. For the default
4342 4360 internal tool, the fuzz can also be configured via ``patch.fuzz``.
4343 4361 See :hg:`help config` for more information about configuration
4344 4362 files and how to use these options.
4345 4363
4346 4364 To read a patch from standard input, use "-" as the patch name. If
4347 4365 a URL is specified, the patch will be downloaded from it.
4348 4366 See :hg:`help dates` for a list of formats valid for -d/--date.
4349 4367
4350 4368 .. container:: verbose
4351 4369
4352 4370 Examples:
4353 4371
4354 4372 - import a traditional patch from a website and detect renames::
4355 4373
4356 4374 hg import -s 80 http://example.com/bugfix.patch
4357 4375
4358 4376 - import a changeset from an hgweb server::
4359 4377
4360 4378 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
4361 4379
4362 4380 - import all the patches in an Unix-style mbox::
4363 4381
4364 4382 hg import incoming-patches.mbox
4365 4383
4366 4384 - attempt to exactly restore an exported changeset (not always
4367 4385 possible)::
4368 4386
4369 4387 hg import --exact proposed-fix.patch
4370 4388
4371 4389 - use an external tool to apply a patch which is too fuzzy for
4372 4390 the default internal tool.
4373 4391
4374 4392 hg import --config ui.patch="patch --merge" fuzzy.patch
4375 4393
4376 4394 - change the default fuzzing from 2 to a less strict 7
4377 4395
4378 4396 hg import --config ui.fuzz=7 fuzz.patch
4379 4397
4380 4398 Returns 0 on success, 1 on partial success (see --partial).
4381 4399 """
4382 4400
4383 4401 if not patch1:
4384 4402 raise error.Abort(_('need at least one patch to import'))
4385 4403
4386 4404 patches = (patch1,) + patches
4387 4405
4388 4406 date = opts.get('date')
4389 4407 if date:
4390 4408 opts['date'] = util.parsedate(date)
4391 4409
4392 4410 update = not opts.get('bypass')
4393 4411 if not update and opts.get('no_commit'):
4394 4412 raise error.Abort(_('cannot use --no-commit with --bypass'))
4395 4413 try:
4396 4414 sim = float(opts.get('similarity') or 0)
4397 4415 except ValueError:
4398 4416 raise error.Abort(_('similarity must be a number'))
4399 4417 if sim < 0 or sim > 100:
4400 4418 raise error.Abort(_('similarity must be between 0 and 100'))
4401 4419 if sim and not update:
4402 4420 raise error.Abort(_('cannot use --similarity with --bypass'))
4403 4421 if opts.get('exact') and opts.get('edit'):
4404 4422 raise error.Abort(_('cannot use --exact with --edit'))
4405 4423 if opts.get('exact') and opts.get('prefix'):
4406 4424 raise error.Abort(_('cannot use --exact with --prefix'))
4407 4425
4408 4426 if update:
4409 4427 cmdutil.checkunfinished(repo)
4410 4428 if (opts.get('exact') or not opts.get('force')) and update:
4411 4429 cmdutil.bailifchanged(repo)
4412 4430
4413 4431 base = opts["base"]
4414 4432 wlock = dsguard = lock = tr = None
4415 4433 msgs = []
4416 4434 ret = 0
4417 4435
4418 4436
4419 4437 try:
4420 4438 try:
4421 4439 wlock = repo.wlock()
4422 4440 if not opts.get('no_commit'):
4423 4441 lock = repo.lock()
4424 4442 tr = repo.transaction('import')
4425 4443 else:
4426 4444 dsguard = cmdutil.dirstateguard(repo, 'import')
4427 4445 parents = repo.parents()
4428 4446 for patchurl in patches:
4429 4447 if patchurl == '-':
4430 4448 ui.status(_('applying patch from stdin\n'))
4431 4449 patchfile = ui.fin
4432 4450 patchurl = 'stdin' # for error message
4433 4451 else:
4434 4452 patchurl = os.path.join(base, patchurl)
4435 4453 ui.status(_('applying %s\n') % patchurl)
4436 4454 patchfile = hg.openpath(ui, patchurl)
4437 4455
4438 4456 haspatch = False
4439 4457 for hunk in patch.split(patchfile):
4440 4458 (msg, node, rej) = cmdutil.tryimportone(ui, repo, hunk,
4441 4459 parents, opts,
4442 4460 msgs, hg.clean)
4443 4461 if msg:
4444 4462 haspatch = True
4445 4463 ui.note(msg + '\n')
4446 4464 if update or opts.get('exact'):
4447 4465 parents = repo.parents()
4448 4466 else:
4449 4467 parents = [repo[node]]
4450 4468 if rej:
4451 4469 ui.write_err(_("patch applied partially\n"))
4452 4470 ui.write_err(_("(fix the .rej files and run "
4453 4471 "`hg commit --amend`)\n"))
4454 4472 ret = 1
4455 4473 break
4456 4474
4457 4475 if not haspatch:
4458 4476 raise error.Abort(_('%s: no diffs found') % patchurl)
4459 4477
4460 4478 if tr:
4461 4479 tr.close()
4462 4480 if msgs:
4463 4481 repo.savecommitmessage('\n* * *\n'.join(msgs))
4464 4482 if dsguard:
4465 4483 dsguard.close()
4466 4484 return ret
4467 4485 finally:
4468 4486 # TODO: get rid of this meaningless try/finally enclosing.
4469 4487 # this is kept only to reduce changes in a patch.
4470 4488 pass
4471 4489 finally:
4472 4490 if tr:
4473 4491 tr.release()
4474 4492 release(lock, dsguard, wlock)
4475 4493
4476 4494 @command('incoming|in',
4477 4495 [('f', 'force', None,
4478 4496 _('run even if remote repository is unrelated')),
4479 4497 ('n', 'newest-first', None, _('show newest record first')),
4480 4498 ('', 'bundle', '',
4481 4499 _('file to store the bundles into'), _('FILE')),
4482 4500 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4483 4501 ('B', 'bookmarks', False, _("compare bookmarks")),
4484 4502 ('b', 'branch', [],
4485 4503 _('a specific branch you would like to pull'), _('BRANCH')),
4486 4504 ] + logopts + remoteopts + subrepoopts,
4487 4505 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
4488 4506 def incoming(ui, repo, source="default", **opts):
4489 4507 """show new changesets found in source
4490 4508
4491 4509 Show new changesets found in the specified path/URL or the default
4492 4510 pull location. These are the changesets that would have been pulled
4493 4511 if a pull at the time you issued this command.
4494 4512
4495 4513 See pull for valid source format details.
4496 4514
4497 4515 .. container:: verbose
4498 4516
4499 4517 With -B/--bookmarks, the result of bookmark comparison between
4500 4518 local and remote repositories is displayed. With -v/--verbose,
4501 4519 status is also displayed for each bookmark like below::
4502 4520
4503 4521 BM1 01234567890a added
4504 4522 BM2 1234567890ab advanced
4505 4523 BM3 234567890abc diverged
4506 4524 BM4 34567890abcd changed
4507 4525
4508 4526 The action taken locally when pulling depends on the
4509 4527 status of each bookmark:
4510 4528
4511 4529 :``added``: pull will create it
4512 4530 :``advanced``: pull will update it
4513 4531 :``diverged``: pull will create a divergent bookmark
4514 4532 :``changed``: result depends on remote changesets
4515 4533
4516 4534 From the point of view of pulling behavior, bookmark
4517 4535 existing only in the remote repository are treated as ``added``,
4518 4536 even if it is in fact locally deleted.
4519 4537
4520 4538 .. container:: verbose
4521 4539
4522 4540 For remote repository, using --bundle avoids downloading the
4523 4541 changesets twice if the incoming is followed by a pull.
4524 4542
4525 4543 Examples:
4526 4544
4527 4545 - show incoming changes with patches and full description::
4528 4546
4529 4547 hg incoming -vp
4530 4548
4531 4549 - show incoming changes excluding merges, store a bundle::
4532 4550
4533 4551 hg in -vpM --bundle incoming.hg
4534 4552 hg pull incoming.hg
4535 4553
4536 4554 - briefly list changes inside a bundle::
4537 4555
4538 4556 hg in changes.hg -T "{desc|firstline}\\n"
4539 4557
4540 4558 Returns 0 if there are incoming changes, 1 otherwise.
4541 4559 """
4542 4560 if opts.get('graph'):
4543 4561 cmdutil.checkunsupportedgraphflags([], opts)
4544 4562 def display(other, chlist, displayer):
4545 4563 revdag = cmdutil.graphrevs(other, chlist, opts)
4546 4564 showparents = [ctx.node() for ctx in repo[None].parents()]
4547 4565 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4548 4566 graphmod.asciiedges)
4549 4567
4550 4568 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
4551 4569 return 0
4552 4570
4553 4571 if opts.get('bundle') and opts.get('subrepos'):
4554 4572 raise error.Abort(_('cannot combine --bundle and --subrepos'))
4555 4573
4556 4574 if opts.get('bookmarks'):
4557 4575 source, branches = hg.parseurl(ui.expandpath(source),
4558 4576 opts.get('branch'))
4559 4577 other = hg.peer(repo, opts, source)
4560 4578 if 'bookmarks' not in other.listkeys('namespaces'):
4561 4579 ui.warn(_("remote doesn't support bookmarks\n"))
4562 4580 return 0
4563 4581 ui.status(_('comparing with %s\n') % util.hidepassword(source))
4564 4582 return bookmarks.incoming(ui, repo, other)
4565 4583
4566 4584 repo._subtoppath = ui.expandpath(source)
4567 4585 try:
4568 4586 return hg.incoming(ui, repo, source, opts)
4569 4587 finally:
4570 4588 del repo._subtoppath
4571 4589
4572 4590
4573 4591 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'),
4574 4592 norepo=True)
4575 4593 def init(ui, dest=".", **opts):
4576 4594 """create a new repository in the given directory
4577 4595
4578 4596 Initialize a new repository in the given directory. If the given
4579 4597 directory does not exist, it will be created.
4580 4598
4581 4599 If no directory is given, the current directory is used.
4582 4600
4583 4601 It is possible to specify an ``ssh://`` URL as the destination.
4584 4602 See :hg:`help urls` for more information.
4585 4603
4586 4604 Returns 0 on success.
4587 4605 """
4588 4606 hg.peer(ui, opts, ui.expandpath(dest), create=True)
4589 4607
4590 4608 @command('locate',
4591 4609 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
4592 4610 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
4593 4611 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
4594 4612 ] + walkopts,
4595 4613 _('[OPTION]... [PATTERN]...'))
4596 4614 def locate(ui, repo, *pats, **opts):
4597 4615 """locate files matching specific patterns (DEPRECATED)
4598 4616
4599 4617 Print files under Mercurial control in the working directory whose
4600 4618 names match the given patterns.
4601 4619
4602 4620 By default, this command searches all directories in the working
4603 4621 directory. To search just the current directory and its
4604 4622 subdirectories, use "--include .".
4605 4623
4606 4624 If no patterns are given to match, this command prints the names
4607 4625 of all files under Mercurial control in the working directory.
4608 4626
4609 4627 If you want to feed the output of this command into the "xargs"
4610 4628 command, use the -0 option to both this command and "xargs". This
4611 4629 will avoid the problem of "xargs" treating single filenames that
4612 4630 contain whitespace as multiple filenames.
4613 4631
4614 4632 See :hg:`help files` for a more versatile command.
4615 4633
4616 4634 Returns 0 if a match is found, 1 otherwise.
4617 4635 """
4618 4636 if opts.get('print0'):
4619 4637 end = '\0'
4620 4638 else:
4621 4639 end = '\n'
4622 4640 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
4623 4641
4624 4642 ret = 1
4625 4643 ctx = repo[rev]
4626 4644 m = scmutil.match(ctx, pats, opts, default='relglob',
4627 4645 badfn=lambda x, y: False)
4628 4646
4629 4647 for abs in ctx.matches(m):
4630 4648 if opts.get('fullpath'):
4631 4649 ui.write(repo.wjoin(abs), end)
4632 4650 else:
4633 4651 ui.write(((pats and m.rel(abs)) or abs), end)
4634 4652 ret = 0
4635 4653
4636 4654 return ret
4637 4655
4638 4656 @command('^log|history',
4639 4657 [('f', 'follow', None,
4640 4658 _('follow changeset history, or file history across copies and renames')),
4641 4659 ('', 'follow-first', None,
4642 4660 _('only follow the first parent of merge changesets (DEPRECATED)')),
4643 4661 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
4644 4662 ('C', 'copies', None, _('show copied files')),
4645 4663 ('k', 'keyword', [],
4646 4664 _('do case-insensitive search for a given text'), _('TEXT')),
4647 4665 ('r', 'rev', [], _('show the specified revision or revset'), _('REV')),
4648 4666 ('', 'removed', None, _('include revisions where files were removed')),
4649 4667 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
4650 4668 ('u', 'user', [], _('revisions committed by user'), _('USER')),
4651 4669 ('', 'only-branch', [],
4652 4670 _('show only changesets within the given named branch (DEPRECATED)'),
4653 4671 _('BRANCH')),
4654 4672 ('b', 'branch', [],
4655 4673 _('show changesets within the given named branch'), _('BRANCH')),
4656 4674 ('P', 'prune', [],
4657 4675 _('do not display revision or any of its ancestors'), _('REV')),
4658 4676 ] + logopts + walkopts,
4659 4677 _('[OPTION]... [FILE]'),
4660 4678 inferrepo=True)
4661 4679 def log(ui, repo, *pats, **opts):
4662 4680 """show revision history of entire repository or files
4663 4681
4664 4682 Print the revision history of the specified files or the entire
4665 4683 project.
4666 4684
4667 4685 If no revision range is specified, the default is ``tip:0`` unless
4668 4686 --follow is set, in which case the working directory parent is
4669 4687 used as the starting revision.
4670 4688
4671 4689 File history is shown without following rename or copy history of
4672 4690 files. Use -f/--follow with a filename to follow history across
4673 4691 renames and copies. --follow without a filename will only show
4674 4692 ancestors or descendants of the starting revision.
4675 4693
4676 4694 By default this command prints revision number and changeset id,
4677 4695 tags, non-trivial parents, user, date and time, and a summary for
4678 4696 each commit. When the -v/--verbose switch is used, the list of
4679 4697 changed files and full commit message are shown.
4680 4698
4681 4699 With --graph the revisions are shown as an ASCII art DAG with the most
4682 4700 recent changeset at the top.
4683 4701 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4684 4702 and '+' represents a fork where the changeset from the lines below is a
4685 4703 parent of the 'o' merge on the same line.
4686 4704
4687 4705 .. note::
4688 4706
4689 4707 log -p/--patch may generate unexpected diff output for merge
4690 4708 changesets, as it will only compare the merge changeset against
4691 4709 its first parent. Also, only files different from BOTH parents
4692 4710 will appear in files:.
4693 4711
4694 4712 .. note::
4695 4713
4696 4714 for performance reasons, log FILE may omit duplicate changes
4697 4715 made on branches and will not show removals or mode changes. To
4698 4716 see all such changes, use the --removed switch.
4699 4717
4700 4718 .. container:: verbose
4701 4719
4702 4720 Some examples:
4703 4721
4704 4722 - changesets with full descriptions and file lists::
4705 4723
4706 4724 hg log -v
4707 4725
4708 4726 - changesets ancestral to the working directory::
4709 4727
4710 4728 hg log -f
4711 4729
4712 4730 - last 10 commits on the current branch::
4713 4731
4714 4732 hg log -l 10 -b .
4715 4733
4716 4734 - changesets showing all modifications of a file, including removals::
4717 4735
4718 4736 hg log --removed file.c
4719 4737
4720 4738 - all changesets that touch a directory, with diffs, excluding merges::
4721 4739
4722 4740 hg log -Mp lib/
4723 4741
4724 4742 - all revision numbers that match a keyword::
4725 4743
4726 4744 hg log -k bug --template "{rev}\\n"
4727 4745
4728 4746 - list available log templates::
4729 4747
4730 4748 hg log -T list
4731 4749
4732 4750 - check if a given changeset is included in a tagged release::
4733 4751
4734 4752 hg log -r "a21ccf and ancestor(1.9)"
4735 4753
4736 4754 - find all changesets by some user in a date range::
4737 4755
4738 4756 hg log -k alice -d "may 2008 to jul 2008"
4739 4757
4740 4758 - summary of all changesets after the last tag::
4741 4759
4742 4760 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4743 4761
4744 4762 See :hg:`help dates` for a list of formats valid for -d/--date.
4745 4763
4746 4764 See :hg:`help revisions` and :hg:`help revsets` for more about
4747 4765 specifying revisions.
4748 4766
4749 4767 See :hg:`help templates` for more about pre-packaged styles and
4750 4768 specifying custom templates.
4751 4769
4752 4770 Returns 0 on success.
4753 4771
4754 4772 """
4755 4773 if opts.get('follow') and opts.get('rev'):
4756 4774 opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]
4757 4775 del opts['follow']
4758 4776
4759 4777 if opts.get('graph'):
4760 4778 return cmdutil.graphlog(ui, repo, *pats, **opts)
4761 4779
4762 4780 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4763 4781 limit = cmdutil.loglimit(opts)
4764 4782 count = 0
4765 4783
4766 4784 getrenamed = None
4767 4785 if opts.get('copies'):
4768 4786 endrev = None
4769 4787 if opts.get('rev'):
4770 4788 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4771 4789 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4772 4790
4773 4791 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4774 4792 for rev in revs:
4775 4793 if count == limit:
4776 4794 break
4777 4795 ctx = repo[rev]
4778 4796 copies = None
4779 4797 if getrenamed is not None and rev:
4780 4798 copies = []
4781 4799 for fn in ctx.files():
4782 4800 rename = getrenamed(fn, rev)
4783 4801 if rename:
4784 4802 copies.append((fn, rename[0]))
4785 4803 if filematcher:
4786 4804 revmatchfn = filematcher(ctx.rev())
4787 4805 else:
4788 4806 revmatchfn = None
4789 4807 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4790 4808 if displayer.flush(ctx):
4791 4809 count += 1
4792 4810
4793 4811 displayer.close()
4794 4812
4795 4813 @command('manifest',
4796 4814 [('r', 'rev', '', _('revision to display'), _('REV')),
4797 4815 ('', 'all', False, _("list files from all revisions"))]
4798 4816 + formatteropts,
4799 4817 _('[-r REV]'))
4800 4818 def manifest(ui, repo, node=None, rev=None, **opts):
4801 4819 """output the current or given revision of the project manifest
4802 4820
4803 4821 Print a list of version controlled files for the given revision.
4804 4822 If no revision is given, the first parent of the working directory
4805 4823 is used, or the null revision if no revision is checked out.
4806 4824
4807 4825 With -v, print file permissions, symlink and executable bits.
4808 4826 With --debug, print file revision hashes.
4809 4827
4810 4828 If option --all is specified, the list of all files from all revisions
4811 4829 is printed. This includes deleted and renamed files.
4812 4830
4813 4831 Returns 0 on success.
4814 4832 """
4815 4833
4816 4834 fm = ui.formatter('manifest', opts)
4817 4835
4818 4836 if opts.get('all'):
4819 4837 if rev or node:
4820 4838 raise error.Abort(_("can't specify a revision with --all"))
4821 4839
4822 4840 res = []
4823 4841 prefix = "data/"
4824 4842 suffix = ".i"
4825 4843 plen = len(prefix)
4826 4844 slen = len(suffix)
4827 4845 lock = repo.lock()
4828 4846 try:
4829 4847 for fn, b, size in repo.store.datafiles():
4830 4848 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4831 4849 res.append(fn[plen:-slen])
4832 4850 finally:
4833 4851 lock.release()
4834 4852 for f in res:
4835 4853 fm.startitem()
4836 4854 fm.write("path", '%s\n', f)
4837 4855 fm.end()
4838 4856 return
4839 4857
4840 4858 if rev and node:
4841 4859 raise error.Abort(_("please specify just one revision"))
4842 4860
4843 4861 if not node:
4844 4862 node = rev
4845 4863
4846 4864 char = {'l': '@', 'x': '*', '': ''}
4847 4865 mode = {'l': '644', 'x': '755', '': '644'}
4848 4866 ctx = scmutil.revsingle(repo, node)
4849 4867 mf = ctx.manifest()
4850 4868 for f in ctx:
4851 4869 fm.startitem()
4852 4870 fl = ctx[f].flags()
4853 4871 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4854 4872 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4855 4873 fm.write('path', '%s\n', f)
4856 4874 fm.end()
4857 4875
4858 4876 @command('^merge',
4859 4877 [('f', 'force', None,
4860 4878 _('force a merge including outstanding changes (DEPRECATED)')),
4861 4879 ('r', 'rev', '', _('revision to merge'), _('REV')),
4862 4880 ('P', 'preview', None,
4863 4881 _('review revisions to merge (no merge is performed)'))
4864 4882 ] + mergetoolopts,
4865 4883 _('[-P] [-f] [[-r] REV]'))
4866 4884 def merge(ui, repo, node=None, **opts):
4867 4885 """merge another revision into working directory
4868 4886
4869 4887 The current working directory is updated with all changes made in
4870 4888 the requested revision since the last common predecessor revision.
4871 4889
4872 4890 Files that changed between either parent are marked as changed for
4873 4891 the next commit and a commit must be performed before any further
4874 4892 updates to the repository are allowed. The next commit will have
4875 4893 two parents.
4876 4894
4877 4895 ``--tool`` can be used to specify the merge tool used for file
4878 4896 merges. It overrides the HGMERGE environment variable and your
4879 4897 configuration files. See :hg:`help merge-tools` for options.
4880 4898
4881 4899 If no revision is specified, the working directory's parent is a
4882 4900 head revision, and the current branch contains exactly one other
4883 4901 head, the other head is merged with by default. Otherwise, an
4884 4902 explicit revision with which to merge with must be provided.
4885 4903
4886 4904 :hg:`resolve` must be used to resolve unresolved files.
4887 4905
4888 4906 To undo an uncommitted merge, use :hg:`update --clean .` which
4889 4907 will check out a clean copy of the original merge parent, losing
4890 4908 all changes.
4891 4909
4892 4910 Returns 0 on success, 1 if there are unresolved files.
4893 4911 """
4894 4912
4895 4913 if opts.get('rev') and node:
4896 4914 raise error.Abort(_("please specify just one revision"))
4897 4915 if not node:
4898 4916 node = opts.get('rev')
4899 4917
4900 4918 if node:
4901 4919 node = scmutil.revsingle(repo, node).node()
4902 4920
4903 4921 if not node:
4904 4922 node = repo[destutil.destmerge(repo)].node()
4905 4923
4906 4924 if opts.get('preview'):
4907 4925 # find nodes that are ancestors of p2 but not of p1
4908 4926 p1 = repo.lookup('.')
4909 4927 p2 = repo.lookup(node)
4910 4928 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4911 4929
4912 4930 displayer = cmdutil.show_changeset(ui, repo, opts)
4913 4931 for node in nodes:
4914 4932 displayer.show(repo[node])
4915 4933 displayer.close()
4916 4934 return 0
4917 4935
4918 4936 try:
4919 4937 # ui.forcemerge is an internal variable, do not document
4920 4938 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
4921 4939 return hg.merge(repo, node, force=opts.get('force'))
4922 4940 finally:
4923 4941 ui.setconfig('ui', 'forcemerge', '', 'merge')
4924 4942
4925 4943 @command('outgoing|out',
4926 4944 [('f', 'force', None, _('run even when the destination is unrelated')),
4927 4945 ('r', 'rev', [],
4928 4946 _('a changeset intended to be included in the destination'), _('REV')),
4929 4947 ('n', 'newest-first', None, _('show newest record first')),
4930 4948 ('B', 'bookmarks', False, _('compare bookmarks')),
4931 4949 ('b', 'branch', [], _('a specific branch you would like to push'),
4932 4950 _('BRANCH')),
4933 4951 ] + logopts + remoteopts + subrepoopts,
4934 4952 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4935 4953 def outgoing(ui, repo, dest=None, **opts):
4936 4954 """show changesets not found in the destination
4937 4955
4938 4956 Show changesets not found in the specified destination repository
4939 4957 or the default push location. These are the changesets that would
4940 4958 be pushed if a push was requested.
4941 4959
4942 4960 See pull for details of valid destination formats.
4943 4961
4944 4962 .. container:: verbose
4945 4963
4946 4964 With -B/--bookmarks, the result of bookmark comparison between
4947 4965 local and remote repositories is displayed. With -v/--verbose,
4948 4966 status is also displayed for each bookmark like below::
4949 4967
4950 4968 BM1 01234567890a added
4951 4969 BM2 deleted
4952 4970 BM3 234567890abc advanced
4953 4971 BM4 34567890abcd diverged
4954 4972 BM5 4567890abcde changed
4955 4973
4956 4974 The action taken when pushing depends on the
4957 4975 status of each bookmark:
4958 4976
4959 4977 :``added``: push with ``-B`` will create it
4960 4978 :``deleted``: push with ``-B`` will delete it
4961 4979 :``advanced``: push will update it
4962 4980 :``diverged``: push with ``-B`` will update it
4963 4981 :``changed``: push with ``-B`` will update it
4964 4982
4965 4983 From the point of view of pushing behavior, bookmarks
4966 4984 existing only in the remote repository are treated as
4967 4985 ``deleted``, even if it is in fact added remotely.
4968 4986
4969 4987 Returns 0 if there are outgoing changes, 1 otherwise.
4970 4988 """
4971 4989 if opts.get('graph'):
4972 4990 cmdutil.checkunsupportedgraphflags([], opts)
4973 4991 o, other = hg._outgoing(ui, repo, dest, opts)
4974 4992 if not o:
4975 4993 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4976 4994 return
4977 4995
4978 4996 revdag = cmdutil.graphrevs(repo, o, opts)
4979 4997 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4980 4998 showparents = [ctx.node() for ctx in repo[None].parents()]
4981 4999 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4982 5000 graphmod.asciiedges)
4983 5001 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4984 5002 return 0
4985 5003
4986 5004 if opts.get('bookmarks'):
4987 5005 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4988 5006 dest, branches = hg.parseurl(dest, opts.get('branch'))
4989 5007 other = hg.peer(repo, opts, dest)
4990 5008 if 'bookmarks' not in other.listkeys('namespaces'):
4991 5009 ui.warn(_("remote doesn't support bookmarks\n"))
4992 5010 return 0
4993 5011 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4994 5012 return bookmarks.outgoing(ui, repo, other)
4995 5013
4996 5014 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4997 5015 try:
4998 5016 return hg.outgoing(ui, repo, dest, opts)
4999 5017 finally:
5000 5018 del repo._subtoppath
5001 5019
5002 5020 @command('parents',
5003 5021 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
5004 5022 ] + templateopts,
5005 5023 _('[-r REV] [FILE]'),
5006 5024 inferrepo=True)
5007 5025 def parents(ui, repo, file_=None, **opts):
5008 5026 """show the parents of the working directory or revision (DEPRECATED)
5009 5027
5010 5028 Print the working directory's parent revisions. If a revision is
5011 5029 given via -r/--rev, the parent of that revision will be printed.
5012 5030 If a file argument is given, the revision in which the file was
5013 5031 last changed (before the working directory revision or the
5014 5032 argument to --rev if given) is printed.
5015 5033
5016 5034 See :hg:`summary` and :hg:`help revsets` for related information.
5017 5035
5018 5036 Returns 0 on success.
5019 5037 """
5020 5038
5021 5039 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
5022 5040
5023 5041 if file_:
5024 5042 m = scmutil.match(ctx, (file_,), opts)
5025 5043 if m.anypats() or len(m.files()) != 1:
5026 5044 raise error.Abort(_('can only specify an explicit filename'))
5027 5045 file_ = m.files()[0]
5028 5046 filenodes = []
5029 5047 for cp in ctx.parents():
5030 5048 if not cp:
5031 5049 continue
5032 5050 try:
5033 5051 filenodes.append(cp.filenode(file_))
5034 5052 except error.LookupError:
5035 5053 pass
5036 5054 if not filenodes:
5037 5055 raise error.Abort(_("'%s' not found in manifest!") % file_)
5038 5056 p = []
5039 5057 for fn in filenodes:
5040 5058 fctx = repo.filectx(file_, fileid=fn)
5041 5059 p.append(fctx.node())
5042 5060 else:
5043 5061 p = [cp.node() for cp in ctx.parents()]
5044 5062
5045 5063 displayer = cmdutil.show_changeset(ui, repo, opts)
5046 5064 for n in p:
5047 5065 if n != nullid:
5048 5066 displayer.show(repo[n])
5049 5067 displayer.close()
5050 5068
5051 5069 @command('paths', [], _('[NAME]'), optionalrepo=True)
5052 5070 def paths(ui, repo, search=None):
5053 5071 """show aliases for remote repositories
5054 5072
5055 5073 Show definition of symbolic path name NAME. If no name is given,
5056 5074 show definition of all available names.
5057 5075
5058 5076 Option -q/--quiet suppresses all output when searching for NAME
5059 5077 and shows only the path names when listing all definitions.
5060 5078
5061 5079 Path names are defined in the [paths] section of your
5062 5080 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
5063 5081 repository, ``.hg/hgrc`` is used, too.
5064 5082
5065 5083 The path names ``default`` and ``default-push`` have a special
5066 5084 meaning. When performing a push or pull operation, they are used
5067 5085 as fallbacks if no location is specified on the command-line.
5068 5086 When ``default-push`` is set, it will be used for push and
5069 5087 ``default`` will be used for pull; otherwise ``default`` is used
5070 5088 as the fallback for both. When cloning a repository, the clone
5071 5089 source is written as ``default`` in ``.hg/hgrc``. Note that
5072 5090 ``default`` and ``default-push`` apply to all inbound (e.g.
5073 5091 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
5074 5092 :hg:`bundle`) operations.
5075 5093
5076 5094 See :hg:`help urls` for more information.
5077 5095
5078 5096 Returns 0 on success.
5079 5097 """
5080 5098 if search:
5081 5099 for name, path in sorted(ui.paths.iteritems()):
5082 5100 if name == search:
5083 5101 ui.status("%s\n" % util.hidepassword(path.loc))
5084 5102 return
5085 5103 if not ui.quiet:
5086 5104 ui.warn(_("not found!\n"))
5087 5105 return 1
5088 5106 else:
5089 5107 for name, path in sorted(ui.paths.iteritems()):
5090 5108 if ui.quiet:
5091 5109 ui.write("%s\n" % name)
5092 5110 else:
5093 5111 ui.write("%s = %s\n" % (name,
5094 5112 util.hidepassword(path.loc)))
5095 5113
5096 5114 @command('phase',
5097 5115 [('p', 'public', False, _('set changeset phase to public')),
5098 5116 ('d', 'draft', False, _('set changeset phase to draft')),
5099 5117 ('s', 'secret', False, _('set changeset phase to secret')),
5100 5118 ('f', 'force', False, _('allow to move boundary backward')),
5101 5119 ('r', 'rev', [], _('target revision'), _('REV')),
5102 5120 ],
5103 5121 _('[-p|-d|-s] [-f] [-r] [REV...]'))
5104 5122 def phase(ui, repo, *revs, **opts):
5105 5123 """set or show the current phase name
5106 5124
5107 5125 With no argument, show the phase name of the current revision(s).
5108 5126
5109 5127 With one of -p/--public, -d/--draft or -s/--secret, change the
5110 5128 phase value of the specified revisions.
5111 5129
5112 5130 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
5113 5131 lower phase to an higher phase. Phases are ordered as follows::
5114 5132
5115 5133 public < draft < secret
5116 5134
5117 5135 Returns 0 on success, 1 if some phases could not be changed.
5118 5136
5119 5137 (For more information about the phases concept, see :hg:`help phases`.)
5120 5138 """
5121 5139 # search for a unique phase argument
5122 5140 targetphase = None
5123 5141 for idx, name in enumerate(phases.phasenames):
5124 5142 if opts[name]:
5125 5143 if targetphase is not None:
5126 5144 raise error.Abort(_('only one phase can be specified'))
5127 5145 targetphase = idx
5128 5146
5129 5147 # look for specified revision
5130 5148 revs = list(revs)
5131 5149 revs.extend(opts['rev'])
5132 5150 if not revs:
5133 5151 # display both parents as the second parent phase can influence
5134 5152 # the phase of a merge commit
5135 5153 revs = [c.rev() for c in repo[None].parents()]
5136 5154
5137 5155 revs = scmutil.revrange(repo, revs)
5138 5156
5139 5157 lock = None
5140 5158 ret = 0
5141 5159 if targetphase is None:
5142 5160 # display
5143 5161 for r in revs:
5144 5162 ctx = repo[r]
5145 5163 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
5146 5164 else:
5147 5165 tr = None
5148 5166 lock = repo.lock()
5149 5167 try:
5150 5168 tr = repo.transaction("phase")
5151 5169 # set phase
5152 5170 if not revs:
5153 5171 raise error.Abort(_('empty revision set'))
5154 5172 nodes = [repo[r].node() for r in revs]
5155 5173 # moving revision from public to draft may hide them
5156 5174 # We have to check result on an unfiltered repository
5157 5175 unfi = repo.unfiltered()
5158 5176 getphase = unfi._phasecache.phase
5159 5177 olddata = [getphase(unfi, r) for r in unfi]
5160 5178 phases.advanceboundary(repo, tr, targetphase, nodes)
5161 5179 if opts['force']:
5162 5180 phases.retractboundary(repo, tr, targetphase, nodes)
5163 5181 tr.close()
5164 5182 finally:
5165 5183 if tr is not None:
5166 5184 tr.release()
5167 5185 lock.release()
5168 5186 getphase = unfi._phasecache.phase
5169 5187 newdata = [getphase(unfi, r) for r in unfi]
5170 5188 changes = sum(newdata[r] != olddata[r] for r in unfi)
5171 5189 cl = unfi.changelog
5172 5190 rejected = [n for n in nodes
5173 5191 if newdata[cl.rev(n)] < targetphase]
5174 5192 if rejected:
5175 5193 ui.warn(_('cannot move %i changesets to a higher '
5176 5194 'phase, use --force\n') % len(rejected))
5177 5195 ret = 1
5178 5196 if changes:
5179 5197 msg = _('phase changed for %i changesets\n') % changes
5180 5198 if ret:
5181 5199 ui.status(msg)
5182 5200 else:
5183 5201 ui.note(msg)
5184 5202 else:
5185 5203 ui.warn(_('no phases changed\n'))
5186 5204 return ret
5187 5205
5188 5206 def postincoming(ui, repo, modheads, optupdate, checkout):
5189 5207 if modheads == 0:
5190 5208 return
5191 5209 if optupdate:
5192 5210 try:
5193 5211 brev = checkout
5194 5212 movemarkfrom = None
5195 5213 if not checkout:
5196 5214 updata = destutil.destupdate(repo)
5197 5215 checkout, movemarkfrom, brev = updata
5198 5216 ret = hg.update(repo, checkout)
5199 5217 except error.UpdateAbort as inst:
5200 5218 ui.warn(_("not updating: %s\n") % str(inst))
5201 5219 if inst.hint:
5202 5220 ui.warn(_("(%s)\n") % inst.hint)
5203 5221 return 0
5204 5222 if not ret and not checkout:
5205 5223 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5206 5224 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
5207 5225 return ret
5208 5226 if modheads > 1:
5209 5227 currentbranchheads = len(repo.branchheads())
5210 5228 if currentbranchheads == modheads:
5211 5229 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
5212 5230 elif currentbranchheads > 1:
5213 5231 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
5214 5232 "merge)\n"))
5215 5233 else:
5216 5234 ui.status(_("(run 'hg heads' to see heads)\n"))
5217 5235 else:
5218 5236 ui.status(_("(run 'hg update' to get a working copy)\n"))
5219 5237
5220 5238 @command('^pull',
5221 5239 [('u', 'update', None,
5222 5240 _('update to new branch head if changesets were pulled')),
5223 5241 ('f', 'force', None, _('run even when remote repository is unrelated')),
5224 5242 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
5225 5243 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
5226 5244 ('b', 'branch', [], _('a specific branch you would like to pull'),
5227 5245 _('BRANCH')),
5228 5246 ] + remoteopts,
5229 5247 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
5230 5248 def pull(ui, repo, source="default", **opts):
5231 5249 """pull changes from the specified source
5232 5250
5233 5251 Pull changes from a remote repository to a local one.
5234 5252
5235 5253 This finds all changes from the repository at the specified path
5236 5254 or URL and adds them to a local repository (the current one unless
5237 5255 -R is specified). By default, this does not update the copy of the
5238 5256 project in the working directory.
5239 5257
5240 5258 Use :hg:`incoming` if you want to see what would have been added
5241 5259 by a pull at the time you issued this command. If you then decide
5242 5260 to add those changes to the repository, you should use :hg:`pull
5243 5261 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
5244 5262
5245 5263 If SOURCE is omitted, the 'default' path will be used.
5246 5264 See :hg:`help urls` for more information.
5247 5265
5248 5266 Returns 0 on success, 1 if an update had unresolved files.
5249 5267 """
5250 5268 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
5251 5269 ui.status(_('pulling from %s\n') % util.hidepassword(source))
5252 5270 other = hg.peer(repo, opts, source)
5253 5271 try:
5254 5272 revs, checkout = hg.addbranchrevs(repo, other, branches,
5255 5273 opts.get('rev'))
5256 5274
5257 5275
5258 5276 pullopargs = {}
5259 5277 if opts.get('bookmark'):
5260 5278 if not revs:
5261 5279 revs = []
5262 5280 # The list of bookmark used here is not the one used to actually
5263 5281 # update the bookmark name. This can result in the revision pulled
5264 5282 # not ending up with the name of the bookmark because of a race
5265 5283 # condition on the server. (See issue 4689 for details)
5266 5284 remotebookmarks = other.listkeys('bookmarks')
5267 5285 pullopargs['remotebookmarks'] = remotebookmarks
5268 5286 for b in opts['bookmark']:
5269 5287 if b not in remotebookmarks:
5270 5288 raise error.Abort(_('remote bookmark %s not found!') % b)
5271 5289 revs.append(remotebookmarks[b])
5272 5290
5273 5291 if revs:
5274 5292 try:
5275 5293 # When 'rev' is a bookmark name, we cannot guarantee that it
5276 5294 # will be updated with that name because of a race condition
5277 5295 # server side. (See issue 4689 for details)
5278 5296 oldrevs = revs
5279 5297 revs = [] # actually, nodes
5280 5298 for r in oldrevs:
5281 5299 node = other.lookup(r)
5282 5300 revs.append(node)
5283 5301 if r == checkout:
5284 5302 checkout = node
5285 5303 except error.CapabilityError:
5286 5304 err = _("other repository doesn't support revision lookup, "
5287 5305 "so a rev cannot be specified.")
5288 5306 raise error.Abort(err)
5289 5307
5290 5308 modheads = exchange.pull(repo, other, heads=revs,
5291 5309 force=opts.get('force'),
5292 5310 bookmarks=opts.get('bookmark', ()),
5293 5311 opargs=pullopargs).cgresult
5294 5312 if checkout:
5295 5313 checkout = str(repo.changelog.rev(checkout))
5296 5314 repo._subtoppath = source
5297 5315 try:
5298 5316 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
5299 5317
5300 5318 finally:
5301 5319 del repo._subtoppath
5302 5320
5303 5321 finally:
5304 5322 other.close()
5305 5323 return ret
5306 5324
5307 5325 @command('^push',
5308 5326 [('f', 'force', None, _('force push')),
5309 5327 ('r', 'rev', [],
5310 5328 _('a changeset intended to be included in the destination'),
5311 5329 _('REV')),
5312 5330 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
5313 5331 ('b', 'branch', [],
5314 5332 _('a specific branch you would like to push'), _('BRANCH')),
5315 5333 ('', 'new-branch', False, _('allow pushing a new branch')),
5316 5334 ] + remoteopts,
5317 5335 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
5318 5336 def push(ui, repo, dest=None, **opts):
5319 5337 """push changes to the specified destination
5320 5338
5321 5339 Push changesets from the local repository to the specified
5322 5340 destination.
5323 5341
5324 5342 This operation is symmetrical to pull: it is identical to a pull
5325 5343 in the destination repository from the current one.
5326 5344
5327 5345 By default, push will not allow creation of new heads at the
5328 5346 destination, since multiple heads would make it unclear which head
5329 5347 to use. In this situation, it is recommended to pull and merge
5330 5348 before pushing.
5331 5349
5332 5350 Use --new-branch if you want to allow push to create a new named
5333 5351 branch that is not present at the destination. This allows you to
5334 5352 only create a new branch without forcing other changes.
5335 5353
5336 5354 .. note::
5337 5355
5338 5356 Extra care should be taken with the -f/--force option,
5339 5357 which will push all new heads on all branches, an action which will
5340 5358 almost always cause confusion for collaborators.
5341 5359
5342 5360 If -r/--rev is used, the specified revision and all its ancestors
5343 5361 will be pushed to the remote repository.
5344 5362
5345 5363 If -B/--bookmark is used, the specified bookmarked revision, its
5346 5364 ancestors, and the bookmark will be pushed to the remote
5347 5365 repository.
5348 5366
5349 5367 Please see :hg:`help urls` for important details about ``ssh://``
5350 5368 URLs. If DESTINATION is omitted, a default path will be used.
5351 5369
5352 5370 Returns 0 if push was successful, 1 if nothing to push.
5353 5371 """
5354 5372
5355 5373 if opts.get('bookmark'):
5356 5374 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
5357 5375 for b in opts['bookmark']:
5358 5376 # translate -B options to -r so changesets get pushed
5359 5377 if b in repo._bookmarks:
5360 5378 opts.setdefault('rev', []).append(b)
5361 5379 else:
5362 5380 # if we try to push a deleted bookmark, translate it to null
5363 5381 # this lets simultaneous -r, -b options continue working
5364 5382 opts.setdefault('rev', []).append("null")
5365 5383
5366 5384 path = ui.paths.getpath(dest, default='default')
5367 5385 if not path:
5368 5386 raise error.Abort(_('default repository not configured!'),
5369 5387 hint=_('see the "path" section in "hg help config"'))
5370 5388 dest, branches = path.pushloc, (path.branch, opts.get('branch') or [])
5371 5389 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
5372 5390 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
5373 5391 other = hg.peer(repo, opts, dest)
5374 5392
5375 5393 if revs:
5376 5394 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
5377 5395 if not revs:
5378 5396 raise error.Abort(_("specified revisions evaluate to an empty set"),
5379 5397 hint=_("use different revision arguments"))
5380 5398
5381 5399 repo._subtoppath = dest
5382 5400 try:
5383 5401 # push subrepos depth-first for coherent ordering
5384 5402 c = repo['']
5385 5403 subs = c.substate # only repos that are committed
5386 5404 for s in sorted(subs):
5387 5405 result = c.sub(s).push(opts)
5388 5406 if result == 0:
5389 5407 return not result
5390 5408 finally:
5391 5409 del repo._subtoppath
5392 5410 pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
5393 5411 newbranch=opts.get('new_branch'),
5394 5412 bookmarks=opts.get('bookmark', ()))
5395 5413
5396 5414 result = not pushop.cgresult
5397 5415
5398 5416 if pushop.bkresult is not None:
5399 5417 if pushop.bkresult == 2:
5400 5418 result = 2
5401 5419 elif not result and pushop.bkresult:
5402 5420 result = 2
5403 5421
5404 5422 return result
5405 5423
5406 5424 @command('recover', [])
5407 5425 def recover(ui, repo):
5408 5426 """roll back an interrupted transaction
5409 5427
5410 5428 Recover from an interrupted commit or pull.
5411 5429
5412 5430 This command tries to fix the repository status after an
5413 5431 interrupted operation. It should only be necessary when Mercurial
5414 5432 suggests it.
5415 5433
5416 5434 Returns 0 if successful, 1 if nothing to recover or verify fails.
5417 5435 """
5418 5436 if repo.recover():
5419 5437 return hg.verify(repo)
5420 5438 return 1
5421 5439
5422 5440 @command('^remove|rm',
5423 5441 [('A', 'after', None, _('record delete for missing files')),
5424 5442 ('f', 'force', None,
5425 5443 _('remove (and delete) file even if added or modified')),
5426 5444 ] + subrepoopts + walkopts,
5427 5445 _('[OPTION]... FILE...'),
5428 5446 inferrepo=True)
5429 5447 def remove(ui, repo, *pats, **opts):
5430 5448 """remove the specified files on the next commit
5431 5449
5432 5450 Schedule the indicated files for removal from the current branch.
5433 5451
5434 5452 This command schedules the files to be removed at the next commit.
5435 5453 To undo a remove before that, see :hg:`revert`. To undo added
5436 5454 files, see :hg:`forget`.
5437 5455
5438 5456 .. container:: verbose
5439 5457
5440 5458 -A/--after can be used to remove only files that have already
5441 5459 been deleted, -f/--force can be used to force deletion, and -Af
5442 5460 can be used to remove files from the next revision without
5443 5461 deleting them from the working directory.
5444 5462
5445 5463 The following table details the behavior of remove for different
5446 5464 file states (columns) and option combinations (rows). The file
5447 5465 states are Added [A], Clean [C], Modified [M] and Missing [!]
5448 5466 (as reported by :hg:`status`). The actions are Warn, Remove
5449 5467 (from branch) and Delete (from disk):
5450 5468
5451 5469 ========= == == == ==
5452 5470 opt/state A C M !
5453 5471 ========= == == == ==
5454 5472 none W RD W R
5455 5473 -f R RD RD R
5456 5474 -A W W W R
5457 5475 -Af R R R R
5458 5476 ========= == == == ==
5459 5477
5460 5478 Note that remove never deletes files in Added [A] state from the
5461 5479 working directory, not even if option --force is specified.
5462 5480
5463 5481 Returns 0 on success, 1 if any warnings encountered.
5464 5482 """
5465 5483
5466 5484 after, force = opts.get('after'), opts.get('force')
5467 5485 if not pats and not after:
5468 5486 raise error.Abort(_('no files specified'))
5469 5487
5470 5488 m = scmutil.match(repo[None], pats, opts)
5471 5489 subrepos = opts.get('subrepos')
5472 5490 return cmdutil.remove(ui, repo, m, "", after, force, subrepos)
5473 5491
5474 5492 @command('rename|move|mv',
5475 5493 [('A', 'after', None, _('record a rename that has already occurred')),
5476 5494 ('f', 'force', None, _('forcibly copy over an existing managed file')),
5477 5495 ] + walkopts + dryrunopts,
5478 5496 _('[OPTION]... SOURCE... DEST'))
5479 5497 def rename(ui, repo, *pats, **opts):
5480 5498 """rename files; equivalent of copy + remove
5481 5499
5482 5500 Mark dest as copies of sources; mark sources for deletion. If dest
5483 5501 is a directory, copies are put in that directory. If dest is a
5484 5502 file, there can only be one source.
5485 5503
5486 5504 By default, this command copies the contents of files as they
5487 5505 exist in the working directory. If invoked with -A/--after, the
5488 5506 operation is recorded, but no copying is performed.
5489 5507
5490 5508 This command takes effect at the next commit. To undo a rename
5491 5509 before that, see :hg:`revert`.
5492 5510
5493 5511 Returns 0 on success, 1 if errors are encountered.
5494 5512 """
5495 5513 wlock = repo.wlock(False)
5496 5514 try:
5497 5515 return cmdutil.copy(ui, repo, pats, opts, rename=True)
5498 5516 finally:
5499 5517 wlock.release()
5500 5518
5501 5519 @command('resolve',
5502 5520 [('a', 'all', None, _('select all unresolved files')),
5503 5521 ('l', 'list', None, _('list state of files needing merge')),
5504 5522 ('m', 'mark', None, _('mark files as resolved')),
5505 5523 ('u', 'unmark', None, _('mark files as unresolved')),
5506 5524 ('n', 'no-status', None, _('hide status prefix'))]
5507 5525 + mergetoolopts + walkopts + formatteropts,
5508 5526 _('[OPTION]... [FILE]...'),
5509 5527 inferrepo=True)
5510 5528 def resolve(ui, repo, *pats, **opts):
5511 5529 """redo merges or set/view the merge status of files
5512 5530
5513 5531 Merges with unresolved conflicts are often the result of
5514 5532 non-interactive merging using the ``internal:merge`` configuration
5515 5533 setting, or a command-line merge tool like ``diff3``. The resolve
5516 5534 command is used to manage the files involved in a merge, after
5517 5535 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
5518 5536 working directory must have two parents). See :hg:`help
5519 5537 merge-tools` for information on configuring merge tools.
5520 5538
5521 5539 The resolve command can be used in the following ways:
5522 5540
5523 5541 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
5524 5542 files, discarding any previous merge attempts. Re-merging is not
5525 5543 performed for files already marked as resolved. Use ``--all/-a``
5526 5544 to select all unresolved files. ``--tool`` can be used to specify
5527 5545 the merge tool used for the given files. It overrides the HGMERGE
5528 5546 environment variable and your configuration files. Previous file
5529 5547 contents are saved with a ``.orig`` suffix.
5530 5548
5531 5549 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
5532 5550 (e.g. after having manually fixed-up the files). The default is
5533 5551 to mark all unresolved files.
5534 5552
5535 5553 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
5536 5554 default is to mark all resolved files.
5537 5555
5538 5556 - :hg:`resolve -l`: list files which had or still have conflicts.
5539 5557 In the printed list, ``U`` = unresolved and ``R`` = resolved.
5540 5558
5541 5559 Note that Mercurial will not let you commit files with unresolved
5542 5560 merge conflicts. You must use :hg:`resolve -m ...` before you can
5543 5561 commit after a conflicting merge.
5544 5562
5545 5563 Returns 0 on success, 1 if any files fail a resolve attempt.
5546 5564 """
5547 5565
5548 5566 all, mark, unmark, show, nostatus = \
5549 5567 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
5550 5568
5551 5569 if (show and (mark or unmark)) or (mark and unmark):
5552 5570 raise error.Abort(_("too many options specified"))
5553 5571 if pats and all:
5554 5572 raise error.Abort(_("can't specify --all and patterns"))
5555 5573 if not (all or pats or show or mark or unmark):
5556 5574 raise error.Abort(_('no files or directories specified'),
5557 5575 hint=('use --all to re-merge all unresolved files'))
5558 5576
5559 5577 if show:
5560 5578 fm = ui.formatter('resolve', opts)
5561 5579 ms = mergemod.mergestate(repo)
5562 5580 m = scmutil.match(repo[None], pats, opts)
5563 5581 for f in ms:
5564 5582 if not m(f):
5565 5583 continue
5566 5584 l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved'}[ms[f]]
5567 5585 fm.startitem()
5568 5586 fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
5569 5587 fm.write('path', '%s\n', f, label=l)
5570 5588 fm.end()
5571 5589 return 0
5572 5590
5573 5591 wlock = repo.wlock()
5574 5592 try:
5575 5593 ms = mergemod.mergestate(repo)
5576 5594
5577 5595 if not (ms.active() or repo.dirstate.p2() != nullid):
5578 5596 raise error.Abort(
5579 5597 _('resolve command not applicable when not merging'))
5580 5598
5581 5599 m = scmutil.match(repo[None], pats, opts)
5582 5600 ret = 0
5583 5601 didwork = False
5584 5602
5585 5603 tocomplete = []
5586 5604 for f in ms:
5587 5605 if not m(f):
5588 5606 continue
5589 5607
5590 5608 didwork = True
5591 5609
5592 5610 if mark:
5593 5611 ms.mark(f, "r")
5594 5612 elif unmark:
5595 5613 ms.mark(f, "u")
5596 5614 else:
5597 5615 wctx = repo[None]
5598 5616
5599 5617 # backup pre-resolve (merge uses .orig for its own purposes)
5600 5618 a = repo.wjoin(f)
5601 5619 util.copyfile(a, a + ".resolve")
5602 5620
5603 5621 try:
5604 5622 # preresolve file
5605 5623 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5606 5624 'resolve')
5607 5625 complete, r = ms.preresolve(f, wctx)
5608 5626 if not complete:
5609 5627 tocomplete.append(f)
5610 5628 elif r:
5611 5629 ret = 1
5612 5630 finally:
5613 5631 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5614 5632 ms.commit()
5615 5633
5616 5634 # replace filemerge's .orig file with our resolve file
5617 5635 # for files in tocomplete, ms.resolve will not overwrite
5618 5636 # .orig -- only preresolve does
5619 5637 util.rename(a + ".resolve", a + ".orig")
5620 5638
5621 5639 for f in tocomplete:
5622 5640 try:
5623 5641 # resolve file
5624 5642 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
5625 5643 'resolve')
5626 5644 r = ms.resolve(f, wctx)
5627 5645 if r:
5628 5646 ret = 1
5629 5647 finally:
5630 5648 ui.setconfig('ui', 'forcemerge', '', 'resolve')
5631 5649 ms.commit()
5632 5650
5633 5651 ms.commit()
5634 5652
5635 5653 if not didwork and pats:
5636 5654 ui.warn(_("arguments do not match paths that need resolving\n"))
5637 5655
5638 5656 finally:
5639 5657 wlock.release()
5640 5658
5641 5659 # Nudge users into finishing an unfinished operation
5642 5660 if not list(ms.unresolved()):
5643 5661 ui.status(_('(no more unresolved files)\n'))
5644 5662
5645 5663 return ret
5646 5664
5647 5665 @command('revert',
5648 5666 [('a', 'all', None, _('revert all changes when no arguments given')),
5649 5667 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5650 5668 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
5651 5669 ('C', 'no-backup', None, _('do not save backup copies of files')),
5652 5670 ('i', 'interactive', None,
5653 5671 _('interactively select the changes (EXPERIMENTAL)')),
5654 5672 ] + walkopts + dryrunopts,
5655 5673 _('[OPTION]... [-r REV] [NAME]...'))
5656 5674 def revert(ui, repo, *pats, **opts):
5657 5675 """restore files to their checkout state
5658 5676
5659 5677 .. note::
5660 5678
5661 5679 To check out earlier revisions, you should use :hg:`update REV`.
5662 5680 To cancel an uncommitted merge (and lose your changes),
5663 5681 use :hg:`update --clean .`.
5664 5682
5665 5683 With no revision specified, revert the specified files or directories
5666 5684 to the contents they had in the parent of the working directory.
5667 5685 This restores the contents of files to an unmodified
5668 5686 state and unschedules adds, removes, copies, and renames. If the
5669 5687 working directory has two parents, you must explicitly specify a
5670 5688 revision.
5671 5689
5672 5690 Using the -r/--rev or -d/--date options, revert the given files or
5673 5691 directories to their states as of a specific revision. Because
5674 5692 revert does not change the working directory parents, this will
5675 5693 cause these files to appear modified. This can be helpful to "back
5676 5694 out" some or all of an earlier change. See :hg:`backout` for a
5677 5695 related method.
5678 5696
5679 5697 Modified files are saved with a .orig suffix before reverting.
5680 5698 To disable these backups, use --no-backup.
5681 5699
5682 5700 See :hg:`help dates` for a list of formats valid for -d/--date.
5683 5701
5684 5702 See :hg:`help backout` for a way to reverse the effect of an
5685 5703 earlier changeset.
5686 5704
5687 5705 Returns 0 on success.
5688 5706 """
5689 5707
5690 5708 if opts.get("date"):
5691 5709 if opts.get("rev"):
5692 5710 raise error.Abort(_("you can't specify a revision and a date"))
5693 5711 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5694 5712
5695 5713 parent, p2 = repo.dirstate.parents()
5696 5714 if not opts.get('rev') and p2 != nullid:
5697 5715 # revert after merge is a trap for new users (issue2915)
5698 5716 raise error.Abort(_('uncommitted merge with no revision specified'),
5699 5717 hint=_('use "hg update" or see "hg help revert"'))
5700 5718
5701 5719 ctx = scmutil.revsingle(repo, opts.get('rev'))
5702 5720
5703 5721 if (not (pats or opts.get('include') or opts.get('exclude') or
5704 5722 opts.get('all') or opts.get('interactive'))):
5705 5723 msg = _("no files or directories specified")
5706 5724 if p2 != nullid:
5707 5725 hint = _("uncommitted merge, use --all to discard all changes,"
5708 5726 " or 'hg update -C .' to abort the merge")
5709 5727 raise error.Abort(msg, hint=hint)
5710 5728 dirty = any(repo.status())
5711 5729 node = ctx.node()
5712 5730 if node != parent:
5713 5731 if dirty:
5714 5732 hint = _("uncommitted changes, use --all to discard all"
5715 5733 " changes, or 'hg update %s' to update") % ctx.rev()
5716 5734 else:
5717 5735 hint = _("use --all to revert all files,"
5718 5736 " or 'hg update %s' to update") % ctx.rev()
5719 5737 elif dirty:
5720 5738 hint = _("uncommitted changes, use --all to discard all changes")
5721 5739 else:
5722 5740 hint = _("use --all to revert all files")
5723 5741 raise error.Abort(msg, hint=hint)
5724 5742
5725 5743 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5726 5744
5727 5745 @command('rollback', dryrunopts +
5728 5746 [('f', 'force', False, _('ignore safety measures'))])
5729 5747 def rollback(ui, repo, **opts):
5730 5748 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5731 5749
5732 5750 Please use :hg:`commit --amend` instead of rollback to correct
5733 5751 mistakes in the last commit.
5734 5752
5735 5753 This command should be used with care. There is only one level of
5736 5754 rollback, and there is no way to undo a rollback. It will also
5737 5755 restore the dirstate at the time of the last transaction, losing
5738 5756 any dirstate changes since that time. This command does not alter
5739 5757 the working directory.
5740 5758
5741 5759 Transactions are used to encapsulate the effects of all commands
5742 5760 that create new changesets or propagate existing changesets into a
5743 5761 repository.
5744 5762
5745 5763 .. container:: verbose
5746 5764
5747 5765 For example, the following commands are transactional, and their
5748 5766 effects can be rolled back:
5749 5767
5750 5768 - commit
5751 5769 - import
5752 5770 - pull
5753 5771 - push (with this repository as the destination)
5754 5772 - unbundle
5755 5773
5756 5774 To avoid permanent data loss, rollback will refuse to rollback a
5757 5775 commit transaction if it isn't checked out. Use --force to
5758 5776 override this protection.
5759 5777
5760 5778 This command is not intended for use on public repositories. Once
5761 5779 changes are visible for pull by other users, rolling a transaction
5762 5780 back locally is ineffective (someone else may already have pulled
5763 5781 the changes). Furthermore, a race is possible with readers of the
5764 5782 repository; for example an in-progress pull from the repository
5765 5783 may fail if a rollback is performed.
5766 5784
5767 5785 Returns 0 on success, 1 if no rollback data is available.
5768 5786 """
5769 5787 return repo.rollback(dryrun=opts.get('dry_run'),
5770 5788 force=opts.get('force'))
5771 5789
5772 5790 @command('root', [])
5773 5791 def root(ui, repo):
5774 5792 """print the root (top) of the current working directory
5775 5793
5776 5794 Print the root directory of the current repository.
5777 5795
5778 5796 Returns 0 on success.
5779 5797 """
5780 5798 ui.write(repo.root + "\n")
5781 5799
5782 5800 @command('^serve',
5783 5801 [('A', 'accesslog', '', _('name of access log file to write to'),
5784 5802 _('FILE')),
5785 5803 ('d', 'daemon', None, _('run server in background')),
5786 5804 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('FILE')),
5787 5805 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5788 5806 # use string type, then we can check if something was passed
5789 5807 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5790 5808 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5791 5809 _('ADDR')),
5792 5810 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5793 5811 _('PREFIX')),
5794 5812 ('n', 'name', '',
5795 5813 _('name to show in web pages (default: working directory)'), _('NAME')),
5796 5814 ('', 'web-conf', '',
5797 5815 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5798 5816 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5799 5817 _('FILE')),
5800 5818 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5801 5819 ('', 'stdio', None, _('for remote clients')),
5802 5820 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5803 5821 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5804 5822 ('', 'style', '', _('template style to use'), _('STYLE')),
5805 5823 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5806 5824 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5807 5825 _('[OPTION]...'),
5808 5826 optionalrepo=True)
5809 5827 def serve(ui, repo, **opts):
5810 5828 """start stand-alone webserver
5811 5829
5812 5830 Start a local HTTP repository browser and pull server. You can use
5813 5831 this for ad-hoc sharing and browsing of repositories. It is
5814 5832 recommended to use a real web server to serve a repository for
5815 5833 longer periods of time.
5816 5834
5817 5835 Please note that the server does not implement access control.
5818 5836 This means that, by default, anybody can read from the server and
5819 5837 nobody can write to it by default. Set the ``web.allow_push``
5820 5838 option to ``*`` to allow everybody to push to the server. You
5821 5839 should use a real web server if you need to authenticate users.
5822 5840
5823 5841 By default, the server logs accesses to stdout and errors to
5824 5842 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5825 5843 files.
5826 5844
5827 5845 To have the server choose a free port number to listen on, specify
5828 5846 a port number of 0; in this case, the server will print the port
5829 5847 number it uses.
5830 5848
5831 5849 Returns 0 on success.
5832 5850 """
5833 5851
5834 5852 if opts["stdio"] and opts["cmdserver"]:
5835 5853 raise error.Abort(_("cannot use --stdio with --cmdserver"))
5836 5854
5837 5855 if opts["stdio"]:
5838 5856 if repo is None:
5839 5857 raise error.RepoError(_("there is no Mercurial repository here"
5840 5858 " (.hg not found)"))
5841 5859 s = sshserver.sshserver(ui, repo)
5842 5860 s.serve_forever()
5843 5861
5844 5862 if opts["cmdserver"]:
5845 5863 import commandserver
5846 5864 service = commandserver.createservice(ui, repo, opts)
5847 5865 return cmdutil.service(opts, initfn=service.init, runfn=service.run)
5848 5866
5849 5867 # this way we can check if something was given in the command-line
5850 5868 if opts.get('port'):
5851 5869 opts['port'] = util.getport(opts.get('port'))
5852 5870
5853 5871 if repo:
5854 5872 baseui = repo.baseui
5855 5873 else:
5856 5874 baseui = ui
5857 5875 optlist = ("name templates style address port prefix ipv6"
5858 5876 " accesslog errorlog certificate encoding")
5859 5877 for o in optlist.split():
5860 5878 val = opts.get(o, '')
5861 5879 if val in (None, ''): # should check against default options instead
5862 5880 continue
5863 5881 baseui.setconfig("web", o, val, 'serve')
5864 5882 if repo and repo.ui != baseui:
5865 5883 repo.ui.setconfig("web", o, val, 'serve')
5866 5884
5867 5885 o = opts.get('web_conf') or opts.get('webdir_conf')
5868 5886 if not o:
5869 5887 if not repo:
5870 5888 raise error.RepoError(_("there is no Mercurial repository"
5871 5889 " here (.hg not found)"))
5872 5890 o = repo
5873 5891
5874 5892 app = hgweb.hgweb(o, baseui=baseui)
5875 5893 service = httpservice(ui, app, opts)
5876 5894 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5877 5895
5878 5896 class httpservice(object):
5879 5897 def __init__(self, ui, app, opts):
5880 5898 self.ui = ui
5881 5899 self.app = app
5882 5900 self.opts = opts
5883 5901
5884 5902 def init(self):
5885 5903 util.setsignalhandler()
5886 5904 self.httpd = hgweb_server.create_server(self.ui, self.app)
5887 5905
5888 5906 if self.opts['port'] and not self.ui.verbose:
5889 5907 return
5890 5908
5891 5909 if self.httpd.prefix:
5892 5910 prefix = self.httpd.prefix.strip('/') + '/'
5893 5911 else:
5894 5912 prefix = ''
5895 5913
5896 5914 port = ':%d' % self.httpd.port
5897 5915 if port == ':80':
5898 5916 port = ''
5899 5917
5900 5918 bindaddr = self.httpd.addr
5901 5919 if bindaddr == '0.0.0.0':
5902 5920 bindaddr = '*'
5903 5921 elif ':' in bindaddr: # IPv6
5904 5922 bindaddr = '[%s]' % bindaddr
5905 5923
5906 5924 fqaddr = self.httpd.fqaddr
5907 5925 if ':' in fqaddr:
5908 5926 fqaddr = '[%s]' % fqaddr
5909 5927 if self.opts['port']:
5910 5928 write = self.ui.status
5911 5929 else:
5912 5930 write = self.ui.write
5913 5931 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5914 5932 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5915 5933 self.ui.flush() # avoid buffering of status message
5916 5934
5917 5935 def run(self):
5918 5936 self.httpd.serve_forever()
5919 5937
5920 5938
5921 5939 @command('^status|st',
5922 5940 [('A', 'all', None, _('show status of all files')),
5923 5941 ('m', 'modified', None, _('show only modified files')),
5924 5942 ('a', 'added', None, _('show only added files')),
5925 5943 ('r', 'removed', None, _('show only removed files')),
5926 5944 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5927 5945 ('c', 'clean', None, _('show only files without changes')),
5928 5946 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5929 5947 ('i', 'ignored', None, _('show only ignored files')),
5930 5948 ('n', 'no-status', None, _('hide status prefix')),
5931 5949 ('C', 'copies', None, _('show source of copied files')),
5932 5950 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5933 5951 ('', 'rev', [], _('show difference from revision'), _('REV')),
5934 5952 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5935 5953 ] + walkopts + subrepoopts + formatteropts,
5936 5954 _('[OPTION]... [FILE]...'),
5937 5955 inferrepo=True)
5938 5956 def status(ui, repo, *pats, **opts):
5939 5957 """show changed files in the working directory
5940 5958
5941 5959 Show status of files in the repository. If names are given, only
5942 5960 files that match are shown. Files that are clean or ignored or
5943 5961 the source of a copy/move operation, are not listed unless
5944 5962 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5945 5963 Unless options described with "show only ..." are given, the
5946 5964 options -mardu are used.
5947 5965
5948 5966 Option -q/--quiet hides untracked (unknown and ignored) files
5949 5967 unless explicitly requested with -u/--unknown or -i/--ignored.
5950 5968
5951 5969 .. note::
5952 5970
5953 5971 status may appear to disagree with diff if permissions have
5954 5972 changed or a merge has occurred. The standard diff format does
5955 5973 not report permission changes and diff only reports changes
5956 5974 relative to one merge parent.
5957 5975
5958 5976 If one revision is given, it is used as the base revision.
5959 5977 If two revisions are given, the differences between them are
5960 5978 shown. The --change option can also be used as a shortcut to list
5961 5979 the changed files of a revision from its first parent.
5962 5980
5963 5981 The codes used to show the status of files are::
5964 5982
5965 5983 M = modified
5966 5984 A = added
5967 5985 R = removed
5968 5986 C = clean
5969 5987 ! = missing (deleted by non-hg command, but still tracked)
5970 5988 ? = not tracked
5971 5989 I = ignored
5972 5990 = origin of the previous file (with --copies)
5973 5991
5974 5992 .. container:: verbose
5975 5993
5976 5994 Examples:
5977 5995
5978 5996 - show changes in the working directory relative to a
5979 5997 changeset::
5980 5998
5981 5999 hg status --rev 9353
5982 6000
5983 6001 - show changes in the working directory relative to the
5984 6002 current directory (see :hg:`help patterns` for more information)::
5985 6003
5986 6004 hg status re:
5987 6005
5988 6006 - show all changes including copies in an existing changeset::
5989 6007
5990 6008 hg status --copies --change 9353
5991 6009
5992 6010 - get a NUL separated list of added files, suitable for xargs::
5993 6011
5994 6012 hg status -an0
5995 6013
5996 6014 Returns 0 on success.
5997 6015 """
5998 6016
5999 6017 revs = opts.get('rev')
6000 6018 change = opts.get('change')
6001 6019
6002 6020 if revs and change:
6003 6021 msg = _('cannot specify --rev and --change at the same time')
6004 6022 raise error.Abort(msg)
6005 6023 elif change:
6006 6024 node2 = scmutil.revsingle(repo, change, None).node()
6007 6025 node1 = repo[node2].p1().node()
6008 6026 else:
6009 6027 node1, node2 = scmutil.revpair(repo, revs)
6010 6028
6011 6029 if pats:
6012 6030 cwd = repo.getcwd()
6013 6031 else:
6014 6032 cwd = ''
6015 6033
6016 6034 if opts.get('print0'):
6017 6035 end = '\0'
6018 6036 else:
6019 6037 end = '\n'
6020 6038 copy = {}
6021 6039 states = 'modified added removed deleted unknown ignored clean'.split()
6022 6040 show = [k for k in states if opts.get(k)]
6023 6041 if opts.get('all'):
6024 6042 show += ui.quiet and (states[:4] + ['clean']) or states
6025 6043 if not show:
6026 6044 if ui.quiet:
6027 6045 show = states[:4]
6028 6046 else:
6029 6047 show = states[:5]
6030 6048
6031 6049 m = scmutil.match(repo[node2], pats, opts)
6032 6050 stat = repo.status(node1, node2, m,
6033 6051 'ignored' in show, 'clean' in show, 'unknown' in show,
6034 6052 opts.get('subrepos'))
6035 6053 changestates = zip(states, 'MAR!?IC', stat)
6036 6054
6037 6055 if (opts.get('all') or opts.get('copies')
6038 6056 or ui.configbool('ui', 'statuscopies')) and not opts.get('no_status'):
6039 6057 copy = copies.pathcopies(repo[node1], repo[node2], m)
6040 6058
6041 6059 fm = ui.formatter('status', opts)
6042 6060 fmt = '%s' + end
6043 6061 showchar = not opts.get('no_status')
6044 6062
6045 6063 for state, char, files in changestates:
6046 6064 if state in show:
6047 6065 label = 'status.' + state
6048 6066 for f in files:
6049 6067 fm.startitem()
6050 6068 fm.condwrite(showchar, 'status', '%s ', char, label=label)
6051 6069 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
6052 6070 if f in copy:
6053 6071 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
6054 6072 label='status.copied')
6055 6073 fm.end()
6056 6074
6057 6075 @command('^summary|sum',
6058 6076 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
6059 6077 def summary(ui, repo, **opts):
6060 6078 """summarize working directory state
6061 6079
6062 6080 This generates a brief summary of the working directory state,
6063 6081 including parents, branch, commit status, phase and available updates.
6064 6082
6065 6083 With the --remote option, this will check the default paths for
6066 6084 incoming and outgoing changes. This can be time-consuming.
6067 6085
6068 6086 Returns 0 on success.
6069 6087 """
6070 6088
6071 6089 ctx = repo[None]
6072 6090 parents = ctx.parents()
6073 6091 pnode = parents[0].node()
6074 6092 marks = []
6075 6093
6076 6094 for p in parents:
6077 6095 # label with log.changeset (instead of log.parent) since this
6078 6096 # shows a working directory parent *changeset*:
6079 6097 # i18n: column positioning for "hg summary"
6080 6098 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
6081 6099 label='log.changeset changeset.%s' % p.phasestr())
6082 6100 ui.write(' '.join(p.tags()), label='log.tag')
6083 6101 if p.bookmarks():
6084 6102 marks.extend(p.bookmarks())
6085 6103 if p.rev() == -1:
6086 6104 if not len(repo):
6087 6105 ui.write(_(' (empty repository)'))
6088 6106 else:
6089 6107 ui.write(_(' (no revision checked out)'))
6090 6108 ui.write('\n')
6091 6109 if p.description():
6092 6110 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
6093 6111 label='log.summary')
6094 6112
6095 6113 branch = ctx.branch()
6096 6114 bheads = repo.branchheads(branch)
6097 6115 # i18n: column positioning for "hg summary"
6098 6116 m = _('branch: %s\n') % branch
6099 6117 if branch != 'default':
6100 6118 ui.write(m, label='log.branch')
6101 6119 else:
6102 6120 ui.status(m, label='log.branch')
6103 6121
6104 6122 if marks:
6105 6123 active = repo._activebookmark
6106 6124 # i18n: column positioning for "hg summary"
6107 6125 ui.write(_('bookmarks:'), label='log.bookmark')
6108 6126 if active is not None:
6109 6127 if active in marks:
6110 6128 ui.write(' *' + active, label=activebookmarklabel)
6111 6129 marks.remove(active)
6112 6130 else:
6113 6131 ui.write(' [%s]' % active, label=activebookmarklabel)
6114 6132 for m in marks:
6115 6133 ui.write(' ' + m, label='log.bookmark')
6116 6134 ui.write('\n', label='log.bookmark')
6117 6135
6118 6136 status = repo.status(unknown=True)
6119 6137
6120 6138 c = repo.dirstate.copies()
6121 6139 copied, renamed = [], []
6122 6140 for d, s in c.iteritems():
6123 6141 if s in status.removed:
6124 6142 status.removed.remove(s)
6125 6143 renamed.append(d)
6126 6144 else:
6127 6145 copied.append(d)
6128 6146 if d in status.added:
6129 6147 status.added.remove(d)
6130 6148
6131 6149 ms = mergemod.mergestate(repo)
6132 6150 unresolved = [f for f in ms if ms[f] == 'u']
6133 6151
6134 6152 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
6135 6153
6136 6154 labels = [(ui.label(_('%d modified'), 'status.modified'), status.modified),
6137 6155 (ui.label(_('%d added'), 'status.added'), status.added),
6138 6156 (ui.label(_('%d removed'), 'status.removed'), status.removed),
6139 6157 (ui.label(_('%d renamed'), 'status.copied'), renamed),
6140 6158 (ui.label(_('%d copied'), 'status.copied'), copied),
6141 6159 (ui.label(_('%d deleted'), 'status.deleted'), status.deleted),
6142 6160 (ui.label(_('%d unknown'), 'status.unknown'), status.unknown),
6143 6161 (ui.label(_('%d unresolved'), 'resolve.unresolved'), unresolved),
6144 6162 (ui.label(_('%d subrepos'), 'status.modified'), subs)]
6145 6163 t = []
6146 6164 for l, s in labels:
6147 6165 if s:
6148 6166 t.append(l % len(s))
6149 6167
6150 6168 t = ', '.join(t)
6151 6169 cleanworkdir = False
6152 6170
6153 6171 if repo.vfs.exists('updatestate'):
6154 6172 t += _(' (interrupted update)')
6155 6173 elif len(parents) > 1:
6156 6174 t += _(' (merge)')
6157 6175 elif branch != parents[0].branch():
6158 6176 t += _(' (new branch)')
6159 6177 elif (parents[0].closesbranch() and
6160 6178 pnode in repo.branchheads(branch, closed=True)):
6161 6179 t += _(' (head closed)')
6162 6180 elif not (status.modified or status.added or status.removed or renamed or
6163 6181 copied or subs):
6164 6182 t += _(' (clean)')
6165 6183 cleanworkdir = True
6166 6184 elif pnode not in bheads:
6167 6185 t += _(' (new branch head)')
6168 6186
6169 6187 if parents:
6170 6188 pendingphase = max(p.phase() for p in parents)
6171 6189 else:
6172 6190 pendingphase = phases.public
6173 6191
6174 6192 if pendingphase > phases.newcommitphase(ui):
6175 6193 t += ' (%s)' % phases.phasenames[pendingphase]
6176 6194
6177 6195 if cleanworkdir:
6178 6196 # i18n: column positioning for "hg summary"
6179 6197 ui.status(_('commit: %s\n') % t.strip())
6180 6198 else:
6181 6199 # i18n: column positioning for "hg summary"
6182 6200 ui.write(_('commit: %s\n') % t.strip())
6183 6201
6184 6202 # all ancestors of branch heads - all ancestors of parent = new csets
6185 6203 new = len(repo.changelog.findmissing([pctx.node() for pctx in parents],
6186 6204 bheads))
6187 6205
6188 6206 if new == 0:
6189 6207 # i18n: column positioning for "hg summary"
6190 6208 ui.status(_('update: (current)\n'))
6191 6209 elif pnode not in bheads:
6192 6210 # i18n: column positioning for "hg summary"
6193 6211 ui.write(_('update: %d new changesets (update)\n') % new)
6194 6212 else:
6195 6213 # i18n: column positioning for "hg summary"
6196 6214 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
6197 6215 (new, len(bheads)))
6198 6216
6199 6217 t = []
6200 6218 draft = len(repo.revs('draft()'))
6201 6219 if draft:
6202 6220 t.append(_('%d draft') % draft)
6203 6221 secret = len(repo.revs('secret()'))
6204 6222 if secret:
6205 6223 t.append(_('%d secret') % secret)
6206 6224
6207 6225 if draft or secret:
6208 6226 ui.status(_('phases: %s\n') % ', '.join(t))
6209 6227
6210 6228 cmdutil.summaryhooks(ui, repo)
6211 6229
6212 6230 if opts.get('remote'):
6213 6231 needsincoming, needsoutgoing = True, True
6214 6232 else:
6215 6233 needsincoming, needsoutgoing = False, False
6216 6234 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
6217 6235 if i:
6218 6236 needsincoming = True
6219 6237 if o:
6220 6238 needsoutgoing = True
6221 6239 if not needsincoming and not needsoutgoing:
6222 6240 return
6223 6241
6224 6242 def getincoming():
6225 6243 source, branches = hg.parseurl(ui.expandpath('default'))
6226 6244 sbranch = branches[0]
6227 6245 try:
6228 6246 other = hg.peer(repo, {}, source)
6229 6247 except error.RepoError:
6230 6248 if opts.get('remote'):
6231 6249 raise
6232 6250 return source, sbranch, None, None, None
6233 6251 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
6234 6252 if revs:
6235 6253 revs = [other.lookup(rev) for rev in revs]
6236 6254 ui.debug('comparing with %s\n' % util.hidepassword(source))
6237 6255 repo.ui.pushbuffer()
6238 6256 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
6239 6257 repo.ui.popbuffer()
6240 6258 return source, sbranch, other, commoninc, commoninc[1]
6241 6259
6242 6260 if needsincoming:
6243 6261 source, sbranch, sother, commoninc, incoming = getincoming()
6244 6262 else:
6245 6263 source = sbranch = sother = commoninc = incoming = None
6246 6264
6247 6265 def getoutgoing():
6248 6266 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
6249 6267 dbranch = branches[0]
6250 6268 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
6251 6269 if source != dest:
6252 6270 try:
6253 6271 dother = hg.peer(repo, {}, dest)
6254 6272 except error.RepoError:
6255 6273 if opts.get('remote'):
6256 6274 raise
6257 6275 return dest, dbranch, None, None
6258 6276 ui.debug('comparing with %s\n' % util.hidepassword(dest))
6259 6277 elif sother is None:
6260 6278 # there is no explicit destination peer, but source one is invalid
6261 6279 return dest, dbranch, None, None
6262 6280 else:
6263 6281 dother = sother
6264 6282 if (source != dest or (sbranch is not None and sbranch != dbranch)):
6265 6283 common = None
6266 6284 else:
6267 6285 common = commoninc
6268 6286 if revs:
6269 6287 revs = [repo.lookup(rev) for rev in revs]
6270 6288 repo.ui.pushbuffer()
6271 6289 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
6272 6290 commoninc=common)
6273 6291 repo.ui.popbuffer()
6274 6292 return dest, dbranch, dother, outgoing
6275 6293
6276 6294 if needsoutgoing:
6277 6295 dest, dbranch, dother, outgoing = getoutgoing()
6278 6296 else:
6279 6297 dest = dbranch = dother = outgoing = None
6280 6298
6281 6299 if opts.get('remote'):
6282 6300 t = []
6283 6301 if incoming:
6284 6302 t.append(_('1 or more incoming'))
6285 6303 o = outgoing.missing
6286 6304 if o:
6287 6305 t.append(_('%d outgoing') % len(o))
6288 6306 other = dother or sother
6289 6307 if 'bookmarks' in other.listkeys('namespaces'):
6290 6308 counts = bookmarks.summary(repo, other)
6291 6309 if counts[0] > 0:
6292 6310 t.append(_('%d incoming bookmarks') % counts[0])
6293 6311 if counts[1] > 0:
6294 6312 t.append(_('%d outgoing bookmarks') % counts[1])
6295 6313
6296 6314 if t:
6297 6315 # i18n: column positioning for "hg summary"
6298 6316 ui.write(_('remote: %s\n') % (', '.join(t)))
6299 6317 else:
6300 6318 # i18n: column positioning for "hg summary"
6301 6319 ui.status(_('remote: (synced)\n'))
6302 6320
6303 6321 cmdutil.summaryremotehooks(ui, repo, opts,
6304 6322 ((source, sbranch, sother, commoninc),
6305 6323 (dest, dbranch, dother, outgoing)))
6306 6324
6307 6325 @command('tag',
6308 6326 [('f', 'force', None, _('force tag')),
6309 6327 ('l', 'local', None, _('make the tag local')),
6310 6328 ('r', 'rev', '', _('revision to tag'), _('REV')),
6311 6329 ('', 'remove', None, _('remove a tag')),
6312 6330 # -l/--local is already there, commitopts cannot be used
6313 6331 ('e', 'edit', None, _('invoke editor on commit messages')),
6314 6332 ('m', 'message', '', _('use text as commit message'), _('TEXT')),
6315 6333 ] + commitopts2,
6316 6334 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
6317 6335 def tag(ui, repo, name1, *names, **opts):
6318 6336 """add one or more tags for the current or given revision
6319 6337
6320 6338 Name a particular revision using <name>.
6321 6339
6322 6340 Tags are used to name particular revisions of the repository and are
6323 6341 very useful to compare different revisions, to go back to significant
6324 6342 earlier versions or to mark branch points as releases, etc. Changing
6325 6343 an existing tag is normally disallowed; use -f/--force to override.
6326 6344
6327 6345 If no revision is given, the parent of the working directory is
6328 6346 used.
6329 6347
6330 6348 To facilitate version control, distribution, and merging of tags,
6331 6349 they are stored as a file named ".hgtags" which is managed similarly
6332 6350 to other project files and can be hand-edited if necessary. This
6333 6351 also means that tagging creates a new commit. The file
6334 6352 ".hg/localtags" is used for local tags (not shared among
6335 6353 repositories).
6336 6354
6337 6355 Tag commits are usually made at the head of a branch. If the parent
6338 6356 of the working directory is not a branch head, :hg:`tag` aborts; use
6339 6357 -f/--force to force the tag commit to be based on a non-head
6340 6358 changeset.
6341 6359
6342 6360 See :hg:`help dates` for a list of formats valid for -d/--date.
6343 6361
6344 6362 Since tag names have priority over branch names during revision
6345 6363 lookup, using an existing branch name as a tag name is discouraged.
6346 6364
6347 6365 Returns 0 on success.
6348 6366 """
6349 6367 wlock = lock = None
6350 6368 try:
6351 6369 wlock = repo.wlock()
6352 6370 lock = repo.lock()
6353 6371 rev_ = "."
6354 6372 names = [t.strip() for t in (name1,) + names]
6355 6373 if len(names) != len(set(names)):
6356 6374 raise error.Abort(_('tag names must be unique'))
6357 6375 for n in names:
6358 6376 scmutil.checknewlabel(repo, n, 'tag')
6359 6377 if not n:
6360 6378 raise error.Abort(_('tag names cannot consist entirely of '
6361 6379 'whitespace'))
6362 6380 if opts.get('rev') and opts.get('remove'):
6363 6381 raise error.Abort(_("--rev and --remove are incompatible"))
6364 6382 if opts.get('rev'):
6365 6383 rev_ = opts['rev']
6366 6384 message = opts.get('message')
6367 6385 if opts.get('remove'):
6368 6386 if opts.get('local'):
6369 6387 expectedtype = 'local'
6370 6388 else:
6371 6389 expectedtype = 'global'
6372 6390
6373 6391 for n in names:
6374 6392 if not repo.tagtype(n):
6375 6393 raise error.Abort(_("tag '%s' does not exist") % n)
6376 6394 if repo.tagtype(n) != expectedtype:
6377 6395 if expectedtype == 'global':
6378 6396 raise error.Abort(_("tag '%s' is not a global tag") % n)
6379 6397 else:
6380 6398 raise error.Abort(_("tag '%s' is not a local tag") % n)
6381 6399 rev_ = 'null'
6382 6400 if not message:
6383 6401 # we don't translate commit messages
6384 6402 message = 'Removed tag %s' % ', '.join(names)
6385 6403 elif not opts.get('force'):
6386 6404 for n in names:
6387 6405 if n in repo.tags():
6388 6406 raise error.Abort(_("tag '%s' already exists "
6389 6407 "(use -f to force)") % n)
6390 6408 if not opts.get('local'):
6391 6409 p1, p2 = repo.dirstate.parents()
6392 6410 if p2 != nullid:
6393 6411 raise error.Abort(_('uncommitted merge'))
6394 6412 bheads = repo.branchheads()
6395 6413 if not opts.get('force') and bheads and p1 not in bheads:
6396 6414 raise error.Abort(_('not at a branch head (use -f to force)'))
6397 6415 r = scmutil.revsingle(repo, rev_).node()
6398 6416
6399 6417 if not message:
6400 6418 # we don't translate commit messages
6401 6419 message = ('Added tag %s for changeset %s' %
6402 6420 (', '.join(names), short(r)))
6403 6421
6404 6422 date = opts.get('date')
6405 6423 if date:
6406 6424 date = util.parsedate(date)
6407 6425
6408 6426 if opts.get('remove'):
6409 6427 editform = 'tag.remove'
6410 6428 else:
6411 6429 editform = 'tag.add'
6412 6430 editor = cmdutil.getcommiteditor(editform=editform, **opts)
6413 6431
6414 6432 # don't allow tagging the null rev
6415 6433 if (not opts.get('remove') and
6416 6434 scmutil.revsingle(repo, rev_).rev() == nullrev):
6417 6435 raise error.Abort(_("cannot tag null revision"))
6418 6436
6419 6437 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
6420 6438 editor=editor)
6421 6439 finally:
6422 6440 release(lock, wlock)
6423 6441
6424 6442 @command('tags', formatteropts, '')
6425 6443 def tags(ui, repo, **opts):
6426 6444 """list repository tags
6427 6445
6428 6446 This lists both regular and local tags. When the -v/--verbose
6429 6447 switch is used, a third column "local" is printed for local tags.
6430 6448
6431 6449 Returns 0 on success.
6432 6450 """
6433 6451
6434 6452 fm = ui.formatter('tags', opts)
6435 6453 hexfunc = fm.hexfunc
6436 6454 tagtype = ""
6437 6455
6438 6456 for t, n in reversed(repo.tagslist()):
6439 6457 hn = hexfunc(n)
6440 6458 label = 'tags.normal'
6441 6459 tagtype = ''
6442 6460 if repo.tagtype(t) == 'local':
6443 6461 label = 'tags.local'
6444 6462 tagtype = 'local'
6445 6463
6446 6464 fm.startitem()
6447 6465 fm.write('tag', '%s', t, label=label)
6448 6466 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
6449 6467 fm.condwrite(not ui.quiet, 'rev node', fmt,
6450 6468 repo.changelog.rev(n), hn, label=label)
6451 6469 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
6452 6470 tagtype, label=label)
6453 6471 fm.plain('\n')
6454 6472 fm.end()
6455 6473
6456 6474 @command('tip',
6457 6475 [('p', 'patch', None, _('show patch')),
6458 6476 ('g', 'git', None, _('use git extended diff format')),
6459 6477 ] + templateopts,
6460 6478 _('[-p] [-g]'))
6461 6479 def tip(ui, repo, **opts):
6462 6480 """show the tip revision (DEPRECATED)
6463 6481
6464 6482 The tip revision (usually just called the tip) is the changeset
6465 6483 most recently added to the repository (and therefore the most
6466 6484 recently changed head).
6467 6485
6468 6486 If you have just made a commit, that commit will be the tip. If
6469 6487 you have just pulled changes from another repository, the tip of
6470 6488 that repository becomes the current tip. The "tip" tag is special
6471 6489 and cannot be renamed or assigned to a different changeset.
6472 6490
6473 6491 This command is deprecated, please use :hg:`heads` instead.
6474 6492
6475 6493 Returns 0 on success.
6476 6494 """
6477 6495 displayer = cmdutil.show_changeset(ui, repo, opts)
6478 6496 displayer.show(repo['tip'])
6479 6497 displayer.close()
6480 6498
6481 6499 @command('unbundle',
6482 6500 [('u', 'update', None,
6483 6501 _('update to new branch head if changesets were unbundled'))],
6484 6502 _('[-u] FILE...'))
6485 6503 def unbundle(ui, repo, fname1, *fnames, **opts):
6486 6504 """apply one or more changegroup files
6487 6505
6488 6506 Apply one or more compressed changegroup files generated by the
6489 6507 bundle command.
6490 6508
6491 6509 Returns 0 on success, 1 if an update has unresolved files.
6492 6510 """
6493 6511 fnames = (fname1,) + fnames
6494 6512
6495 6513 lock = repo.lock()
6496 6514 try:
6497 6515 for fname in fnames:
6498 6516 f = hg.openpath(ui, fname)
6499 6517 gen = exchange.readbundle(ui, f, fname)
6500 6518 if isinstance(gen, bundle2.unbundle20):
6501 6519 tr = repo.transaction('unbundle')
6502 6520 try:
6503 6521 op = bundle2.processbundle(repo, gen, lambda: tr)
6504 6522 tr.close()
6505 6523 except error.BundleUnknownFeatureError as exc:
6506 6524 raise error.Abort(_('%s: unknown bundle feature, %s')
6507 6525 % (fname, exc),
6508 6526 hint=_("see https://mercurial-scm.org/"
6509 6527 "wiki/BundleFeature for more "
6510 6528 "information"))
6511 6529 finally:
6512 6530 if tr:
6513 6531 tr.release()
6514 6532 changes = [r.get('return', 0)
6515 6533 for r in op.records['changegroup']]
6516 6534 modheads = changegroup.combineresults(changes)
6517 6535 else:
6518 6536 modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
6519 6537 finally:
6520 6538 lock.release()
6521 6539
6522 6540 return postincoming(ui, repo, modheads, opts.get('update'), None)
6523 6541
6524 6542 @command('^update|up|checkout|co',
6525 6543 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
6526 6544 ('c', 'check', None,
6527 6545 _('update across branches if no uncommitted changes')),
6528 6546 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
6529 6547 ('r', 'rev', '', _('revision'), _('REV'))
6530 6548 ] + mergetoolopts,
6531 6549 _('[-c] [-C] [-d DATE] [[-r] REV]'))
6532 6550 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
6533 6551 tool=None):
6534 6552 """update working directory (or switch revisions)
6535 6553
6536 6554 Update the repository's working directory to the specified
6537 6555 changeset. If no changeset is specified, update to the tip of the
6538 6556 current named branch and move the active bookmark (see :hg:`help
6539 6557 bookmarks`).
6540 6558
6541 6559 Update sets the working directory's parent revision to the specified
6542 6560 changeset (see :hg:`help parents`).
6543 6561
6544 6562 If the changeset is not a descendant or ancestor of the working
6545 6563 directory's parent, the update is aborted. With the -c/--check
6546 6564 option, the working directory is checked for uncommitted changes; if
6547 6565 none are found, the working directory is updated to the specified
6548 6566 changeset.
6549 6567
6550 6568 .. container:: verbose
6551 6569
6552 6570 The following rules apply when the working directory contains
6553 6571 uncommitted changes:
6554 6572
6555 6573 1. If neither -c/--check nor -C/--clean is specified, and if
6556 6574 the requested changeset is an ancestor or descendant of
6557 6575 the working directory's parent, the uncommitted changes
6558 6576 are merged into the requested changeset and the merged
6559 6577 result is left uncommitted. If the requested changeset is
6560 6578 not an ancestor or descendant (that is, it is on another
6561 6579 branch), the update is aborted and the uncommitted changes
6562 6580 are preserved.
6563 6581
6564 6582 2. With the -c/--check option, the update is aborted and the
6565 6583 uncommitted changes are preserved.
6566 6584
6567 6585 3. With the -C/--clean option, uncommitted changes are discarded and
6568 6586 the working directory is updated to the requested changeset.
6569 6587
6570 6588 To cancel an uncommitted merge (and lose your changes), use
6571 6589 :hg:`update --clean .`.
6572 6590
6573 6591 Use null as the changeset to remove the working directory (like
6574 6592 :hg:`clone -U`).
6575 6593
6576 6594 If you want to revert just one file to an older revision, use
6577 6595 :hg:`revert [-r REV] NAME`.
6578 6596
6579 6597 See :hg:`help dates` for a list of formats valid for -d/--date.
6580 6598
6581 6599 Returns 0 on success, 1 if there are unresolved files.
6582 6600 """
6583 6601 movemarkfrom = None
6584 6602 if rev and node:
6585 6603 raise error.Abort(_("please specify just one revision"))
6586 6604
6587 6605 if rev is None or rev == '':
6588 6606 rev = node
6589 6607
6590 6608 wlock = repo.wlock()
6591 6609 try:
6592 6610 cmdutil.clearunfinished(repo)
6593 6611
6594 6612 if date:
6595 6613 if rev is not None:
6596 6614 raise error.Abort(_("you can't specify a revision and a date"))
6597 6615 rev = cmdutil.finddate(ui, repo, date)
6598 6616
6599 6617 # if we defined a bookmark, we have to remember the original name
6600 6618 brev = rev
6601 6619 rev = scmutil.revsingle(repo, rev, rev).rev()
6602 6620
6603 6621 if check and clean:
6604 6622 raise error.Abort(_("cannot specify both -c/--check and -C/--clean")
6605 6623 )
6606 6624
6607 6625 if check:
6608 6626 cmdutil.bailifchanged(repo, merge=False)
6609 6627 if rev is None:
6610 6628 updata = destutil.destupdate(repo, clean=clean, check=check)
6611 6629 rev, movemarkfrom, brev = updata
6612 6630
6613 6631 repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
6614 6632
6615 6633 if clean:
6616 6634 ret = hg.clean(repo, rev)
6617 6635 else:
6618 6636 ret = hg.update(repo, rev)
6619 6637
6620 6638 if not ret and movemarkfrom:
6621 6639 if movemarkfrom == repo['.'].node():
6622 6640 pass # no-op update
6623 6641 elif bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
6624 6642 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
6625 6643 else:
6626 6644 # this can happen with a non-linear update
6627 6645 ui.status(_("(leaving bookmark %s)\n") %
6628 6646 repo._activebookmark)
6629 6647 bookmarks.deactivate(repo)
6630 6648 elif brev in repo._bookmarks:
6631 6649 bookmarks.activate(repo, brev)
6632 6650 ui.status(_("(activating bookmark %s)\n") % brev)
6633 6651 elif brev:
6634 6652 if repo._activebookmark:
6635 6653 ui.status(_("(leaving bookmark %s)\n") %
6636 6654 repo._activebookmark)
6637 6655 bookmarks.deactivate(repo)
6638 6656 finally:
6639 6657 wlock.release()
6640 6658
6641 6659 return ret
6642 6660
6643 6661 @command('verify', [])
6644 6662 def verify(ui, repo):
6645 6663 """verify the integrity of the repository
6646 6664
6647 6665 Verify the integrity of the current repository.
6648 6666
6649 6667 This will perform an extensive check of the repository's
6650 6668 integrity, validating the hashes and checksums of each entry in
6651 6669 the changelog, manifest, and tracked files, as well as the
6652 6670 integrity of their crosslinks and indices.
6653 6671
6654 6672 Please see https://mercurial-scm.org/wiki/RepositoryCorruption
6655 6673 for more information about recovery from corruption of the
6656 6674 repository.
6657 6675
6658 6676 Returns 0 on success, 1 if errors are encountered.
6659 6677 """
6660 6678 return hg.verify(repo)
6661 6679
6662 6680 @command('version', [], norepo=True)
6663 6681 def version_(ui):
6664 6682 """output version and copyright information"""
6665 6683 ui.write(_("Mercurial Distributed SCM (version %s)\n")
6666 6684 % util.version())
6667 6685 ui.status(_(
6668 6686 "(see https://mercurial-scm.org for more information)\n"
6669 6687 "\nCopyright (C) 2005-2015 Matt Mackall and others\n"
6670 6688 "This is free software; see the source for copying conditions. "
6671 6689 "There is NO\nwarranty; "
6672 6690 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
6673 6691 ))
6674 6692
6675 6693 ui.note(_("\nEnabled extensions:\n\n"))
6676 6694 if ui.verbose:
6677 6695 # format names and versions into columns
6678 6696 names = []
6679 6697 vers = []
6680 6698 for name, module in extensions.extensions():
6681 6699 names.append(name)
6682 6700 vers.append(extensions.moduleversion(module))
6683 6701 if names:
6684 6702 maxnamelen = max(len(n) for n in names)
6685 6703 for i, name in enumerate(names):
6686 6704 ui.write(" %-*s %s\n" % (maxnamelen, name, vers[i]))
@@ -1,659 +1,697
1 1 Setting up test
2 2
3 3 $ hg init test
4 4 $ cd test
5 5 $ echo 0 > afile
6 6 $ hg add afile
7 7 $ hg commit -m "0.0"
8 8 $ echo 1 >> afile
9 9 $ hg commit -m "0.1"
10 10 $ echo 2 >> afile
11 11 $ hg commit -m "0.2"
12 12 $ echo 3 >> afile
13 13 $ hg commit -m "0.3"
14 14 $ hg update -C 0
15 15 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
16 16 $ echo 1 >> afile
17 17 $ hg commit -m "1.1"
18 18 created new head
19 19 $ echo 2 >> afile
20 20 $ hg commit -m "1.2"
21 21 $ echo "a line" > fred
22 22 $ echo 3 >> afile
23 23 $ hg add fred
24 24 $ hg commit -m "1.3"
25 25 $ hg mv afile adifferentfile
26 26 $ hg commit -m "1.3m"
27 27 $ hg update -C 3
28 28 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
29 29 $ hg mv afile anotherfile
30 30 $ hg commit -m "0.3m"
31 31 $ hg verify
32 32 checking changesets
33 33 checking manifests
34 34 crosschecking files in changesets and manifests
35 35 checking files
36 36 4 files, 9 changesets, 7 total revisions
37 37 $ cd ..
38 38 $ hg init empty
39 39
40 40 Bundle and phase
41 41
42 42 $ hg -R test phase --force --secret 0
43 43 $ hg -R test bundle phase.hg empty
44 44 searching for changes
45 45 no changes found (ignored 9 secret changesets)
46 46 [1]
47 47 $ hg -R test phase --draft -r 'head()'
48 48
49 49 Bundle --all
50 50
51 51 $ hg -R test bundle --all all.hg
52 52 9 changesets found
53 53
54 54 Bundle test to full.hg
55 55
56 56 $ hg -R test bundle full.hg empty
57 57 searching for changes
58 58 9 changesets found
59 59
60 60 Unbundle full.hg in test
61 61
62 62 $ hg -R test unbundle full.hg
63 63 adding changesets
64 64 adding manifests
65 65 adding file changes
66 66 added 0 changesets with 0 changes to 4 files
67 67 (run 'hg update' to get a working copy)
68 68
69 69 Verify empty
70 70
71 71 $ hg -R empty heads
72 72 [1]
73 73 $ hg -R empty verify
74 74 checking changesets
75 75 checking manifests
76 76 crosschecking files in changesets and manifests
77 77 checking files
78 78 0 files, 0 changesets, 0 total revisions
79 79
80 80 Pull full.hg into test (using --cwd)
81 81
82 82 $ hg --cwd test pull ../full.hg
83 83 pulling from ../full.hg
84 84 searching for changes
85 85 no changes found
86 86
87 87 Verify that there are no leaked temporary files after pull (issue2797)
88 88
89 89 $ ls test/.hg | grep .hg10un
90 90 [1]
91 91
92 92 Pull full.hg into empty (using --cwd)
93 93
94 94 $ hg --cwd empty pull ../full.hg
95 95 pulling from ../full.hg
96 96 requesting all changes
97 97 adding changesets
98 98 adding manifests
99 99 adding file changes
100 100 added 9 changesets with 7 changes to 4 files (+1 heads)
101 101 (run 'hg heads' to see heads, 'hg merge' to merge)
102 102
103 103 Rollback empty
104 104
105 105 $ hg -R empty rollback
106 106 repository tip rolled back to revision -1 (undo pull)
107 107
108 108 Pull full.hg into empty again (using --cwd)
109 109
110 110 $ hg --cwd empty pull ../full.hg
111 111 pulling from ../full.hg
112 112 requesting all changes
113 113 adding changesets
114 114 adding manifests
115 115 adding file changes
116 116 added 9 changesets with 7 changes to 4 files (+1 heads)
117 117 (run 'hg heads' to see heads, 'hg merge' to merge)
118 118
119 119 Pull full.hg into test (using -R)
120 120
121 121 $ hg -R test pull full.hg
122 122 pulling from full.hg
123 123 searching for changes
124 124 no changes found
125 125
126 126 Pull full.hg into empty (using -R)
127 127
128 128 $ hg -R empty pull full.hg
129 129 pulling from full.hg
130 130 searching for changes
131 131 no changes found
132 132
133 133 Rollback empty
134 134
135 135 $ hg -R empty rollback
136 136 repository tip rolled back to revision -1 (undo pull)
137 137
138 138 Pull full.hg into empty again (using -R)
139 139
140 140 $ hg -R empty pull full.hg
141 141 pulling from full.hg
142 142 requesting all changes
143 143 adding changesets
144 144 adding manifests
145 145 adding file changes
146 146 added 9 changesets with 7 changes to 4 files (+1 heads)
147 147 (run 'hg heads' to see heads, 'hg merge' to merge)
148 148
149 149 Log -R full.hg in fresh empty
150 150
151 151 $ rm -r empty
152 152 $ hg init empty
153 153 $ cd empty
154 154 $ hg -R bundle://../full.hg log
155 155 changeset: 8:aa35859c02ea
156 156 tag: tip
157 157 parent: 3:eebf5a27f8ca
158 158 user: test
159 159 date: Thu Jan 01 00:00:00 1970 +0000
160 160 summary: 0.3m
161 161
162 162 changeset: 7:a6a34bfa0076
163 163 user: test
164 164 date: Thu Jan 01 00:00:00 1970 +0000
165 165 summary: 1.3m
166 166
167 167 changeset: 6:7373c1169842
168 168 user: test
169 169 date: Thu Jan 01 00:00:00 1970 +0000
170 170 summary: 1.3
171 171
172 172 changeset: 5:1bb50a9436a7
173 173 user: test
174 174 date: Thu Jan 01 00:00:00 1970 +0000
175 175 summary: 1.2
176 176
177 177 changeset: 4:095197eb4973
178 178 parent: 0:f9ee2f85a263
179 179 user: test
180 180 date: Thu Jan 01 00:00:00 1970 +0000
181 181 summary: 1.1
182 182
183 183 changeset: 3:eebf5a27f8ca
184 184 user: test
185 185 date: Thu Jan 01 00:00:00 1970 +0000
186 186 summary: 0.3
187 187
188 188 changeset: 2:e38ba6f5b7e0
189 189 user: test
190 190 date: Thu Jan 01 00:00:00 1970 +0000
191 191 summary: 0.2
192 192
193 193 changeset: 1:34c2bf6b0626
194 194 user: test
195 195 date: Thu Jan 01 00:00:00 1970 +0000
196 196 summary: 0.1
197 197
198 198 changeset: 0:f9ee2f85a263
199 199 user: test
200 200 date: Thu Jan 01 00:00:00 1970 +0000
201 201 summary: 0.0
202 202
203 203 Make sure bundlerepo doesn't leak tempfiles (issue2491)
204 204
205 205 $ ls .hg
206 206 00changelog.i
207 207 cache
208 208 requires
209 209 store
210 210
211 211 Pull ../full.hg into empty (with hook)
212 212
213 213 $ echo "[hooks]" >> .hg/hgrc
214 214 $ echo "changegroup = printenv.py changegroup" >> .hg/hgrc
215 215
216 216 doesn't work (yet ?)
217 217
218 218 hg -R bundle://../full.hg verify
219 219
220 220 $ hg pull bundle://../full.hg
221 221 pulling from bundle:../full.hg
222 222 requesting all changes
223 223 adding changesets
224 224 adding manifests
225 225 adding file changes
226 226 added 9 changesets with 7 changes to 4 files (+1 heads)
227 227 changegroup hook: HG_NODE=f9ee2f85a263049e9ae6d37a0e67e96194ffb735 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=bundle:../full.hg (glob)
228 228 (run 'hg heads' to see heads, 'hg merge' to merge)
229 229
230 230 Rollback empty
231 231
232 232 $ hg rollback
233 233 repository tip rolled back to revision -1 (undo pull)
234 234 $ cd ..
235 235
236 236 Log -R bundle:empty+full.hg
237 237
238 238 $ hg -R bundle:empty+full.hg log --template="{rev} "; echo ""
239 239 8 7 6 5 4 3 2 1 0
240 240
241 241 Pull full.hg into empty again (using -R; with hook)
242 242
243 243 $ hg -R empty pull full.hg
244 244 pulling from full.hg
245 245 requesting all changes
246 246 adding changesets
247 247 adding manifests
248 248 adding file changes
249 249 added 9 changesets with 7 changes to 4 files (+1 heads)
250 250 changegroup hook: HG_NODE=f9ee2f85a263049e9ae6d37a0e67e96194ffb735 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=bundle:empty+full.hg (glob)
251 251 (run 'hg heads' to see heads, 'hg merge' to merge)
252 252
253 Cannot produce streaming clone bundles with "hg bundle"
254
255 $ hg -R test bundle -t packed1 packed.hg
256 abort: packed bundles cannot be produced by "hg bundle"
257 (use "hg debugcreatestreamclonebundle")
258 [255]
259
260 packed1 is produced properly
261
262 $ hg -R test debugcreatestreamclonebundle packed.hg
263 writing 2608 bytes for 6 files
264 bundle requirements: revlogv1
265
266 $ f -B 64 --size --sha1 --hexdump packed.hg
267 packed.hg: size=2758, sha1=864c1c7b490bac9f2950ef5a660668378ac0524e
268 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 06 00 00 |HGS1UN..........|
269 0010: 00 00 00 00 0a 30 00 09 72 65 76 6c 6f 67 76 31 |.....0..revlogv1|
270 0020: 00 64 61 74 61 2f 61 64 69 66 66 65 72 65 6e 74 |.data/adifferent|
271 0030: 66 69 6c 65 2e 69 00 31 33 39 0a 00 01 00 01 00 |file.i.139......|
272
273 generaldelta requirement is listed in stream clone bundles
274
275 $ hg --config format.generaldelta=true init testgd
276 $ cd testgd
277 $ touch foo
278 $ hg -q commit -A -m initial
279 $ cd ..
280 $ hg -R testgd debugcreatestreamclonebundle packedgd.hg
281 writing 301 bytes for 3 files
282 bundle requirements: generaldelta, revlogv1
283
284 $ f -B 64 --size --sha1 --hexdump packedgd.hg
285 packedgd.hg: size=396, sha1=981f9e589799335304a5a9a44caa3623a48d2a9f
286 0000: 48 47 53 31 55 4e 00 00 00 00 00 00 00 03 00 00 |HGS1UN..........|
287 0010: 00 00 00 00 01 2d 00 16 67 65 6e 65 72 61 6c 64 |.....-..generald|
288 0020: 65 6c 74 61 2c 72 65 76 6c 6f 67 76 31 00 64 61 |elta,revlogv1.da|
289 0030: 74 61 2f 66 6f 6f 2e 69 00 36 34 0a 00 03 00 01 |ta/foo.i.64.....|
290
253 291 Create partial clones
254 292
255 293 $ rm -r empty
256 294 $ hg init empty
257 295 $ hg clone -r 3 test partial
258 296 adding changesets
259 297 adding manifests
260 298 adding file changes
261 299 added 4 changesets with 4 changes to 1 files
262 300 updating to branch default
263 301 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
264 302 $ hg clone partial partial2
265 303 updating to branch default
266 304 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
267 305 $ cd partial
268 306
269 307 Log -R full.hg in partial
270 308
271 309 $ hg -R bundle://../full.hg log -T phases
272 310 changeset: 8:aa35859c02ea
273 311 tag: tip
274 312 phase: draft
275 313 parent: 3:eebf5a27f8ca
276 314 user: test
277 315 date: Thu Jan 01 00:00:00 1970 +0000
278 316 summary: 0.3m
279 317
280 318 changeset: 7:a6a34bfa0076
281 319 phase: draft
282 320 user: test
283 321 date: Thu Jan 01 00:00:00 1970 +0000
284 322 summary: 1.3m
285 323
286 324 changeset: 6:7373c1169842
287 325 phase: draft
288 326 user: test
289 327 date: Thu Jan 01 00:00:00 1970 +0000
290 328 summary: 1.3
291 329
292 330 changeset: 5:1bb50a9436a7
293 331 phase: draft
294 332 user: test
295 333 date: Thu Jan 01 00:00:00 1970 +0000
296 334 summary: 1.2
297 335
298 336 changeset: 4:095197eb4973
299 337 phase: draft
300 338 parent: 0:f9ee2f85a263
301 339 user: test
302 340 date: Thu Jan 01 00:00:00 1970 +0000
303 341 summary: 1.1
304 342
305 343 changeset: 3:eebf5a27f8ca
306 344 phase: public
307 345 user: test
308 346 date: Thu Jan 01 00:00:00 1970 +0000
309 347 summary: 0.3
310 348
311 349 changeset: 2:e38ba6f5b7e0
312 350 phase: public
313 351 user: test
314 352 date: Thu Jan 01 00:00:00 1970 +0000
315 353 summary: 0.2
316 354
317 355 changeset: 1:34c2bf6b0626
318 356 phase: public
319 357 user: test
320 358 date: Thu Jan 01 00:00:00 1970 +0000
321 359 summary: 0.1
322 360
323 361 changeset: 0:f9ee2f85a263
324 362 phase: public
325 363 user: test
326 364 date: Thu Jan 01 00:00:00 1970 +0000
327 365 summary: 0.0
328 366
329 367
330 368 Incoming full.hg in partial
331 369
332 370 $ hg incoming bundle://../full.hg
333 371 comparing with bundle:../full.hg
334 372 searching for changes
335 373 changeset: 4:095197eb4973
336 374 parent: 0:f9ee2f85a263
337 375 user: test
338 376 date: Thu Jan 01 00:00:00 1970 +0000
339 377 summary: 1.1
340 378
341 379 changeset: 5:1bb50a9436a7
342 380 user: test
343 381 date: Thu Jan 01 00:00:00 1970 +0000
344 382 summary: 1.2
345 383
346 384 changeset: 6:7373c1169842
347 385 user: test
348 386 date: Thu Jan 01 00:00:00 1970 +0000
349 387 summary: 1.3
350 388
351 389 changeset: 7:a6a34bfa0076
352 390 user: test
353 391 date: Thu Jan 01 00:00:00 1970 +0000
354 392 summary: 1.3m
355 393
356 394 changeset: 8:aa35859c02ea
357 395 tag: tip
358 396 parent: 3:eebf5a27f8ca
359 397 user: test
360 398 date: Thu Jan 01 00:00:00 1970 +0000
361 399 summary: 0.3m
362 400
363 401
364 402 Outgoing -R full.hg vs partial2 in partial
365 403
366 404 $ hg -R bundle://../full.hg outgoing ../partial2
367 405 comparing with ../partial2
368 406 searching for changes
369 407 changeset: 4:095197eb4973
370 408 parent: 0:f9ee2f85a263
371 409 user: test
372 410 date: Thu Jan 01 00:00:00 1970 +0000
373 411 summary: 1.1
374 412
375 413 changeset: 5:1bb50a9436a7
376 414 user: test
377 415 date: Thu Jan 01 00:00:00 1970 +0000
378 416 summary: 1.2
379 417
380 418 changeset: 6:7373c1169842
381 419 user: test
382 420 date: Thu Jan 01 00:00:00 1970 +0000
383 421 summary: 1.3
384 422
385 423 changeset: 7:a6a34bfa0076
386 424 user: test
387 425 date: Thu Jan 01 00:00:00 1970 +0000
388 426 summary: 1.3m
389 427
390 428 changeset: 8:aa35859c02ea
391 429 tag: tip
392 430 parent: 3:eebf5a27f8ca
393 431 user: test
394 432 date: Thu Jan 01 00:00:00 1970 +0000
395 433 summary: 0.3m
396 434
397 435
398 436 Outgoing -R does-not-exist.hg vs partial2 in partial
399 437
400 438 $ hg -R bundle://../does-not-exist.hg outgoing ../partial2
401 439 abort: *../does-not-exist.hg* (glob)
402 440 [255]
403 441 $ cd ..
404 442
405 443 hide outer repo
406 444 $ hg init
407 445
408 446 Direct clone from bundle (all-history)
409 447
410 448 $ hg clone full.hg full-clone
411 449 requesting all changes
412 450 adding changesets
413 451 adding manifests
414 452 adding file changes
415 453 added 9 changesets with 7 changes to 4 files (+1 heads)
416 454 updating to branch default
417 455 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
418 456 $ hg -R full-clone heads
419 457 changeset: 8:aa35859c02ea
420 458 tag: tip
421 459 parent: 3:eebf5a27f8ca
422 460 user: test
423 461 date: Thu Jan 01 00:00:00 1970 +0000
424 462 summary: 0.3m
425 463
426 464 changeset: 7:a6a34bfa0076
427 465 user: test
428 466 date: Thu Jan 01 00:00:00 1970 +0000
429 467 summary: 1.3m
430 468
431 469 $ rm -r full-clone
432 470
433 471 When cloning from a non-copiable repository into '', do not
434 472 recurse infinitely (issue2528)
435 473
436 474 $ hg clone full.hg ''
437 475 abort: empty destination path is not valid
438 476 [255]
439 477
440 478 test for https://bz.mercurial-scm.org/216
441 479
442 480 Unbundle incremental bundles into fresh empty in one go
443 481
444 482 $ rm -r empty
445 483 $ hg init empty
446 484 $ hg -R test bundle --base null -r 0 ../0.hg
447 485 1 changesets found
448 486 $ hg -R test bundle --base 0 -r 1 ../1.hg
449 487 1 changesets found
450 488 $ hg -R empty unbundle -u ../0.hg ../1.hg
451 489 adding changesets
452 490 adding manifests
453 491 adding file changes
454 492 added 1 changesets with 1 changes to 1 files
455 493 adding changesets
456 494 adding manifests
457 495 adding file changes
458 496 added 1 changesets with 1 changes to 1 files
459 497 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
460 498
461 499 View full contents of the bundle
462 500 $ hg -R test bundle --base null -r 3 ../partial.hg
463 501 4 changesets found
464 502 $ cd test
465 503 $ hg -R ../../partial.hg log -r "bundle()"
466 504 changeset: 0:f9ee2f85a263
467 505 user: test
468 506 date: Thu Jan 01 00:00:00 1970 +0000
469 507 summary: 0.0
470 508
471 509 changeset: 1:34c2bf6b0626
472 510 user: test
473 511 date: Thu Jan 01 00:00:00 1970 +0000
474 512 summary: 0.1
475 513
476 514 changeset: 2:e38ba6f5b7e0
477 515 user: test
478 516 date: Thu Jan 01 00:00:00 1970 +0000
479 517 summary: 0.2
480 518
481 519 changeset: 3:eebf5a27f8ca
482 520 user: test
483 521 date: Thu Jan 01 00:00:00 1970 +0000
484 522 summary: 0.3
485 523
486 524 $ cd ..
487 525
488 526 test for 540d1059c802
489 527
490 528 test for 540d1059c802
491 529
492 530 $ hg init orig
493 531 $ cd orig
494 532 $ echo foo > foo
495 533 $ hg add foo
496 534 $ hg ci -m 'add foo'
497 535
498 536 $ hg clone . ../copy
499 537 updating to branch default
500 538 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
501 539 $ hg tag foo
502 540
503 541 $ cd ../copy
504 542 $ echo >> foo
505 543 $ hg ci -m 'change foo'
506 544 $ hg bundle ../bundle.hg ../orig
507 545 searching for changes
508 546 1 changesets found
509 547
510 548 $ cd ../orig
511 549 $ hg incoming ../bundle.hg
512 550 comparing with ../bundle.hg
513 551 searching for changes
514 552 changeset: 2:ed1b79f46b9a
515 553 tag: tip
516 554 parent: 0:bbd179dfa0a7
517 555 user: test
518 556 date: Thu Jan 01 00:00:00 1970 +0000
519 557 summary: change foo
520 558
521 559 $ cd ..
522 560
523 561 test bundle with # in the filename (issue2154):
524 562
525 563 $ cp bundle.hg 'test#bundle.hg'
526 564 $ cd orig
527 565 $ hg incoming '../test#bundle.hg'
528 566 comparing with ../test
529 567 abort: unknown revision 'bundle.hg'!
530 568 [255]
531 569
532 570 note that percent encoding is not handled:
533 571
534 572 $ hg incoming ../test%23bundle.hg
535 573 abort: repository ../test%23bundle.hg not found!
536 574 [255]
537 575 $ cd ..
538 576
539 577 test to bundle revisions on the newly created branch (issue3828):
540 578
541 579 $ hg -q clone -U test test-clone
542 580 $ cd test
543 581
544 582 $ hg -q branch foo
545 583 $ hg commit -m "create foo branch"
546 584 $ hg -q outgoing ../test-clone
547 585 9:b4f5acb1ee27
548 586 $ hg -q bundle --branch foo foo.hg ../test-clone
549 587 $ hg -R foo.hg -q log -r "bundle()"
550 588 9:b4f5acb1ee27
551 589
552 590 $ cd ..
553 591
554 592 test for https://bz.mercurial-scm.org/1144
555 593
556 594 test that verify bundle does not traceback
557 595
558 596 partial history bundle, fails w/ unknown parent
559 597
560 598 $ hg -R bundle.hg verify
561 599 abort: 00changelog.i@bbd179dfa0a7: unknown parent!
562 600 [255]
563 601
564 602 full history bundle, refuses to verify non-local repo
565 603
566 604 $ hg -R all.hg verify
567 605 abort: cannot verify bundle or remote repos
568 606 [255]
569 607
570 608 but, regular verify must continue to work
571 609
572 610 $ hg -R orig verify
573 611 checking changesets
574 612 checking manifests
575 613 crosschecking files in changesets and manifests
576 614 checking files
577 615 2 files, 2 changesets, 2 total revisions
578 616
579 617 diff against bundle
580 618
581 619 $ hg init b
582 620 $ cd b
583 621 $ hg -R ../all.hg diff -r tip
584 622 diff -r aa35859c02ea anotherfile
585 623 --- a/anotherfile Thu Jan 01 00:00:00 1970 +0000
586 624 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
587 625 @@ -1,4 +0,0 @@
588 626 -0
589 627 -1
590 628 -2
591 629 -3
592 630 $ cd ..
593 631
594 632 bundle single branch
595 633
596 634 $ hg init branchy
597 635 $ cd branchy
598 636 $ echo a >a
599 637 $ echo x >x
600 638 $ hg ci -Ama
601 639 adding a
602 640 adding x
603 641 $ echo c >c
604 642 $ echo xx >x
605 643 $ hg ci -Amc
606 644 adding c
607 645 $ echo c1 >c1
608 646 $ hg ci -Amc1
609 647 adding c1
610 648 $ hg up 0
611 649 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
612 650 $ echo b >b
613 651 $ hg ci -Amb
614 652 adding b
615 653 created new head
616 654 $ echo b1 >b1
617 655 $ echo xx >x
618 656 $ hg ci -Amb1
619 657 adding b1
620 658 $ hg clone -q -r2 . part
621 659
622 660 == bundling via incoming
623 661
624 662 $ hg in -R part --bundle incoming.hg --template "{node}\n" .
625 663 comparing with .
626 664 searching for changes
627 665 1a38c1b849e8b70c756d2d80b0b9a3ac0b7ea11a
628 666 057f4db07f61970e1c11e83be79e9d08adc4dc31
629 667
630 668 == bundling
631 669
632 670 $ hg bundle bundle.hg part --debug --config progress.debug=true
633 671 query 1; heads
634 672 searching for changes
635 673 all remote heads known locally
636 674 2 changesets found
637 675 list of changesets:
638 676 1a38c1b849e8b70c756d2d80b0b9a3ac0b7ea11a
639 677 057f4db07f61970e1c11e83be79e9d08adc4dc31
640 678 bundling: 1/2 changesets (50.00%)
641 679 bundling: 2/2 changesets (100.00%)
642 680 bundling: 1/2 manifests (50.00%)
643 681 bundling: 2/2 manifests (100.00%)
644 682 bundling: b 1/3 files (33.33%)
645 683 bundling: b1 2/3 files (66.67%)
646 684 bundling: x 3/3 files (100.00%)
647 685
648 686 == Test for issue3441
649 687
650 688 $ hg clone -q -r0 . part2
651 689 $ hg -q -R part2 pull bundle.hg
652 690 $ hg -R part2 verify
653 691 checking changesets
654 692 checking manifests
655 693 crosschecking files in changesets and manifests
656 694 checking files
657 695 4 files, 3 changesets, 5 total revisions
658 696
659 697 $ cd ..
@@ -1,344 +1,346
1 1 Show all commands except debug commands
2 2 $ hg debugcomplete
3 3 add
4 4 addremove
5 5 annotate
6 6 archive
7 7 backout
8 8 bisect
9 9 bookmarks
10 10 branch
11 11 branches
12 12 bundle
13 13 cat
14 14 clone
15 15 commit
16 16 config
17 17 copy
18 18 diff
19 19 export
20 20 files
21 21 forget
22 22 graft
23 23 grep
24 24 heads
25 25 help
26 26 identify
27 27 import
28 28 incoming
29 29 init
30 30 locate
31 31 log
32 32 manifest
33 33 merge
34 34 outgoing
35 35 parents
36 36 paths
37 37 phase
38 38 pull
39 39 push
40 40 recover
41 41 remove
42 42 rename
43 43 resolve
44 44 revert
45 45 rollback
46 46 root
47 47 serve
48 48 status
49 49 summary
50 50 tag
51 51 tags
52 52 tip
53 53 unbundle
54 54 update
55 55 verify
56 56 version
57 57
58 58 Show all commands that start with "a"
59 59 $ hg debugcomplete a
60 60 add
61 61 addremove
62 62 annotate
63 63 archive
64 64
65 65 Do not show debug commands if there are other candidates
66 66 $ hg debugcomplete d
67 67 diff
68 68
69 69 Show debug commands if there are no other candidates
70 70 $ hg debugcomplete debug
71 71 debugancestor
72 72 debugbuilddag
73 73 debugbundle
74 74 debugcheckstate
75 75 debugcommands
76 76 debugcomplete
77 77 debugconfig
78 debugcreatestreamclonebundle
78 79 debugdag
79 80 debugdata
80 81 debugdate
81 82 debugdirstate
82 83 debugdiscovery
83 84 debugextensions
84 85 debugfileset
85 86 debugfsinfo
86 87 debuggetbundle
87 88 debugignore
88 89 debugindex
89 90 debugindexdot
90 91 debuginstall
91 92 debugknown
92 93 debuglabelcomplete
93 94 debuglocks
94 95 debugmergestate
95 96 debugnamecomplete
96 97 debugobsolete
97 98 debugpathcomplete
98 99 debugpushkey
99 100 debugpvec
100 101 debugrebuilddirstate
101 102 debugrebuildfncache
102 103 debugrename
103 104 debugrevlog
104 105 debugrevspec
105 106 debugsetparents
106 107 debugsub
107 108 debugsuccessorssets
108 109 debugwalk
109 110 debugwireargs
110 111
111 112 Do not show the alias of a debug command if there are other candidates
112 113 (this should hide rawcommit)
113 114 $ hg debugcomplete r
114 115 recover
115 116 remove
116 117 rename
117 118 resolve
118 119 revert
119 120 rollback
120 121 root
121 122 Show the alias of a debug command if there are no other candidates
122 123 $ hg debugcomplete rawc
123 124
124 125
125 126 Show the global options
126 127 $ hg debugcomplete --options | sort
127 128 --config
128 129 --cwd
129 130 --debug
130 131 --debugger
131 132 --encoding
132 133 --encodingmode
133 134 --help
134 135 --hidden
135 136 --noninteractive
136 137 --profile
137 138 --quiet
138 139 --repository
139 140 --time
140 141 --traceback
141 142 --verbose
142 143 --version
143 144 -R
144 145 -h
145 146 -q
146 147 -v
147 148 -y
148 149
149 150 Show the options for the "serve" command
150 151 $ hg debugcomplete --options serve | sort
151 152 --accesslog
152 153 --address
153 154 --certificate
154 155 --cmdserver
155 156 --config
156 157 --cwd
157 158 --daemon
158 159 --daemon-pipefds
159 160 --debug
160 161 --debugger
161 162 --encoding
162 163 --encodingmode
163 164 --errorlog
164 165 --help
165 166 --hidden
166 167 --ipv6
167 168 --name
168 169 --noninteractive
169 170 --pid-file
170 171 --port
171 172 --prefix
172 173 --profile
173 174 --quiet
174 175 --repository
175 176 --stdio
176 177 --style
177 178 --templates
178 179 --time
179 180 --traceback
180 181 --verbose
181 182 --version
182 183 --web-conf
183 184 -6
184 185 -A
185 186 -E
186 187 -R
187 188 -a
188 189 -d
189 190 -h
190 191 -n
191 192 -p
192 193 -q
193 194 -t
194 195 -v
195 196 -y
196 197
197 198 Show an error if we use --options with an ambiguous abbreviation
198 199 $ hg debugcomplete --options s
199 200 hg: command 's' is ambiguous:
200 201 serve showconfig status summary
201 202 [255]
202 203
203 204 Show all commands + options
204 205 $ hg debugcommands
205 206 add: include, exclude, subrepos, dry-run
206 207 annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template
207 208 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
208 209 commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos
209 210 diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos
210 211 export: output, switch-parent, rev, text, git, nodates
211 212 forget: include, exclude
212 213 init: ssh, remotecmd, insecure
213 214 log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude
214 215 merge: force, rev, preview, tool
215 216 pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
216 217 push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
217 218 remove: after, force, subrepos, include, exclude
218 219 serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, cmdserver, templates, style, ipv6, certificate
219 220 status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos, template
220 221 summary: remote
221 222 update: clean, check, date, rev, tool
222 223 addremove: similarity, subrepos, include, exclude, dry-run
223 224 archive: no-decode, prefix, rev, type, subrepos, include, exclude
224 225 backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
225 226 bisect: reset, good, bad, skip, extend, command, noupdate
226 227 bookmarks: force, rev, delete, rename, inactive, template
227 228 branch: force, clean
228 229 branches: active, closed, template
229 230 bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
230 231 cat: output, rev, decode, include, exclude
231 232 config: untrusted, edit, local, global
232 233 copy: after, force, include, exclude, dry-run
233 234 debugancestor:
234 235 debugbuilddag: mergeable-file, overwritten-file, new-file
235 236 debugbundle: all
236 237 debugcheckstate:
237 238 debugcommands:
238 239 debugcomplete: options
240 debugcreatestreamclonebundle:
239 241 debugdag: tags, branches, dots, spaces
240 242 debugdata: changelog, manifest, dir
241 243 debugdate: extended
242 244 debugdirstate: nodates, datesort
243 245 debugdiscovery: old, nonheads, ssh, remotecmd, insecure
244 246 debugextensions: template
245 247 debugfileset: rev
246 248 debugfsinfo:
247 249 debuggetbundle: head, common, type
248 250 debugignore:
249 251 debugindex: changelog, manifest, dir, format
250 252 debugindexdot:
251 253 debuginstall:
252 254 debugknown:
253 255 debuglabelcomplete:
254 256 debuglocks: force-lock, force-wlock
255 257 debugmergestate:
256 258 debugnamecomplete:
257 259 debugobsolete: flags, record-parents, rev, date, user
258 260 debugpathcomplete: full, normal, added, removed
259 261 debugpushkey:
260 262 debugpvec:
261 263 debugrebuilddirstate: rev, minimal
262 264 debugrebuildfncache:
263 265 debugrename: rev
264 266 debugrevlog: changelog, manifest, dir, dump
265 267 debugrevspec: optimize
266 268 debugsetparents:
267 269 debugsub: rev
268 270 debugsuccessorssets:
269 271 debugwalk: include, exclude
270 272 debugwireargs: three, four, five, ssh, remotecmd, insecure
271 273 files: rev, print0, include, exclude, template, subrepos
272 274 graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
273 275 grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
274 276 heads: rev, topo, active, closed, style, template
275 277 help: extension, command, keyword
276 278 identify: rev, num, id, branch, tags, bookmarks, ssh, remotecmd, insecure
277 279 import: strip, base, edit, force, no-commit, bypass, partial, exact, prefix, import-branch, message, logfile, date, user, similarity
278 280 incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
279 281 locate: rev, print0, fullpath, include, exclude
280 282 manifest: rev, all, template
281 283 outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, graph, style, template, ssh, remotecmd, insecure, subrepos
282 284 parents: rev, style, template
283 285 paths:
284 286 phase: public, draft, secret, force, rev
285 287 recover:
286 288 rename: after, force, include, exclude, dry-run
287 289 resolve: all, list, mark, unmark, no-status, tool, include, exclude, template
288 290 revert: all, date, rev, no-backup, interactive, include, exclude, dry-run
289 291 rollback: dry-run, force
290 292 root:
291 293 tag: force, local, rev, remove, edit, message, date, user
292 294 tags: template
293 295 tip: patch, git, style, template
294 296 unbundle: update
295 297 verify:
296 298 version:
297 299
298 300 $ hg init a
299 301 $ cd a
300 302 $ echo fee > fee
301 303 $ hg ci -q -Amfee
302 304 $ hg tag fee
303 305 $ mkdir fie
304 306 $ echo dead > fie/dead
305 307 $ echo live > fie/live
306 308 $ hg bookmark fo
307 309 $ hg branch -q fie
308 310 $ hg ci -q -Amfie
309 311 $ echo fo > fo
310 312 $ hg branch -qf default
311 313 $ hg ci -q -Amfo
312 314 $ echo Fum > Fum
313 315 $ hg ci -q -AmFum
314 316 $ hg bookmark Fum
315 317
316 318 Test debugpathcomplete
317 319
318 320 $ hg debugpathcomplete f
319 321 fee
320 322 fie
321 323 fo
322 324 $ hg debugpathcomplete -f f
323 325 fee
324 326 fie/dead
325 327 fie/live
326 328 fo
327 329
328 330 $ hg rm Fum
329 331 $ hg debugpathcomplete -r F
330 332 Fum
331 333
332 334 Test debugnamecomplete
333 335
334 336 $ hg debugnamecomplete
335 337 Fum
336 338 default
337 339 fee
338 340 fie
339 341 fo
340 342 tip
341 343 $ hg debugnamecomplete f
342 344 fee
343 345 fie
344 346 fo
@@ -1,2381 +1,2384
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 another revision into working directory
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 another revision into working directory
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 create a new bookmark or list existing bookmarks
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 config show combined config settings from all hgrc files
66 66 copy mark files as copied for the next commit
67 67 diff diff repository (or selected files)
68 68 export dump the header and diffs for one or more changesets
69 69 files list tracked files
70 70 forget forget the specified files on the next commit
71 71 graft copy changes from other branches onto the current branch
72 72 grep search for a pattern in specified files and revisions
73 73 heads show branch heads
74 74 help show help for a given topic or a help overview
75 75 identify identify the working directory or specified revision
76 76 import import an ordered set of patches
77 77 incoming show new changesets found in source
78 78 init create a new repository in the given directory
79 79 log show revision history of entire repository or files
80 80 manifest output the current or given revision of the project manifest
81 81 merge merge another revision into working directory
82 82 outgoing show changesets not found in the destination
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 status show changed files in the working directory
95 95 summary summarize working directory state
96 96 tag add one or more tags for the current or given revision
97 97 tags list repository tags
98 98 unbundle apply one or more changegroup files
99 99 update update working directory (or switch revisions)
100 100 verify verify the integrity of the repository
101 101 version output version and copyright information
102 102
103 103 additional help topics:
104 104
105 105 config Configuration Files
106 106 dates Date Formats
107 107 diffs Diff Formats
108 108 environment Environment Variables
109 109 extensions Using Additional Features
110 110 filesets Specifying File Sets
111 111 glossary Glossary
112 112 hgignore Syntax for Mercurial Ignore Files
113 113 hgweb Configuring hgweb
114 114 merge-tools Merge Tools
115 115 multirevs Specifying Multiple Revisions
116 116 patterns File Name Patterns
117 117 phases Working with Phases
118 118 revisions Specifying Single Revisions
119 119 revsets Specifying Revision Sets
120 120 scripting Using Mercurial from scripts and automation
121 121 subrepos Subrepositories
122 122 templating Template Usage
123 123 urls URL Paths
124 124
125 125 (use "hg help -v" to show built-in 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 create a new bookmark or list existing bookmarks
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 config show combined config settings from all hgrc files
142 142 copy mark files as copied for the next commit
143 143 diff diff repository (or selected files)
144 144 export dump the header and diffs for one or more changesets
145 145 files list tracked files
146 146 forget forget the specified files on the next commit
147 147 graft copy changes from other branches onto the current branch
148 148 grep search for a pattern in specified files and revisions
149 149 heads show branch heads
150 150 help show help for a given topic or a help overview
151 151 identify identify the working directory or specified revision
152 152 import import an ordered set of patches
153 153 incoming show new changesets found in source
154 154 init create a new repository in the given directory
155 155 log show revision history of entire repository or files
156 156 manifest output the current or given revision of the project manifest
157 157 merge merge another revision into working directory
158 158 outgoing show changesets not found in the destination
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 status show changed files in the working directory
171 171 summary summarize working directory state
172 172 tag add one or more tags for the current or given revision
173 173 tags list repository tags
174 174 unbundle apply one or more changegroup files
175 175 update update working directory (or switch revisions)
176 176 verify verify the integrity of the repository
177 177 version output version and copyright information
178 178
179 179 additional help topics:
180 180
181 181 config Configuration Files
182 182 dates Date Formats
183 183 diffs Diff Formats
184 184 environment Environment Variables
185 185 extensions Using Additional Features
186 186 filesets Specifying File Sets
187 187 glossary Glossary
188 188 hgignore Syntax for Mercurial Ignore Files
189 189 hgweb Configuring hgweb
190 190 merge-tools Merge Tools
191 191 multirevs Specifying Multiple Revisions
192 192 patterns File Name Patterns
193 193 phases Working with Phases
194 194 revisions Specifying Single Revisions
195 195 revsets Specifying Revision Sets
196 196 scripting Using Mercurial from scripts and automation
197 197 subrepos Subrepositories
198 198 templating Template Usage
199 199 urls URL Paths
200 200
201 201 Test extension help:
202 202 $ hg help extensions --config extensions.rebase= --config extensions.children=
203 203 Using Additional Features
204 204 """""""""""""""""""""""""
205 205
206 206 Mercurial has the ability to add new features through the use of
207 207 extensions. Extensions may add new commands, add options to existing
208 208 commands, change the default behavior of commands, or implement hooks.
209 209
210 210 To enable the "foo" extension, either shipped with Mercurial or in the
211 211 Python search path, create an entry for it in your configuration file,
212 212 like this:
213 213
214 214 [extensions]
215 215 foo =
216 216
217 217 You may also specify the full path to an extension:
218 218
219 219 [extensions]
220 220 myfeature = ~/.hgext/myfeature.py
221 221
222 222 See "hg help config" for more information on configuration files.
223 223
224 224 Extensions are not loaded by default for a variety of reasons: they can
225 225 increase startup overhead; they may be meant for advanced usage only; they
226 226 may provide potentially dangerous abilities (such as letting you destroy
227 227 or modify history); they might not be ready for prime time; or they may
228 228 alter some usual behaviors of stock Mercurial. It is thus up to the user
229 229 to activate extensions as needed.
230 230
231 231 To explicitly disable an extension enabled in a configuration file of
232 232 broader scope, prepend its path with !:
233 233
234 234 [extensions]
235 235 # disabling extension bar residing in /path/to/extension/bar.py
236 236 bar = !/path/to/extension/bar.py
237 237 # ditto, but no path was supplied for extension baz
238 238 baz = !
239 239
240 240 enabled extensions:
241 241
242 242 children command to display child changesets (DEPRECATED)
243 243 rebase command to move sets of revisions to a different ancestor
244 244
245 245 disabled extensions:
246 246
247 247 acl hooks for controlling repository access
248 248 blackbox log repository events to a blackbox for debugging
249 249 bugzilla hooks for integrating with the Bugzilla bug tracker
250 250 censor erase file content at a given revision
251 251 churn command to display statistics about repository history
252 252 clonebundles server side extension to advertise pre-generated bundles to
253 253 seed clones.
254 254 color colorize output from some commands
255 255 convert import revisions from foreign VCS repositories into
256 256 Mercurial
257 257 eol automatically manage newlines in repository files
258 258 extdiff command to allow external programs to compare revisions
259 259 factotum http authentication with factotum
260 260 gpg commands to sign and verify changesets
261 261 hgcia hooks for integrating with the CIA.vc notification service
262 262 hgk browse the repository in a graphical way
263 263 highlight syntax highlighting for hgweb (requires Pygments)
264 264 histedit interactive history editing
265 265 keyword expand keywords in tracked files
266 266 largefiles track large binary files
267 267 mq manage a stack of patches
268 268 notify hooks for sending email push notifications
269 269 pager browse command output with an external pager
270 270 patchbomb command to send changesets as (a series of) patch emails
271 271 purge command to delete untracked files from the working
272 272 directory
273 273 record commands to interactively select changes for
274 274 commit/qrefresh
275 275 relink recreates hardlinks between repository clones
276 276 schemes extend schemes with shortcuts to repository swarms
277 277 share share a common history between several working directories
278 278 shelve save and restore changes to the working directory
279 279 strip strip changesets and their descendants from history
280 280 transplant command to transplant changesets from another branch
281 281 win32mbcs allow the use of MBCS paths with problematic encodings
282 282 zeroconf discover and advertise repositories on the local network
283 283
284 284 Verify that extension keywords appear in help templates
285 285
286 286 $ hg help --config extensions.transplant= templating|grep transplant > /dev/null
287 287
288 288 Test short command list with verbose option
289 289
290 290 $ hg -v help shortlist
291 291 Mercurial Distributed SCM
292 292
293 293 basic commands:
294 294
295 295 add add the specified files on the next commit
296 296 annotate, blame
297 297 show changeset information by line for each file
298 298 clone make a copy of an existing repository
299 299 commit, ci commit the specified files or all outstanding changes
300 300 diff diff repository (or selected files)
301 301 export dump the header and diffs for one or more changesets
302 302 forget forget the specified files on the next commit
303 303 init create a new repository in the given directory
304 304 log, history show revision history of entire repository or files
305 305 merge merge another revision into working directory
306 306 pull pull changes from the specified source
307 307 push push changes to the specified destination
308 308 remove, rm remove the specified files on the next commit
309 309 serve start stand-alone webserver
310 310 status, st show changed files in the working directory
311 311 summary, sum summarize working directory state
312 312 update, up, checkout, co
313 313 update working directory (or switch revisions)
314 314
315 315 global options ([+] can be repeated):
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 (use "hg help" for the full list of commands)
337 337
338 338 $ hg add -h
339 339 hg add [OPTION]... [FILE]...
340 340
341 341 add the specified files on the next commit
342 342
343 343 Schedule files to be version controlled and added to the repository.
344 344
345 345 The files will be added to the repository at the next commit. To undo an
346 346 add before that, see "hg forget".
347 347
348 348 If no names are given, add all files to the repository.
349 349
350 350 Returns 0 if all files are successfully added.
351 351
352 352 options ([+] can be repeated):
353 353
354 354 -I --include PATTERN [+] include names matching the given patterns
355 355 -X --exclude PATTERN [+] exclude names matching the given patterns
356 356 -S --subrepos recurse into subrepositories
357 357 -n --dry-run do not perform actions, just print output
358 358
359 359 (some details hidden, use --verbose to show complete help)
360 360
361 361 Verbose help for add
362 362
363 363 $ hg add -hv
364 364 hg add [OPTION]... [FILE]...
365 365
366 366 add the specified files on the next commit
367 367
368 368 Schedule files to be version controlled and added to the repository.
369 369
370 370 The files will be added to the repository at the next commit. To undo an
371 371 add before that, see "hg forget".
372 372
373 373 If no names are given, add all files to the repository.
374 374
375 375 An example showing how new (unknown) files are added automatically by "hg
376 376 add":
377 377
378 378 $ ls
379 379 foo.c
380 380 $ hg status
381 381 ? foo.c
382 382 $ hg add
383 383 adding foo.c
384 384 $ hg status
385 385 A foo.c
386 386
387 387 Returns 0 if all files are successfully added.
388 388
389 389 options ([+] can be repeated):
390 390
391 391 -I --include PATTERN [+] include names matching the given patterns
392 392 -X --exclude PATTERN [+] exclude names matching the given patterns
393 393 -S --subrepos recurse into subrepositories
394 394 -n --dry-run do not perform actions, just print output
395 395
396 396 global options ([+] can be repeated):
397 397
398 398 -R --repository REPO repository root directory or name of overlay bundle
399 399 file
400 400 --cwd DIR change working directory
401 401 -y --noninteractive do not prompt, automatically pick the first choice for
402 402 all prompts
403 403 -q --quiet suppress output
404 404 -v --verbose enable additional output
405 405 --config CONFIG [+] set/override config option (use 'section.name=value')
406 406 --debug enable debugging output
407 407 --debugger start debugger
408 408 --encoding ENCODE set the charset encoding (default: ascii)
409 409 --encodingmode MODE set the charset encoding mode (default: strict)
410 410 --traceback always print a traceback on exception
411 411 --time time how long the command takes
412 412 --profile print command execution profile
413 413 --version output version information and exit
414 414 -h --help display help and exit
415 415 --hidden consider hidden changesets
416 416
417 417 Test help option with version option
418 418
419 419 $ hg add -h --version
420 420 Mercurial Distributed SCM (version *) (glob)
421 421 (see https://mercurial-scm.org for more information)
422 422
423 423 Copyright (C) 2005-2015 Matt Mackall and others
424 424 This is free software; see the source for copying conditions. There is NO
425 425 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
426 426
427 427 $ hg add --skjdfks
428 428 hg add: option --skjdfks not recognized
429 429 hg add [OPTION]... [FILE]...
430 430
431 431 add the specified files on the next commit
432 432
433 433 options ([+] can be repeated):
434 434
435 435 -I --include PATTERN [+] include names matching the given patterns
436 436 -X --exclude PATTERN [+] exclude names matching the given patterns
437 437 -S --subrepos recurse into subrepositories
438 438 -n --dry-run do not perform actions, just print output
439 439
440 440 (use "hg add -h" to show more help)
441 441 [255]
442 442
443 443 Test ambiguous command help
444 444
445 445 $ hg help ad
446 446 list of commands:
447 447
448 448 add add the specified files on the next commit
449 449 addremove add all new files, delete all missing files
450 450
451 451 (use "hg help -v ad" to show built-in aliases and global options)
452 452
453 453 Test command without options
454 454
455 455 $ hg help verify
456 456 hg verify
457 457
458 458 verify the integrity of the repository
459 459
460 460 Verify the integrity of the current repository.
461 461
462 462 This will perform an extensive check of the repository's integrity,
463 463 validating the hashes and checksums of each entry in the changelog,
464 464 manifest, and tracked files, as well as the integrity of their crosslinks
465 465 and indices.
466 466
467 467 Please see https://mercurial-scm.org/wiki/RepositoryCorruption for more
468 468 information about recovery from corruption of the repository.
469 469
470 470 Returns 0 on success, 1 if errors are encountered.
471 471
472 472 (some details hidden, use --verbose to show complete help)
473 473
474 474 $ hg help diff
475 475 hg diff [OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...
476 476
477 477 diff repository (or selected files)
478 478
479 479 Show differences between revisions for the specified files.
480 480
481 481 Differences between files are shown using the unified diff format.
482 482
483 483 Note:
484 484 diff may generate unexpected results for merges, as it will default to
485 485 comparing against the working directory's first parent changeset if no
486 486 revisions are specified.
487 487
488 488 When two revision arguments are given, then changes are shown between
489 489 those revisions. If only one revision is specified then that revision is
490 490 compared to the working directory, and, when no revisions are specified,
491 491 the working directory files are compared to its parent.
492 492
493 493 Alternatively you can specify -c/--change with a revision to see the
494 494 changes in that changeset relative to its first parent.
495 495
496 496 Without the -a/--text option, diff will avoid generating diffs of files it
497 497 detects as binary. With -a, diff will generate a diff anyway, probably
498 498 with undesirable results.
499 499
500 500 Use the -g/--git option to generate diffs in the git extended diff format.
501 501 For more information, read "hg help diffs".
502 502
503 503 Returns 0 on success.
504 504
505 505 options ([+] can be repeated):
506 506
507 507 -r --rev REV [+] revision
508 508 -c --change REV change made by revision
509 509 -a --text treat all files as text
510 510 -g --git use git extended diff format
511 511 --nodates omit dates from diff headers
512 512 --noprefix omit a/ and b/ prefixes from filenames
513 513 -p --show-function show which function each change is in
514 514 --reverse produce a diff that undoes the changes
515 515 -w --ignore-all-space ignore white space when comparing lines
516 516 -b --ignore-space-change ignore changes in the amount of white space
517 517 -B --ignore-blank-lines ignore changes whose lines are all blank
518 518 -U --unified NUM number of lines of context to show
519 519 --stat output diffstat-style summary of changes
520 520 --root DIR produce diffs relative to subdirectory
521 521 -I --include PATTERN [+] include names matching the given patterns
522 522 -X --exclude PATTERN [+] exclude names matching the given patterns
523 523 -S --subrepos recurse into subrepositories
524 524
525 525 (some details hidden, use --verbose to show complete help)
526 526
527 527 $ hg help status
528 528 hg status [OPTION]... [FILE]...
529 529
530 530 aliases: st
531 531
532 532 show changed files in the working directory
533 533
534 534 Show status of files in the repository. If names are given, only files
535 535 that match are shown. Files that are clean or ignored or the source of a
536 536 copy/move operation, are not listed unless -c/--clean, -i/--ignored,
537 537 -C/--copies or -A/--all are given. Unless options described with "show
538 538 only ..." are given, the options -mardu are used.
539 539
540 540 Option -q/--quiet hides untracked (unknown and ignored) files unless
541 541 explicitly requested with -u/--unknown or -i/--ignored.
542 542
543 543 Note:
544 544 status may appear to disagree with diff if permissions have changed or
545 545 a merge has occurred. The standard diff format does not report
546 546 permission changes and diff only reports changes relative to one merge
547 547 parent.
548 548
549 549 If one revision is given, it is used as the base revision. If two
550 550 revisions are given, the differences between them are shown. The --change
551 551 option can also be used as a shortcut to list the changed files of a
552 552 revision from its first parent.
553 553
554 554 The codes used to show the status of files are:
555 555
556 556 M = modified
557 557 A = added
558 558 R = removed
559 559 C = clean
560 560 ! = missing (deleted by non-hg command, but still tracked)
561 561 ? = not tracked
562 562 I = ignored
563 563 = origin of the previous file (with --copies)
564 564
565 565 Returns 0 on success.
566 566
567 567 options ([+] can be repeated):
568 568
569 569 -A --all show status of all files
570 570 -m --modified show only modified files
571 571 -a --added show only added files
572 572 -r --removed show only removed files
573 573 -d --deleted show only deleted (but tracked) files
574 574 -c --clean show only files without changes
575 575 -u --unknown show only unknown (not tracked) files
576 576 -i --ignored show only ignored files
577 577 -n --no-status hide status prefix
578 578 -C --copies show source of copied files
579 579 -0 --print0 end filenames with NUL, for use with xargs
580 580 --rev REV [+] show difference from revision
581 581 --change REV list the changed files of a revision
582 582 -I --include PATTERN [+] include names matching the given patterns
583 583 -X --exclude PATTERN [+] exclude names matching the given patterns
584 584 -S --subrepos recurse into subrepositories
585 585
586 586 (some details hidden, use --verbose to show complete help)
587 587
588 588 $ hg -q help status
589 589 hg status [OPTION]... [FILE]...
590 590
591 591 show changed files in the working directory
592 592
593 593 $ hg help foo
594 594 abort: no such help topic: foo
595 595 (try "hg help --keyword foo")
596 596 [255]
597 597
598 598 $ hg skjdfks
599 599 hg: unknown command 'skjdfks'
600 600 Mercurial Distributed SCM
601 601
602 602 basic commands:
603 603
604 604 add add the specified files on the next commit
605 605 annotate show changeset information by line for each file
606 606 clone make a copy of an existing repository
607 607 commit commit the specified files or all outstanding changes
608 608 diff diff repository (or selected files)
609 609 export dump the header and diffs for one or more changesets
610 610 forget forget the specified files on the next commit
611 611 init create a new repository in the given directory
612 612 log show revision history of entire repository or files
613 613 merge merge another revision into working directory
614 614 pull pull changes from the specified source
615 615 push push changes to the specified destination
616 616 remove remove the specified files on the next commit
617 617 serve start stand-alone webserver
618 618 status show changed files in the working directory
619 619 summary summarize working directory state
620 620 update update working directory (or switch revisions)
621 621
622 622 (use "hg help" for the full list of commands or "hg -v" for details)
623 623 [255]
624 624
625 625
626 626 Make sure that we don't run afoul of the help system thinking that
627 627 this is a section and erroring out weirdly.
628 628
629 629 $ hg .log
630 630 hg: unknown command '.log'
631 631 (did you mean one of log?)
632 632 [255]
633 633
634 634 $ hg log.
635 635 hg: unknown command 'log.'
636 636 (did you mean one of log?)
637 637 [255]
638 638 $ hg pu.lh
639 639 hg: unknown command 'pu.lh'
640 640 (did you mean one of pull, push?)
641 641 [255]
642 642
643 643 $ cat > helpext.py <<EOF
644 644 > import os
645 645 > from mercurial import cmdutil, commands
646 646 >
647 647 > cmdtable = {}
648 648 > command = cmdutil.command(cmdtable)
649 649 >
650 650 > @command('nohelp',
651 651 > [('', 'longdesc', 3, 'x'*90),
652 652 > ('n', '', None, 'normal desc'),
653 653 > ('', 'newline', '', 'line1\nline2')],
654 654 > 'hg nohelp',
655 655 > norepo=True)
656 656 > @command('debugoptDEP', [('', 'dopt', None, 'option is (DEPRECATED)')])
657 657 > @command('debugoptEXP', [('', 'eopt', None, 'option is (EXPERIMENTAL)')])
658 658 > def nohelp(ui, *args, **kwargs):
659 659 > pass
660 660 >
661 661 > EOF
662 662 $ echo '[extensions]' >> $HGRCPATH
663 663 $ echo "helpext = `pwd`/helpext.py" >> $HGRCPATH
664 664
665 665 Test command with no help text
666 666
667 667 $ hg help nohelp
668 668 hg nohelp
669 669
670 670 (no help text available)
671 671
672 672 options:
673 673
674 674 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
675 675 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
676 676 -n -- normal desc
677 677 --newline VALUE line1 line2
678 678
679 679 (some details hidden, use --verbose to show complete help)
680 680
681 681 $ hg help -k nohelp
682 682 Commands:
683 683
684 684 nohelp hg nohelp
685 685
686 686 Extension Commands:
687 687
688 688 nohelp (no help text available)
689 689
690 690 Test that default list of commands omits extension commands
691 691
692 692 $ hg help
693 693 Mercurial Distributed SCM
694 694
695 695 list of commands:
696 696
697 697 add add the specified files on the next commit
698 698 addremove add all new files, delete all missing files
699 699 annotate show changeset information by line for each file
700 700 archive create an unversioned archive of a repository revision
701 701 backout reverse effect of earlier changeset
702 702 bisect subdivision search of changesets
703 703 bookmarks create a new bookmark or list existing bookmarks
704 704 branch set or show the current branch name
705 705 branches list repository named branches
706 706 bundle create a changegroup file
707 707 cat output the current or given revision of files
708 708 clone make a copy of an existing repository
709 709 commit commit the specified files or all outstanding changes
710 710 config show combined config settings from all hgrc files
711 711 copy mark files as copied for the next commit
712 712 diff diff repository (or selected files)
713 713 export dump the header and diffs for one or more changesets
714 714 files list tracked files
715 715 forget forget the specified files on the next commit
716 716 graft copy changes from other branches onto the current branch
717 717 grep search for a pattern in specified files and revisions
718 718 heads show branch heads
719 719 help show help for a given topic or a help overview
720 720 identify identify the working directory or specified revision
721 721 import import an ordered set of patches
722 722 incoming show new changesets found in source
723 723 init create a new repository in the given directory
724 724 log show revision history of entire repository or files
725 725 manifest output the current or given revision of the project manifest
726 726 merge merge another revision into working directory
727 727 outgoing show changesets not found in the destination
728 728 paths show aliases for remote repositories
729 729 phase set or show the current phase name
730 730 pull pull changes from the specified source
731 731 push push changes to the specified destination
732 732 recover roll back an interrupted transaction
733 733 remove remove the specified files on the next commit
734 734 rename rename files; equivalent of copy + remove
735 735 resolve redo merges or set/view the merge status of files
736 736 revert restore files to their checkout state
737 737 root print the root (top) of the current working directory
738 738 serve start stand-alone webserver
739 739 status show changed files in the working directory
740 740 summary summarize working directory state
741 741 tag add one or more tags for the current or given revision
742 742 tags list repository tags
743 743 unbundle apply one or more changegroup files
744 744 update update working directory (or switch revisions)
745 745 verify verify the integrity of the repository
746 746 version output version and copyright information
747 747
748 748 enabled extensions:
749 749
750 750 helpext (no help text available)
751 751
752 752 additional help topics:
753 753
754 754 config Configuration Files
755 755 dates Date Formats
756 756 diffs Diff Formats
757 757 environment Environment Variables
758 758 extensions Using Additional Features
759 759 filesets Specifying File Sets
760 760 glossary Glossary
761 761 hgignore Syntax for Mercurial Ignore Files
762 762 hgweb Configuring hgweb
763 763 merge-tools Merge Tools
764 764 multirevs Specifying Multiple Revisions
765 765 patterns File Name Patterns
766 766 phases Working with Phases
767 767 revisions Specifying Single Revisions
768 768 revsets Specifying Revision Sets
769 769 scripting Using Mercurial from scripts and automation
770 770 subrepos Subrepositories
771 771 templating Template Usage
772 772 urls URL Paths
773 773
774 774 (use "hg help -v" to show built-in aliases and global options)
775 775
776 776
777 777 Test list of internal help commands
778 778
779 779 $ hg help debug
780 780 debug commands (internal and unsupported):
781 781
782 782 debugancestor
783 783 find the ancestor revision of two revisions in a given index
784 784 debugbuilddag
785 785 builds a repo with a given DAG from scratch in the current
786 786 empty repo
787 787 debugbundle lists the contents of a bundle
788 788 debugcheckstate
789 789 validate the correctness of the current dirstate
790 790 debugcommands
791 791 list all available commands and options
792 792 debugcomplete
793 793 returns the completion list associated with the given command
794 debugcreatestreamclonebundle
795 create a stream clone bundle file
794 796 debugdag format the changelog or an index DAG as a concise textual
795 797 description
796 798 debugdata dump the contents of a data file revision
797 799 debugdate parse and display a date
798 800 debugdirstate
799 801 show the contents of the current dirstate
800 802 debugdiscovery
801 803 runs the changeset discovery protocol in isolation
802 804 debugextensions
803 805 show information about active extensions
804 806 debugfileset parse and apply a fileset specification
805 807 debugfsinfo show information detected about current filesystem
806 808 debuggetbundle
807 809 retrieves a bundle from a repo
808 810 debugignore display the combined ignore pattern
809 811 debugindex dump the contents of an index file
810 812 debugindexdot
811 813 dump an index DAG as a graphviz dot file
812 814 debuginstall test Mercurial installation
813 815 debugknown test whether node ids are known to a repo
814 816 debuglocks show or modify state of locks
815 817 debugmergestate
816 818 print merge state
817 819 debugnamecomplete
818 820 complete "names" - tags, open branch names, bookmark names
819 821 debugobsolete
820 822 create arbitrary obsolete marker
821 823 debugoptDEP (no help text available)
822 824 debugoptEXP (no help text available)
823 825 debugpathcomplete
824 826 complete part or all of a tracked path
825 827 debugpushkey access the pushkey key/value protocol
826 828 debugpvec (no help text available)
827 829 debugrebuilddirstate
828 830 rebuild the dirstate as it would look like for the given
829 831 revision
830 832 debugrebuildfncache
831 833 rebuild the fncache file
832 834 debugrename dump rename information
833 835 debugrevlog show data and statistics about a revlog
834 836 debugrevspec parse and apply a revision specification
835 837 debugsetparents
836 838 manually set the parents of the current working directory
837 839 debugsub (no help text available)
838 840 debugsuccessorssets
839 841 show set of successors for revision
840 842 debugwalk show how files match on given patterns
841 843 debugwireargs
842 844 (no help text available)
843 845
844 846 (use "hg help -v debug" to show built-in aliases and global options)
845 847
846 848
847 849 Test list of commands with command with no help text
848 850
849 851 $ hg help helpext
850 852 helpext extension - no help text available
851 853
852 854 list of commands:
853 855
854 856 nohelp (no help text available)
855 857
856 858 (use "hg help -v helpext" to show built-in aliases and global options)
857 859
858 860
859 861 test deprecated and experimental options are hidden in command help
860 862 $ hg help debugoptDEP
861 863 hg debugoptDEP
862 864
863 865 (no help text available)
864 866
865 867 options:
866 868
867 869 (some details hidden, use --verbose to show complete help)
868 870
869 871 $ hg help debugoptEXP
870 872 hg debugoptEXP
871 873
872 874 (no help text available)
873 875
874 876 options:
875 877
876 878 (some details hidden, use --verbose to show complete help)
877 879
878 880 test deprecated and experimental options is shown with -v
879 881 $ hg help -v debugoptDEP | grep dopt
880 882 --dopt option is (DEPRECATED)
881 883 $ hg help -v debugoptEXP | grep eopt
882 884 --eopt option is (EXPERIMENTAL)
883 885
884 886 #if gettext
885 887 test deprecated option is hidden with translation with untranslated description
886 888 (use many globy for not failing on changed transaction)
887 889 $ LANGUAGE=sv hg help debugoptDEP
888 890 hg debugoptDEP
889 891
890 892 (*) (glob)
891 893
892 894 options:
893 895
894 896 (some details hidden, use --verbose to show complete help)
895 897 #endif
896 898
897 899 Test commands that collide with topics (issue4240)
898 900
899 901 $ hg config -hq
900 902 hg config [-u] [NAME]...
901 903
902 904 show combined config settings from all hgrc files
903 905 $ hg showconfig -hq
904 906 hg config [-u] [NAME]...
905 907
906 908 show combined config settings from all hgrc files
907 909
908 910 Test a help topic
909 911
910 912 $ hg help revs
911 913 Specifying Single Revisions
912 914 """""""""""""""""""""""""""
913 915
914 916 Mercurial supports several ways to specify individual revisions.
915 917
916 918 A plain integer is treated as a revision number. Negative integers are
917 919 treated as sequential offsets from the tip, with -1 denoting the tip, -2
918 920 denoting the revision prior to the tip, and so forth.
919 921
920 922 A 40-digit hexadecimal string is treated as a unique revision identifier.
921 923
922 924 A hexadecimal string less than 40 characters long is treated as a unique
923 925 revision identifier and is referred to as a short-form identifier. A
924 926 short-form identifier is only valid if it is the prefix of exactly one
925 927 full-length identifier.
926 928
927 929 Any other string is treated as a bookmark, tag, or branch name. A bookmark
928 930 is a movable pointer to a revision. A tag is a permanent name associated
929 931 with a revision. A branch name denotes the tipmost open branch head of
930 932 that branch - or if they are all closed, the tipmost closed head of the
931 933 branch. Bookmark, tag, and branch names must not contain the ":"
932 934 character.
933 935
934 936 The reserved name "tip" always identifies the most recent revision.
935 937
936 938 The reserved name "null" indicates the null revision. This is the revision
937 939 of an empty repository, and the parent of revision 0.
938 940
939 941 The reserved name "." indicates the working directory parent. If no
940 942 working directory is checked out, it is equivalent to null. If an
941 943 uncommitted merge is in progress, "." is the revision of the first parent.
942 944
943 945 Test repeated config section name
944 946
945 947 $ hg help config.host
946 948 "http_proxy.host"
947 949 Host name and (optional) port of the proxy server, for example
948 950 "myproxy:8000".
949 951
950 952 "smtp.host"
951 953 Host name of mail server, e.g. "mail.example.com".
952 954
953 955 Unrelated trailing paragraphs shouldn't be included
954 956
955 957 $ hg help config.extramsg | grep '^$'
956 958
957 959
958 960 Test capitalized section name
959 961
960 962 $ hg help scripting.HGPLAIN > /dev/null
961 963
962 964 Help subsection:
963 965
964 966 $ hg help config.charsets |grep "Email example:" > /dev/null
965 967 [1]
966 968
967 969 Show nested definitions
968 970 ("profiling.type"[break]"ls"[break]"stat"[break])
969 971
970 972 $ hg help config.type | egrep '^$'|wc -l
971 973 \s*3 (re)
972 974
973 975 Last item in help config.*:
974 976
975 977 $ hg help config.`hg help config|grep '^ "'| \
976 978 > tail -1|sed 's![ "]*!!g'`| \
977 979 > grep "hg help -c config" > /dev/null
978 980 [1]
979 981
980 982 note to use help -c for general hg help config:
981 983
982 984 $ hg help config |grep "hg help -c config" > /dev/null
983 985
984 986 Test templating help
985 987
986 988 $ hg help templating | egrep '(desc|diffstat|firstline|nonempty) '
987 989 desc String. The text of the changeset description.
988 990 diffstat String. Statistics of changes with the following format:
989 991 firstline Any text. Returns the first line of text.
990 992 nonempty Any text. Returns '(none)' if the string is empty.
991 993
992 994 Test deprecated items
993 995
994 996 $ hg help -v templating | grep currentbookmark
995 997 currentbookmark
996 998 $ hg help templating | (grep currentbookmark || true)
997 999
998 1000 Test help hooks
999 1001
1000 1002 $ cat > helphook1.py <<EOF
1001 1003 > from mercurial import help
1002 1004 >
1003 1005 > def rewrite(ui, topic, doc):
1004 1006 > return doc + '\nhelphook1\n'
1005 1007 >
1006 1008 > def extsetup(ui):
1007 1009 > help.addtopichook('revsets', rewrite)
1008 1010 > EOF
1009 1011 $ cat > helphook2.py <<EOF
1010 1012 > from mercurial import help
1011 1013 >
1012 1014 > def rewrite(ui, topic, doc):
1013 1015 > return doc + '\nhelphook2\n'
1014 1016 >
1015 1017 > def extsetup(ui):
1016 1018 > help.addtopichook('revsets', rewrite)
1017 1019 > EOF
1018 1020 $ echo '[extensions]' >> $HGRCPATH
1019 1021 $ echo "helphook1 = `pwd`/helphook1.py" >> $HGRCPATH
1020 1022 $ echo "helphook2 = `pwd`/helphook2.py" >> $HGRCPATH
1021 1023 $ hg help revsets | grep helphook
1022 1024 helphook1
1023 1025 helphook2
1024 1026
1025 1027 Test -e / -c / -k combinations
1026 1028
1027 1029 $ hg help -c progress
1028 1030 abort: no such help topic: progress
1029 1031 (try "hg help --keyword progress")
1030 1032 [255]
1031 1033 $ hg help -e progress |head -1
1032 1034 progress extension - show progress bars for some actions (DEPRECATED)
1033 1035 $ hg help -c -k dates |egrep '^(Topics|Extensions|Commands):'
1034 1036 Commands:
1035 1037 $ hg help -e -k a |egrep '^(Topics|Extensions|Commands):'
1036 1038 Extensions:
1037 1039 $ hg help -e -c -k date |egrep '^(Topics|Extensions|Commands):'
1038 1040 Extensions:
1039 1041 Commands:
1040 1042 $ hg help -c commit > /dev/null
1041 1043 $ hg help -e -c commit > /dev/null
1042 1044 $ hg help -e commit > /dev/null
1043 1045 abort: no such help topic: commit
1044 1046 (try "hg help --keyword commit")
1045 1047 [255]
1046 1048
1047 1049 Test keyword search help
1048 1050
1049 1051 $ cat > prefixedname.py <<EOF
1050 1052 > '''matched against word "clone"
1051 1053 > '''
1052 1054 > EOF
1053 1055 $ echo '[extensions]' >> $HGRCPATH
1054 1056 $ echo "dot.dot.prefixedname = `pwd`/prefixedname.py" >> $HGRCPATH
1055 1057 $ hg help -k clone
1056 1058 Topics:
1057 1059
1058 1060 config Configuration Files
1059 1061 extensions Using Additional Features
1060 1062 glossary Glossary
1061 1063 phases Working with Phases
1062 1064 subrepos Subrepositories
1063 1065 urls URL Paths
1064 1066
1065 1067 Commands:
1066 1068
1067 bookmarks create a new bookmark or list existing bookmarks
1068 clone make a copy of an existing repository
1069 paths show aliases for remote repositories
1070 update update working directory (or switch revisions)
1069 bookmarks create a new bookmark or list existing bookmarks
1070 clone make a copy of an existing repository
1071 debugcreatestreamclonebundle create a stream clone bundle file
1072 paths show aliases for remote repositories
1073 update update working directory (or switch revisions)
1071 1074
1072 1075 Extensions:
1073 1076
1074 1077 clonebundles server side extension to advertise pre-generated bundles to seed
1075 1078 clones.
1076 1079 prefixedname matched against word "clone"
1077 1080 relink recreates hardlinks between repository clones
1078 1081
1079 1082 Extension Commands:
1080 1083
1081 1084 qclone clone main and patch repository at same time
1082 1085
1083 1086 Test unfound topic
1084 1087
1085 1088 $ hg help nonexistingtopicthatwillneverexisteverever
1086 1089 abort: no such help topic: nonexistingtopicthatwillneverexisteverever
1087 1090 (try "hg help --keyword nonexistingtopicthatwillneverexisteverever")
1088 1091 [255]
1089 1092
1090 1093 Test unfound keyword
1091 1094
1092 1095 $ hg help --keyword nonexistingwordthatwillneverexisteverever
1093 1096 abort: no matches
1094 1097 (try "hg help" for a list of topics)
1095 1098 [255]
1096 1099
1097 1100 Test omit indicating for help
1098 1101
1099 1102 $ cat > addverboseitems.py <<EOF
1100 1103 > '''extension to test omit indicating.
1101 1104 >
1102 1105 > This paragraph is never omitted (for extension)
1103 1106 >
1104 1107 > .. container:: verbose
1105 1108 >
1106 1109 > This paragraph is omitted,
1107 1110 > if :hg:\`help\` is invoked without \`\`-v\`\` (for extension)
1108 1111 >
1109 1112 > This paragraph is never omitted, too (for extension)
1110 1113 > '''
1111 1114 >
1112 1115 > from mercurial import help, commands
1113 1116 > testtopic = """This paragraph is never omitted (for topic).
1114 1117 >
1115 1118 > .. container:: verbose
1116 1119 >
1117 1120 > This paragraph is omitted,
1118 1121 > if :hg:\`help\` is invoked without \`\`-v\`\` (for topic)
1119 1122 >
1120 1123 > This paragraph is never omitted, too (for topic)
1121 1124 > """
1122 1125 > def extsetup(ui):
1123 1126 > help.helptable.append((["topic-containing-verbose"],
1124 1127 > "This is the topic to test omit indicating.",
1125 1128 > lambda ui: testtopic))
1126 1129 > EOF
1127 1130 $ echo '[extensions]' >> $HGRCPATH
1128 1131 $ echo "addverboseitems = `pwd`/addverboseitems.py" >> $HGRCPATH
1129 1132 $ hg help addverboseitems
1130 1133 addverboseitems extension - extension to test omit indicating.
1131 1134
1132 1135 This paragraph is never omitted (for extension)
1133 1136
1134 1137 This paragraph is never omitted, too (for extension)
1135 1138
1136 1139 (some details hidden, use --verbose to show complete help)
1137 1140
1138 1141 no commands defined
1139 1142 $ hg help -v addverboseitems
1140 1143 addverboseitems extension - extension to test omit indicating.
1141 1144
1142 1145 This paragraph is never omitted (for extension)
1143 1146
1144 1147 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1145 1148 extension)
1146 1149
1147 1150 This paragraph is never omitted, too (for extension)
1148 1151
1149 1152 no commands defined
1150 1153 $ hg help topic-containing-verbose
1151 1154 This is the topic to test omit indicating.
1152 1155 """"""""""""""""""""""""""""""""""""""""""
1153 1156
1154 1157 This paragraph is never omitted (for topic).
1155 1158
1156 1159 This paragraph is never omitted, too (for topic)
1157 1160
1158 1161 (some details hidden, use --verbose to show complete help)
1159 1162 $ hg help -v topic-containing-verbose
1160 1163 This is the topic to test omit indicating.
1161 1164 """"""""""""""""""""""""""""""""""""""""""
1162 1165
1163 1166 This paragraph is never omitted (for topic).
1164 1167
1165 1168 This paragraph is omitted, if "hg help" is invoked without "-v" (for
1166 1169 topic)
1167 1170
1168 1171 This paragraph is never omitted, too (for topic)
1169 1172
1170 1173 Test section lookup
1171 1174
1172 1175 $ hg help revset.merge
1173 1176 "merge()"
1174 1177 Changeset is a merge changeset.
1175 1178
1176 1179 $ hg help glossary.dag
1177 1180 DAG
1178 1181 The repository of changesets of a distributed version control system
1179 1182 (DVCS) can be described as a directed acyclic graph (DAG), consisting
1180 1183 of nodes and edges, where nodes correspond to changesets and edges
1181 1184 imply a parent -> child relation. This graph can be visualized by
1182 1185 graphical tools such as "hg log --graph". In Mercurial, the DAG is
1183 1186 limited by the requirement for children to have at most two parents.
1184 1187
1185 1188
1186 1189 $ hg help hgrc.paths
1187 1190 "paths"
1188 1191 -------
1189 1192
1190 1193 Assigns symbolic names to repositories. The left side is the symbolic
1191 1194 name, and the right gives the directory or URL that is the location of the
1192 1195 repository. Default paths can be declared by setting the following
1193 1196 entries.
1194 1197
1195 1198 "default"
1196 1199 Directory or URL to use when pulling if no source is specified.
1197 1200 (default: repository from which the current repository was cloned)
1198 1201
1199 1202 "default-push"
1200 1203 Optional. Directory or URL to use when pushing if no destination is
1201 1204 specified.
1202 1205
1203 1206 Custom paths can be defined by assigning the path to a name that later can
1204 1207 be used from the command line. Example:
1205 1208
1206 1209 [paths]
1207 1210 my_path = http://example.com/path
1208 1211
1209 1212 To push to the path defined in "my_path" run the command:
1210 1213
1211 1214 hg push my_path
1212 1215
1213 1216 $ hg help glossary.mcguffin
1214 1217 abort: help section not found
1215 1218 [255]
1216 1219
1217 1220 $ hg help glossary.mc.guffin
1218 1221 abort: help section not found
1219 1222 [255]
1220 1223
1221 1224 $ hg help template.files
1222 1225 files List of strings. All files modified, added, or removed by
1223 1226 this changeset.
1224 1227
1225 1228 Test dynamic list of merge tools only shows up once
1226 1229 $ hg help merge-tools
1227 1230 Merge Tools
1228 1231 """""""""""
1229 1232
1230 1233 To merge files Mercurial uses merge tools.
1231 1234
1232 1235 A merge tool combines two different versions of a file into a merged file.
1233 1236 Merge tools are given the two files and the greatest common ancestor of
1234 1237 the two file versions, so they can determine the changes made on both
1235 1238 branches.
1236 1239
1237 1240 Merge tools are used both for "hg resolve", "hg merge", "hg update", "hg
1238 1241 backout" and in several extensions.
1239 1242
1240 1243 Usually, the merge tool tries to automatically reconcile the files by
1241 1244 combining all non-overlapping changes that occurred separately in the two
1242 1245 different evolutions of the same initial base file. Furthermore, some
1243 1246 interactive merge programs make it easier to manually resolve conflicting
1244 1247 merges, either in a graphical way, or by inserting some conflict markers.
1245 1248 Mercurial does not include any interactive merge programs but relies on
1246 1249 external tools for that.
1247 1250
1248 1251 Available merge tools
1249 1252 =====================
1250 1253
1251 1254 External merge tools and their properties are configured in the merge-
1252 1255 tools configuration section - see hgrc(5) - but they can often just be
1253 1256 named by their executable.
1254 1257
1255 1258 A merge tool is generally usable if its executable can be found on the
1256 1259 system and if it can handle the merge. The executable is found if it is an
1257 1260 absolute or relative executable path or the name of an application in the
1258 1261 executable search path. The tool is assumed to be able to handle the merge
1259 1262 if it can handle symlinks if the file is a symlink, if it can handle
1260 1263 binary files if the file is binary, and if a GUI is available if the tool
1261 1264 requires a GUI.
1262 1265
1263 1266 There are some internal merge tools which can be used. The internal merge
1264 1267 tools are:
1265 1268
1266 1269 ":dump"
1267 1270 Creates three versions of the files to merge, containing the contents of
1268 1271 local, other and base. These files can then be used to perform a merge
1269 1272 manually. If the file to be merged is named "a.txt", these files will
1270 1273 accordingly be named "a.txt.local", "a.txt.other" and "a.txt.base" and
1271 1274 they will be placed in the same directory as "a.txt".
1272 1275
1273 1276 ":fail"
1274 1277 Rather than attempting to merge files that were modified on both
1275 1278 branches, it marks them as unresolved. The resolve command must be used
1276 1279 to resolve these conflicts.
1277 1280
1278 1281 ":local"
1279 1282 Uses the local version of files as the merged version.
1280 1283
1281 1284 ":merge"
1282 1285 Uses the internal non-interactive simple merge algorithm for merging
1283 1286 files. It will fail if there are any conflicts and leave markers in the
1284 1287 partially merged file. Markers will have two sections, one for each side
1285 1288 of merge.
1286 1289
1287 1290 ":merge-local"
1288 1291 Like :merge, but resolve all conflicts non-interactively in favor of the
1289 1292 local changes.
1290 1293
1291 1294 ":merge-other"
1292 1295 Like :merge, but resolve all conflicts non-interactively in favor of the
1293 1296 other changes.
1294 1297
1295 1298 ":merge3"
1296 1299 Uses the internal non-interactive simple merge algorithm for merging
1297 1300 files. It will fail if there are any conflicts and leave markers in the
1298 1301 partially merged file. Marker will have three sections, one from each
1299 1302 side of the merge and one for the base content.
1300 1303
1301 1304 ":other"
1302 1305 Uses the other version of files as the merged version.
1303 1306
1304 1307 ":prompt"
1305 1308 Asks the user which of the local or the other version to keep as the
1306 1309 merged version.
1307 1310
1308 1311 ":tagmerge"
1309 1312 Uses the internal tag merge algorithm (experimental).
1310 1313
1311 1314 ":union"
1312 1315 Uses the internal non-interactive simple merge algorithm for merging
1313 1316 files. It will use both left and right sides for conflict regions. No
1314 1317 markers are inserted.
1315 1318
1316 1319 Internal tools are always available and do not require a GUI but will by
1317 1320 default not handle symlinks or binary files.
1318 1321
1319 1322 Choosing a merge tool
1320 1323 =====================
1321 1324
1322 1325 Mercurial uses these rules when deciding which merge tool to use:
1323 1326
1324 1327 1. If a tool has been specified with the --tool option to merge or
1325 1328 resolve, it is used. If it is the name of a tool in the merge-tools
1326 1329 configuration, its configuration is used. Otherwise the specified tool
1327 1330 must be executable by the shell.
1328 1331 2. If the "HGMERGE" environment variable is present, its value is used and
1329 1332 must be executable by the shell.
1330 1333 3. If the filename of the file to be merged matches any of the patterns in
1331 1334 the merge-patterns configuration section, the first usable merge tool
1332 1335 corresponding to a matching pattern is used. Here, binary capabilities
1333 1336 of the merge tool are not considered.
1334 1337 4. If ui.merge is set it will be considered next. If the value is not the
1335 1338 name of a configured tool, the specified value is used and must be
1336 1339 executable by the shell. Otherwise the named tool is used if it is
1337 1340 usable.
1338 1341 5. If any usable merge tools are present in the merge-tools configuration
1339 1342 section, the one with the highest priority is used.
1340 1343 6. If a program named "hgmerge" can be found on the system, it is used -
1341 1344 but it will by default not be used for symlinks and binary files.
1342 1345 7. If the file to be merged is not binary and is not a symlink, then
1343 1346 internal ":merge" is used.
1344 1347 8. The merge of the file fails and must be resolved before commit.
1345 1348
1346 1349 Note:
1347 1350 After selecting a merge program, Mercurial will by default attempt to
1348 1351 merge the files using a simple merge algorithm first. Only if it
1349 1352 doesn't succeed because of conflicting changes Mercurial will actually
1350 1353 execute the merge program. Whether to use the simple merge algorithm
1351 1354 first can be controlled by the premerge setting of the merge tool.
1352 1355 Premerge is enabled by default unless the file is binary or a symlink.
1353 1356
1354 1357 See the merge-tools and ui sections of hgrc(5) for details on the
1355 1358 configuration of merge tools.
1356 1359
1357 1360 Test usage of section marks in help documents
1358 1361
1359 1362 $ cd "$TESTDIR"/../doc
1360 1363 $ python check-seclevel.py
1361 1364 $ cd $TESTTMP
1362 1365
1363 1366 #if serve
1364 1367
1365 1368 Test the help pages in hgweb.
1366 1369
1367 1370 Dish up an empty repo; serve it cold.
1368 1371
1369 1372 $ hg init "$TESTTMP/test"
1370 1373 $ hg serve -R "$TESTTMP/test" -n test -p $HGPORT -d --pid-file=hg.pid
1371 1374 $ cat hg.pid >> $DAEMON_PIDS
1372 1375
1373 1376 $ get-with-headers.py 127.0.0.1:$HGPORT "help"
1374 1377 200 Script output follows
1375 1378
1376 1379 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1377 1380 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1378 1381 <head>
1379 1382 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1380 1383 <meta name="robots" content="index, nofollow" />
1381 1384 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1382 1385 <script type="text/javascript" src="/static/mercurial.js"></script>
1383 1386
1384 1387 <title>Help: Index</title>
1385 1388 </head>
1386 1389 <body>
1387 1390
1388 1391 <div class="container">
1389 1392 <div class="menu">
1390 1393 <div class="logo">
1391 1394 <a href="https://mercurial-scm.org/">
1392 1395 <img src="/static/hglogo.png" alt="mercurial" /></a>
1393 1396 </div>
1394 1397 <ul>
1395 1398 <li><a href="/shortlog">log</a></li>
1396 1399 <li><a href="/graph">graph</a></li>
1397 1400 <li><a href="/tags">tags</a></li>
1398 1401 <li><a href="/bookmarks">bookmarks</a></li>
1399 1402 <li><a href="/branches">branches</a></li>
1400 1403 </ul>
1401 1404 <ul>
1402 1405 <li class="active">help</li>
1403 1406 </ul>
1404 1407 </div>
1405 1408
1406 1409 <div class="main">
1407 1410 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1408 1411 <form class="search" action="/log">
1409 1412
1410 1413 <p><input name="rev" id="search1" type="text" size="30" /></p>
1411 1414 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1412 1415 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1413 1416 </form>
1414 1417 <table class="bigtable">
1415 1418 <tr><td colspan="2"><h2><a name="main" href="#topics">Topics</a></h2></td></tr>
1416 1419
1417 1420 <tr><td>
1418 1421 <a href="/help/config">
1419 1422 config
1420 1423 </a>
1421 1424 </td><td>
1422 1425 Configuration Files
1423 1426 </td></tr>
1424 1427 <tr><td>
1425 1428 <a href="/help/dates">
1426 1429 dates
1427 1430 </a>
1428 1431 </td><td>
1429 1432 Date Formats
1430 1433 </td></tr>
1431 1434 <tr><td>
1432 1435 <a href="/help/diffs">
1433 1436 diffs
1434 1437 </a>
1435 1438 </td><td>
1436 1439 Diff Formats
1437 1440 </td></tr>
1438 1441 <tr><td>
1439 1442 <a href="/help/environment">
1440 1443 environment
1441 1444 </a>
1442 1445 </td><td>
1443 1446 Environment Variables
1444 1447 </td></tr>
1445 1448 <tr><td>
1446 1449 <a href="/help/extensions">
1447 1450 extensions
1448 1451 </a>
1449 1452 </td><td>
1450 1453 Using Additional Features
1451 1454 </td></tr>
1452 1455 <tr><td>
1453 1456 <a href="/help/filesets">
1454 1457 filesets
1455 1458 </a>
1456 1459 </td><td>
1457 1460 Specifying File Sets
1458 1461 </td></tr>
1459 1462 <tr><td>
1460 1463 <a href="/help/glossary">
1461 1464 glossary
1462 1465 </a>
1463 1466 </td><td>
1464 1467 Glossary
1465 1468 </td></tr>
1466 1469 <tr><td>
1467 1470 <a href="/help/hgignore">
1468 1471 hgignore
1469 1472 </a>
1470 1473 </td><td>
1471 1474 Syntax for Mercurial Ignore Files
1472 1475 </td></tr>
1473 1476 <tr><td>
1474 1477 <a href="/help/hgweb">
1475 1478 hgweb
1476 1479 </a>
1477 1480 </td><td>
1478 1481 Configuring hgweb
1479 1482 </td></tr>
1480 1483 <tr><td>
1481 1484 <a href="/help/merge-tools">
1482 1485 merge-tools
1483 1486 </a>
1484 1487 </td><td>
1485 1488 Merge Tools
1486 1489 </td></tr>
1487 1490 <tr><td>
1488 1491 <a href="/help/multirevs">
1489 1492 multirevs
1490 1493 </a>
1491 1494 </td><td>
1492 1495 Specifying Multiple Revisions
1493 1496 </td></tr>
1494 1497 <tr><td>
1495 1498 <a href="/help/patterns">
1496 1499 patterns
1497 1500 </a>
1498 1501 </td><td>
1499 1502 File Name Patterns
1500 1503 </td></tr>
1501 1504 <tr><td>
1502 1505 <a href="/help/phases">
1503 1506 phases
1504 1507 </a>
1505 1508 </td><td>
1506 1509 Working with Phases
1507 1510 </td></tr>
1508 1511 <tr><td>
1509 1512 <a href="/help/revisions">
1510 1513 revisions
1511 1514 </a>
1512 1515 </td><td>
1513 1516 Specifying Single Revisions
1514 1517 </td></tr>
1515 1518 <tr><td>
1516 1519 <a href="/help/revsets">
1517 1520 revsets
1518 1521 </a>
1519 1522 </td><td>
1520 1523 Specifying Revision Sets
1521 1524 </td></tr>
1522 1525 <tr><td>
1523 1526 <a href="/help/scripting">
1524 1527 scripting
1525 1528 </a>
1526 1529 </td><td>
1527 1530 Using Mercurial from scripts and automation
1528 1531 </td></tr>
1529 1532 <tr><td>
1530 1533 <a href="/help/subrepos">
1531 1534 subrepos
1532 1535 </a>
1533 1536 </td><td>
1534 1537 Subrepositories
1535 1538 </td></tr>
1536 1539 <tr><td>
1537 1540 <a href="/help/templating">
1538 1541 templating
1539 1542 </a>
1540 1543 </td><td>
1541 1544 Template Usage
1542 1545 </td></tr>
1543 1546 <tr><td>
1544 1547 <a href="/help/urls">
1545 1548 urls
1546 1549 </a>
1547 1550 </td><td>
1548 1551 URL Paths
1549 1552 </td></tr>
1550 1553 <tr><td>
1551 1554 <a href="/help/topic-containing-verbose">
1552 1555 topic-containing-verbose
1553 1556 </a>
1554 1557 </td><td>
1555 1558 This is the topic to test omit indicating.
1556 1559 </td></tr>
1557 1560
1558 1561 <tr><td colspan="2"><h2><a name="main" href="#main">Main Commands</a></h2></td></tr>
1559 1562
1560 1563 <tr><td>
1561 1564 <a href="/help/add">
1562 1565 add
1563 1566 </a>
1564 1567 </td><td>
1565 1568 add the specified files on the next commit
1566 1569 </td></tr>
1567 1570 <tr><td>
1568 1571 <a href="/help/annotate">
1569 1572 annotate
1570 1573 </a>
1571 1574 </td><td>
1572 1575 show changeset information by line for each file
1573 1576 </td></tr>
1574 1577 <tr><td>
1575 1578 <a href="/help/clone">
1576 1579 clone
1577 1580 </a>
1578 1581 </td><td>
1579 1582 make a copy of an existing repository
1580 1583 </td></tr>
1581 1584 <tr><td>
1582 1585 <a href="/help/commit">
1583 1586 commit
1584 1587 </a>
1585 1588 </td><td>
1586 1589 commit the specified files or all outstanding changes
1587 1590 </td></tr>
1588 1591 <tr><td>
1589 1592 <a href="/help/diff">
1590 1593 diff
1591 1594 </a>
1592 1595 </td><td>
1593 1596 diff repository (or selected files)
1594 1597 </td></tr>
1595 1598 <tr><td>
1596 1599 <a href="/help/export">
1597 1600 export
1598 1601 </a>
1599 1602 </td><td>
1600 1603 dump the header and diffs for one or more changesets
1601 1604 </td></tr>
1602 1605 <tr><td>
1603 1606 <a href="/help/forget">
1604 1607 forget
1605 1608 </a>
1606 1609 </td><td>
1607 1610 forget the specified files on the next commit
1608 1611 </td></tr>
1609 1612 <tr><td>
1610 1613 <a href="/help/init">
1611 1614 init
1612 1615 </a>
1613 1616 </td><td>
1614 1617 create a new repository in the given directory
1615 1618 </td></tr>
1616 1619 <tr><td>
1617 1620 <a href="/help/log">
1618 1621 log
1619 1622 </a>
1620 1623 </td><td>
1621 1624 show revision history of entire repository or files
1622 1625 </td></tr>
1623 1626 <tr><td>
1624 1627 <a href="/help/merge">
1625 1628 merge
1626 1629 </a>
1627 1630 </td><td>
1628 1631 merge another revision into working directory
1629 1632 </td></tr>
1630 1633 <tr><td>
1631 1634 <a href="/help/pull">
1632 1635 pull
1633 1636 </a>
1634 1637 </td><td>
1635 1638 pull changes from the specified source
1636 1639 </td></tr>
1637 1640 <tr><td>
1638 1641 <a href="/help/push">
1639 1642 push
1640 1643 </a>
1641 1644 </td><td>
1642 1645 push changes to the specified destination
1643 1646 </td></tr>
1644 1647 <tr><td>
1645 1648 <a href="/help/remove">
1646 1649 remove
1647 1650 </a>
1648 1651 </td><td>
1649 1652 remove the specified files on the next commit
1650 1653 </td></tr>
1651 1654 <tr><td>
1652 1655 <a href="/help/serve">
1653 1656 serve
1654 1657 </a>
1655 1658 </td><td>
1656 1659 start stand-alone webserver
1657 1660 </td></tr>
1658 1661 <tr><td>
1659 1662 <a href="/help/status">
1660 1663 status
1661 1664 </a>
1662 1665 </td><td>
1663 1666 show changed files in the working directory
1664 1667 </td></tr>
1665 1668 <tr><td>
1666 1669 <a href="/help/summary">
1667 1670 summary
1668 1671 </a>
1669 1672 </td><td>
1670 1673 summarize working directory state
1671 1674 </td></tr>
1672 1675 <tr><td>
1673 1676 <a href="/help/update">
1674 1677 update
1675 1678 </a>
1676 1679 </td><td>
1677 1680 update working directory (or switch revisions)
1678 1681 </td></tr>
1679 1682
1680 1683 <tr><td colspan="2"><h2><a name="other" href="#other">Other Commands</a></h2></td></tr>
1681 1684
1682 1685 <tr><td>
1683 1686 <a href="/help/addremove">
1684 1687 addremove
1685 1688 </a>
1686 1689 </td><td>
1687 1690 add all new files, delete all missing files
1688 1691 </td></tr>
1689 1692 <tr><td>
1690 1693 <a href="/help/archive">
1691 1694 archive
1692 1695 </a>
1693 1696 </td><td>
1694 1697 create an unversioned archive of a repository revision
1695 1698 </td></tr>
1696 1699 <tr><td>
1697 1700 <a href="/help/backout">
1698 1701 backout
1699 1702 </a>
1700 1703 </td><td>
1701 1704 reverse effect of earlier changeset
1702 1705 </td></tr>
1703 1706 <tr><td>
1704 1707 <a href="/help/bisect">
1705 1708 bisect
1706 1709 </a>
1707 1710 </td><td>
1708 1711 subdivision search of changesets
1709 1712 </td></tr>
1710 1713 <tr><td>
1711 1714 <a href="/help/bookmarks">
1712 1715 bookmarks
1713 1716 </a>
1714 1717 </td><td>
1715 1718 create a new bookmark or list existing bookmarks
1716 1719 </td></tr>
1717 1720 <tr><td>
1718 1721 <a href="/help/branch">
1719 1722 branch
1720 1723 </a>
1721 1724 </td><td>
1722 1725 set or show the current branch name
1723 1726 </td></tr>
1724 1727 <tr><td>
1725 1728 <a href="/help/branches">
1726 1729 branches
1727 1730 </a>
1728 1731 </td><td>
1729 1732 list repository named branches
1730 1733 </td></tr>
1731 1734 <tr><td>
1732 1735 <a href="/help/bundle">
1733 1736 bundle
1734 1737 </a>
1735 1738 </td><td>
1736 1739 create a changegroup file
1737 1740 </td></tr>
1738 1741 <tr><td>
1739 1742 <a href="/help/cat">
1740 1743 cat
1741 1744 </a>
1742 1745 </td><td>
1743 1746 output the current or given revision of files
1744 1747 </td></tr>
1745 1748 <tr><td>
1746 1749 <a href="/help/config">
1747 1750 config
1748 1751 </a>
1749 1752 </td><td>
1750 1753 show combined config settings from all hgrc files
1751 1754 </td></tr>
1752 1755 <tr><td>
1753 1756 <a href="/help/copy">
1754 1757 copy
1755 1758 </a>
1756 1759 </td><td>
1757 1760 mark files as copied for the next commit
1758 1761 </td></tr>
1759 1762 <tr><td>
1760 1763 <a href="/help/files">
1761 1764 files
1762 1765 </a>
1763 1766 </td><td>
1764 1767 list tracked files
1765 1768 </td></tr>
1766 1769 <tr><td>
1767 1770 <a href="/help/graft">
1768 1771 graft
1769 1772 </a>
1770 1773 </td><td>
1771 1774 copy changes from other branches onto the current branch
1772 1775 </td></tr>
1773 1776 <tr><td>
1774 1777 <a href="/help/grep">
1775 1778 grep
1776 1779 </a>
1777 1780 </td><td>
1778 1781 search for a pattern in specified files and revisions
1779 1782 </td></tr>
1780 1783 <tr><td>
1781 1784 <a href="/help/heads">
1782 1785 heads
1783 1786 </a>
1784 1787 </td><td>
1785 1788 show branch heads
1786 1789 </td></tr>
1787 1790 <tr><td>
1788 1791 <a href="/help/help">
1789 1792 help
1790 1793 </a>
1791 1794 </td><td>
1792 1795 show help for a given topic or a help overview
1793 1796 </td></tr>
1794 1797 <tr><td>
1795 1798 <a href="/help/identify">
1796 1799 identify
1797 1800 </a>
1798 1801 </td><td>
1799 1802 identify the working directory or specified revision
1800 1803 </td></tr>
1801 1804 <tr><td>
1802 1805 <a href="/help/import">
1803 1806 import
1804 1807 </a>
1805 1808 </td><td>
1806 1809 import an ordered set of patches
1807 1810 </td></tr>
1808 1811 <tr><td>
1809 1812 <a href="/help/incoming">
1810 1813 incoming
1811 1814 </a>
1812 1815 </td><td>
1813 1816 show new changesets found in source
1814 1817 </td></tr>
1815 1818 <tr><td>
1816 1819 <a href="/help/manifest">
1817 1820 manifest
1818 1821 </a>
1819 1822 </td><td>
1820 1823 output the current or given revision of the project manifest
1821 1824 </td></tr>
1822 1825 <tr><td>
1823 1826 <a href="/help/nohelp">
1824 1827 nohelp
1825 1828 </a>
1826 1829 </td><td>
1827 1830 (no help text available)
1828 1831 </td></tr>
1829 1832 <tr><td>
1830 1833 <a href="/help/outgoing">
1831 1834 outgoing
1832 1835 </a>
1833 1836 </td><td>
1834 1837 show changesets not found in the destination
1835 1838 </td></tr>
1836 1839 <tr><td>
1837 1840 <a href="/help/paths">
1838 1841 paths
1839 1842 </a>
1840 1843 </td><td>
1841 1844 show aliases for remote repositories
1842 1845 </td></tr>
1843 1846 <tr><td>
1844 1847 <a href="/help/phase">
1845 1848 phase
1846 1849 </a>
1847 1850 </td><td>
1848 1851 set or show the current phase name
1849 1852 </td></tr>
1850 1853 <tr><td>
1851 1854 <a href="/help/recover">
1852 1855 recover
1853 1856 </a>
1854 1857 </td><td>
1855 1858 roll back an interrupted transaction
1856 1859 </td></tr>
1857 1860 <tr><td>
1858 1861 <a href="/help/rename">
1859 1862 rename
1860 1863 </a>
1861 1864 </td><td>
1862 1865 rename files; equivalent of copy + remove
1863 1866 </td></tr>
1864 1867 <tr><td>
1865 1868 <a href="/help/resolve">
1866 1869 resolve
1867 1870 </a>
1868 1871 </td><td>
1869 1872 redo merges or set/view the merge status of files
1870 1873 </td></tr>
1871 1874 <tr><td>
1872 1875 <a href="/help/revert">
1873 1876 revert
1874 1877 </a>
1875 1878 </td><td>
1876 1879 restore files to their checkout state
1877 1880 </td></tr>
1878 1881 <tr><td>
1879 1882 <a href="/help/root">
1880 1883 root
1881 1884 </a>
1882 1885 </td><td>
1883 1886 print the root (top) of the current working directory
1884 1887 </td></tr>
1885 1888 <tr><td>
1886 1889 <a href="/help/tag">
1887 1890 tag
1888 1891 </a>
1889 1892 </td><td>
1890 1893 add one or more tags for the current or given revision
1891 1894 </td></tr>
1892 1895 <tr><td>
1893 1896 <a href="/help/tags">
1894 1897 tags
1895 1898 </a>
1896 1899 </td><td>
1897 1900 list repository tags
1898 1901 </td></tr>
1899 1902 <tr><td>
1900 1903 <a href="/help/unbundle">
1901 1904 unbundle
1902 1905 </a>
1903 1906 </td><td>
1904 1907 apply one or more changegroup files
1905 1908 </td></tr>
1906 1909 <tr><td>
1907 1910 <a href="/help/verify">
1908 1911 verify
1909 1912 </a>
1910 1913 </td><td>
1911 1914 verify the integrity of the repository
1912 1915 </td></tr>
1913 1916 <tr><td>
1914 1917 <a href="/help/version">
1915 1918 version
1916 1919 </a>
1917 1920 </td><td>
1918 1921 output version and copyright information
1919 1922 </td></tr>
1920 1923 </table>
1921 1924 </div>
1922 1925 </div>
1923 1926
1924 1927 <script type="text/javascript">process_dates()</script>
1925 1928
1926 1929
1927 1930 </body>
1928 1931 </html>
1929 1932
1930 1933
1931 1934 $ get-with-headers.py 127.0.0.1:$HGPORT "help/add"
1932 1935 200 Script output follows
1933 1936
1934 1937 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
1935 1938 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
1936 1939 <head>
1937 1940 <link rel="icon" href="/static/hgicon.png" type="image/png" />
1938 1941 <meta name="robots" content="index, nofollow" />
1939 1942 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
1940 1943 <script type="text/javascript" src="/static/mercurial.js"></script>
1941 1944
1942 1945 <title>Help: add</title>
1943 1946 </head>
1944 1947 <body>
1945 1948
1946 1949 <div class="container">
1947 1950 <div class="menu">
1948 1951 <div class="logo">
1949 1952 <a href="https://mercurial-scm.org/">
1950 1953 <img src="/static/hglogo.png" alt="mercurial" /></a>
1951 1954 </div>
1952 1955 <ul>
1953 1956 <li><a href="/shortlog">log</a></li>
1954 1957 <li><a href="/graph">graph</a></li>
1955 1958 <li><a href="/tags">tags</a></li>
1956 1959 <li><a href="/bookmarks">bookmarks</a></li>
1957 1960 <li><a href="/branches">branches</a></li>
1958 1961 </ul>
1959 1962 <ul>
1960 1963 <li class="active"><a href="/help">help</a></li>
1961 1964 </ul>
1962 1965 </div>
1963 1966
1964 1967 <div class="main">
1965 1968 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
1966 1969 <h3>Help: add</h3>
1967 1970
1968 1971 <form class="search" action="/log">
1969 1972
1970 1973 <p><input name="rev" id="search1" type="text" size="30" /></p>
1971 1974 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
1972 1975 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
1973 1976 </form>
1974 1977 <div id="doc">
1975 1978 <p>
1976 1979 hg add [OPTION]... [FILE]...
1977 1980 </p>
1978 1981 <p>
1979 1982 add the specified files on the next commit
1980 1983 </p>
1981 1984 <p>
1982 1985 Schedule files to be version controlled and added to the
1983 1986 repository.
1984 1987 </p>
1985 1988 <p>
1986 1989 The files will be added to the repository at the next commit. To
1987 1990 undo an add before that, see &quot;hg forget&quot;.
1988 1991 </p>
1989 1992 <p>
1990 1993 If no names are given, add all files to the repository.
1991 1994 </p>
1992 1995 <p>
1993 1996 An example showing how new (unknown) files are added
1994 1997 automatically by &quot;hg add&quot;:
1995 1998 </p>
1996 1999 <pre>
1997 2000 \$ ls (re)
1998 2001 foo.c
1999 2002 \$ hg status (re)
2000 2003 ? foo.c
2001 2004 \$ hg add (re)
2002 2005 adding foo.c
2003 2006 \$ hg status (re)
2004 2007 A foo.c
2005 2008 </pre>
2006 2009 <p>
2007 2010 Returns 0 if all files are successfully added.
2008 2011 </p>
2009 2012 <p>
2010 2013 options ([+] can be repeated):
2011 2014 </p>
2012 2015 <table>
2013 2016 <tr><td>-I</td>
2014 2017 <td>--include PATTERN [+]</td>
2015 2018 <td>include names matching the given patterns</td></tr>
2016 2019 <tr><td>-X</td>
2017 2020 <td>--exclude PATTERN [+]</td>
2018 2021 <td>exclude names matching the given patterns</td></tr>
2019 2022 <tr><td>-S</td>
2020 2023 <td>--subrepos</td>
2021 2024 <td>recurse into subrepositories</td></tr>
2022 2025 <tr><td>-n</td>
2023 2026 <td>--dry-run</td>
2024 2027 <td>do not perform actions, just print output</td></tr>
2025 2028 </table>
2026 2029 <p>
2027 2030 global options ([+] can be repeated):
2028 2031 </p>
2029 2032 <table>
2030 2033 <tr><td>-R</td>
2031 2034 <td>--repository REPO</td>
2032 2035 <td>repository root directory or name of overlay bundle file</td></tr>
2033 2036 <tr><td></td>
2034 2037 <td>--cwd DIR</td>
2035 2038 <td>change working directory</td></tr>
2036 2039 <tr><td>-y</td>
2037 2040 <td>--noninteractive</td>
2038 2041 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2039 2042 <tr><td>-q</td>
2040 2043 <td>--quiet</td>
2041 2044 <td>suppress output</td></tr>
2042 2045 <tr><td>-v</td>
2043 2046 <td>--verbose</td>
2044 2047 <td>enable additional output</td></tr>
2045 2048 <tr><td></td>
2046 2049 <td>--config CONFIG [+]</td>
2047 2050 <td>set/override config option (use 'section.name=value')</td></tr>
2048 2051 <tr><td></td>
2049 2052 <td>--debug</td>
2050 2053 <td>enable debugging output</td></tr>
2051 2054 <tr><td></td>
2052 2055 <td>--debugger</td>
2053 2056 <td>start debugger</td></tr>
2054 2057 <tr><td></td>
2055 2058 <td>--encoding ENCODE</td>
2056 2059 <td>set the charset encoding (default: ascii)</td></tr>
2057 2060 <tr><td></td>
2058 2061 <td>--encodingmode MODE</td>
2059 2062 <td>set the charset encoding mode (default: strict)</td></tr>
2060 2063 <tr><td></td>
2061 2064 <td>--traceback</td>
2062 2065 <td>always print a traceback on exception</td></tr>
2063 2066 <tr><td></td>
2064 2067 <td>--time</td>
2065 2068 <td>time how long the command takes</td></tr>
2066 2069 <tr><td></td>
2067 2070 <td>--profile</td>
2068 2071 <td>print command execution profile</td></tr>
2069 2072 <tr><td></td>
2070 2073 <td>--version</td>
2071 2074 <td>output version information and exit</td></tr>
2072 2075 <tr><td>-h</td>
2073 2076 <td>--help</td>
2074 2077 <td>display help and exit</td></tr>
2075 2078 <tr><td></td>
2076 2079 <td>--hidden</td>
2077 2080 <td>consider hidden changesets</td></tr>
2078 2081 </table>
2079 2082
2080 2083 </div>
2081 2084 </div>
2082 2085 </div>
2083 2086
2084 2087 <script type="text/javascript">process_dates()</script>
2085 2088
2086 2089
2087 2090 </body>
2088 2091 </html>
2089 2092
2090 2093
2091 2094 $ get-with-headers.py 127.0.0.1:$HGPORT "help/remove"
2092 2095 200 Script output follows
2093 2096
2094 2097 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2095 2098 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2096 2099 <head>
2097 2100 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2098 2101 <meta name="robots" content="index, nofollow" />
2099 2102 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2100 2103 <script type="text/javascript" src="/static/mercurial.js"></script>
2101 2104
2102 2105 <title>Help: remove</title>
2103 2106 </head>
2104 2107 <body>
2105 2108
2106 2109 <div class="container">
2107 2110 <div class="menu">
2108 2111 <div class="logo">
2109 2112 <a href="https://mercurial-scm.org/">
2110 2113 <img src="/static/hglogo.png" alt="mercurial" /></a>
2111 2114 </div>
2112 2115 <ul>
2113 2116 <li><a href="/shortlog">log</a></li>
2114 2117 <li><a href="/graph">graph</a></li>
2115 2118 <li><a href="/tags">tags</a></li>
2116 2119 <li><a href="/bookmarks">bookmarks</a></li>
2117 2120 <li><a href="/branches">branches</a></li>
2118 2121 </ul>
2119 2122 <ul>
2120 2123 <li class="active"><a href="/help">help</a></li>
2121 2124 </ul>
2122 2125 </div>
2123 2126
2124 2127 <div class="main">
2125 2128 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2126 2129 <h3>Help: remove</h3>
2127 2130
2128 2131 <form class="search" action="/log">
2129 2132
2130 2133 <p><input name="rev" id="search1" type="text" size="30" /></p>
2131 2134 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2132 2135 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2133 2136 </form>
2134 2137 <div id="doc">
2135 2138 <p>
2136 2139 hg remove [OPTION]... FILE...
2137 2140 </p>
2138 2141 <p>
2139 2142 aliases: rm
2140 2143 </p>
2141 2144 <p>
2142 2145 remove the specified files on the next commit
2143 2146 </p>
2144 2147 <p>
2145 2148 Schedule the indicated files for removal from the current branch.
2146 2149 </p>
2147 2150 <p>
2148 2151 This command schedules the files to be removed at the next commit.
2149 2152 To undo a remove before that, see &quot;hg revert&quot;. To undo added
2150 2153 files, see &quot;hg forget&quot;.
2151 2154 </p>
2152 2155 <p>
2153 2156 -A/--after can be used to remove only files that have already
2154 2157 been deleted, -f/--force can be used to force deletion, and -Af
2155 2158 can be used to remove files from the next revision without
2156 2159 deleting them from the working directory.
2157 2160 </p>
2158 2161 <p>
2159 2162 The following table details the behavior of remove for different
2160 2163 file states (columns) and option combinations (rows). The file
2161 2164 states are Added [A], Clean [C], Modified [M] and Missing [!]
2162 2165 (as reported by &quot;hg status&quot;). The actions are Warn, Remove
2163 2166 (from branch) and Delete (from disk):
2164 2167 </p>
2165 2168 <table>
2166 2169 <tr><td>opt/state</td>
2167 2170 <td>A</td>
2168 2171 <td>C</td>
2169 2172 <td>M</td>
2170 2173 <td>!</td></tr>
2171 2174 <tr><td>none</td>
2172 2175 <td>W</td>
2173 2176 <td>RD</td>
2174 2177 <td>W</td>
2175 2178 <td>R</td></tr>
2176 2179 <tr><td>-f</td>
2177 2180 <td>R</td>
2178 2181 <td>RD</td>
2179 2182 <td>RD</td>
2180 2183 <td>R</td></tr>
2181 2184 <tr><td>-A</td>
2182 2185 <td>W</td>
2183 2186 <td>W</td>
2184 2187 <td>W</td>
2185 2188 <td>R</td></tr>
2186 2189 <tr><td>-Af</td>
2187 2190 <td>R</td>
2188 2191 <td>R</td>
2189 2192 <td>R</td>
2190 2193 <td>R</td></tr>
2191 2194 </table>
2192 2195 <p>
2193 2196 Note that remove never deletes files in Added [A] state from the
2194 2197 working directory, not even if option --force is specified.
2195 2198 </p>
2196 2199 <p>
2197 2200 Returns 0 on success, 1 if any warnings encountered.
2198 2201 </p>
2199 2202 <p>
2200 2203 options ([+] can be repeated):
2201 2204 </p>
2202 2205 <table>
2203 2206 <tr><td>-A</td>
2204 2207 <td>--after</td>
2205 2208 <td>record delete for missing files</td></tr>
2206 2209 <tr><td>-f</td>
2207 2210 <td>--force</td>
2208 2211 <td>remove (and delete) file even if added or modified</td></tr>
2209 2212 <tr><td>-S</td>
2210 2213 <td>--subrepos</td>
2211 2214 <td>recurse into subrepositories</td></tr>
2212 2215 <tr><td>-I</td>
2213 2216 <td>--include PATTERN [+]</td>
2214 2217 <td>include names matching the given patterns</td></tr>
2215 2218 <tr><td>-X</td>
2216 2219 <td>--exclude PATTERN [+]</td>
2217 2220 <td>exclude names matching the given patterns</td></tr>
2218 2221 </table>
2219 2222 <p>
2220 2223 global options ([+] can be repeated):
2221 2224 </p>
2222 2225 <table>
2223 2226 <tr><td>-R</td>
2224 2227 <td>--repository REPO</td>
2225 2228 <td>repository root directory or name of overlay bundle file</td></tr>
2226 2229 <tr><td></td>
2227 2230 <td>--cwd DIR</td>
2228 2231 <td>change working directory</td></tr>
2229 2232 <tr><td>-y</td>
2230 2233 <td>--noninteractive</td>
2231 2234 <td>do not prompt, automatically pick the first choice for all prompts</td></tr>
2232 2235 <tr><td>-q</td>
2233 2236 <td>--quiet</td>
2234 2237 <td>suppress output</td></tr>
2235 2238 <tr><td>-v</td>
2236 2239 <td>--verbose</td>
2237 2240 <td>enable additional output</td></tr>
2238 2241 <tr><td></td>
2239 2242 <td>--config CONFIG [+]</td>
2240 2243 <td>set/override config option (use 'section.name=value')</td></tr>
2241 2244 <tr><td></td>
2242 2245 <td>--debug</td>
2243 2246 <td>enable debugging output</td></tr>
2244 2247 <tr><td></td>
2245 2248 <td>--debugger</td>
2246 2249 <td>start debugger</td></tr>
2247 2250 <tr><td></td>
2248 2251 <td>--encoding ENCODE</td>
2249 2252 <td>set the charset encoding (default: ascii)</td></tr>
2250 2253 <tr><td></td>
2251 2254 <td>--encodingmode MODE</td>
2252 2255 <td>set the charset encoding mode (default: strict)</td></tr>
2253 2256 <tr><td></td>
2254 2257 <td>--traceback</td>
2255 2258 <td>always print a traceback on exception</td></tr>
2256 2259 <tr><td></td>
2257 2260 <td>--time</td>
2258 2261 <td>time how long the command takes</td></tr>
2259 2262 <tr><td></td>
2260 2263 <td>--profile</td>
2261 2264 <td>print command execution profile</td></tr>
2262 2265 <tr><td></td>
2263 2266 <td>--version</td>
2264 2267 <td>output version information and exit</td></tr>
2265 2268 <tr><td>-h</td>
2266 2269 <td>--help</td>
2267 2270 <td>display help and exit</td></tr>
2268 2271 <tr><td></td>
2269 2272 <td>--hidden</td>
2270 2273 <td>consider hidden changesets</td></tr>
2271 2274 </table>
2272 2275
2273 2276 </div>
2274 2277 </div>
2275 2278 </div>
2276 2279
2277 2280 <script type="text/javascript">process_dates()</script>
2278 2281
2279 2282
2280 2283 </body>
2281 2284 </html>
2282 2285
2283 2286
2284 2287 $ get-with-headers.py 127.0.0.1:$HGPORT "help/revisions"
2285 2288 200 Script output follows
2286 2289
2287 2290 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2288 2291 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2289 2292 <head>
2290 2293 <link rel="icon" href="/static/hgicon.png" type="image/png" />
2291 2294 <meta name="robots" content="index, nofollow" />
2292 2295 <link rel="stylesheet" href="/static/style-paper.css" type="text/css" />
2293 2296 <script type="text/javascript" src="/static/mercurial.js"></script>
2294 2297
2295 2298 <title>Help: revisions</title>
2296 2299 </head>
2297 2300 <body>
2298 2301
2299 2302 <div class="container">
2300 2303 <div class="menu">
2301 2304 <div class="logo">
2302 2305 <a href="https://mercurial-scm.org/">
2303 2306 <img src="/static/hglogo.png" alt="mercurial" /></a>
2304 2307 </div>
2305 2308 <ul>
2306 2309 <li><a href="/shortlog">log</a></li>
2307 2310 <li><a href="/graph">graph</a></li>
2308 2311 <li><a href="/tags">tags</a></li>
2309 2312 <li><a href="/bookmarks">bookmarks</a></li>
2310 2313 <li><a href="/branches">branches</a></li>
2311 2314 </ul>
2312 2315 <ul>
2313 2316 <li class="active"><a href="/help">help</a></li>
2314 2317 </ul>
2315 2318 </div>
2316 2319
2317 2320 <div class="main">
2318 2321 <h2 class="breadcrumb"><a href="/">Mercurial</a> </h2>
2319 2322 <h3>Help: revisions</h3>
2320 2323
2321 2324 <form class="search" action="/log">
2322 2325
2323 2326 <p><input name="rev" id="search1" type="text" size="30" /></p>
2324 2327 <div id="hint">Find changesets by keywords (author, files, the commit message), revision
2325 2328 number or hash, or <a href="/help/revsets">revset expression</a>.</div>
2326 2329 </form>
2327 2330 <div id="doc">
2328 2331 <h1>Specifying Single Revisions</h1>
2329 2332 <p>
2330 2333 Mercurial supports several ways to specify individual revisions.
2331 2334 </p>
2332 2335 <p>
2333 2336 A plain integer is treated as a revision number. Negative integers are
2334 2337 treated as sequential offsets from the tip, with -1 denoting the tip,
2335 2338 -2 denoting the revision prior to the tip, and so forth.
2336 2339 </p>
2337 2340 <p>
2338 2341 A 40-digit hexadecimal string is treated as a unique revision
2339 2342 identifier.
2340 2343 </p>
2341 2344 <p>
2342 2345 A hexadecimal string less than 40 characters long is treated as a
2343 2346 unique revision identifier and is referred to as a short-form
2344 2347 identifier. A short-form identifier is only valid if it is the prefix
2345 2348 of exactly one full-length identifier.
2346 2349 </p>
2347 2350 <p>
2348 2351 Any other string is treated as a bookmark, tag, or branch name. A
2349 2352 bookmark is a movable pointer to a revision. A tag is a permanent name
2350 2353 associated with a revision. A branch name denotes the tipmost open branch head
2351 2354 of that branch - or if they are all closed, the tipmost closed head of the
2352 2355 branch. Bookmark, tag, and branch names must not contain the &quot;:&quot; character.
2353 2356 </p>
2354 2357 <p>
2355 2358 The reserved name &quot;tip&quot; always identifies the most recent revision.
2356 2359 </p>
2357 2360 <p>
2358 2361 The reserved name &quot;null&quot; indicates the null revision. This is the
2359 2362 revision of an empty repository, and the parent of revision 0.
2360 2363 </p>
2361 2364 <p>
2362 2365 The reserved name &quot;.&quot; indicates the working directory parent. If no
2363 2366 working directory is checked out, it is equivalent to null. If an
2364 2367 uncommitted merge is in progress, &quot;.&quot; is the revision of the first
2365 2368 parent.
2366 2369 </p>
2367 2370
2368 2371 </div>
2369 2372 </div>
2370 2373 </div>
2371 2374
2372 2375 <script type="text/javascript">process_dates()</script>
2373 2376
2374 2377
2375 2378 </body>
2376 2379 </html>
2377 2380
2378 2381
2379 2382 $ killdaemons.py
2380 2383
2381 2384 #endif
General Comments 0
You need to be logged in to leave comments. Login now