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