##// END OF EJS Templates
Improve English for help text of many core hg commands....
timeless -
r8779:70893850 default
parent child Browse files
Show More
@@ -1,3467 +1,3472 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, incorporated herein by reference.
7 7
8 8 from node import hex, nullid, nullrev, short
9 9 from lock import release
10 10 from i18n import _, gettext
11 11 import os, re, sys, textwrap, subprocess, difflib, time
12 12 import hg, util, revlog, bundlerepo, extensions, copies, context, error
13 13 import patch, help, mdiff, tempfile, url, encoding
14 14 import archival, changegroup, cmdutil, sshserver, hbisect
15 15 from hgweb import server
16 16 import merge as merge_
17 17
18 18 # Commands start here, listed alphabetically
19 19
20 20 def add(ui, repo, *pats, **opts):
21 21 """add the specified files on the next commit
22 22
23 23 Schedule files to be version controlled and added to the
24 24 repository.
25 25
26 26 The files will be added to the repository at the next commit. To
27 27 undo an add before that, see hg revert.
28 28
29 29 If no names are given, add all files to the repository.
30 30 """
31 31
32 32 bad = []
33 33 exacts = {}
34 34 names = []
35 35 m = cmdutil.match(repo, pats, opts)
36 36 oldbad = m.bad
37 37 m.bad = lambda x,y: bad.append(x) or oldbad(x,y)
38 38
39 39 for f in repo.walk(m):
40 40 exact = m.exact(f)
41 41 if exact or f not in repo.dirstate:
42 42 names.append(f)
43 43 if ui.verbose or not exact:
44 44 ui.status(_('adding %s\n') % m.rel(f))
45 45 if not opts.get('dry_run'):
46 46 bad += [f for f in repo.add(names) if f in m.files()]
47 47 return bad and 1 or 0
48 48
49 49 def addremove(ui, repo, *pats, **opts):
50 50 """add all new files, delete all missing files
51 51
52 52 Add all new files and remove all missing files from the
53 53 repository.
54 54
55 55 New files are ignored if they match any of the patterns in
56 56 .hgignore. As with add, these changes take effect at the next
57 57 commit.
58 58
59 59 Use the -s/--similarity option to detect renamed files. With a
60 60 parameter > 0, this compares every removed file with every added
61 61 file and records those similar enough as renames. This option
62 62 takes a percentage between 0 (disabled) and 100 (files must be
63 63 identical) as its parameter. Detecting renamed files this way can
64 64 be expensive.
65 65 """
66 66 try:
67 67 sim = float(opts.get('similarity') or 0)
68 68 except ValueError:
69 69 raise util.Abort(_('similarity must be a number'))
70 70 if sim < 0 or sim > 100:
71 71 raise util.Abort(_('similarity must be between 0 and 100'))
72 72 return cmdutil.addremove(repo, pats, opts, similarity=sim/100.)
73 73
74 74 def annotate(ui, repo, *pats, **opts):
75 """show changeset information per file line
75 """show changeset information by line for each file
76 76
77 77 List changes in files, showing the revision id responsible for
78 78 each line
79 79
80 This command is useful to discover who did a change or when a
81 change took place.
80 This command is useful for discovering when a change was made and
81 by whom.
82 82
83 83 Without the -a/--text option, annotate will avoid processing files
84 it detects as binary. With -a, annotate will generate an
85 annotation anyway, probably with undesirable results.
84 it detects as binary. With -a, annotate will annotate the file
85 anyway, although the results will probably be neither useful
86 nor desirable.
86 87 """
87 88 datefunc = ui.quiet and util.shortdate or util.datestr
88 89 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
89 90
90 91 if not pats:
91 92 raise util.Abort(_('at least one filename or pattern is required'))
92 93
93 94 opmap = [('user', lambda x: ui.shortuser(x[0].user())),
94 95 ('number', lambda x: str(x[0].rev())),
95 96 ('changeset', lambda x: short(x[0].node())),
96 97 ('date', getdate),
97 98 ('follow', lambda x: x[0].path()),
98 99 ]
99 100
100 101 if (not opts.get('user') and not opts.get('changeset') and not opts.get('date')
101 102 and not opts.get('follow')):
102 103 opts['number'] = 1
103 104
104 105 linenumber = opts.get('line_number') is not None
105 106 if (linenumber and (not opts.get('changeset')) and (not opts.get('number'))):
106 107 raise util.Abort(_('at least one of -n/-c is required for -l'))
107 108
108 109 funcmap = [func for op, func in opmap if opts.get(op)]
109 110 if linenumber:
110 111 lastfunc = funcmap[-1]
111 112 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
112 113
113 114 ctx = repo[opts.get('rev')]
114 115
115 116 m = cmdutil.match(repo, pats, opts)
116 117 for abs in ctx.walk(m):
117 118 fctx = ctx[abs]
118 119 if not opts.get('text') and util.binary(fctx.data()):
119 120 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
120 121 continue
121 122
122 123 lines = fctx.annotate(follow=opts.get('follow'),
123 124 linenumber=linenumber)
124 125 pieces = []
125 126
126 127 for f in funcmap:
127 128 l = [f(n) for n, dummy in lines]
128 129 if l:
129 130 ml = max(map(len, l))
130 131 pieces.append(["%*s" % (ml, x) for x in l])
131 132
132 133 if pieces:
133 134 for p, l in zip(zip(*pieces), lines):
134 135 ui.write("%s: %s" % (" ".join(p), l[1]))
135 136
136 137 def archive(ui, repo, dest, **opts):
137 '''create unversioned archive of a repository revision
138 '''create an unversioned archive of a repository revision
138 139
139 140 By default, the revision used is the parent of the working
140 141 directory; use -r/--rev to specify a different revision.
141 142
142 143 To specify the type of archive to create, use -t/--type. Valid
143 144 types are:
144 145
145 146 "files" (default): a directory full of files
146 147 "tar": tar archive, uncompressed
147 148 "tbz2": tar archive, compressed using bzip2
148 149 "tgz": tar archive, compressed using gzip
149 150 "uzip": zip archive, uncompressed
150 151 "zip": zip archive, compressed using deflate
151 152
152 153 The exact name of the destination archive or directory is given
153 154 using a format string; see 'hg help export' for details.
154 155
155 156 Each member added to an archive file has a directory prefix
156 157 prepended. Use -p/--prefix to specify a format string for the
157 158 prefix. The default is the basename of the archive, with suffixes
158 159 removed.
159 160 '''
160 161
161 162 ctx = repo[opts.get('rev')]
162 163 if not ctx:
163 164 raise util.Abort(_('no working directory: please specify a revision'))
164 165 node = ctx.node()
165 166 dest = cmdutil.make_filename(repo, dest, node)
166 167 if os.path.realpath(dest) == repo.root:
167 168 raise util.Abort(_('repository root cannot be destination'))
168 169 matchfn = cmdutil.match(repo, [], opts)
169 170 kind = opts.get('type') or 'files'
170 171 prefix = opts.get('prefix')
171 172 if dest == '-':
172 173 if kind == 'files':
173 174 raise util.Abort(_('cannot archive plain files to stdout'))
174 175 dest = sys.stdout
175 176 if not prefix: prefix = os.path.basename(repo.root) + '-%h'
176 177 prefix = cmdutil.make_filename(repo, prefix, node)
177 178 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
178 179 matchfn, prefix)
179 180
180 181 def backout(ui, repo, node=None, rev=None, **opts):
181 182 '''reverse effect of earlier changeset
182 183
183 184 Commit the backed out changes as a new changeset. The new
184 185 changeset is a child of the backed out changeset.
185 186
186 If you back out a changeset other than the tip, a new head is
187 If you backout a changeset other than the tip, a new head is
187 188 created. This head will be the new tip and you should merge this
188 backout changeset with another head (current one by default).
189 backout changeset with another head.
189 190
190 191 The --merge option remembers the parent of the working directory
191 192 before starting the backout, then merges the new head with that
192 193 changeset afterwards. This saves you from doing the merge by hand.
193 194 The result of this merge is not committed, as with a normal merge.
194 195
195 196 See 'hg help dates' for a list of formats valid for -d/--date.
196 197 '''
197 198 if rev and node:
198 199 raise util.Abort(_("please specify just one revision"))
199 200
200 201 if not rev:
201 202 rev = node
202 203
203 204 if not rev:
204 205 raise util.Abort(_("please specify a revision to backout"))
205 206
206 207 date = opts.get('date')
207 208 if date:
208 209 opts['date'] = util.parsedate(date)
209 210
210 211 cmdutil.bail_if_changed(repo)
211 212 node = repo.lookup(rev)
212 213
213 214 op1, op2 = repo.dirstate.parents()
214 215 a = repo.changelog.ancestor(op1, node)
215 216 if a != node:
216 raise util.Abort(_('cannot back out change on a different branch'))
217 raise util.Abort(_('cannot backout change on a different branch'))
217 218
218 219 p1, p2 = repo.changelog.parents(node)
219 220 if p1 == nullid:
220 raise util.Abort(_('cannot back out a change with no parents'))
221 raise util.Abort(_('cannot backout a change with no parents'))
221 222 if p2 != nullid:
222 223 if not opts.get('parent'):
223 raise util.Abort(_('cannot back out a merge changeset without '
224 raise util.Abort(_('cannot backout a merge changeset without '
224 225 '--parent'))
225 226 p = repo.lookup(opts['parent'])
226 227 if p not in (p1, p2):
227 228 raise util.Abort(_('%s is not a parent of %s') %
228 229 (short(p), short(node)))
229 230 parent = p
230 231 else:
231 232 if opts.get('parent'):
232 233 raise util.Abort(_('cannot use --parent on non-merge changeset'))
233 234 parent = p1
234 235
235 236 # the backout should appear on the same branch
236 237 branch = repo.dirstate.branch()
237 238 hg.clean(repo, node, show_stats=False)
238 239 repo.dirstate.setbranch(branch)
239 240 revert_opts = opts.copy()
240 241 revert_opts['date'] = None
241 242 revert_opts['all'] = True
242 243 revert_opts['rev'] = hex(parent)
243 244 revert_opts['no_backup'] = None
244 245 revert(ui, repo, **revert_opts)
245 246 commit_opts = opts.copy()
246 247 commit_opts['addremove'] = False
247 248 if not commit_opts['message'] and not commit_opts['logfile']:
248 249 commit_opts['message'] = _("Backed out changeset %s") % (short(node))
249 250 commit_opts['force_editor'] = True
250 251 commit(ui, repo, **commit_opts)
251 252 def nice(node):
252 253 return '%d:%s' % (repo.changelog.rev(node), short(node))
253 254 ui.status(_('changeset %s backs out changeset %s\n') %
254 255 (nice(repo.changelog.tip()), nice(node)))
255 256 if op1 != node:
256 257 hg.clean(repo, op1, show_stats=False)
257 258 if opts.get('merge'):
258 259 ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip()))
259 260 hg.merge(repo, hex(repo.changelog.tip()))
260 261 else:
261 262 ui.status(_('the backout changeset is a new head - '
262 263 'do not forget to merge\n'))
263 264 ui.status(_('(use "backout --merge" '
264 265 'if you want to auto-merge)\n'))
265 266
266 267 def bisect(ui, repo, rev=None, extra=None, command=None,
267 268 reset=None, good=None, bad=None, skip=None, noupdate=None):
268 269 """subdivision search of changesets
269 270
270 271 This command helps to find changesets which introduce problems. To
271 272 use, mark the earliest changeset you know exhibits the problem as
272 273 bad, then mark the latest changeset which is free from the problem
273 274 as good. Bisect will update your working directory to a revision
274 275 for testing (unless the -U/--noupdate option is specified). Once
275 you have performed tests, mark the working directory as bad or
276 good and bisect will either update to another candidate changeset
276 you have performed tests, mark the working directory as good or
277 bad, and bisect will either update to another candidate changeset
277 278 or announce that it has found the bad revision.
278 279
279 280 As a shortcut, you can also use the revision argument to mark a
280 281 revision as good or bad without checking it out first.
281 282
282 If you supply a command it will be used for automatic bisection.
283 Its exit status will be used as flag to mark revision as bad or
284 good. In case exit status is 0 the revision is marked as good, 125
285 - skipped, 127 (command not found) - bisection will be aborted;
286 any other status bigger than 0 will mark revision as bad.
283 If you supply a command, it will be used for automatic bisection.
284 Its exit status will be used to mark revisions as good or bad:
285 status 0 means good, 125 means to skip the revision, 127
286 (command not found) will abort the bisection, and any other
287 non-zero exit status means the revision is bad.
287 288 """
288 289 def print_result(nodes, good):
289 290 displayer = cmdutil.show_changeset(ui, repo, {})
290 291 if len(nodes) == 1:
291 292 # narrowed it down to a single revision
292 293 if good:
293 294 ui.write(_("The first good revision is:\n"))
294 295 else:
295 296 ui.write(_("The first bad revision is:\n"))
296 297 displayer.show(repo[nodes[0]])
297 298 else:
298 299 # multiple possible revisions
299 300 if good:
300 301 ui.write(_("Due to skipped revisions, the first "
301 302 "good revision could be any of:\n"))
302 303 else:
303 304 ui.write(_("Due to skipped revisions, the first "
304 305 "bad revision could be any of:\n"))
305 306 for n in nodes:
306 307 displayer.show(repo[n])
307 308
308 309 def check_state(state, interactive=True):
309 310 if not state['good'] or not state['bad']:
310 311 if (good or bad or skip or reset) and interactive:
311 312 return
312 313 if not state['good']:
313 314 raise util.Abort(_('cannot bisect (no known good revisions)'))
314 315 else:
315 316 raise util.Abort(_('cannot bisect (no known bad revisions)'))
316 317 return True
317 318
318 319 # backward compatibility
319 320 if rev in "good bad reset init".split():
320 321 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
321 322 cmd, rev, extra = rev, extra, None
322 323 if cmd == "good":
323 324 good = True
324 325 elif cmd == "bad":
325 326 bad = True
326 327 else:
327 328 reset = True
328 329 elif extra or good + bad + skip + reset + bool(command) > 1:
329 330 raise util.Abort(_('incompatible arguments'))
330 331
331 332 if reset:
332 333 p = repo.join("bisect.state")
333 334 if os.path.exists(p):
334 335 os.unlink(p)
335 336 return
336 337
337 338 state = hbisect.load_state(repo)
338 339
339 340 if command:
340 341 commandpath = util.find_exe(command)
341 342 changesets = 1
342 343 try:
343 344 while changesets:
344 345 # update state
345 346 status = subprocess.call([commandpath])
346 347 if status == 125:
347 348 transition = "skip"
348 349 elif status == 0:
349 350 transition = "good"
350 351 # status < 0 means process was killed
351 352 elif status == 127:
352 353 raise util.Abort(_("failed to execute %s") % command)
353 354 elif status < 0:
354 355 raise util.Abort(_("%s killed") % command)
355 356 else:
356 357 transition = "bad"
357 358 node = repo.lookup(rev or '.')
358 359 state[transition].append(node)
359 360 ui.note(_('Changeset %s: %s\n') % (short(node), transition))
360 361 check_state(state, interactive=False)
361 362 # bisect
362 363 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
363 364 # update to next check
364 365 cmdutil.bail_if_changed(repo)
365 366 hg.clean(repo, nodes[0], show_stats=False)
366 367 finally:
367 368 hbisect.save_state(repo, state)
368 369 return print_result(nodes, not status)
369 370
370 371 # update state
371 372 node = repo.lookup(rev or '.')
372 373 if good:
373 374 state['good'].append(node)
374 375 elif bad:
375 376 state['bad'].append(node)
376 377 elif skip:
377 378 state['skip'].append(node)
378 379
379 380 hbisect.save_state(repo, state)
380 381
381 382 if not check_state(state):
382 383 return
383 384
384 385 # actually bisect
385 386 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
386 387 if changesets == 0:
387 388 print_result(nodes, good)
388 389 else:
389 390 assert len(nodes) == 1 # only a single node can be tested next
390 391 node = nodes[0]
391 392 # compute the approximate number of remaining tests
392 393 tests, size = 0, 2
393 394 while size <= changesets:
394 395 tests, size = tests + 1, size * 2
395 396 rev = repo.changelog.rev(node)
396 397 ui.write(_("Testing changeset %s:%s "
397 398 "(%s changesets remaining, ~%s tests)\n")
398 399 % (rev, short(node), changesets, tests))
399 400 if not noupdate:
400 401 cmdutil.bail_if_changed(repo)
401 402 return hg.clean(repo, node)
402 403
403 404 def branch(ui, repo, label=None, **opts):
404 405 """set or show the current branch name
405 406
406 407 With no argument, show the current branch name. With one argument,
407 set the working directory branch name (the branch does not exist
408 in the repository until the next commit). It is recommended to use
409 the 'default' branch as your primary development branch.
408 set the working directory branch name (the branch will not exist
409 in the repository until the next commit). Standard practice
410 recommends that primary development take place on the 'default'
411 branch.
410 412
411 413 Unless -f/--force is specified, branch will not let you set a
412 branch name that shadows an existing branch.
414 branch name that already exists, even if it's inactive.
413 415
414 416 Use -C/--clean to reset the working directory branch to that of
415 417 the parent of the working directory, negating a previous branch
416 418 change.
417 419
418 420 Use the command 'hg update' to switch to an existing branch.
419 421 """
420 422
421 423 if opts.get('clean'):
422 424 label = repo[None].parents()[0].branch()
423 425 repo.dirstate.setbranch(label)
424 426 ui.status(_('reset working directory to branch %s\n') % label)
425 427 elif label:
426 428 if not opts.get('force') and label in repo.branchtags():
427 429 if label not in [p.branch() for p in repo.parents()]:
428 430 raise util.Abort(_('a branch of the same name already exists'
429 431 ' (use --force to override)'))
430 432 repo.dirstate.setbranch(encoding.fromlocal(label))
431 433 ui.status(_('marked working directory as branch %s\n') % label)
432 434 else:
433 435 ui.write("%s\n" % encoding.tolocal(repo.dirstate.branch()))
434 436
435 437 def branches(ui, repo, active=False):
436 438 """list repository named branches
437 439
438 440 List the repository's named branches, indicating which ones are
439 441 inactive. If active is specified, only show active branches.
440 442
441 443 A branch is considered active if it contains repository heads.
442 444
443 445 Use the command 'hg update' to switch to an existing branch.
444 446 """
445 447 hexfunc = ui.debugflag and hex or short
446 448 activebranches = [encoding.tolocal(repo[n].branch())
447 449 for n in repo.heads(closed=False)]
448 450 branches = sorted([(tag in activebranches, repo.changelog.rev(node), tag)
449 451 for tag, node in repo.branchtags().items()],
450 452 reverse=True)
451 453
452 454 for isactive, node, tag in branches:
453 455 if (not active) or isactive:
454 456 if ui.quiet:
455 457 ui.write("%s\n" % tag)
456 458 else:
457 459 hn = repo.lookup(node)
458 460 if isactive:
459 461 notice = ''
460 462 elif hn not in repo.branchheads(tag, closed=False):
461 463 notice = ' (closed)'
462 464 else:
463 465 notice = ' (inactive)'
464 466 rev = str(node).rjust(31 - encoding.colwidth(tag))
465 467 data = tag, rev, hexfunc(hn), notice
466 468 ui.write("%s %s:%s%s\n" % data)
467 469
468 470 def bundle(ui, repo, fname, dest=None, **opts):
469 471 """create a changegroup file
470 472
471 473 Generate a compressed changegroup file collecting changesets not
472 474 known to be in another repository.
473 475
474 476 If no destination repository is specified the destination is
475 477 assumed to have all the nodes specified by one or more --base
476 478 parameters. To create a bundle containing all changesets, use
477 479 -a/--all (or --base null). To change the compression method
478 480 applied, use the -t/--type option (by default, bundles are
479 481 compressed using bz2).
480 482
481 483 The bundle file can then be transferred using conventional means
482 484 and applied to another repository with the unbundle or pull
483 485 command. This is useful when direct push and pull are not
484 486 available or when exporting an entire repository is undesirable.
485 487
486 488 Applying bundles preserves all changeset contents including
487 489 permissions, copy/rename information, and revision history.
488 490 """
489 491 revs = opts.get('rev') or None
490 492 if revs:
491 493 revs = [repo.lookup(rev) for rev in revs]
492 494 if opts.get('all'):
493 495 base = ['null']
494 496 else:
495 497 base = opts.get('base')
496 498 if base:
497 499 if dest:
498 500 raise util.Abort(_("--base is incompatible with specifying "
499 501 "a destination"))
500 502 base = [repo.lookup(rev) for rev in base]
501 503 # create the right base
502 504 # XXX: nodesbetween / changegroup* should be "fixed" instead
503 505 o = []
504 506 has = set((nullid,))
505 507 for n in base:
506 508 has.update(repo.changelog.reachable(n))
507 509 if revs:
508 510 visit = list(revs)
509 511 else:
510 512 visit = repo.changelog.heads()
511 513 seen = {}
512 514 while visit:
513 515 n = visit.pop(0)
514 516 parents = [p for p in repo.changelog.parents(n) if p not in has]
515 517 if len(parents) == 0:
516 518 o.insert(0, n)
517 519 else:
518 520 for p in parents:
519 521 if p not in seen:
520 522 seen[p] = 1
521 523 visit.append(p)
522 524 else:
523 525 dest, revs, checkout = hg.parseurl(
524 526 ui.expandpath(dest or 'default-push', dest or 'default'), revs)
525 527 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
526 528 o = repo.findoutgoing(other, force=opts.get('force'))
527 529
528 530 if revs:
529 531 cg = repo.changegroupsubset(o, revs, 'bundle')
530 532 else:
531 533 cg = repo.changegroup(o, 'bundle')
532 534
533 535 bundletype = opts.get('type', 'bzip2').lower()
534 536 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
535 537 bundletype = btypes.get(bundletype)
536 538 if bundletype not in changegroup.bundletypes:
537 539 raise util.Abort(_('unknown bundle type specified with --type'))
538 540
539 541 changegroup.writebundle(cg, fname, bundletype)
540 542
541 543 def cat(ui, repo, file1, *pats, **opts):
542 544 """output the current or given revision of files
543 545
544 546 Print the specified files as they were at the given revision. If
545 547 no revision is given, the parent of the working directory is used,
546 548 or tip if no revision is checked out.
547 549
548 550 Output may be to a file, in which case the name of the file is
549 551 given using a format string. The formatting rules are the same as
550 552 for the export command, with the following additions:
551 553
552 554 %s basename of file being printed
553 555 %d dirname of file being printed, or '.' if in repository root
554 556 %p root-relative path name of file being printed
555 557 """
556 558 ctx = repo[opts.get('rev')]
557 559 err = 1
558 560 m = cmdutil.match(repo, (file1,) + pats, opts)
559 561 for abs in ctx.walk(m):
560 562 fp = cmdutil.make_file(repo, opts.get('output'), ctx.node(), pathname=abs)
561 563 data = ctx[abs].data()
562 564 if opts.get('decode'):
563 565 data = repo.wwritedata(abs, data)
564 566 fp.write(data)
565 567 err = 0
566 568 return err
567 569
568 570 def clone(ui, source, dest=None, **opts):
569 571 """make a copy of an existing repository
570 572
571 573 Create a copy of an existing repository in a new directory.
572 574
573 575 If no destination directory name is specified, it defaults to the
574 576 basename of the source.
575 577
576 578 The location of the source is added to the new repository's
577 579 .hg/hgrc file, as the default to be used for future pulls.
578 580
579 581 If you use the -r/--rev option to clone up to a specific revision,
580 582 no subsequent revisions (including subsequent tags) will be
581 583 present in the cloned repository. This option implies --pull, even
582 584 on local repositories.
583 585
584 586 By default, clone will check out the head of the 'default' branch.
585 587 If the -U/--noupdate option is used, the new clone will contain
586 588 only a repository (.hg) and no working copy (the working copy
587 589 parent is the null revision).
588 590
589 591 See 'hg help urls' for valid source format details.
590 592
591 593 It is possible to specify an ssh:// URL as the destination, but no
592 594 .hg/hgrc and working directory will be created on the remote side.
593 Look at the help text for URLs for important details about ssh://
594 URLs.
595 Please see 'hg help urls' for important details about ssh:// URLs.
595 596
596 597 For efficiency, hardlinks are used for cloning whenever the source
597 598 and destination are on the same filesystem (note this applies only
598 599 to the repository data, not to the checked out files). Some
599 600 filesystems, such as AFS, implement hardlinking incorrectly, but
600 601 do not report errors. In these cases, use the --pull option to
601 602 avoid hardlinking.
602 603
603 604 In some cases, you can clone repositories and checked out files
604 605 using full hardlinks with
605 606
606 607 $ cp -al REPO REPOCLONE
607 608
608 609 This is the fastest way to clone, but it is not always safe. The
609 610 operation is not atomic (making sure REPO is not modified during
610 611 the operation is up to you) and you have to make sure your editor
611 612 breaks hardlinks (Emacs and most Linux Kernel tools do so). Also,
612 613 this is not compatible with certain extensions that place their
613 614 metadata under the .hg directory, such as mq.
614 615
615 616 """
616 617 hg.clone(cmdutil.remoteui(ui, opts), source, dest,
617 618 pull=opts.get('pull'),
618 619 stream=opts.get('uncompressed'),
619 620 rev=opts.get('rev'),
620 621 update=not opts.get('noupdate'))
621 622
622 623 def commit(ui, repo, *pats, **opts):
623 624 """commit the specified files or all outstanding changes
624 625
625 626 Commit changes to the given files into the repository. Unlike a
626 627 centralized RCS, this operation is a local operation. See hg push
627 for means to actively distribute your changes.
628 for a way to actively distribute your changes.
628 629
629 630 If a list of files is omitted, all changes reported by "hg status"
630 631 will be committed.
631 632
632 633 If you are committing the result of a merge, do not provide any
633 634 filenames or -I/-X filters.
634 635
635 636 If no commit message is specified, the configured editor is
636 637 started to prompt you for a message.
637 638
638 639 See 'hg help dates' for a list of formats valid for -d/--date.
639 640 """
640 641 extra = {}
641 642 if opts.get('close_branch'):
642 643 extra['close'] = 1
643 644 e = cmdutil.commiteditor
644 645 if opts.get('force_editor'):
645 646 e = cmdutil.commitforceeditor
646 647
647 648 def commitfunc(ui, repo, message, match, opts):
648 649 return repo.commit(message, opts.get('user'), opts.get('date'), match,
649 650 editor=e, extra=extra)
650 651
651 652 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
652 653 if not node:
653 654 return
654 655 cl = repo.changelog
655 656 rev = cl.rev(node)
656 657 parents = cl.parentrevs(rev)
657 658 if rev - 1 in parents:
658 659 # one of the parents was the old tip
659 660 pass
660 661 elif (parents == (nullrev, nullrev) or
661 662 len(cl.heads(cl.node(parents[0]))) > 1 and
662 663 (parents[1] == nullrev or len(cl.heads(cl.node(parents[1]))) > 1)):
663 664 ui.status(_('created new head\n'))
664 665
665 666 if ui.debugflag:
666 667 ui.write(_('committed changeset %d:%s\n') % (rev,hex(node)))
667 668 elif ui.verbose:
668 669 ui.write(_('committed changeset %d:%s\n') % (rev,short(node)))
669 670
670 671 def copy(ui, repo, *pats, **opts):
671 672 """mark files as copied for the next commit
672 673
673 674 Mark dest as having copies of source files. If dest is a
674 675 directory, copies are put in that directory. If dest is a file,
675 676 the source must be a single file.
676 677
677 678 By default, this command copies the contents of files as they
678 stand in the working directory. If invoked with -A/--after, the
679 exist in the working directory. If invoked with -A/--after, the
679 680 operation is recorded, but no copying is performed.
680 681
681 682 This command takes effect with the next commit. To undo a copy
682 683 before that, see hg revert.
683 684 """
684 685 wlock = repo.wlock(False)
685 686 try:
686 687 return cmdutil.copy(ui, repo, pats, opts)
687 688 finally:
688 689 wlock.release()
689 690
690 691 def debugancestor(ui, repo, *args):
691 692 """find the ancestor revision of two revisions in a given index"""
692 693 if len(args) == 3:
693 694 index, rev1, rev2 = args
694 695 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
695 696 lookup = r.lookup
696 697 elif len(args) == 2:
697 698 if not repo:
698 699 raise util.Abort(_("There is no Mercurial repository here "
699 700 "(.hg not found)"))
700 701 rev1, rev2 = args
701 702 r = repo.changelog
702 703 lookup = repo.lookup
703 704 else:
704 705 raise util.Abort(_('either two or three arguments required'))
705 706 a = r.ancestor(lookup(rev1), lookup(rev2))
706 707 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
707 708
708 709 def debugcommands(ui, cmd='', *args):
709 710 for cmd, vals in sorted(table.iteritems()):
710 711 cmd = cmd.split('|')[0].strip('^')
711 712 opts = ', '.join([i[1] for i in vals[1]])
712 713 ui.write('%s: %s\n' % (cmd, opts))
713 714
714 715 def debugcomplete(ui, cmd='', **opts):
715 716 """returns the completion list associated with the given command"""
716 717
717 718 if opts.get('options'):
718 719 options = []
719 720 otables = [globalopts]
720 721 if cmd:
721 722 aliases, entry = cmdutil.findcmd(cmd, table, False)
722 723 otables.append(entry[1])
723 724 for t in otables:
724 725 for o in t:
725 726 if o[0]:
726 727 options.append('-%s' % o[0])
727 728 options.append('--%s' % o[1])
728 729 ui.write("%s\n" % "\n".join(options))
729 730 return
730 731
731 732 cmdlist = cmdutil.findpossible(cmd, table)
732 733 if ui.verbose:
733 734 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
734 735 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
735 736
736 737 def debugfsinfo(ui, path = "."):
737 738 file('.debugfsinfo', 'w').write('')
738 739 ui.write('exec: %s\n' % (util.checkexec(path) and 'yes' or 'no'))
739 740 ui.write('symlink: %s\n' % (util.checklink(path) and 'yes' or 'no'))
740 741 ui.write('case-sensitive: %s\n' % (util.checkcase('.debugfsinfo')
741 742 and 'yes' or 'no'))
742 743 os.unlink('.debugfsinfo')
743 744
744 745 def debugrebuildstate(ui, repo, rev="tip"):
745 746 """rebuild the dirstate as it would look like for the given revision"""
746 747 ctx = repo[rev]
747 748 wlock = repo.wlock()
748 749 try:
749 750 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
750 751 finally:
751 752 wlock.release()
752 753
753 754 def debugcheckstate(ui, repo):
754 755 """validate the correctness of the current dirstate"""
755 756 parent1, parent2 = repo.dirstate.parents()
756 757 m1 = repo[parent1].manifest()
757 758 m2 = repo[parent2].manifest()
758 759 errors = 0
759 760 for f in repo.dirstate:
760 761 state = repo.dirstate[f]
761 762 if state in "nr" and f not in m1:
762 763 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
763 764 errors += 1
764 765 if state in "a" and f in m1:
765 766 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
766 767 errors += 1
767 768 if state in "m" and f not in m1 and f not in m2:
768 769 ui.warn(_("%s in state %s, but not in either manifest\n") %
769 770 (f, state))
770 771 errors += 1
771 772 for f in m1:
772 773 state = repo.dirstate[f]
773 774 if state not in "nrm":
774 775 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
775 776 errors += 1
776 777 if errors:
777 778 error = _(".hg/dirstate inconsistent with current parent's manifest")
778 779 raise util.Abort(error)
779 780
780 781 def showconfig(ui, repo, *values, **opts):
781 782 """show combined config settings from all hgrc files
782 783
783 784 With no arguments, print names and values of all config items.
784 785
785 786 With one argument of the form section.name, print just the value
786 787 of that config item.
787 788
788 789 With multiple arguments, print names and values of all config
789 790 items with matching section names.
790 791
791 With the --debug flag, the source (filename and line number) is
792 printed for each config item.
792 With --debug, the source (filename and line number) is printed
793 for each config item.
793 794 """
794 795
795 796 untrusted = bool(opts.get('untrusted'))
796 797 if values:
797 798 if len([v for v in values if '.' in v]) > 1:
798 799 raise util.Abort(_('only one config item permitted'))
799 800 for section, name, value in ui.walkconfig(untrusted=untrusted):
800 801 sectname = section + '.' + name
801 802 if values:
802 803 for v in values:
803 804 if v == section:
804 805 ui.debug('%s: ' %
805 806 ui.configsource(section, name, untrusted))
806 807 ui.write('%s=%s\n' % (sectname, value))
807 808 elif v == sectname:
808 809 ui.debug('%s: ' %
809 810 ui.configsource(section, name, untrusted))
810 811 ui.write(value, '\n')
811 812 else:
812 813 ui.debug('%s: ' %
813 814 ui.configsource(section, name, untrusted))
814 815 ui.write('%s=%s\n' % (sectname, value))
815 816
816 817 def debugsetparents(ui, repo, rev1, rev2=None):
817 818 """manually set the parents of the current working directory
818 819
819 820 This is useful for writing repository conversion tools, but should
820 821 be used with care.
821 822 """
822 823
823 824 if not rev2:
824 825 rev2 = hex(nullid)
825 826
826 827 wlock = repo.wlock()
827 828 try:
828 829 repo.dirstate.setparents(repo.lookup(rev1), repo.lookup(rev2))
829 830 finally:
830 831 wlock.release()
831 832
832 833 def debugstate(ui, repo, nodates=None):
833 834 """show the contents of the current dirstate"""
834 835 timestr = ""
835 836 showdate = not nodates
836 837 for file_, ent in sorted(repo.dirstate._map.iteritems()):
837 838 if showdate:
838 839 if ent[3] == -1:
839 840 # Pad or slice to locale representation
840 841 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(0)))
841 842 timestr = 'unset'
842 843 timestr = timestr[:locale_len] + ' '*(locale_len - len(timestr))
843 844 else:
844 845 timestr = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(ent[3]))
845 846 if ent[1] & 020000:
846 847 mode = 'lnk'
847 848 else:
848 849 mode = '%3o' % (ent[1] & 0777)
849 850 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
850 851 for f in repo.dirstate.copies():
851 852 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
852 853
853 854 def debugdata(ui, file_, rev):
854 855 """dump the contents of a data file revision"""
855 856 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
856 857 try:
857 858 ui.write(r.revision(r.lookup(rev)))
858 859 except KeyError:
859 860 raise util.Abort(_('invalid revision identifier %s') % rev)
860 861
861 862 def debugdate(ui, date, range=None, **opts):
862 863 """parse and display a date"""
863 864 if opts["extended"]:
864 865 d = util.parsedate(date, util.extendeddateformats)
865 866 else:
866 867 d = util.parsedate(date)
867 868 ui.write("internal: %s %s\n" % d)
868 869 ui.write("standard: %s\n" % util.datestr(d))
869 870 if range:
870 871 m = util.matchdate(range)
871 872 ui.write("match: %s\n" % m(d[0]))
872 873
873 874 def debugindex(ui, file_):
874 875 """dump the contents of an index file"""
875 876 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
876 877 ui.write(" rev offset length base linkrev"
877 878 " nodeid p1 p2\n")
878 879 for i in r:
879 880 node = r.node(i)
880 881 try:
881 882 pp = r.parents(node)
882 883 except:
883 884 pp = [nullid, nullid]
884 885 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
885 886 i, r.start(i), r.length(i), r.base(i), r.linkrev(i),
886 887 short(node), short(pp[0]), short(pp[1])))
887 888
888 889 def debugindexdot(ui, file_):
889 """dump an index DAG as a .dot file"""
890 """dump an index DAG as a graphviz dot file"""
890 891 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
891 892 ui.write("digraph G {\n")
892 893 for i in r:
893 894 node = r.node(i)
894 895 pp = r.parents(node)
895 896 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
896 897 if pp[1] != nullid:
897 898 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
898 899 ui.write("}\n")
899 900
900 901 def debuginstall(ui):
901 902 '''test Mercurial installation'''
902 903
903 904 def writetemp(contents):
904 905 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
905 906 f = os.fdopen(fd, "wb")
906 907 f.write(contents)
907 908 f.close()
908 909 return name
909 910
910 911 problems = 0
911 912
912 913 # encoding
913 914 ui.status(_("Checking encoding (%s)...\n") % encoding.encoding)
914 915 try:
915 916 encoding.fromlocal("test")
916 917 except util.Abort, inst:
917 918 ui.write(" %s\n" % inst)
918 919 ui.write(_(" (check that your locale is properly set)\n"))
919 920 problems += 1
920 921
921 922 # compiled modules
922 923 ui.status(_("Checking extensions...\n"))
923 924 try:
924 925 import bdiff, mpatch, base85
925 926 except Exception, inst:
926 927 ui.write(" %s\n" % inst)
927 928 ui.write(_(" One or more extensions could not be found"))
928 929 ui.write(_(" (check that you compiled the extensions)\n"))
929 930 problems += 1
930 931
931 932 # templates
932 933 ui.status(_("Checking templates...\n"))
933 934 try:
934 935 import templater
935 936 templater.templater(templater.templatepath("map-cmdline.default"))
936 937 except Exception, inst:
937 938 ui.write(" %s\n" % inst)
938 939 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
939 940 problems += 1
940 941
941 942 # patch
942 943 ui.status(_("Checking patch...\n"))
943 944 patchproblems = 0
944 945 a = "1\n2\n3\n4\n"
945 946 b = "1\n2\n3\ninsert\n4\n"
946 947 fa = writetemp(a)
947 948 d = mdiff.unidiff(a, None, b, None, os.path.basename(fa),
948 949 os.path.basename(fa))
949 950 fd = writetemp(d)
950 951
951 952 files = {}
952 953 try:
953 954 patch.patch(fd, ui, cwd=os.path.dirname(fa), files=files)
954 955 except util.Abort, e:
955 956 ui.write(_(" patch call failed:\n"))
956 957 ui.write(" " + str(e) + "\n")
957 958 patchproblems += 1
958 959 else:
959 960 if list(files) != [os.path.basename(fa)]:
960 961 ui.write(_(" unexpected patch output!\n"))
961 962 patchproblems += 1
962 963 a = file(fa).read()
963 964 if a != b:
964 965 ui.write(_(" patch test failed!\n"))
965 966 patchproblems += 1
966 967
967 968 if patchproblems:
968 969 if ui.config('ui', 'patch'):
969 970 ui.write(_(" (Current patch tool may be incompatible with patch,"
970 971 " or misconfigured. Please check your .hgrc file)\n"))
971 972 else:
972 973 ui.write(_(" Internal patcher failure, please report this error"
973 974 " to http://www.selenic.com/mercurial/bts\n"))
974 975 problems += patchproblems
975 976
976 977 os.unlink(fa)
977 978 os.unlink(fd)
978 979
979 980 # editor
980 981 ui.status(_("Checking commit editor...\n"))
981 982 editor = ui.geteditor()
982 983 cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
983 984 if not cmdpath:
984 985 if editor == 'vi':
985 986 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
986 987 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
987 988 else:
988 989 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
989 990 ui.write(_(" (specify a commit editor in your .hgrc file)\n"))
990 991 problems += 1
991 992
992 993 # check username
993 994 ui.status(_("Checking username...\n"))
994 995 user = os.environ.get("HGUSER")
995 996 if user is None:
996 997 user = ui.config("ui", "username")
997 998 if user is None:
998 999 user = os.environ.get("EMAIL")
999 1000 if not user:
1000 1001 ui.warn(" ")
1001 1002 ui.username()
1002 1003 ui.write(_(" (specify a username in your .hgrc file)\n"))
1003 1004
1004 1005 if not problems:
1005 1006 ui.status(_("No problems detected\n"))
1006 1007 else:
1007 1008 ui.write(_("%s problems detected,"
1008 1009 " please check your install!\n") % problems)
1009 1010
1010 1011 return problems
1011 1012
1012 1013 def debugrename(ui, repo, file1, *pats, **opts):
1013 1014 """dump rename information"""
1014 1015
1015 1016 ctx = repo[opts.get('rev')]
1016 1017 m = cmdutil.match(repo, (file1,) + pats, opts)
1017 1018 for abs in ctx.walk(m):
1018 1019 fctx = ctx[abs]
1019 1020 o = fctx.filelog().renamed(fctx.filenode())
1020 1021 rel = m.rel(abs)
1021 1022 if o:
1022 1023 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
1023 1024 else:
1024 1025 ui.write(_("%s not renamed\n") % rel)
1025 1026
1026 1027 def debugwalk(ui, repo, *pats, **opts):
1027 1028 """show how files match on given patterns"""
1028 1029 m = cmdutil.match(repo, pats, opts)
1029 1030 items = list(repo.walk(m))
1030 1031 if not items:
1031 1032 return
1032 1033 fmt = 'f %%-%ds %%-%ds %%s' % (
1033 1034 max([len(abs) for abs in items]),
1034 1035 max([len(m.rel(abs)) for abs in items]))
1035 1036 for abs in items:
1036 1037 line = fmt % (abs, m.rel(abs), m.exact(abs) and 'exact' or '')
1037 1038 ui.write("%s\n" % line.rstrip())
1038 1039
1039 1040 def diff(ui, repo, *pats, **opts):
1040 1041 """diff repository (or selected files)
1041 1042
1042 1043 Show differences between revisions for the specified files.
1043 1044
1044 1045 Differences between files are shown using the unified diff format.
1045 1046
1046 1047 NOTE: diff may generate unexpected results for merges, as it will
1047 1048 default to comparing against the working directory's first parent
1048 1049 changeset if no revisions are specified.
1049 1050
1050 1051 When two revision arguments are given, then changes are shown
1051 1052 between those revisions. If only one revision is specified then
1052 1053 that revision is compared to the working directory, and, when no
1053 1054 revisions are specified, the working directory files are compared
1054 1055 to its parent.
1055 1056
1056 1057 Without the -a/--text option, diff will avoid generating diffs of
1057 1058 files it detects as binary. With -a, diff will generate a diff
1058 1059 anyway, probably with undesirable results.
1059 1060
1060 1061 Use the -g/--git option to generate diffs in the git extended diff
1061 1062 format. For more information, read 'hg help diffs'.
1062 1063 """
1063 1064
1064 1065 revs = opts.get('rev')
1065 1066 change = opts.get('change')
1066 1067
1067 1068 if revs and change:
1068 1069 msg = _('cannot specify --rev and --change at the same time')
1069 1070 raise util.Abort(msg)
1070 1071 elif change:
1071 1072 node2 = repo.lookup(change)
1072 1073 node1 = repo[node2].parents()[0].node()
1073 1074 else:
1074 1075 node1, node2 = cmdutil.revpair(repo, revs)
1075 1076
1076 1077 m = cmdutil.match(repo, pats, opts)
1077 1078 it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts))
1078 1079 for chunk in it:
1079 1080 ui.write(chunk)
1080 1081
1081 1082 def export(ui, repo, *changesets, **opts):
1082 1083 """dump the header and diffs for one or more changesets
1083 1084
1084 1085 Print the changeset header and diffs for one or more revisions.
1085 1086
1086 1087 The information shown in the changeset header is: author,
1087 1088 changeset hash, parent(s) and commit comment.
1088 1089
1089 1090 NOTE: export may generate unexpected diff output for merge
1090 1091 changesets, as it will compare the merge changeset against its
1091 1092 first parent only.
1092 1093
1093 1094 Output may be to a file, in which case the name of the file is
1094 1095 given using a format string. The formatting rules are as follows:
1095 1096
1096 1097 %% literal "%" character
1097 1098 %H changeset hash (40 bytes of hexadecimal)
1098 1099 %N number of patches being generated
1099 1100 %R changeset revision number
1100 1101 %b basename of the exporting repository
1101 1102 %h short-form changeset hash (12 bytes of hexadecimal)
1102 1103 %n zero-padded sequence number, starting at 1
1103 1104 %r zero-padded changeset revision number
1104 1105
1105 1106 Without the -a/--text option, export will avoid generating diffs
1106 1107 of files it detects as binary. With -a, export will generate a
1107 1108 diff anyway, probably with undesirable results.
1108 1109
1109 1110 Use the -g/--git option to generate diffs in the git extended diff
1110 format. Read the diffs help topic for more information.
1111 format. See 'hg help diffs' for more information.
1111 1112
1112 1113 With the --switch-parent option, the diff will be against the
1113 1114 second parent. It can be useful to review a merge.
1114 1115 """
1115 1116 if not changesets:
1116 1117 raise util.Abort(_("export requires at least one changeset"))
1117 1118 revs = cmdutil.revrange(repo, changesets)
1118 1119 if len(revs) > 1:
1119 1120 ui.note(_('exporting patches:\n'))
1120 1121 else:
1121 1122 ui.note(_('exporting patch:\n'))
1122 1123 patch.export(repo, revs, template=opts.get('output'),
1123 1124 switch_parent=opts.get('switch_parent'),
1124 1125 opts=patch.diffopts(ui, opts))
1125 1126
1126 1127 def grep(ui, repo, pattern, *pats, **opts):
1127 1128 """search for a pattern in specified files and revisions
1128 1129
1129 1130 Search revisions of files for a regular expression.
1130 1131
1131 1132 This command behaves differently than Unix grep. It only accepts
1132 1133 Python/Perl regexps. It searches repository history, not the
1133 1134 working directory. It always prints the revision number in which a
1134 1135 match appears.
1135 1136
1136 1137 By default, grep only prints output for the first revision of a
1137 1138 file in which it finds a match. To get it to print every revision
1138 1139 that contains a change in match status ("-" for a match that
1139 1140 becomes a non-match, or "+" for a non-match that becomes a match),
1140 1141 use the --all flag.
1141 1142 """
1142 1143 reflags = 0
1143 1144 if opts.get('ignore_case'):
1144 1145 reflags |= re.I
1145 1146 try:
1146 1147 regexp = re.compile(pattern, reflags)
1147 1148 except Exception, inst:
1148 1149 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
1149 1150 return None
1150 1151 sep, eol = ':', '\n'
1151 1152 if opts.get('print0'):
1152 1153 sep = eol = '\0'
1153 1154
1154 1155 fcache = {}
1155 1156 forder = []
1156 1157 def getfile(fn):
1157 1158 if fn not in fcache:
1158 1159 if len(fcache) > 20:
1159 1160 del fcache[forder.pop(0)]
1160 1161 fcache[fn] = repo.file(fn)
1161 1162 else:
1162 1163 forder.remove(fn)
1163 1164
1164 1165 forder.append(fn)
1165 1166 return fcache[fn]
1166 1167
1167 1168 def matchlines(body):
1168 1169 begin = 0
1169 1170 linenum = 0
1170 1171 while True:
1171 1172 match = regexp.search(body, begin)
1172 1173 if not match:
1173 1174 break
1174 1175 mstart, mend = match.span()
1175 1176 linenum += body.count('\n', begin, mstart) + 1
1176 1177 lstart = body.rfind('\n', begin, mstart) + 1 or begin
1177 1178 begin = body.find('\n', mend) + 1 or len(body)
1178 1179 lend = begin - 1
1179 1180 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
1180 1181
1181 1182 class linestate(object):
1182 1183 def __init__(self, line, linenum, colstart, colend):
1183 1184 self.line = line
1184 1185 self.linenum = linenum
1185 1186 self.colstart = colstart
1186 1187 self.colend = colend
1187 1188
1188 1189 def __hash__(self):
1189 1190 return hash((self.linenum, self.line))
1190 1191
1191 1192 def __eq__(self, other):
1192 1193 return self.line == other.line
1193 1194
1194 1195 matches = {}
1195 1196 copies = {}
1196 1197 def grepbody(fn, rev, body):
1197 1198 matches[rev].setdefault(fn, [])
1198 1199 m = matches[rev][fn]
1199 1200 for lnum, cstart, cend, line in matchlines(body):
1200 1201 s = linestate(line, lnum, cstart, cend)
1201 1202 m.append(s)
1202 1203
1203 1204 def difflinestates(a, b):
1204 1205 sm = difflib.SequenceMatcher(None, a, b)
1205 1206 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
1206 1207 if tag == 'insert':
1207 1208 for i in xrange(blo, bhi):
1208 1209 yield ('+', b[i])
1209 1210 elif tag == 'delete':
1210 1211 for i in xrange(alo, ahi):
1211 1212 yield ('-', a[i])
1212 1213 elif tag == 'replace':
1213 1214 for i in xrange(alo, ahi):
1214 1215 yield ('-', a[i])
1215 1216 for i in xrange(blo, bhi):
1216 1217 yield ('+', b[i])
1217 1218
1218 1219 prev = {}
1219 1220 def display(fn, rev, states, prevstates):
1220 1221 datefunc = ui.quiet and util.shortdate or util.datestr
1221 1222 found = False
1222 1223 filerevmatches = {}
1223 1224 r = prev.get(fn, -1)
1224 1225 if opts.get('all'):
1225 1226 iter = difflinestates(states, prevstates)
1226 1227 else:
1227 1228 iter = [('', l) for l in prevstates]
1228 1229 for change, l in iter:
1229 1230 cols = [fn, str(r)]
1230 1231 if opts.get('line_number'):
1231 1232 cols.append(str(l.linenum))
1232 1233 if opts.get('all'):
1233 1234 cols.append(change)
1234 1235 if opts.get('user'):
1235 1236 cols.append(ui.shortuser(get(r)[1]))
1236 1237 if opts.get('date'):
1237 1238 cols.append(datefunc(get(r)[2]))
1238 1239 if opts.get('files_with_matches'):
1239 1240 c = (fn, r)
1240 1241 if c in filerevmatches:
1241 1242 continue
1242 1243 filerevmatches[c] = 1
1243 1244 else:
1244 1245 cols.append(l.line)
1245 1246 ui.write(sep.join(cols), eol)
1246 1247 found = True
1247 1248 return found
1248 1249
1249 1250 fstate = {}
1250 1251 skip = {}
1251 1252 get = util.cachefunc(lambda r: repo[r].changeset())
1252 1253 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1253 1254 found = False
1254 1255 follow = opts.get('follow')
1255 1256 for st, rev, fns in changeiter:
1256 1257 if st == 'window':
1257 1258 matches.clear()
1258 1259 elif st == 'add':
1259 1260 ctx = repo[rev]
1260 1261 matches[rev] = {}
1261 1262 for fn in fns:
1262 1263 if fn in skip:
1263 1264 continue
1264 1265 try:
1265 1266 grepbody(fn, rev, getfile(fn).read(ctx.filenode(fn)))
1266 1267 fstate.setdefault(fn, [])
1267 1268 if follow:
1268 1269 copied = getfile(fn).renamed(ctx.filenode(fn))
1269 1270 if copied:
1270 1271 copies.setdefault(rev, {})[fn] = copied[0]
1271 1272 except error.LookupError:
1272 1273 pass
1273 1274 elif st == 'iter':
1274 1275 for fn, m in sorted(matches[rev].items()):
1275 1276 copy = copies.get(rev, {}).get(fn)
1276 1277 if fn in skip:
1277 1278 if copy:
1278 1279 skip[copy] = True
1279 1280 continue
1280 1281 if fn in prev or fstate[fn]:
1281 1282 r = display(fn, rev, m, fstate[fn])
1282 1283 found = found or r
1283 1284 if r and not opts.get('all'):
1284 1285 skip[fn] = True
1285 1286 if copy:
1286 1287 skip[copy] = True
1287 1288 fstate[fn] = m
1288 1289 if copy:
1289 1290 fstate[copy] = m
1290 1291 prev[fn] = rev
1291 1292
1292 1293 for fn, state in sorted(fstate.items()):
1293 1294 if fn in skip:
1294 1295 continue
1295 1296 if fn not in copies.get(prev[fn], {}):
1296 1297 found = display(fn, rev, {}, state) or found
1297 1298 return (not found and 1) or 0
1298 1299
1299 1300 def heads(ui, repo, *branchrevs, **opts):
1300 1301 """show current repository heads or show branch heads
1301 1302
1302 1303 With no arguments, show all repository head changesets.
1303 1304
1304 If branch or revisions names are given this will show the heads of
1305 If branch names or revisions are given this will show the heads of
1305 1306 the specified branches or the branches those revisions are tagged
1306 1307 with.
1307 1308
1308 1309 Repository "heads" are changesets that don't have child
1309 1310 changesets. They are where development generally takes place and
1310 1311 are the usual targets for update and merge operations.
1311 1312
1312 1313 Branch heads are changesets that have a given branch tag, but have
1313 1314 no child changesets with that tag. They are usually where
1314 development on the given branch takes place.
1315 development on a given branch takes place.
1315 1316 """
1316 1317 if opts.get('rev'):
1317 1318 start = repo.lookup(opts['rev'])
1318 1319 else:
1319 1320 start = None
1320 1321 closed = opts.get('closed')
1321 1322 hideinactive, _heads = opts.get('active'), None
1322 1323 if not branchrevs:
1323 1324 # Assume we're looking repo-wide heads if no revs were specified.
1324 1325 heads = repo.heads(start, closed=closed)
1325 1326 else:
1326 1327 if hideinactive:
1327 1328 _heads = repo.heads(start, closed=closed)
1328 1329 heads = []
1329 1330 visitedset = set()
1330 1331 for branchrev in branchrevs:
1331 1332 branch = repo[branchrev].branch()
1332 1333 if branch in visitedset:
1333 1334 continue
1334 1335 visitedset.add(branch)
1335 1336 bheads = repo.branchheads(branch, start, closed=closed)
1336 1337 if not bheads:
1337 1338 if branch != branchrev:
1338 1339 ui.warn(_("no changes on branch %s containing %s are "
1339 1340 "reachable from %s\n")
1340 1341 % (branch, branchrev, opts.get('rev')))
1341 1342 else:
1342 1343 ui.warn(_("no changes on branch %s are reachable from %s\n")
1343 1344 % (branch, opts.get('rev')))
1344 1345 if hideinactive:
1345 1346 bheads = [bhead for bhead in bheads if bhead in _heads]
1346 1347 heads.extend(bheads)
1347 1348 if not heads:
1348 1349 return 1
1349 1350 displayer = cmdutil.show_changeset(ui, repo, opts)
1350 1351 for n in heads:
1351 1352 displayer.show(repo[n])
1352 1353
1353 1354 def help_(ui, name=None, with_version=False):
1354 1355 """show help for a given topic or a help overview
1355 1356
1356 With no arguments, print a list of commands and short help.
1357 With no arguments, print a list of commands with short help messages.
1357 1358
1358 1359 Given a topic, extension, or command name, print help for that
1359 1360 topic."""
1360 1361 option_lists = []
1361 1362
1362 1363 def addglobalopts(aliases):
1363 1364 if ui.verbose:
1364 1365 option_lists.append((_("global options:"), globalopts))
1365 1366 if name == 'shortlist':
1366 1367 option_lists.append((_('use "hg help" for the full list '
1367 1368 'of commands'), ()))
1368 1369 else:
1369 1370 if name == 'shortlist':
1370 1371 msg = _('use "hg help" for the full list of commands '
1371 1372 'or "hg -v" for details')
1372 1373 elif aliases:
1373 1374 msg = _('use "hg -v help%s" to show aliases and '
1374 1375 'global options') % (name and " " + name or "")
1375 1376 else:
1376 1377 msg = _('use "hg -v help %s" to show global options') % name
1377 1378 option_lists.append((msg, ()))
1378 1379
1379 1380 def helpcmd(name):
1380 1381 if with_version:
1381 1382 version_(ui)
1382 1383 ui.write('\n')
1383 1384
1384 1385 try:
1385 1386 aliases, i = cmdutil.findcmd(name, table, False)
1386 1387 except error.AmbiguousCommand, inst:
1387 1388 select = lambda c: c.lstrip('^').startswith(inst.args[0])
1388 1389 helplist(_('list of commands:\n\n'), select)
1389 1390 return
1390 1391
1391 1392 # synopsis
1392 1393 if len(i) > 2:
1393 1394 if i[2].startswith('hg'):
1394 1395 ui.write("%s\n" % i[2])
1395 1396 else:
1396 1397 ui.write('hg %s %s\n' % (aliases[0], i[2]))
1397 1398 else:
1398 1399 ui.write('hg %s\n' % aliases[0])
1399 1400
1400 1401 # aliases
1401 1402 if not ui.quiet and len(aliases) > 1:
1402 1403 ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
1403 1404
1404 1405 # description
1405 1406 doc = gettext(i[0].__doc__)
1406 1407 if not doc:
1407 1408 doc = _("(no help text available)")
1408 1409 if ui.quiet:
1409 1410 doc = doc.splitlines(0)[0]
1410 1411 ui.write("\n%s\n" % doc.rstrip())
1411 1412
1412 1413 if not ui.quiet:
1413 1414 # options
1414 1415 if i[1]:
1415 1416 option_lists.append((_("options:\n"), i[1]))
1416 1417
1417 1418 addglobalopts(False)
1418 1419
1419 1420 def helplist(header, select=None):
1420 1421 h = {}
1421 1422 cmds = {}
1422 1423 for c, e in table.iteritems():
1423 1424 f = c.split("|", 1)[0]
1424 1425 if select and not select(f):
1425 1426 continue
1426 1427 if (not select and name != 'shortlist' and
1427 1428 e[0].__module__ != __name__):
1428 1429 continue
1429 1430 if name == "shortlist" and not f.startswith("^"):
1430 1431 continue
1431 1432 f = f.lstrip("^")
1432 1433 if not ui.debugflag and f.startswith("debug"):
1433 1434 continue
1434 1435 doc = gettext(e[0].__doc__)
1435 1436 if not doc:
1436 1437 doc = _("(no help text available)")
1437 1438 h[f] = doc.splitlines(0)[0].rstrip()
1438 1439 cmds[f] = c.lstrip("^")
1439 1440
1440 1441 if not h:
1441 1442 ui.status(_('no commands defined\n'))
1442 1443 return
1443 1444
1444 1445 ui.status(header)
1445 1446 fns = sorted(h)
1446 1447 m = max(map(len, fns))
1447 1448 for f in fns:
1448 1449 if ui.verbose:
1449 1450 commands = cmds[f].replace("|",", ")
1450 1451 ui.write(" %s:\n %s\n"%(commands, h[f]))
1451 1452 else:
1452 1453 ui.write(' %-*s %s\n' % (m, f, h[f]))
1453 1454
1454 1455 exts = list(extensions.extensions())
1455 1456 if exts and name != 'shortlist':
1456 1457 ui.write(_('\nenabled extensions:\n\n'))
1457 1458 maxlength = 0
1458 1459 exthelps = []
1459 1460 for ename, ext in exts:
1460 1461 doc = (gettext(ext.__doc__) or _('(no help text available)'))
1461 1462 ename = ename.split('.')[-1]
1462 1463 maxlength = max(len(ename), maxlength)
1463 1464 exthelps.append((ename, doc.splitlines(0)[0].strip()))
1464 1465 for ename, text in exthelps:
1465 1466 ui.write(_(' %s %s\n') % (ename.ljust(maxlength), text))
1466 1467
1467 1468 if not ui.quiet:
1468 1469 addglobalopts(True)
1469 1470
1470 1471 def helptopic(name):
1471 1472 for names, header, doc in help.helptable:
1472 1473 if name in names:
1473 1474 break
1474 1475 else:
1475 1476 raise error.UnknownCommand(name)
1476 1477
1477 1478 # description
1478 1479 if not doc:
1479 1480 doc = _("(no help text available)")
1480 1481 if hasattr(doc, '__call__'):
1481 1482 doc = doc()
1482 1483
1483 1484 ui.write("%s\n" % header)
1484 1485 ui.write("%s\n" % doc.rstrip())
1485 1486
1486 1487 def helpext(name):
1487 1488 try:
1488 1489 mod = extensions.find(name)
1489 1490 except KeyError:
1490 1491 raise error.UnknownCommand(name)
1491 1492
1492 1493 doc = gettext(mod.__doc__) or _('no help text available')
1493 1494 doc = doc.splitlines(0)
1494 1495 ui.write(_('%s extension - %s\n') % (name.split('.')[-1], doc[0]))
1495 1496 for d in doc[1:]:
1496 1497 ui.write(d, '\n')
1497 1498
1498 1499 ui.status('\n')
1499 1500
1500 1501 try:
1501 1502 ct = mod.cmdtable
1502 1503 except AttributeError:
1503 1504 ct = {}
1504 1505
1505 1506 modcmds = set([c.split('|', 1)[0] for c in ct])
1506 1507 helplist(_('list of commands:\n\n'), modcmds.__contains__)
1507 1508
1508 1509 if name and name != 'shortlist':
1509 1510 i = None
1510 1511 for f in (helptopic, helpcmd, helpext):
1511 1512 try:
1512 1513 f(name)
1513 1514 i = None
1514 1515 break
1515 1516 except error.UnknownCommand, inst:
1516 1517 i = inst
1517 1518 if i:
1518 1519 raise i
1519 1520
1520 1521 else:
1521 1522 # program name
1522 1523 if ui.verbose or with_version:
1523 1524 version_(ui)
1524 1525 else:
1525 1526 ui.status(_("Mercurial Distributed SCM\n"))
1526 1527 ui.status('\n')
1527 1528
1528 1529 # list of commands
1529 1530 if name == "shortlist":
1530 1531 header = _('basic commands:\n\n')
1531 1532 else:
1532 1533 header = _('list of commands:\n\n')
1533 1534
1534 1535 helplist(header)
1535 1536
1536 1537 # list all option lists
1537 1538 opt_output = []
1538 1539 for title, options in option_lists:
1539 1540 opt_output.append(("\n%s" % title, None))
1540 1541 for shortopt, longopt, default, desc in options:
1541 1542 if "DEPRECATED" in desc and not ui.verbose: continue
1542 1543 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
1543 1544 longopt and " --%s" % longopt),
1544 1545 "%s%s" % (desc,
1545 1546 default
1546 1547 and _(" (default: %s)") % default
1547 1548 or "")))
1548 1549
1549 1550 if not name:
1550 1551 ui.write(_("\nadditional help topics:\n\n"))
1551 1552 topics = []
1552 1553 for names, header, doc in help.helptable:
1553 1554 names = [(-len(name), name) for name in names]
1554 1555 names.sort()
1555 1556 topics.append((names[0][1], header))
1556 1557 topics_len = max([len(s[0]) for s in topics])
1557 1558 for t, desc in topics:
1558 1559 ui.write(" %-*s %s\n" % (topics_len, t, desc))
1559 1560
1560 1561 if opt_output:
1561 1562 opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
1562 1563 for first, second in opt_output:
1563 1564 if second:
1564 1565 # wrap descriptions at 70 characters, just like the
1565 1566 # main help texts
1566 1567 second = textwrap.wrap(second, width=70 - opts_len - 3)
1567 1568 pad = '\n' + ' ' * (opts_len + 3)
1568 1569 ui.write(" %-*s %s\n" % (opts_len, first, pad.join(second)))
1569 1570 else:
1570 1571 ui.write("%s\n" % first)
1571 1572
1572 1573 def identify(ui, repo, source=None,
1573 1574 rev=None, num=None, id=None, branch=None, tags=None):
1574 1575 """identify the working copy or specified revision
1575 1576
1576 1577 With no revision, print a summary of the current state of the
1577 1578 repository.
1578 1579
1579 With a path, do a lookup in another repository.
1580 Specifying a path to a repository root or Mercurial bundle will
1581 cause lookup to operate on that repository/bundle.
1580 1582
1581 1583 This summary identifies the repository state using one or two
1582 1584 parent hash identifiers, followed by a "+" if there are
1583 1585 uncommitted changes in the working directory, a list of tags for
1584 1586 this revision and a branch name for non-default branches.
1585 1587 """
1586 1588
1587 1589 if not repo and not source:
1588 1590 raise util.Abort(_("There is no Mercurial repository here "
1589 1591 "(.hg not found)"))
1590 1592
1591 1593 hexfunc = ui.debugflag and hex or short
1592 1594 default = not (num or id or branch or tags)
1593 1595 output = []
1594 1596
1595 1597 revs = []
1596 1598 if source:
1597 1599 source, revs, checkout = hg.parseurl(ui.expandpath(source), [])
1598 1600 repo = hg.repository(ui, source)
1599 1601
1600 1602 if not repo.local():
1601 1603 if not rev and revs:
1602 1604 rev = revs[0]
1603 1605 if not rev:
1604 1606 rev = "tip"
1605 1607 if num or branch or tags:
1606 1608 raise util.Abort(
1607 1609 "can't query remote revision number, branch, or tags")
1608 1610 output = [hexfunc(repo.lookup(rev))]
1609 1611 elif not rev:
1610 1612 ctx = repo[None]
1611 1613 parents = ctx.parents()
1612 1614 changed = False
1613 1615 if default or id or num:
1614 1616 changed = ctx.files() + ctx.deleted()
1615 1617 if default or id:
1616 1618 output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
1617 1619 (changed) and "+" or "")]
1618 1620 if num:
1619 1621 output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
1620 1622 (changed) and "+" or ""))
1621 1623 else:
1622 1624 ctx = repo[rev]
1623 1625 if default or id:
1624 1626 output = [hexfunc(ctx.node())]
1625 1627 if num:
1626 1628 output.append(str(ctx.rev()))
1627 1629
1628 1630 if repo.local() and default and not ui.quiet:
1629 1631 b = encoding.tolocal(ctx.branch())
1630 1632 if b != 'default':
1631 1633 output.append("(%s)" % b)
1632 1634
1633 1635 # multiple tags for a single parent separated by '/'
1634 1636 t = "/".join(ctx.tags())
1635 1637 if t:
1636 1638 output.append(t)
1637 1639
1638 1640 if branch:
1639 1641 output.append(encoding.tolocal(ctx.branch()))
1640 1642
1641 1643 if tags:
1642 1644 output.extend(ctx.tags())
1643 1645
1644 1646 ui.write("%s\n" % ' '.join(output))
1645 1647
1646 1648 def import_(ui, repo, patch1, *patches, **opts):
1647 1649 """import an ordered set of patches
1648 1650
1649 1651 Import a list of patches and commit them individually.
1650 1652
1651 1653 If there are outstanding changes in the working directory, import
1652 1654 will abort unless given the -f/--force flag.
1653 1655
1654 1656 You can import a patch straight from a mail message. Even patches
1655 as attachments work (body part must be type text/plain or
1656 text/x-patch to be used). From and Subject headers of email
1657 as attachments work (to use the body part, it must have type
1658 text/plain or text/x-patch). From and Subject headers of email
1657 1659 message are used as default committer and commit message. All
1658 1660 text/plain body parts before first diff are added to commit
1659 1661 message.
1660 1662
1661 1663 If the imported patch was generated by hg export, user and
1662 1664 description from patch override values from message headers and
1663 1665 body. Values given on command line with -m/--message and -u/--user
1664 1666 override these.
1665 1667
1666 1668 If --exact is specified, import will set the working directory to
1667 1669 the parent of each patch before applying it, and will abort if the
1668 1670 resulting changeset has a different ID than the one recorded in
1669 1671 the patch. This may happen due to character set problems or other
1670 1672 deficiencies in the text patch format.
1671 1673
1672 1674 With -s/--similarity, hg will attempt to discover renames and
1673 1675 copies in the patch in the same way as 'addremove'.
1674 1676
1675 To read a patch from standard input, use patch name "-". See 'hg
1676 help dates' for a list of formats valid for -d/--date.
1677 To read a patch from standard input, use "-" as the patch name.
1678 See 'hg help dates' for a list of formats valid for -d/--date.
1677 1679 """
1678 1680 patches = (patch1,) + patches
1679 1681
1680 1682 date = opts.get('date')
1681 1683 if date:
1682 1684 opts['date'] = util.parsedate(date)
1683 1685
1684 1686 try:
1685 1687 sim = float(opts.get('similarity') or 0)
1686 1688 except ValueError:
1687 1689 raise util.Abort(_('similarity must be a number'))
1688 1690 if sim < 0 or sim > 100:
1689 1691 raise util.Abort(_('similarity must be between 0 and 100'))
1690 1692
1691 1693 if opts.get('exact') or not opts.get('force'):
1692 1694 cmdutil.bail_if_changed(repo)
1693 1695
1694 1696 d = opts["base"]
1695 1697 strip = opts["strip"]
1696 1698 wlock = lock = None
1697 1699 try:
1698 1700 wlock = repo.wlock()
1699 1701 lock = repo.lock()
1700 1702 for p in patches:
1701 1703 pf = os.path.join(d, p)
1702 1704
1703 1705 if pf == '-':
1704 1706 ui.status(_("applying patch from stdin\n"))
1705 1707 pf = sys.stdin
1706 1708 else:
1707 1709 ui.status(_("applying %s\n") % p)
1708 1710 pf = url.open(ui, pf)
1709 1711 data = patch.extract(ui, pf)
1710 1712 tmpname, message, user, date, branch, nodeid, p1, p2 = data
1711 1713
1712 1714 if tmpname is None:
1713 1715 raise util.Abort(_('no diffs found'))
1714 1716
1715 1717 try:
1716 1718 cmdline_message = cmdutil.logmessage(opts)
1717 1719 if cmdline_message:
1718 1720 # pickup the cmdline msg
1719 1721 message = cmdline_message
1720 1722 elif message:
1721 1723 # pickup the patch msg
1722 1724 message = message.strip()
1723 1725 else:
1724 1726 # launch the editor
1725 1727 message = None
1726 1728 ui.debug(_('message:\n%s\n') % message)
1727 1729
1728 1730 wp = repo.parents()
1729 1731 if opts.get('exact'):
1730 1732 if not nodeid or not p1:
1731 1733 raise util.Abort(_('not a Mercurial patch'))
1732 1734 p1 = repo.lookup(p1)
1733 1735 p2 = repo.lookup(p2 or hex(nullid))
1734 1736
1735 1737 if p1 != wp[0].node():
1736 1738 hg.clean(repo, p1)
1737 1739 repo.dirstate.setparents(p1, p2)
1738 1740 elif p2:
1739 1741 try:
1740 1742 p1 = repo.lookup(p1)
1741 1743 p2 = repo.lookup(p2)
1742 1744 if p1 == wp[0].node():
1743 1745 repo.dirstate.setparents(p1, p2)
1744 1746 except error.RepoError:
1745 1747 pass
1746 1748 if opts.get('exact') or opts.get('import_branch'):
1747 1749 repo.dirstate.setbranch(branch or 'default')
1748 1750
1749 1751 files = {}
1750 1752 try:
1751 1753 patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
1752 1754 files=files)
1753 1755 finally:
1754 1756 files = patch.updatedir(ui, repo, files, similarity=sim/100.)
1755 1757 if not opts.get('no_commit'):
1756 1758 m = cmdutil.matchfiles(repo, files or [])
1757 1759 n = repo.commit(message, opts.get('user') or user,
1758 1760 opts.get('date') or date, match=m,
1759 1761 editor=cmdutil.commiteditor)
1760 1762 if opts.get('exact'):
1761 1763 if hex(n) != nodeid:
1762 1764 repo.rollback()
1763 1765 raise util.Abort(_('patch is damaged'
1764 1766 ' or loses information'))
1765 1767 # Force a dirstate write so that the next transaction
1766 1768 # backups an up-do-date file.
1767 1769 repo.dirstate.write()
1768 1770 finally:
1769 1771 os.unlink(tmpname)
1770 1772 finally:
1771 1773 release(lock, wlock)
1772 1774
1773 1775 def incoming(ui, repo, source="default", **opts):
1774 1776 """show new changesets found in source
1775 1777
1776 1778 Show new changesets found in the specified path/URL or the default
1777 pull location. These are the changesets that would be pulled if a
1778 pull was requested.
1779 pull location. These are the changesets that would have been pulled
1780 if a pull at the time you issued this command.
1779 1781
1780 1782 For remote repository, using --bundle avoids downloading the
1781 1783 changesets twice if the incoming is followed by a pull.
1782 1784
1783 1785 See pull for valid source format details.
1784 1786 """
1785 1787 limit = cmdutil.loglimit(opts)
1786 1788 source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
1787 1789 other = hg.repository(cmdutil.remoteui(repo, opts), source)
1788 1790 ui.status(_('comparing with %s\n') % url.hidepassword(source))
1789 1791 if revs:
1790 1792 revs = [other.lookup(rev) for rev in revs]
1791 1793 common, incoming, rheads = repo.findcommonincoming(other, heads=revs,
1792 1794 force=opts["force"])
1793 1795 if not incoming:
1794 1796 try:
1795 1797 os.unlink(opts["bundle"])
1796 1798 except:
1797 1799 pass
1798 1800 ui.status(_("no changes found\n"))
1799 1801 return 1
1800 1802
1801 1803 cleanup = None
1802 1804 try:
1803 1805 fname = opts["bundle"]
1804 1806 if fname or not other.local():
1805 1807 # create a bundle (uncompressed if other repo is not local)
1806 1808
1807 1809 if revs is None and other.capable('changegroupsubset'):
1808 1810 revs = rheads
1809 1811
1810 1812 if revs is None:
1811 1813 cg = other.changegroup(incoming, "incoming")
1812 1814 else:
1813 1815 cg = other.changegroupsubset(incoming, revs, 'incoming')
1814 1816 bundletype = other.local() and "HG10BZ" or "HG10UN"
1815 1817 fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
1816 1818 # keep written bundle?
1817 1819 if opts["bundle"]:
1818 1820 cleanup = None
1819 1821 if not other.local():
1820 1822 # use the created uncompressed bundlerepo
1821 1823 other = bundlerepo.bundlerepository(ui, repo.root, fname)
1822 1824
1823 1825 o = other.changelog.nodesbetween(incoming, revs)[0]
1824 1826 if opts.get('newest_first'):
1825 1827 o.reverse()
1826 1828 displayer = cmdutil.show_changeset(ui, other, opts)
1827 1829 count = 0
1828 1830 for n in o:
1829 1831 if count >= limit:
1830 1832 break
1831 1833 parents = [p for p in other.changelog.parents(n) if p != nullid]
1832 1834 if opts.get('no_merges') and len(parents) == 2:
1833 1835 continue
1834 1836 count += 1
1835 1837 displayer.show(other[n])
1836 1838 finally:
1837 1839 if hasattr(other, 'close'):
1838 1840 other.close()
1839 1841 if cleanup:
1840 1842 os.unlink(cleanup)
1841 1843
1842 1844 def init(ui, dest=".", **opts):
1843 1845 """create a new repository in the given directory
1844 1846
1845 1847 Initialize a new repository in the given directory. If the given
1846 directory does not exist, it is created.
1848 directory does not exist, it will be created.
1847 1849
1848 1850 If no directory is given, the current directory is used.
1849 1851
1850 1852 It is possible to specify an ssh:// URL as the destination.
1851 1853 See 'hg help urls' for more information.
1852 1854 """
1853 1855 hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
1854 1856
1855 1857 def locate(ui, repo, *pats, **opts):
1856 1858 """locate files matching specific patterns
1857 1859
1858 Print all files under Mercurial control whose names match the
1859 given patterns.
1860
1861 This command searches the entire repository by default. To search
1862 just the current directory and its subdirectories, use
1863 "--include .".
1864
1865 If no patterns are given to match, this command prints all file
1866 names.
1860 Print files under Mercurial control in the working directory whose
1861 names match the given patterns.
1862
1863 By default, this command searches all directories in the working
1864 directory. To search just the current directory and its
1865 subdirectories, use "--include .".
1866
1867 If no patterns are given to match, this command prints the names
1868 of all files under Mercurial control in the working directory.
1867 1869
1868 1870 If you want to feed the output of this command into the "xargs"
1869 1871 command, use the -0 option to both this command and "xargs". This
1870 1872 will avoid the problem of "xargs" treating single filenames that
1871 contain white space as multiple filenames.
1873 contain whitespace as multiple filenames.
1872 1874 """
1873 1875 end = opts.get('print0') and '\0' or '\n'
1874 1876 rev = opts.get('rev') or None
1875 1877
1876 1878 ret = 1
1877 1879 m = cmdutil.match(repo, pats, opts, default='relglob')
1878 1880 m.bad = lambda x,y: False
1879 1881 for abs in repo[rev].walk(m):
1880 1882 if not rev and abs not in repo.dirstate:
1881 1883 continue
1882 1884 if opts.get('fullpath'):
1883 1885 ui.write(repo.wjoin(abs), end)
1884 1886 else:
1885 1887 ui.write(((pats and m.rel(abs)) or abs), end)
1886 1888 ret = 0
1887 1889
1888 1890 return ret
1889 1891
1890 1892 def log(ui, repo, *pats, **opts):
1891 1893 """show revision history of entire repository or files
1892 1894
1893 1895 Print the revision history of the specified files or the entire
1894 1896 project.
1895 1897
1896 1898 File history is shown without following rename or copy history of
1897 1899 files. Use -f/--follow with a filename to follow history across
1898 1900 renames and copies. --follow without a filename will only show
1899 1901 ancestors or descendants of the starting revision. --follow-first
1900 1902 only follows the first parent of merge revisions.
1901 1903
1902 1904 If no revision range is specified, the default is tip:0 unless
1903 1905 --follow is set, in which case the working directory parent is
1904 1906 used as the starting revision.
1905 1907
1906 1908 See 'hg help dates' for a list of formats valid for -d/--date.
1907 1909
1908 By default this command outputs: changeset id and hash, tags,
1909 non-trivial parents, user, date and time, and a summary for each
1910 commit. When the -v/--verbose switch is used, the list of changed
1911 files and full commit message is shown.
1910 By default this command prints revision number and changeset id,
1911 tags, non-trivial parents, user, date and time, and a summary for
1912 each commit. When the -v/--verbose switch is used, the list of
1913 changed files and full commit message are shown.
1912 1914
1913 1915 NOTE: log -p/--patch may generate unexpected diff output for merge
1914 1916 changesets, as it will only compare the merge changeset against
1915 its first parent. Also, the files: list will only reflect files
1916 that are different from BOTH parents.
1917
1917 its first parent. Also, only files different from BOTH parents
1918 will appear in files:.
1918 1919 """
1919 1920
1920 1921 get = util.cachefunc(lambda r: repo[r].changeset())
1921 1922 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1922 1923
1923 1924 limit = cmdutil.loglimit(opts)
1924 1925 count = 0
1925 1926
1926 1927 if opts.get('copies') and opts.get('rev'):
1927 1928 endrev = max(cmdutil.revrange(repo, opts.get('rev'))) + 1
1928 1929 else:
1929 1930 endrev = len(repo)
1930 1931 rcache = {}
1931 1932 ncache = {}
1932 1933 def getrenamed(fn, rev):
1933 1934 '''looks up all renames for a file (up to endrev) the first
1934 1935 time the file is given. It indexes on the changerev and only
1935 1936 parses the manifest if linkrev != changerev.
1936 1937 Returns rename info for fn at changerev rev.'''
1937 1938 if fn not in rcache:
1938 1939 rcache[fn] = {}
1939 1940 ncache[fn] = {}
1940 1941 fl = repo.file(fn)
1941 1942 for i in fl:
1942 1943 node = fl.node(i)
1943 1944 lr = fl.linkrev(i)
1944 1945 renamed = fl.renamed(node)
1945 1946 rcache[fn][lr] = renamed
1946 1947 if renamed:
1947 1948 ncache[fn][node] = renamed
1948 1949 if lr >= endrev:
1949 1950 break
1950 1951 if rev in rcache[fn]:
1951 1952 return rcache[fn][rev]
1952 1953
1953 1954 # If linkrev != rev (i.e. rev not found in rcache) fallback to
1954 1955 # filectx logic.
1955 1956
1956 1957 try:
1957 1958 return repo[rev][fn].renamed()
1958 1959 except error.LookupError:
1959 1960 pass
1960 1961 return None
1961 1962
1962 1963 df = False
1963 1964 if opts["date"]:
1964 1965 df = util.matchdate(opts["date"])
1965 1966
1966 1967 only_branches = opts.get('only_branch')
1967 1968
1968 1969 displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
1969 1970 for st, rev, fns in changeiter:
1970 1971 if st == 'add':
1971 1972 parents = [p for p in repo.changelog.parentrevs(rev)
1972 1973 if p != nullrev]
1973 1974 if opts.get('no_merges') and len(parents) == 2:
1974 1975 continue
1975 1976 if opts.get('only_merges') and len(parents) != 2:
1976 1977 continue
1977 1978
1978 1979 if only_branches:
1979 1980 revbranch = get(rev)[5]['branch']
1980 1981 if revbranch not in only_branches:
1981 1982 continue
1982 1983
1983 1984 if df:
1984 1985 changes = get(rev)
1985 1986 if not df(changes[2][0]):
1986 1987 continue
1987 1988
1988 1989 if opts.get('keyword'):
1989 1990 changes = get(rev)
1990 1991 miss = 0
1991 1992 for k in [kw.lower() for kw in opts['keyword']]:
1992 1993 if not (k in changes[1].lower() or
1993 1994 k in changes[4].lower() or
1994 1995 k in " ".join(changes[3]).lower()):
1995 1996 miss = 1
1996 1997 break
1997 1998 if miss:
1998 1999 continue
1999 2000
2000 2001 if opts['user']:
2001 2002 changes = get(rev)
2002 2003 if not [k for k in opts['user'] if k in changes[1]]:
2003 2004 continue
2004 2005
2005 2006 copies = []
2006 2007 if opts.get('copies') and rev:
2007 2008 for fn in get(rev)[3]:
2008 2009 rename = getrenamed(fn, rev)
2009 2010 if rename:
2010 2011 copies.append((fn, rename[0]))
2011 2012 displayer.show(context.changectx(repo, rev), copies=copies)
2012 2013 elif st == 'iter':
2013 2014 if count == limit: break
2014 2015 if displayer.flush(rev):
2015 2016 count += 1
2016 2017
2017 2018 def manifest(ui, repo, node=None, rev=None):
2018 2019 """output the current or given revision of the project manifest
2019 2020
2020 2021 Print a list of version controlled files for the given revision.
2021 2022 If no revision is given, the first parent of the working directory
2022 is used, or the null revision if none is checked out.
2023
2024 With -v flag, print file permissions, symlink and executable bits.
2025 With --debug flag, print file revision hashes.
2023 is used, or the null revision if no revision is checked out.
2024
2025 With -v, print file permissions, symlink and executable bits.
2026 With --debug, print file revision hashes.
2026 2027 """
2027 2028
2028 2029 if rev and node:
2029 2030 raise util.Abort(_("please specify just one revision"))
2030 2031
2031 2032 if not node:
2032 2033 node = rev
2033 2034
2034 2035 decor = {'l':'644 @ ', 'x':'755 * ', '':'644 '}
2035 2036 ctx = repo[node]
2036 2037 for f in ctx:
2037 2038 if ui.debugflag:
2038 2039 ui.write("%40s " % hex(ctx.manifest()[f]))
2039 2040 if ui.verbose:
2040 2041 ui.write(decor[ctx.flags(f)])
2041 2042 ui.write("%s\n" % f)
2042 2043
2043 2044 def merge(ui, repo, node=None, **opts):
2044 2045 """merge working directory with another revision
2045 2046
2046 The contents of the current working directory is updated with all
2047 changes made in the requested revision since the last common
2048 predecessor revision.
2047 The current working directory is updated with all changes made in
2048 the requested revision since the last common predecessor revision.
2049 2049
2050 2050 Files that changed between either parent are marked as changed for
2051 2051 the next commit and a commit must be performed before any further
2052 updates are allowed. The next commit has two parents.
2052 updates to the repository are allowed. The next commit will have
2053 two parents.
2053 2054
2054 2055 If no revision is specified, the working directory's parent is a
2055 2056 head revision, and the current branch contains exactly one other
2056 2057 head, the other head is merged with by default. Otherwise, an
2057 explicit revision to merge with must be provided.
2058 explicit revision with which to merge with must be provided.
2058 2059 """
2059 2060
2060 2061 if opts.get('rev') and node:
2061 2062 raise util.Abort(_("please specify just one revision"))
2062 2063 if not node:
2063 2064 node = opts.get('rev')
2064 2065
2065 2066 if not node:
2066 2067 branch = repo.changectx(None).branch()
2067 2068 bheads = repo.branchheads(branch)
2068 2069 if len(bheads) > 2:
2069 2070 raise util.Abort(_("branch '%s' has %d heads - "
2070 2071 "please merge with an explicit rev") %
2071 2072 (branch, len(bheads)))
2072 2073
2073 2074 parent = repo.dirstate.parents()[0]
2074 2075 if len(bheads) == 1:
2075 2076 if len(repo.heads()) > 1:
2076 2077 raise util.Abort(_("branch '%s' has one head - "
2077 2078 "please merge with an explicit rev") %
2078 2079 branch)
2079 2080 msg = _('there is nothing to merge')
2080 2081 if parent != repo.lookup(repo[None].branch()):
2081 2082 msg = _('%s - use "hg update" instead') % msg
2082 2083 raise util.Abort(msg)
2083 2084
2084 2085 if parent not in bheads:
2085 2086 raise util.Abort(_('working dir not at a head rev - '
2086 2087 'use "hg update" or merge with an explicit rev'))
2087 2088 node = parent == bheads[0] and bheads[-1] or bheads[0]
2088 2089
2089 2090 if opts.get('show'):
2090 2091 p1 = repo['.']
2091 2092 p2 = repo[node]
2092 2093 common = p1.ancestor(p2)
2093 2094 roots, heads = [common.node()], [p2.node()]
2094 2095 displayer = cmdutil.show_changeset(ui, repo, opts)
2095 2096 for node in repo.changelog.nodesbetween(roots=roots, heads=heads)[0]:
2096 2097 displayer.show(repo[node])
2097 2098 return 0
2098 2099
2099 2100 return hg.merge(repo, node, force=opts.get('force'))
2100 2101
2101 2102 def outgoing(ui, repo, dest=None, **opts):
2102 2103 """show changesets not found in destination
2103 2104
2104 2105 Show changesets not found in the specified destination repository
2105 2106 or the default push location. These are the changesets that would
2106 2107 be pushed if a push was requested.
2107 2108
2108 2109 See pull for valid destination format details.
2109 2110 """
2110 2111 limit = cmdutil.loglimit(opts)
2111 2112 dest, revs, checkout = hg.parseurl(
2112 2113 ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
2113 2114 if revs:
2114 2115 revs = [repo.lookup(rev) for rev in revs]
2115 2116
2116 2117 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
2117 2118 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
2118 2119 o = repo.findoutgoing(other, force=opts.get('force'))
2119 2120 if not o:
2120 2121 ui.status(_("no changes found\n"))
2121 2122 return 1
2122 2123 o = repo.changelog.nodesbetween(o, revs)[0]
2123 2124 if opts.get('newest_first'):
2124 2125 o.reverse()
2125 2126 displayer = cmdutil.show_changeset(ui, repo, opts)
2126 2127 count = 0
2127 2128 for n in o:
2128 2129 if count >= limit:
2129 2130 break
2130 2131 parents = [p for p in repo.changelog.parents(n) if p != nullid]
2131 2132 if opts.get('no_merges') and len(parents) == 2:
2132 2133 continue
2133 2134 count += 1
2134 2135 displayer.show(repo[n])
2135 2136
2136 2137 def parents(ui, repo, file_=None, **opts):
2137 2138 """show the parents of the working directory or revision
2138 2139
2139 2140 Print the working directory's parent revisions. If a revision is
2140 2141 given via -r/--rev, the parent of that revision will be printed.
2141 If a file argument is given, revision in which the file was last
2142 changed (before the working directory revision or the argument to
2143 --rev if given) is printed.
2142 If a file argument is given, the revision in which the file was
2143 last changed (before the working directory revision or the
2144 argument to --rev if given) is printed.
2144 2145 """
2145 2146 rev = opts.get('rev')
2146 2147 if rev:
2147 2148 ctx = repo[rev]
2148 2149 else:
2149 2150 ctx = repo[None]
2150 2151
2151 2152 if file_:
2152 2153 m = cmdutil.match(repo, (file_,), opts)
2153 2154 if m.anypats() or len(m.files()) != 1:
2154 2155 raise util.Abort(_('can only specify an explicit filename'))
2155 2156 file_ = m.files()[0]
2156 2157 filenodes = []
2157 2158 for cp in ctx.parents():
2158 2159 if not cp:
2159 2160 continue
2160 2161 try:
2161 2162 filenodes.append(cp.filenode(file_))
2162 2163 except error.LookupError:
2163 2164 pass
2164 2165 if not filenodes:
2165 2166 raise util.Abort(_("'%s' not found in manifest!") % file_)
2166 2167 fl = repo.file(file_)
2167 2168 p = [repo.lookup(fl.linkrev(fl.rev(fn))) for fn in filenodes]
2168 2169 else:
2169 2170 p = [cp.node() for cp in ctx.parents()]
2170 2171
2171 2172 displayer = cmdutil.show_changeset(ui, repo, opts)
2172 2173 for n in p:
2173 2174 if n != nullid:
2174 2175 displayer.show(repo[n])
2175 2176
2176 2177 def paths(ui, repo, search=None):
2177 2178 """show aliases for remote repositories
2178 2179
2179 2180 Show definition of symbolic path name NAME. If no name is given,
2180 show definition of available names.
2181 show definition of all available names.
2181 2182
2182 2183 Path names are defined in the [paths] section of /etc/mercurial/hgrc
2183 2184 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
2184 2185
2185 2186 See 'hg help urls' for more information.
2186 2187 """
2187 2188 if search:
2188 2189 for name, path in ui.configitems("paths"):
2189 2190 if name == search:
2190 2191 ui.write("%s\n" % url.hidepassword(path))
2191 2192 return
2192 2193 ui.warn(_("not found!\n"))
2193 2194 return 1
2194 2195 else:
2195 2196 for name, path in ui.configitems("paths"):
2196 2197 ui.write("%s = %s\n" % (name, url.hidepassword(path)))
2197 2198
2198 2199 def postincoming(ui, repo, modheads, optupdate, checkout):
2199 2200 if modheads == 0:
2200 2201 return
2201 2202 if optupdate:
2202 2203 if (modheads <= 1 or len(repo.branchheads()) == 1) or checkout:
2203 2204 return hg.update(repo, checkout)
2204 2205 else:
2205 2206 ui.status(_("not updating, since new heads added\n"))
2206 2207 if modheads > 1:
2207 2208 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
2208 2209 else:
2209 2210 ui.status(_("(run 'hg update' to get a working copy)\n"))
2210 2211
2211 2212 def pull(ui, repo, source="default", **opts):
2212 2213 """pull changes from the specified source
2213 2214
2214 Pull changes from a remote repository to the local one.
2215 Pull changes from a remote repository to a local one.
2215 2216
2216 2217 This finds all changes from the repository at the specified path
2217 or URL and adds them to the local repository. By default, this
2218 does not update the copy of the project in the working directory.
2219
2220 Use hg incoming if you want to see what will be added by the next
2221 pull without actually adding the changes to the repository.
2218 or URL and adds them to a local repository (the current one unless
2219 -R is specified). By default, this does not update the copy of the
2220 project in the working directory.
2221
2222 Use hg incoming if you want to see what would have been added by a
2223 pull at the time you issued this command. If you then decide to
2224 added those changes to the repository, you should use pull -r X
2225 where X is the last changeset listed by hg incoming.
2222 2226
2223 2227 If SOURCE is omitted, the 'default' path will be used.
2224 2228 See 'hg help urls' for more information.
2225 2229 """
2226 2230 source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
2227 2231 other = hg.repository(cmdutil.remoteui(repo, opts), source)
2228 2232 ui.status(_('pulling from %s\n') % url.hidepassword(source))
2229 2233 if revs:
2230 2234 try:
2231 2235 revs = [other.lookup(rev) for rev in revs]
2232 2236 except error.CapabilityError:
2233 2237 err = _("Other repository doesn't support revision lookup, "
2234 2238 "so a rev cannot be specified.")
2235 2239 raise util.Abort(err)
2236 2240
2237 2241 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
2238 2242 return postincoming(ui, repo, modheads, opts.get('update'), checkout)
2239 2243
2240 2244 def push(ui, repo, dest=None, **opts):
2241 2245 """push changes to the specified destination
2242 2246
2243 2247 Push changes from the local repository to the given destination.
2244 2248
2245 2249 This is the symmetrical operation for pull. It moves changes from
2246 2250 the current repository to a different one. If the destination is
2247 2251 local this is identical to a pull in that directory from the
2248 2252 current one.
2249 2253
2250 2254 By default, push will refuse to run if it detects the result would
2251 2255 increase the number of remote heads. This generally indicates the
2252 the client has forgotten to pull and merge before pushing.
2256 user forgot to pull and merge before pushing.
2253 2257
2254 2258 If -r/--rev is used, the named revision and all its ancestors will
2255 2259 be pushed to the remote repository.
2256 2260
2257 Look at the help text for URLs for important details about ssh://
2261 Please see 'hg help urls' for important details about ssh://
2258 2262 URLs. If DESTINATION is omitted, a default path will be used.
2259 2263 See 'hg help urls' for more information.
2260 2264 """
2261 2265 dest, revs, checkout = hg.parseurl(
2262 2266 ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
2263 2267 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
2264 2268 ui.status(_('pushing to %s\n') % url.hidepassword(dest))
2265 2269 if revs:
2266 2270 revs = [repo.lookup(rev) for rev in revs]
2267 2271 r = repo.push(other, opts.get('force'), revs=revs)
2268 2272 return r == 0
2269 2273
2270 2274 def recover(ui, repo):
2271 2275 """roll back an interrupted transaction
2272 2276
2273 2277 Recover from an interrupted commit or pull.
2274 2278
2275 2279 This command tries to fix the repository status after an
2276 2280 interrupted operation. It should only be necessary when Mercurial
2277 2281 suggests it.
2278 2282 """
2279 2283 if repo.recover():
2280 2284 return hg.verify(repo)
2281 2285 return 1
2282 2286
2283 2287 def remove(ui, repo, *pats, **opts):
2284 2288 """remove the specified files on the next commit
2285 2289
2286 2290 Schedule the indicated files for removal from the repository.
2287 2291
2288 2292 This only removes files from the current branch, not from the
2289 2293 entire project history. -A/--after can be used to remove only
2290 2294 files that have already been deleted, -f/--force can be used to
2291 2295 force deletion, and -Af can be used to remove files from the next
2292 revision without deleting them.
2296 revision without deleting them from the working directory.
2293 2297
2294 2298 The following table details the behavior of remove for different
2295 2299 file states (columns) and option combinations (rows). The file
2296 states are Added, Clean, Modified and Missing (as reported by hg
2297 status). The actions are Warn, Remove (from branch) and Delete
2298 (from disk).
2300 states are Added [A], Clean [C], Modified [M] and Missing [!]
2301 (as reported by hg status). The actions are Warn, Remove (from
2302 branch) and Delete (from disk).
2299 2303
2300 2304 A C M !
2301 2305 none W RD W R
2302 2306 -f R RD RD R
2303 2307 -A W W W R
2304 2308 -Af R R R R
2305 2309
2306 2310 This command schedules the files to be removed at the next commit.
2307 2311 To undo a remove before that, see hg revert.
2308 2312 """
2309 2313
2310 2314 after, force = opts.get('after'), opts.get('force')
2311 2315 if not pats and not after:
2312 2316 raise util.Abort(_('no files specified'))
2313 2317
2314 2318 m = cmdutil.match(repo, pats, opts)
2315 2319 s = repo.status(match=m, clean=True)
2316 2320 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
2317 2321
2318 2322 for f in m.files():
2319 2323 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
2320 2324 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
2321 2325
2322 2326 def warn(files, reason):
2323 2327 for f in files:
2324 2328 ui.warn(_('not removing %s: file %s (use -f to force removal)\n')
2325 2329 % (m.rel(f), reason))
2326 2330
2327 2331 if force:
2328 2332 remove, forget = modified + deleted + clean, added
2329 2333 elif after:
2330 2334 remove, forget = deleted, []
2331 2335 warn(modified + added + clean, _('still exists'))
2332 2336 else:
2333 2337 remove, forget = deleted + clean, []
2334 2338 warn(modified, _('is modified'))
2335 2339 warn(added, _('has been marked for add'))
2336 2340
2337 2341 for f in sorted(remove + forget):
2338 2342 if ui.verbose or not m.exact(f):
2339 2343 ui.status(_('removing %s\n') % m.rel(f))
2340 2344
2341 2345 repo.forget(forget)
2342 2346 repo.remove(remove, unlink=not after)
2343 2347
2344 2348 def rename(ui, repo, *pats, **opts):
2345 2349 """rename files; equivalent of copy + remove
2346 2350
2347 2351 Mark dest as copies of sources; mark sources for deletion. If dest
2348 2352 is a directory, copies are put in that directory. If dest is a
2349 2353 file, there can only be one source.
2350 2354
2351 2355 By default, this command copies the contents of files as they
2352 2356 exist in the working directory. If invoked with -A/--after, the
2353 2357 operation is recorded, but no copying is performed.
2354 2358
2355 2359 This command takes effect at the next commit. To undo a rename
2356 2360 before that, see hg revert.
2357 2361 """
2358 2362 wlock = repo.wlock(False)
2359 2363 try:
2360 2364 return cmdutil.copy(ui, repo, pats, opts, rename=True)
2361 2365 finally:
2362 2366 wlock.release()
2363 2367
2364 2368 def resolve(ui, repo, *pats, **opts):
2365 2369 """retry file merges from a merge or update
2366 2370
2367 2371 This command will cleanly retry unresolved file merges using file
2368 2372 revisions preserved from the last update or merge. To attempt to
2369 2373 resolve all unresolved files, use the -a/--all switch.
2370 2374
2371 2375 If a conflict is resolved manually, please note that the changes
2372 2376 will be overwritten if the merge is retried with resolve. The
2373 2377 -m/--mark switch should be used to mark the file as resolved.
2374 2378
2375 This command will also allow listing resolved files and manually
2376 marking and unmarking files as resolved. All files must be marked
2377 as resolved before the new commits are permitted.
2379 This command also allows listing resolved files and manually
2380 indicating whether or not files are resolved. All files must be
2381 marked as resolved before a commit is permitted.
2378 2382
2379 2383 The codes used to show the status of files are:
2380 2384 U = unresolved
2381 2385 R = resolved
2382 2386 """
2383 2387
2384 2388 all, mark, unmark, show = [opts.get(o) for o in 'all mark unmark list'.split()]
2385 2389
2386 2390 if (show and (mark or unmark)) or (mark and unmark):
2387 2391 raise util.Abort(_("too many options specified"))
2388 2392 if pats and all:
2389 2393 raise util.Abort(_("can't specify --all and patterns"))
2390 2394 if not (all or pats or show or mark or unmark):
2391 2395 raise util.Abort(_('no files or directories specified; '
2392 2396 'use --all to remerge all files'))
2393 2397
2394 2398 ms = merge_.mergestate(repo)
2395 2399 m = cmdutil.match(repo, pats, opts)
2396 2400
2397 2401 for f in ms:
2398 2402 if m(f):
2399 2403 if show:
2400 2404 ui.write("%s %s\n" % (ms[f].upper(), f))
2401 2405 elif mark:
2402 2406 ms.mark(f, "r")
2403 2407 elif unmark:
2404 2408 ms.mark(f, "u")
2405 2409 else:
2406 2410 wctx = repo[None]
2407 2411 mctx = wctx.parents()[-1]
2408 2412
2409 2413 # backup pre-resolve (merge uses .orig for its own purposes)
2410 2414 a = repo.wjoin(f)
2411 2415 util.copyfile(a, a + ".resolve")
2412 2416
2413 2417 # resolve file
2414 2418 ms.resolve(f, wctx, mctx)
2415 2419
2416 2420 # replace filemerge's .orig file with our resolve file
2417 2421 util.rename(a + ".resolve", a + ".orig")
2418 2422
2419 2423 def revert(ui, repo, *pats, **opts):
2420 2424 """restore individual files or directories to an earlier state
2421 2425
2422 2426 (Use update -r to check out earlier revisions, revert does not
2423 2427 change the working directory parents.)
2424 2428
2425 2429 With no revision specified, revert the named files or directories
2426 2430 to the contents they had in the parent of the working directory.
2427 2431 This restores the contents of the affected files to an unmodified
2428 2432 state and unschedules adds, removes, copies, and renames. If the
2429 2433 working directory has two parents, you must explicitly specify the
2430 2434 revision to revert to.
2431 2435
2432 2436 Using the -r/--rev option, revert the given files or directories
2433 2437 to their contents as of a specific revision. This can be helpful
2434 2438 to "roll back" some or all of an earlier change. See 'hg help
2435 2439 dates' for a list of formats valid for -d/--date.
2436 2440
2437 2441 Revert modifies the working directory. It does not commit any
2438 2442 changes, or change the parent of the working directory. If you
2439 2443 revert to a revision other than the parent of the working
2440 2444 directory, the reverted files will thus appear modified
2441 2445 afterwards.
2442 2446
2443 2447 If a file has been deleted, it is restored. If the executable mode
2444 2448 of a file was changed, it is reset.
2445 2449
2446 2450 If names are given, all files matching the names are reverted.
2447 2451 If no arguments are given, no files are reverted.
2448 2452
2449 2453 Modified files are saved with a .orig suffix before reverting.
2450 2454 To disable these backups, use --no-backup.
2451 2455 """
2452 2456
2453 2457 if opts["date"]:
2454 2458 if opts["rev"]:
2455 2459 raise util.Abort(_("you can't specify a revision and a date"))
2456 2460 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
2457 2461
2458 2462 if not pats and not opts.get('all'):
2459 2463 raise util.Abort(_('no files or directories specified; '
2460 2464 'use --all to revert the whole repo'))
2461 2465
2462 2466 parent, p2 = repo.dirstate.parents()
2463 2467 if not opts.get('rev') and p2 != nullid:
2464 2468 raise util.Abort(_('uncommitted merge - please provide a '
2465 2469 'specific revision'))
2466 2470 ctx = repo[opts.get('rev')]
2467 2471 node = ctx.node()
2468 2472 mf = ctx.manifest()
2469 2473 if node == parent:
2470 2474 pmf = mf
2471 2475 else:
2472 2476 pmf = None
2473 2477
2474 2478 # need all matching names in dirstate and manifest of target rev,
2475 2479 # so have to walk both. do not print errors if files exist in one
2476 2480 # but not other.
2477 2481
2478 2482 names = {}
2479 2483
2480 2484 wlock = repo.wlock()
2481 2485 try:
2482 2486 # walk dirstate.
2483 2487
2484 2488 m = cmdutil.match(repo, pats, opts)
2485 2489 m.bad = lambda x,y: False
2486 2490 for abs in repo.walk(m):
2487 2491 names[abs] = m.rel(abs), m.exact(abs)
2488 2492
2489 2493 # walk target manifest.
2490 2494
2491 2495 def badfn(path, msg):
2492 2496 if path in names:
2493 2497 return
2494 2498 path_ = path + '/'
2495 2499 for f in names:
2496 2500 if f.startswith(path_):
2497 2501 return
2498 2502 ui.warn("%s: %s\n" % (m.rel(path), msg))
2499 2503
2500 2504 m = cmdutil.match(repo, pats, opts)
2501 2505 m.bad = badfn
2502 2506 for abs in repo[node].walk(m):
2503 2507 if abs not in names:
2504 2508 names[abs] = m.rel(abs), m.exact(abs)
2505 2509
2506 2510 m = cmdutil.matchfiles(repo, names)
2507 2511 changes = repo.status(match=m)[:4]
2508 2512 modified, added, removed, deleted = map(set, changes)
2509 2513
2510 2514 # if f is a rename, also revert the source
2511 2515 cwd = repo.getcwd()
2512 2516 for f in added:
2513 2517 src = repo.dirstate.copied(f)
2514 2518 if src and src not in names and repo.dirstate[src] == 'r':
2515 2519 removed.add(src)
2516 2520 names[src] = (repo.pathto(src, cwd), True)
2517 2521
2518 2522 def removeforget(abs):
2519 2523 if repo.dirstate[abs] == 'a':
2520 2524 return _('forgetting %s\n')
2521 2525 return _('removing %s\n')
2522 2526
2523 2527 revert = ([], _('reverting %s\n'))
2524 2528 add = ([], _('adding %s\n'))
2525 2529 remove = ([], removeforget)
2526 2530 undelete = ([], _('undeleting %s\n'))
2527 2531
2528 2532 disptable = (
2529 2533 # dispatch table:
2530 2534 # file state
2531 2535 # action if in target manifest
2532 2536 # action if not in target manifest
2533 2537 # make backup if in target manifest
2534 2538 # make backup if not in target manifest
2535 2539 (modified, revert, remove, True, True),
2536 2540 (added, revert, remove, True, False),
2537 2541 (removed, undelete, None, False, False),
2538 2542 (deleted, revert, remove, False, False),
2539 2543 )
2540 2544
2541 2545 for abs, (rel, exact) in sorted(names.items()):
2542 2546 mfentry = mf.get(abs)
2543 2547 target = repo.wjoin(abs)
2544 2548 def handle(xlist, dobackup):
2545 2549 xlist[0].append(abs)
2546 2550 if dobackup and not opts.get('no_backup') and util.lexists(target):
2547 2551 bakname = "%s.orig" % rel
2548 2552 ui.note(_('saving current version of %s as %s\n') %
2549 2553 (rel, bakname))
2550 2554 if not opts.get('dry_run'):
2551 2555 util.copyfile(target, bakname)
2552 2556 if ui.verbose or not exact:
2553 2557 msg = xlist[1]
2554 2558 if not isinstance(msg, basestring):
2555 2559 msg = msg(abs)
2556 2560 ui.status(msg % rel)
2557 2561 for table, hitlist, misslist, backuphit, backupmiss in disptable:
2558 2562 if abs not in table: continue
2559 2563 # file has changed in dirstate
2560 2564 if mfentry:
2561 2565 handle(hitlist, backuphit)
2562 2566 elif misslist is not None:
2563 2567 handle(misslist, backupmiss)
2564 2568 break
2565 2569 else:
2566 2570 if abs not in repo.dirstate:
2567 2571 if mfentry:
2568 2572 handle(add, True)
2569 2573 elif exact:
2570 2574 ui.warn(_('file not managed: %s\n') % rel)
2571 2575 continue
2572 2576 # file has not changed in dirstate
2573 2577 if node == parent:
2574 2578 if exact: ui.warn(_('no changes needed to %s\n') % rel)
2575 2579 continue
2576 2580 if pmf is None:
2577 2581 # only need parent manifest in this unlikely case,
2578 2582 # so do not read by default
2579 2583 pmf = repo[parent].manifest()
2580 2584 if abs in pmf:
2581 2585 if mfentry:
2582 2586 # if version of file is same in parent and target
2583 2587 # manifests, do nothing
2584 2588 if (pmf[abs] != mfentry or
2585 2589 pmf.flags(abs) != mf.flags(abs)):
2586 2590 handle(revert, False)
2587 2591 else:
2588 2592 handle(remove, False)
2589 2593
2590 2594 if not opts.get('dry_run'):
2591 2595 def checkout(f):
2592 2596 fc = ctx[f]
2593 2597 repo.wwrite(f, fc.data(), fc.flags())
2594 2598
2595 2599 audit_path = util.path_auditor(repo.root)
2596 2600 for f in remove[0]:
2597 2601 if repo.dirstate[f] == 'a':
2598 2602 repo.dirstate.forget(f)
2599 2603 continue
2600 2604 audit_path(f)
2601 2605 try:
2602 2606 util.unlink(repo.wjoin(f))
2603 2607 except OSError:
2604 2608 pass
2605 2609 repo.dirstate.remove(f)
2606 2610
2607 2611 normal = None
2608 2612 if node == parent:
2609 2613 # We're reverting to our parent. If possible, we'd like status
2610 2614 # to report the file as clean. We have to use normallookup for
2611 2615 # merges to avoid losing information about merged/dirty files.
2612 2616 if p2 != nullid:
2613 2617 normal = repo.dirstate.normallookup
2614 2618 else:
2615 2619 normal = repo.dirstate.normal
2616 2620 for f in revert[0]:
2617 2621 checkout(f)
2618 2622 if normal:
2619 2623 normal(f)
2620 2624
2621 2625 for f in add[0]:
2622 2626 checkout(f)
2623 2627 repo.dirstate.add(f)
2624 2628
2625 2629 normal = repo.dirstate.normallookup
2626 2630 if node == parent and p2 == nullid:
2627 2631 normal = repo.dirstate.normal
2628 2632 for f in undelete[0]:
2629 2633 checkout(f)
2630 2634 normal(f)
2631 2635
2632 2636 finally:
2633 2637 wlock.release()
2634 2638
2635 2639 def rollback(ui, repo):
2636 2640 """roll back the last transaction
2637 2641
2638 2642 This command should be used with care. There is only one level of
2639 2643 rollback, and there is no way to undo a rollback. It will also
2640 2644 restore the dirstate at the time of the last transaction, losing
2641 2645 any dirstate changes since that time.
2642 2646
2643 2647 Transactions are used to encapsulate the effects of all commands
2644 2648 that create new changesets or propagate existing changesets into a
2645 2649 repository. For example, the following commands are transactional,
2646 2650 and their effects can be rolled back:
2647 2651
2648 2652 commit
2649 2653 import
2650 2654 pull
2651 2655 push (with this repository as destination)
2652 2656 unbundle
2653 2657
2654 2658 This command is not intended for use on public repositories. Once
2655 2659 changes are visible for pull by other users, rolling a transaction
2656 2660 back locally is ineffective (someone else may already have pulled
2657 2661 the changes). Furthermore, a race is possible with readers of the
2658 2662 repository; for example an in-progress pull from the repository
2659 2663 may fail if a rollback is performed.
2660 2664 """
2661 2665 repo.rollback()
2662 2666
2663 2667 def root(ui, repo):
2664 2668 """print the root (top) of the current working directory
2665 2669
2666 2670 Print the root directory of the current repository.
2667 2671 """
2668 2672 ui.write(repo.root + "\n")
2669 2673
2670 2674 def serve(ui, repo, **opts):
2671 2675 """export the repository via HTTP
2672 2676
2673 2677 Start a local HTTP repository browser and pull server.
2674 2678
2675 2679 By default, the server logs accesses to stdout and errors to
2676 2680 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
2677 2681 files.
2678 2682 """
2679 2683
2680 2684 if opts["stdio"]:
2681 2685 if repo is None:
2682 2686 raise error.RepoError(_("There is no Mercurial repository here"
2683 2687 " (.hg not found)"))
2684 2688 s = sshserver.sshserver(ui, repo)
2685 2689 s.serve_forever()
2686 2690
2687 2691 baseui = repo and repo.baseui or ui
2688 2692 optlist = ("name templates style address port prefix ipv6"
2689 2693 " accesslog errorlog webdir_conf certificate")
2690 2694 for o in optlist.split():
2691 2695 if opts[o]:
2692 2696 baseui.setconfig("web", o, str(opts[o]))
2693 2697 if (repo is not None) and (repo.ui != baseui):
2694 2698 repo.ui.setconfig("web", o, str(opts[o]))
2695 2699
2696 2700 if repo is None and not ui.config("web", "webdir_conf"):
2697 2701 raise error.RepoError(_("There is no Mercurial repository here"
2698 2702 " (.hg not found)"))
2699 2703
2700 2704 class service(object):
2701 2705 def init(self):
2702 2706 util.set_signal_handler()
2703 2707 self.httpd = server.create_server(baseui, repo)
2704 2708
2705 2709 if not ui.verbose: return
2706 2710
2707 2711 if self.httpd.prefix:
2708 2712 prefix = self.httpd.prefix.strip('/') + '/'
2709 2713 else:
2710 2714 prefix = ''
2711 2715
2712 2716 port = ':%d' % self.httpd.port
2713 2717 if port == ':80':
2714 2718 port = ''
2715 2719
2716 2720 bindaddr = self.httpd.addr
2717 2721 if bindaddr == '0.0.0.0':
2718 2722 bindaddr = '*'
2719 2723 elif ':' in bindaddr: # IPv6
2720 2724 bindaddr = '[%s]' % bindaddr
2721 2725
2722 2726 fqaddr = self.httpd.fqaddr
2723 2727 if ':' in fqaddr:
2724 2728 fqaddr = '[%s]' % fqaddr
2725 2729 ui.status(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
2726 2730 (fqaddr, port, prefix, bindaddr, self.httpd.port))
2727 2731
2728 2732 def run(self):
2729 2733 self.httpd.serve_forever()
2730 2734
2731 2735 service = service()
2732 2736
2733 2737 cmdutil.service(opts, initfn=service.init, runfn=service.run)
2734 2738
2735 2739 def status(ui, repo, *pats, **opts):
2736 2740 """show changed files in the working directory
2737 2741
2738 2742 Show status of files in the repository. If names are given, only
2739 2743 files that match are shown. Files that are clean or ignored or
2740 source of a copy/move operation, are not listed unless -c/--clean,
2741 -i/--ignored, -C/--copies or -A/--all is given. Unless options
2742 described with "show only ..." are given, the options -mardu are
2743 used.
2744 the source of a copy/move operation, are not listed unless
2745 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
2746 Unless options described with "show only ..." are given, the
2747 options -mardu are used.
2744 2748
2745 2749 Option -q/--quiet hides untracked (unknown and ignored) files
2746 2750 unless explicitly requested with -u/--unknown or -i/--ignored.
2747 2751
2748 2752 NOTE: status may appear to disagree with diff if permissions have
2749 2753 changed or a merge has occurred. The standard diff format does not
2750 2754 report permission changes and diff only reports changes relative
2751 2755 to one merge parent.
2752 2756
2753 2757 If one revision is given, it is used as the base revision.
2754 If two revisions are given, the difference between them is shown.
2758 If two revisions are given, the differences between them are
2759 shown.
2755 2760
2756 2761 The codes used to show the status of files are:
2757 2762 M = modified
2758 2763 A = added
2759 2764 R = removed
2760 2765 C = clean
2761 2766 ! = missing (deleted by non-hg command, but still tracked)
2762 2767 ? = not tracked
2763 2768 I = ignored
2764 = the previous added file was copied from here
2769 = origin of the previous file listed as A (added)
2765 2770 """
2766 2771
2767 2772 node1, node2 = cmdutil.revpair(repo, opts.get('rev'))
2768 2773 cwd = (pats and repo.getcwd()) or ''
2769 2774 end = opts.get('print0') and '\0' or '\n'
2770 2775 copy = {}
2771 2776 states = 'modified added removed deleted unknown ignored clean'.split()
2772 2777 show = [k for k in states if opts.get(k)]
2773 2778 if opts.get('all'):
2774 2779 show += ui.quiet and (states[:4] + ['clean']) or states
2775 2780 if not show:
2776 2781 show = ui.quiet and states[:4] or states[:5]
2777 2782
2778 2783 stat = repo.status(node1, node2, cmdutil.match(repo, pats, opts),
2779 2784 'ignored' in show, 'clean' in show, 'unknown' in show)
2780 2785 changestates = zip(states, 'MAR!?IC', stat)
2781 2786
2782 2787 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
2783 2788 ctxn = repo[nullid]
2784 2789 ctx1 = repo[node1]
2785 2790 ctx2 = repo[node2]
2786 2791 added = stat[1]
2787 2792 if node2 is None:
2788 2793 added = stat[0] + stat[1] # merged?
2789 2794
2790 2795 for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].iteritems():
2791 2796 if k in added:
2792 2797 copy[k] = v
2793 2798 elif v in added:
2794 2799 copy[v] = k
2795 2800
2796 2801 for state, char, files in changestates:
2797 2802 if state in show:
2798 2803 format = "%s %%s%s" % (char, end)
2799 2804 if opts.get('no_status'):
2800 2805 format = "%%s%s" % end
2801 2806
2802 2807 for f in files:
2803 2808 ui.write(format % repo.pathto(f, cwd))
2804 2809 if f in copy:
2805 2810 ui.write(' %s%s' % (repo.pathto(copy[f], cwd), end))
2806 2811
2807 2812 def tag(ui, repo, name1, *names, **opts):
2808 2813 """add one or more tags for the current or given revision
2809 2814
2810 2815 Name a particular revision using <name>.
2811 2816
2812 2817 Tags are used to name particular revisions of the repository and are
2813 2818 very useful to compare different revisions, to go back to significant
2814 2819 earlier versions or to mark branch points as releases, etc.
2815 2820
2816 2821 If no revision is given, the parent of the working directory is
2817 2822 used, or tip if no revision is checked out.
2818 2823
2819 2824 To facilitate version control, distribution, and merging of tags,
2820 2825 they are stored as a file named ".hgtags" which is managed
2821 2826 similarly to other project files and can be hand-edited if
2822 2827 necessary. The file '.hg/localtags' is used for local tags (not
2823 2828 shared among repositories).
2824 2829
2825 2830 See 'hg help dates' for a list of formats valid for -d/--date.
2826 2831 """
2827 2832
2828 2833 rev_ = "."
2829 2834 names = (name1,) + names
2830 2835 if len(names) != len(set(names)):
2831 2836 raise util.Abort(_('tag names must be unique'))
2832 2837 for n in names:
2833 2838 if n in ['tip', '.', 'null']:
2834 2839 raise util.Abort(_('the name \'%s\' is reserved') % n)
2835 2840 if opts.get('rev') and opts.get('remove'):
2836 2841 raise util.Abort(_("--rev and --remove are incompatible"))
2837 2842 if opts.get('rev'):
2838 2843 rev_ = opts['rev']
2839 2844 message = opts.get('message')
2840 2845 if opts.get('remove'):
2841 2846 expectedtype = opts.get('local') and 'local' or 'global'
2842 2847 for n in names:
2843 2848 if not repo.tagtype(n):
2844 2849 raise util.Abort(_('tag \'%s\' does not exist') % n)
2845 2850 if repo.tagtype(n) != expectedtype:
2846 2851 if expectedtype == 'global':
2847 2852 raise util.Abort(_('tag \'%s\' is not a global tag') % n)
2848 2853 else:
2849 2854 raise util.Abort(_('tag \'%s\' is not a local tag') % n)
2850 2855 rev_ = nullid
2851 2856 if not message:
2852 2857 message = _('Removed tag %s') % ', '.join(names)
2853 2858 elif not opts.get('force'):
2854 2859 for n in names:
2855 2860 if n in repo.tags():
2856 2861 raise util.Abort(_('tag \'%s\' already exists '
2857 2862 '(use -f to force)') % n)
2858 2863 if not rev_ and repo.dirstate.parents()[1] != nullid:
2859 2864 raise util.Abort(_('uncommitted merge - please provide a '
2860 2865 'specific revision'))
2861 2866 r = repo[rev_].node()
2862 2867
2863 2868 if not message:
2864 2869 message = (_('Added tag %s for changeset %s') %
2865 2870 (', '.join(names), short(r)))
2866 2871
2867 2872 date = opts.get('date')
2868 2873 if date:
2869 2874 date = util.parsedate(date)
2870 2875
2871 2876 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date)
2872 2877
2873 2878 def tags(ui, repo):
2874 2879 """list repository tags
2875 2880
2876 2881 This lists both regular and local tags. When the -v/--verbose
2877 2882 switch is used, a third column "local" is printed for local tags.
2878 2883 """
2879 2884
2880 2885 hexfunc = ui.debugflag and hex or short
2881 2886 tagtype = ""
2882 2887
2883 2888 for t, n in reversed(repo.tagslist()):
2884 2889 if ui.quiet:
2885 2890 ui.write("%s\n" % t)
2886 2891 continue
2887 2892
2888 2893 try:
2889 2894 hn = hexfunc(n)
2890 2895 r = "%5d:%s" % (repo.changelog.rev(n), hn)
2891 2896 except error.LookupError:
2892 2897 r = " ?:%s" % hn
2893 2898 else:
2894 2899 spaces = " " * (30 - encoding.colwidth(t))
2895 2900 if ui.verbose:
2896 2901 if repo.tagtype(t) == 'local':
2897 2902 tagtype = " local"
2898 2903 else:
2899 2904 tagtype = ""
2900 2905 ui.write("%s%s %s%s\n" % (t, spaces, r, tagtype))
2901 2906
2902 2907 def tip(ui, repo, **opts):
2903 2908 """show the tip revision
2904 2909
2905 The tip revision (usually just called the tip) is the most
2906 recently added changeset in the repository, the most recently
2907 changed head.
2910 The tip revision (usually just called the tip) is the changeset
2911 most recently added to the repository (and therefore the most
2912 recently changed head).
2908 2913
2909 2914 If you have just made a commit, that commit will be the tip. If
2910 2915 you have just pulled changes from another repository, the tip of
2911 2916 that repository becomes the current tip. The "tip" tag is special
2912 2917 and cannot be renamed or assigned to a different changeset.
2913 2918 """
2914 2919 cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1])
2915 2920
2916 2921 def unbundle(ui, repo, fname1, *fnames, **opts):
2917 2922 """apply one or more changegroup files
2918 2923
2919 2924 Apply one or more compressed changegroup files generated by the
2920 2925 bundle command.
2921 2926 """
2922 2927 fnames = (fname1,) + fnames
2923 2928
2924 2929 lock = repo.lock()
2925 2930 try:
2926 2931 for fname in fnames:
2927 2932 f = url.open(ui, fname)
2928 2933 gen = changegroup.readbundle(f, fname)
2929 2934 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
2930 2935 finally:
2931 2936 lock.release()
2932 2937
2933 2938 return postincoming(ui, repo, modheads, opts.get('update'), None)
2934 2939
2935 2940 def update(ui, repo, node=None, rev=None, clean=False, date=None):
2936 2941 """update working directory
2937 2942
2938 2943 Update the repository's working directory to the specified
2939 2944 revision, or the tip of the current branch if none is specified.
2940 2945 Use null as the revision to remove the working copy (like 'hg
2941 2946 clone -U').
2942 2947
2943 2948 When the working directory contains no uncommitted changes, it
2944 2949 will be replaced by the state of the requested revision from the
2945 2950 repository. When the requested revision is on a different branch,
2946 2951 the working directory will additionally be switched to that
2947 2952 branch.
2948 2953
2949 2954 When there are uncommitted changes, use option -C/--clean to
2950 2955 discard them, forcibly replacing the state of the working
2951 2956 directory with the requested revision.
2952 2957
2953 2958 When there are uncommitted changes and option -C/--clean is not
2954 2959 used, and the parent revision and requested revision are on the
2955 2960 same branch, and one of them is an ancestor of the other, then the
2956 2961 new working directory will contain the requested revision merged
2957 2962 with the uncommitted changes. Otherwise, the update will fail with
2958 2963 a suggestion to use 'merge' or 'update -C' instead.
2959 2964
2960 2965 If you want to update just one file to an older revision, use
2961 2966 revert.
2962 2967
2963 2968 See 'hg help dates' for a list of formats valid for -d/--date.
2964 2969 """
2965 2970 if rev and node:
2966 2971 raise util.Abort(_("please specify just one revision"))
2967 2972
2968 2973 if not rev:
2969 2974 rev = node
2970 2975
2971 2976 if date:
2972 2977 if rev:
2973 2978 raise util.Abort(_("you can't specify a revision and a date"))
2974 2979 rev = cmdutil.finddate(ui, repo, date)
2975 2980
2976 2981 if clean:
2977 2982 return hg.clean(repo, rev)
2978 2983 else:
2979 2984 return hg.update(repo, rev)
2980 2985
2981 2986 def verify(ui, repo):
2982 2987 """verify the integrity of the repository
2983 2988
2984 2989 Verify the integrity of the current repository.
2985 2990
2986 2991 This will perform an extensive check of the repository's
2987 2992 integrity, validating the hashes and checksums of each entry in
2988 2993 the changelog, manifest, and tracked files, as well as the
2989 2994 integrity of their crosslinks and indices.
2990 2995 """
2991 2996 return hg.verify(repo)
2992 2997
2993 2998 def version_(ui):
2994 2999 """output version and copyright information"""
2995 3000 ui.write(_("Mercurial Distributed SCM (version %s)\n")
2996 3001 % util.version())
2997 3002 ui.status(_(
2998 3003 "\nCopyright (C) 2005-2009 Matt Mackall <mpm@selenic.com> and others\n"
2999 3004 "This is free software; see the source for copying conditions. "
3000 3005 "There is NO\nwarranty; "
3001 3006 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
3002 3007 ))
3003 3008
3004 3009 # Command options and aliases are listed here, alphabetically
3005 3010
3006 3011 globalopts = [
3007 3012 ('R', 'repository', '',
3008 3013 _('repository root directory or symbolic path name')),
3009 3014 ('', 'cwd', '', _('change working directory')),
3010 3015 ('y', 'noninteractive', None,
3011 3016 _('do not prompt, assume \'yes\' for any required answers')),
3012 3017 ('q', 'quiet', None, _('suppress output')),
3013 3018 ('v', 'verbose', None, _('enable additional output')),
3014 3019 ('', 'config', [], _('set/override config option')),
3015 3020 ('', 'debug', None, _('enable debugging output')),
3016 3021 ('', 'debugger', None, _('start debugger')),
3017 3022 ('', 'encoding', encoding.encoding, _('set the charset encoding')),
3018 3023 ('', 'encodingmode', encoding.encodingmode,
3019 3024 _('set the charset encoding mode')),
3020 3025 ('', 'traceback', None, _('print traceback on exception')),
3021 3026 ('', 'time', None, _('time how long the command takes')),
3022 3027 ('', 'profile', None, _('print command execution profile')),
3023 3028 ('', 'version', None, _('output version information and exit')),
3024 3029 ('h', 'help', None, _('display help and exit')),
3025 3030 ]
3026 3031
3027 3032 dryrunopts = [('n', 'dry-run', None,
3028 3033 _('do not perform actions, just print output'))]
3029 3034
3030 3035 remoteopts = [
3031 3036 ('e', 'ssh', '', _('specify ssh command to use')),
3032 3037 ('', 'remotecmd', '', _('specify hg command to run on the remote side')),
3033 3038 ]
3034 3039
3035 3040 walkopts = [
3036 3041 ('I', 'include', [], _('include names matching the given patterns')),
3037 3042 ('X', 'exclude', [], _('exclude names matching the given patterns')),
3038 3043 ]
3039 3044
3040 3045 commitopts = [
3041 3046 ('m', 'message', '', _('use <text> as commit message')),
3042 3047 ('l', 'logfile', '', _('read commit message from <file>')),
3043 3048 ]
3044 3049
3045 3050 commitopts2 = [
3046 3051 ('d', 'date', '', _('record datecode as commit date')),
3047 3052 ('u', 'user', '', _('record the specified user as committer')),
3048 3053 ]
3049 3054
3050 3055 templateopts = [
3051 3056 ('', 'style', '', _('display using template map file')),
3052 3057 ('', 'template', '', _('display with template')),
3053 3058 ]
3054 3059
3055 3060 logopts = [
3056 3061 ('p', 'patch', None, _('show patch')),
3057 3062 ('g', 'git', None, _('use git extended diff format')),
3058 3063 ('l', 'limit', '', _('limit number of changes displayed')),
3059 3064 ('M', 'no-merges', None, _('do not show merges')),
3060 3065 ] + templateopts
3061 3066
3062 3067 diffopts = [
3063 3068 ('a', 'text', None, _('treat all files as text')),
3064 3069 ('g', 'git', None, _('use git extended diff format')),
3065 3070 ('', 'nodates', None, _("don't include dates in diff headers"))
3066 3071 ]
3067 3072
3068 3073 diffopts2 = [
3069 3074 ('p', 'show-function', None, _('show which function each change is in')),
3070 3075 ('w', 'ignore-all-space', None,
3071 3076 _('ignore white space when comparing lines')),
3072 3077 ('b', 'ignore-space-change', None,
3073 3078 _('ignore changes in the amount of white space')),
3074 3079 ('B', 'ignore-blank-lines', None,
3075 3080 _('ignore changes whose lines are all blank')),
3076 3081 ('U', 'unified', '', _('number of lines of context to show'))
3077 3082 ]
3078 3083
3079 3084 similarityopts = [
3080 3085 ('s', 'similarity', '',
3081 3086 _('guess renamed files by similarity (0<=s<=100)'))
3082 3087 ]
3083 3088
3084 3089 table = {
3085 3090 "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')),
3086 3091 "addremove":
3087 3092 (addremove, similarityopts + walkopts + dryrunopts,
3088 3093 _('[OPTION]... [FILE]...')),
3089 3094 "^annotate|blame":
3090 3095 (annotate,
3091 3096 [('r', 'rev', '', _('annotate the specified revision')),
3092 3097 ('f', 'follow', None, _('follow file copies and renames')),
3093 3098 ('a', 'text', None, _('treat all files as text')),
3094 3099 ('u', 'user', None, _('list the author (long with -v)')),
3095 3100 ('d', 'date', None, _('list the date (short with -q)')),
3096 3101 ('n', 'number', None, _('list the revision number (default)')),
3097 3102 ('c', 'changeset', None, _('list the changeset')),
3098 3103 ('l', 'line-number', None,
3099 3104 _('show line number at the first appearance'))
3100 3105 ] + walkopts,
3101 3106 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...')),
3102 3107 "archive":
3103 3108 (archive,
3104 3109 [('', 'no-decode', None, _('do not pass files through decoders')),
3105 3110 ('p', 'prefix', '', _('directory prefix for files in archive')),
3106 3111 ('r', 'rev', '', _('revision to distribute')),
3107 3112 ('t', 'type', '', _('type of distribution to create')),
3108 3113 ] + walkopts,
3109 3114 _('[OPTION]... DEST')),
3110 3115 "backout":
3111 3116 (backout,
3112 3117 [('', 'merge', None,
3113 3118 _('merge with old dirstate parent after backout')),
3114 3119 ('', 'parent', '', _('parent to choose when backing out merge')),
3115 3120 ('r', 'rev', '', _('revision to backout')),
3116 3121 ] + walkopts + commitopts + commitopts2,
3117 3122 _('[OPTION]... [-r] REV')),
3118 3123 "bisect":
3119 3124 (bisect,
3120 3125 [('r', 'reset', False, _('reset bisect state')),
3121 3126 ('g', 'good', False, _('mark changeset good')),
3122 3127 ('b', 'bad', False, _('mark changeset bad')),
3123 3128 ('s', 'skip', False, _('skip testing changeset')),
3124 3129 ('c', 'command', '', _('use command to check changeset state')),
3125 3130 ('U', 'noupdate', False, _('do not update to target'))],
3126 3131 _("[-gbsr] [-c CMD] [REV]")),
3127 3132 "branch":
3128 3133 (branch,
3129 3134 [('f', 'force', None,
3130 3135 _('set branch name even if it shadows an existing branch')),
3131 3136 ('C', 'clean', None, _('reset branch name to parent branch name'))],
3132 3137 _('[-fC] [NAME]')),
3133 3138 "branches":
3134 3139 (branches,
3135 3140 [('a', 'active', False,
3136 3141 _('show only branches that have unmerged heads'))],
3137 3142 _('[-a]')),
3138 3143 "bundle":
3139 3144 (bundle,
3140 3145 [('f', 'force', None,
3141 3146 _('run even when remote repository is unrelated')),
3142 3147 ('r', 'rev', [],
3143 3148 _('a changeset up to which you would like to bundle')),
3144 3149 ('', 'base', [],
3145 3150 _('a base changeset to specify instead of a destination')),
3146 3151 ('a', 'all', None, _('bundle all changesets in the repository')),
3147 3152 ('t', 'type', 'bzip2', _('bundle compression type to use')),
3148 3153 ] + remoteopts,
3149 3154 _('[-f] [-a] [-r REV]... [--base REV]... FILE [DEST]')),
3150 3155 "cat":
3151 3156 (cat,
3152 3157 [('o', 'output', '', _('print output to file with formatted name')),
3153 3158 ('r', 'rev', '', _('print the given revision')),
3154 3159 ('', 'decode', None, _('apply any matching decode filter')),
3155 3160 ] + walkopts,
3156 3161 _('[OPTION]... FILE...')),
3157 3162 "^clone":
3158 3163 (clone,
3159 3164 [('U', 'noupdate', None,
3160 3165 _('the clone will only contain a repository (no working copy)')),
3161 3166 ('r', 'rev', [],
3162 3167 _('a changeset you would like to have after cloning')),
3163 3168 ('', 'pull', None, _('use pull protocol to copy metadata')),
3164 3169 ('', 'uncompressed', None,
3165 3170 _('use uncompressed transfer (fast over LAN)')),
3166 3171 ] + remoteopts,
3167 3172 _('[OPTION]... SOURCE [DEST]')),
3168 3173 "^commit|ci":
3169 3174 (commit,
3170 3175 [('A', 'addremove', None,
3171 3176 _('mark new/missing files as added/removed before committing')),
3172 3177 ('', 'close-branch', None,
3173 3178 _('mark a branch as closed, hiding it from the branch list')),
3174 3179 ] + walkopts + commitopts + commitopts2,
3175 3180 _('[OPTION]... [FILE]...')),
3176 3181 "copy|cp":
3177 3182 (copy,
3178 3183 [('A', 'after', None, _('record a copy that has already occurred')),
3179 3184 ('f', 'force', None,
3180 3185 _('forcibly copy over an existing managed file')),
3181 3186 ] + walkopts + dryrunopts,
3182 3187 _('[OPTION]... [SOURCE]... DEST')),
3183 3188 "debugancestor": (debugancestor, [], _('[INDEX] REV1 REV2')),
3184 3189 "debugcheckstate": (debugcheckstate, []),
3185 3190 "debugcommands": (debugcommands, [], _('[COMMAND]')),
3186 3191 "debugcomplete":
3187 3192 (debugcomplete,
3188 3193 [('o', 'options', None, _('show the command options'))],
3189 3194 _('[-o] CMD')),
3190 3195 "debugdate":
3191 3196 (debugdate,
3192 3197 [('e', 'extended', None, _('try extended date formats'))],
3193 3198 _('[-e] DATE [RANGE]')),
3194 3199 "debugdata": (debugdata, [], _('FILE REV')),
3195 3200 "debugfsinfo": (debugfsinfo, [], _('[PATH]')),
3196 3201 "debugindex": (debugindex, [], _('FILE')),
3197 3202 "debugindexdot": (debugindexdot, [], _('FILE')),
3198 3203 "debuginstall": (debuginstall, []),
3199 3204 "debugrebuildstate":
3200 3205 (debugrebuildstate,
3201 3206 [('r', 'rev', '', _('revision to rebuild to'))],
3202 3207 _('[-r REV] [REV]')),
3203 3208 "debugrename":
3204 3209 (debugrename,
3205 3210 [('r', 'rev', '', _('revision to debug'))],
3206 3211 _('[-r REV] FILE')),
3207 3212 "debugsetparents":
3208 3213 (debugsetparents, [], _('REV1 [REV2]')),
3209 3214 "debugstate":
3210 3215 (debugstate,
3211 3216 [('', 'nodates', None, _('do not display the saved mtime'))],
3212 3217 _('[OPTION]...')),
3213 3218 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
3214 3219 "^diff":
3215 3220 (diff,
3216 3221 [('r', 'rev', [], _('revision')),
3217 3222 ('c', 'change', '', _('change made by revision'))
3218 3223 ] + diffopts + diffopts2 + walkopts,
3219 3224 _('[OPTION]... [-r REV1 [-r REV2]] [FILE]...')),
3220 3225 "^export":
3221 3226 (export,
3222 3227 [('o', 'output', '', _('print output to file with formatted name')),
3223 3228 ('', 'switch-parent', None, _('diff against the second parent'))
3224 3229 ] + diffopts,
3225 3230 _('[OPTION]... [-o OUTFILESPEC] REV...')),
3226 3231 "grep":
3227 3232 (grep,
3228 3233 [('0', 'print0', None, _('end fields with NUL')),
3229 3234 ('', 'all', None, _('print all revisions that match')),
3230 3235 ('f', 'follow', None,
3231 3236 _('follow changeset history, or file history across copies and renames')),
3232 3237 ('i', 'ignore-case', None, _('ignore case when matching')),
3233 3238 ('l', 'files-with-matches', None,
3234 3239 _('print only filenames and revisions that match')),
3235 3240 ('n', 'line-number', None, _('print matching line numbers')),
3236 3241 ('r', 'rev', [], _('search in given revision range')),
3237 3242 ('u', 'user', None, _('list the author (long with -v)')),
3238 3243 ('d', 'date', None, _('list the date (short with -q)')),
3239 3244 ] + walkopts,
3240 3245 _('[OPTION]... PATTERN [FILE]...')),
3241 3246 "heads":
3242 3247 (heads,
3243 3248 [('r', 'rev', '', _('show only heads which are descendants of REV')),
3244 3249 ('a', 'active', False,
3245 3250 _('show only the active heads from open branches')),
3246 3251 ('c', 'closed', False,
3247 3252 _('show normal and closed heads')),
3248 3253 ] + templateopts,
3249 3254 _('[-r REV] [REV]...')),
3250 3255 "help": (help_, [], _('[TOPIC]')),
3251 3256 "identify|id":
3252 3257 (identify,
3253 3258 [('r', 'rev', '', _('identify the specified revision')),
3254 3259 ('n', 'num', None, _('show local revision number')),
3255 3260 ('i', 'id', None, _('show global revision id')),
3256 3261 ('b', 'branch', None, _('show branch')),
3257 3262 ('t', 'tags', None, _('show tags'))],
3258 3263 _('[-nibt] [-r REV] [SOURCE]')),
3259 3264 "import|patch":
3260 3265 (import_,
3261 3266 [('p', 'strip', 1,
3262 3267 _('directory strip option for patch. This has the same '
3263 3268 'meaning as the corresponding patch option')),
3264 3269 ('b', 'base', '', _('base path')),
3265 3270 ('f', 'force', None,
3266 3271 _('skip check for outstanding uncommitted changes')),
3267 3272 ('', 'no-commit', None, _("don't commit, just update the working directory")),
3268 3273 ('', 'exact', None,
3269 3274 _('apply patch to the nodes from which it was generated')),
3270 3275 ('', 'import-branch', None,
3271 3276 _('use any branch information in patch (implied by --exact)'))] +
3272 3277 commitopts + commitopts2 + similarityopts,
3273 3278 _('[OPTION]... PATCH...')),
3274 3279 "incoming|in":
3275 3280 (incoming,
3276 3281 [('f', 'force', None,
3277 3282 _('run even when remote repository is unrelated')),
3278 3283 ('n', 'newest-first', None, _('show newest record first')),
3279 3284 ('', 'bundle', '', _('file to store the bundles into')),
3280 3285 ('r', 'rev', [],
3281 3286 _('a specific revision up to which you would like to pull')),
3282 3287 ] + logopts + remoteopts,
3283 3288 _('[-p] [-n] [-M] [-f] [-r REV]...'
3284 3289 ' [--bundle FILENAME] [SOURCE]')),
3285 3290 "^init":
3286 3291 (init,
3287 3292 remoteopts,
3288 3293 _('[-e CMD] [--remotecmd CMD] [DEST]')),
3289 3294 "locate":
3290 3295 (locate,
3291 3296 [('r', 'rev', '', _('search the repository as it stood at REV')),
3292 3297 ('0', 'print0', None,
3293 3298 _('end filenames with NUL, for use with xargs')),
3294 3299 ('f', 'fullpath', None,
3295 3300 _('print complete paths from the filesystem root')),
3296 3301 ] + walkopts,
3297 3302 _('[OPTION]... [PATTERN]...')),
3298 3303 "^log|history":
3299 3304 (log,
3300 3305 [('f', 'follow', None,
3301 3306 _('follow changeset history, or file history across copies and renames')),
3302 3307 ('', 'follow-first', None,
3303 3308 _('only follow the first parent of merge changesets')),
3304 3309 ('d', 'date', '', _('show revisions matching date spec')),
3305 3310 ('C', 'copies', None, _('show copied files')),
3306 3311 ('k', 'keyword', [], _('do case-insensitive search for a keyword')),
3307 3312 ('r', 'rev', [], _('show the specified revision or range')),
3308 3313 ('', 'removed', None, _('include revisions where files were removed')),
3309 3314 ('m', 'only-merges', None, _('show only merges')),
3310 3315 ('u', 'user', [], _('revisions committed by user')),
3311 3316 ('b', 'only-branch', [],
3312 3317 _('show only changesets within the given named branch')),
3313 3318 ('P', 'prune', [], _('do not display revision or any of its ancestors')),
3314 3319 ] + logopts + walkopts,
3315 3320 _('[OPTION]... [FILE]')),
3316 3321 "manifest":
3317 3322 (manifest,
3318 3323 [('r', 'rev', '', _('revision to display'))],
3319 3324 _('[-r REV]')),
3320 3325 "^merge":
3321 3326 (merge,
3322 3327 [('f', 'force', None, _('force a merge with outstanding changes')),
3323 3328 ('r', 'rev', '', _('revision to merge')),
3324 3329 ('S', 'show', None,
3325 3330 _('review revisions to merge (no merge is performed)'))],
3326 3331 _('[-f] [[-r] REV]')),
3327 3332 "outgoing|out":
3328 3333 (outgoing,
3329 3334 [('f', 'force', None,
3330 3335 _('run even when remote repository is unrelated')),
3331 3336 ('r', 'rev', [],
3332 3337 _('a specific revision up to which you would like to push')),
3333 3338 ('n', 'newest-first', None, _('show newest record first')),
3334 3339 ] + logopts + remoteopts,
3335 3340 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]')),
3336 3341 "^parents":
3337 3342 (parents,
3338 3343 [('r', 'rev', '', _('show parents from the specified revision')),
3339 3344 ] + templateopts,
3340 3345 _('[-r REV] [FILE]')),
3341 3346 "paths": (paths, [], _('[NAME]')),
3342 3347 "^pull":
3343 3348 (pull,
3344 3349 [('u', 'update', None,
3345 3350 _('update to new tip if changesets were pulled')),
3346 3351 ('f', 'force', None,
3347 3352 _('run even when remote repository is unrelated')),
3348 3353 ('r', 'rev', [],
3349 3354 _('a specific revision up to which you would like to pull')),
3350 3355 ] + remoteopts,
3351 3356 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
3352 3357 "^push":
3353 3358 (push,
3354 3359 [('f', 'force', None, _('force push')),
3355 3360 ('r', 'rev', [],
3356 3361 _('a specific revision up to which you would like to push')),
3357 3362 ] + remoteopts,
3358 3363 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]')),
3359 3364 "recover": (recover, []),
3360 3365 "^remove|rm":
3361 3366 (remove,
3362 3367 [('A', 'after', None, _('record delete for missing files')),
3363 3368 ('f', 'force', None,
3364 3369 _('remove (and delete) file even if added or modified')),
3365 3370 ] + walkopts,
3366 3371 _('[OPTION]... FILE...')),
3367 3372 "rename|mv":
3368 3373 (rename,
3369 3374 [('A', 'after', None, _('record a rename that has already occurred')),
3370 3375 ('f', 'force', None,
3371 3376 _('forcibly copy over an existing managed file')),
3372 3377 ] + walkopts + dryrunopts,
3373 3378 _('[OPTION]... SOURCE... DEST')),
3374 3379 "resolve":
3375 3380 (resolve,
3376 3381 [('a', 'all', None, _('remerge all unresolved files')),
3377 3382 ('l', 'list', None, _('list state of files needing merge')),
3378 3383 ('m', 'mark', None, _('mark files as resolved')),
3379 3384 ('u', 'unmark', None, _('unmark files as resolved'))]
3380 3385 + walkopts,
3381 3386 _('[OPTION]... [FILE]...')),
3382 3387 "revert":
3383 3388 (revert,
3384 3389 [('a', 'all', None, _('revert all changes when no arguments given')),
3385 3390 ('d', 'date', '', _('tipmost revision matching date')),
3386 3391 ('r', 'rev', '', _('revision to revert to')),
3387 3392 ('', 'no-backup', None, _('do not save backup copies of files')),
3388 3393 ] + walkopts + dryrunopts,
3389 3394 _('[OPTION]... [-r REV] [NAME]...')),
3390 3395 "rollback": (rollback, []),
3391 3396 "root": (root, []),
3392 3397 "^serve":
3393 3398 (serve,
3394 3399 [('A', 'accesslog', '', _('name of access log file to write to')),
3395 3400 ('d', 'daemon', None, _('run server in background')),
3396 3401 ('', 'daemon-pipefds', '', _('used internally by daemon mode')),
3397 3402 ('E', 'errorlog', '', _('name of error log file to write to')),
3398 3403 ('p', 'port', 0, _('port to listen on (default: 8000)')),
3399 3404 ('a', 'address', '', _('address to listen on (default: all interfaces)')),
3400 3405 ('', 'prefix', '', _('prefix path to serve from (default: server root)')),
3401 3406 ('n', 'name', '',
3402 3407 _('name to show in web pages (default: working directory)')),
3403 3408 ('', 'webdir-conf', '', _('name of the webdir config file'
3404 3409 ' (serve more than one repository)')),
3405 3410 ('', 'pid-file', '', _('name of file to write process ID to')),
3406 3411 ('', 'stdio', None, _('for remote clients')),
3407 3412 ('t', 'templates', '', _('web templates to use')),
3408 3413 ('', 'style', '', _('template style to use')),
3409 3414 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
3410 3415 ('', 'certificate', '', _('SSL certificate file'))],
3411 3416 _('[OPTION]...')),
3412 3417 "showconfig|debugconfig":
3413 3418 (showconfig,
3414 3419 [('u', 'untrusted', None, _('show untrusted configuration options'))],
3415 3420 _('[-u] [NAME]...')),
3416 3421 "^status|st":
3417 3422 (status,
3418 3423 [('A', 'all', None, _('show status of all files')),
3419 3424 ('m', 'modified', None, _('show only modified files')),
3420 3425 ('a', 'added', None, _('show only added files')),
3421 3426 ('r', 'removed', None, _('show only removed files')),
3422 3427 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
3423 3428 ('c', 'clean', None, _('show only files without changes')),
3424 3429 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
3425 3430 ('i', 'ignored', None, _('show only ignored files')),
3426 3431 ('n', 'no-status', None, _('hide status prefix')),
3427 3432 ('C', 'copies', None, _('show source of copied files')),
3428 3433 ('0', 'print0', None,
3429 3434 _('end filenames with NUL, for use with xargs')),
3430 3435 ('', 'rev', [], _('show difference from revision')),
3431 3436 ] + walkopts,
3432 3437 _('[OPTION]... [FILE]...')),
3433 3438 "tag":
3434 3439 (tag,
3435 3440 [('f', 'force', None, _('replace existing tag')),
3436 3441 ('l', 'local', None, _('make the tag local')),
3437 3442 ('r', 'rev', '', _('revision to tag')),
3438 3443 ('', 'remove', None, _('remove a tag')),
3439 3444 # -l/--local is already there, commitopts cannot be used
3440 3445 ('m', 'message', '', _('use <text> as commit message')),
3441 3446 ] + commitopts2,
3442 3447 _('[-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...')),
3443 3448 "tags": (tags, []),
3444 3449 "tip":
3445 3450 (tip,
3446 3451 [('p', 'patch', None, _('show patch')),
3447 3452 ('g', 'git', None, _('use git extended diff format')),
3448 3453 ] + templateopts,
3449 3454 _('[-p]')),
3450 3455 "unbundle":
3451 3456 (unbundle,
3452 3457 [('u', 'update', None,
3453 3458 _('update to new tip if changesets were unbundled'))],
3454 3459 _('[-u] FILE...')),
3455 3460 "^update|up|checkout|co":
3456 3461 (update,
3457 3462 [('C', 'clean', None, _('overwrite locally modified files (no backup)')),
3458 3463 ('d', 'date', '', _('tipmost revision matching date')),
3459 3464 ('r', 'rev', '', _('revision'))],
3460 3465 _('[-C] [-d DATE] [[-r] REV]')),
3461 3466 "verify": (verify, []),
3462 3467 "version": (version_, []),
3463 3468 }
3464 3469
3465 3470 norepo = ("clone init version help debugcommands debugcomplete debugdata"
3466 3471 " debugindex debugindexdot debugdate debuginstall debugfsinfo")
3467 3472 optionalrepo = ("identify paths serve showconfig debugancestor")
@@ -1,95 +1,95 b''
1 1 # should complain
2 2 abort: please specify a revision to backout
3 3 abort: please specify just one revision
4 4 # basic operation
5 5 adding a
6 6 reverting a
7 7 changeset 2:2929462c3dff backs out changeset 1:a820f4f40a57
8 8 a
9 9 # file that was removed is recreated
10 10 adding a
11 11 adding a
12 12 changeset 2:de31bdc76c0d backs out changeset 1:76862dcce372
13 13 content
14 14 # backout of backout is as if nothing happened
15 15 removing a
16 16 changeset 3:7f6d0f120113 backs out changeset 2:de31bdc76c0d
17 17 cat: a: No such file or directory
18 18 # across branch
19 19 adding a
20 20 adding b
21 21 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
22 abort: cannot back out change on a different branch
22 abort: cannot backout change on a different branch
23 23 adding c
24 24 created new head
25 abort: cannot back out change on a different branch
25 abort: cannot backout change on a different branch
26 26 # backout with merge
27 27 adding a
28 28 reverting a
29 29 created new head
30 30 changeset 3:26b8ccb9ad91 backs out changeset 1:5a50a024c182
31 31 merging with changeset 3:26b8ccb9ad91
32 32 merging a
33 33 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
34 34 (branch merge, don't forget to commit)
35 35 line 1
36 36 line 2
37 37 line 3
38 38 # backout should not back out subsequent changesets
39 39 adding a
40 40 adding b
41 41 reverting a
42 42 created new head
43 43 changeset 3:3202beb76721 backs out changeset 1:22bca4c721e5
44 44 the backout changeset is a new head - do not forget to merge
45 45 (use "backout --merge" if you want to auto-merge)
46 46 b
47 47 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
48 48 adding a
49 49 adding b
50 50 adding c
51 51 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
52 52 adding d
53 53 created new head
54 54 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 55 (branch merge, don't forget to commit)
56 56 # backout of merge should fail
57 abort: cannot back out a merge changeset without --parent
57 abort: cannot backout a merge changeset without --parent
58 58 # backout of merge with bad parent should fail
59 59 abort: cb9a9f314b8b is not a parent of b2f3bb92043e
60 60 # backout of non-merge with parent should fail
61 61 abort: cannot use --parent on non-merge changeset
62 62 # backout with valid parent should be ok
63 63 removing d
64 64 changeset 5:10e5328c8435 backs out changeset 4:b2f3bb92043e
65 65 rolling back last transaction
66 66 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
67 67 removing c
68 68 changeset 5:033590168430 backs out changeset 4:b2f3bb92043e
69 69 # named branches
70 70 adding default
71 71 marked working directory as branch branch1
72 72 adding file1
73 73 marked working directory as branch branch2
74 74 adding file2
75 75 removing file1
76 76 created new head
77 77 changeset 3:d4e8f6db59fb backs out changeset 1:bf1602f437f3
78 78 the backout changeset is a new head - do not forget to merge
79 79 (use "backout --merge" if you want to auto-merge)
80 80 % on branch2 with branch1 not merged, so file1 should still exist:
81 81 45bbcd363bf0 (branch2)
82 82 C default
83 83 C file1
84 84 C file2
85 85 % on branch2 with branch1 merged, so file1 should be gone:
86 86 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
87 87 (branch merge, don't forget to commit)
88 88 22149cdde76d (branch2) tip
89 89 C default
90 90 C file2
91 91 % on branch1, so no file1 and file2:
92 92 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
93 93 bf1602f437f3 (branch1)
94 94 C default
95 95 C file1
@@ -1,278 +1,278 b''
1 1 adding a
2 2 adding b
3 3 updating working directory
4 4 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
5 5 pulling from ../b
6 6 searching for changes
7 7 warning: repository is unrelated
8 8 adding changesets
9 9 adding manifests
10 10 adding file changes
11 11 added 1 changesets with 1 changes to 1 files (+1 heads)
12 12 (run 'hg heads' to see heads, 'hg merge' to merge)
13 13 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
14 14 (branch merge, don't forget to commit)
15 15 %% -R/--repository
16 16 changeset: 0:8580ff50825a
17 17 tag: tip
18 18 user: test
19 19 date: Thu Jan 01 00:00:01 1970 +0000
20 20 summary: a
21 21
22 22 changeset: 0:b6c483daf290
23 23 tag: tip
24 24 user: test
25 25 date: Thu Jan 01 00:00:01 1970 +0000
26 26 summary: b
27 27
28 28 %% implicit -R
29 29 0: a
30 30 0: a
31 31 abort: There is no Mercurial repository here (.hg not found)!
32 32 abort: a/a not under root
33 33 abort: There is no Mercurial repository here (.hg not found)!
34 34 %% abbrev of long option
35 35 changeset: 1:b6c483daf290
36 36 tag: tip
37 37 parent: -1:000000000000
38 38 user: test
39 39 date: Thu Jan 01 00:00:01 1970 +0000
40 40 summary: b
41 41
42 42 %% earlygetopt with duplicate options (36d23de02da1)
43 43 changeset: 1:b6c483daf290
44 44 tag: tip
45 45 parent: -1:000000000000
46 46 user: test
47 47 date: Thu Jan 01 00:00:01 1970 +0000
48 48 summary: b
49 49
50 50 changeset: 0:8580ff50825a
51 51 tag: tip
52 52 user: test
53 53 date: Thu Jan 01 00:00:01 1970 +0000
54 54 summary: a
55 55
56 56 %% earlygetopt short option without following space
57 57 0:b6c483daf290
58 58 %% earlygetopt with illegal abbreviations
59 59 abort: Option --config may not be abbreviated!
60 60 abort: Option --cwd may not be abbreviated!
61 61 abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo!
62 62 abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo!
63 63 abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo!
64 64 abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo!
65 65 %% --cwd
66 66 changeset: 0:8580ff50825a
67 67 tag: tip
68 68 user: test
69 69 date: Thu Jan 01 00:00:01 1970 +0000
70 70 summary: a
71 71
72 72 %% -y/--noninteractive - just be sure it is parsed
73 73 0:8580ff50825a
74 74 0:8580ff50825a
75 75 %% -q/--quiet
76 76 0:8580ff50825a
77 77 0:b6c483daf290
78 78 0:8580ff50825a
79 79 1:b6c483daf290
80 80 %% -v/--verbose
81 81 changeset: 1:b6c483daf290
82 82 tag: tip
83 83 parent: -1:000000000000
84 84 user: test
85 85 date: Thu Jan 01 00:00:01 1970 +0000
86 86 files: b
87 87 description:
88 88 b
89 89
90 90
91 91 changeset: 0:8580ff50825a
92 92 user: test
93 93 date: Thu Jan 01 00:00:01 1970 +0000
94 94 files: a
95 95 description:
96 96 a
97 97
98 98
99 99 changeset: 0:b6c483daf290
100 100 tag: tip
101 101 user: test
102 102 date: Thu Jan 01 00:00:01 1970 +0000
103 103 files: b
104 104 description:
105 105 b
106 106
107 107
108 108 %% --config
109 109 quuxfoo
110 110 abort: malformed --config option:
111 111 abort: malformed --config option: a.b
112 112 abort: malformed --config option: a
113 113 abort: malformed --config option: a.=
114 114 abort: malformed --config option: .b=
115 115 %% --debug
116 116 changeset: 1:b6c483daf2907ce5825c0bb50f5716226281cc1a
117 117 tag: tip
118 118 parent: -1:0000000000000000000000000000000000000000
119 119 parent: -1:0000000000000000000000000000000000000000
120 120 manifest: 1:23226e7a252cacdc2d99e4fbdc3653441056de49
121 121 user: test
122 122 date: Thu Jan 01 00:00:01 1970 +0000
123 123 files+: b
124 124 extra: branch=default
125 125 description:
126 126 b
127 127
128 128
129 129 changeset: 0:8580ff50825a50c8f716709acdf8de0deddcd6ab
130 130 parent: -1:0000000000000000000000000000000000000000
131 131 parent: -1:0000000000000000000000000000000000000000
132 132 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
133 133 user: test
134 134 date: Thu Jan 01 00:00:01 1970 +0000
135 135 files+: a
136 136 extra: branch=default
137 137 description:
138 138 a
139 139
140 140
141 141 %% --traceback
142 142 Traceback (most recent call last):
143 143 %% --time
144 144 Time: real x.x secs (user x.x+x.x sys x.x+x.x)
145 145 %% --version
146 146 Mercurial Distributed SCM (version xxx)
147 147 %% -h/--help
148 148 Mercurial Distributed SCM
149 149
150 150 list of commands:
151 151
152 152 add add the specified files on the next commit
153 153 addremove add all new files, delete all missing files
154 annotate show changeset information per file line
155 archive create unversioned archive of a repository revision
154 annotate show changeset information by line for each file
155 archive create an unversioned archive of a repository revision
156 156 backout reverse effect of earlier changeset
157 157 bisect subdivision search of changesets
158 158 branch set or show the current branch name
159 159 branches list repository named branches
160 160 bundle create a changegroup file
161 161 cat output the current or given revision of files
162 162 clone make a copy of an existing repository
163 163 commit commit the specified files or all outstanding changes
164 164 copy mark files as copied for the next commit
165 165 diff diff repository (or selected files)
166 166 export dump the header and diffs for one or more changesets
167 167 grep search for a pattern in specified files and revisions
168 168 heads show current repository heads or show branch heads
169 169 help show help for a given topic or a help overview
170 170 identify identify the working copy or specified revision
171 171 import import an ordered set of patches
172 172 incoming show new changesets found in source
173 173 init create a new repository in the given directory
174 174 locate locate files matching specific patterns
175 175 log show revision history of entire repository or files
176 176 manifest output the current or given revision of the project manifest
177 177 merge merge working directory with another revision
178 178 outgoing show changesets not found in destination
179 179 parents show the parents of the working directory or revision
180 180 paths show aliases for remote repositories
181 181 pull pull changes from the specified source
182 182 push push changes to the specified destination
183 183 recover roll back an interrupted transaction
184 184 remove remove the specified files on the next commit
185 185 rename rename files; equivalent of copy + remove
186 186 resolve retry file merges from a merge or update
187 187 revert restore individual files or directories to an earlier state
188 188 rollback roll back the last transaction
189 189 root print the root (top) of the current working directory
190 190 serve export the repository via HTTP
191 191 showconfig show combined config settings from all hgrc files
192 192 status show changed files in the working directory
193 193 tag add one or more tags for the current or given revision
194 194 tags list repository tags
195 195 tip show the tip revision
196 196 unbundle apply one or more changegroup files
197 197 update update working directory
198 198 verify verify the integrity of the repository
199 199 version output version and copyright information
200 200
201 201 additional help topics:
202 202
203 203 dates Date Formats
204 204 patterns File Name Patterns
205 205 environment Environment Variables
206 206 revisions Specifying Single Revisions
207 207 multirevs Specifying Multiple Revisions
208 208 diffs Diff Formats
209 209 templating Template Usage
210 210 urls URL Paths
211 211
212 212 use "hg -v help" to show aliases and global options
213 213 Mercurial Distributed SCM
214 214
215 215 list of commands:
216 216
217 217 add add the specified files on the next commit
218 218 addremove add all new files, delete all missing files
219 annotate show changeset information per file line
220 archive create unversioned archive of a repository revision
219 annotate show changeset information by line for each file
220 archive create an unversioned archive of a repository revision
221 221 backout reverse effect of earlier changeset
222 222 bisect subdivision search of changesets
223 223 branch set or show the current branch name
224 224 branches list repository named branches
225 225 bundle create a changegroup file
226 226 cat output the current or given revision of files
227 227 clone make a copy of an existing repository
228 228 commit commit the specified files or all outstanding changes
229 229 copy mark files as copied for the next commit
230 230 diff diff repository (or selected files)
231 231 export dump the header and diffs for one or more changesets
232 232 grep search for a pattern in specified files and revisions
233 233 heads show current repository heads or show branch heads
234 234 help show help for a given topic or a help overview
235 235 identify identify the working copy or specified revision
236 236 import import an ordered set of patches
237 237 incoming show new changesets found in source
238 238 init create a new repository in the given directory
239 239 locate locate files matching specific patterns
240 240 log show revision history of entire repository or files
241 241 manifest output the current or given revision of the project manifest
242 242 merge merge working directory with another revision
243 243 outgoing show changesets not found in destination
244 244 parents show the parents of the working directory or revision
245 245 paths show aliases for remote repositories
246 246 pull pull changes from the specified source
247 247 push push changes to the specified destination
248 248 recover roll back an interrupted transaction
249 249 remove remove the specified files on the next commit
250 250 rename rename files; equivalent of copy + remove
251 251 resolve retry file merges from a merge or update
252 252 revert restore individual files or directories to an earlier state
253 253 rollback roll back the last transaction
254 254 root print the root (top) of the current working directory
255 255 serve export the repository via HTTP
256 256 showconfig show combined config settings from all hgrc files
257 257 status show changed files in the working directory
258 258 tag add one or more tags for the current or given revision
259 259 tags list repository tags
260 260 tip show the tip revision
261 261 unbundle apply one or more changegroup files
262 262 update update working directory
263 263 verify verify the integrity of the repository
264 264 version output version and copyright information
265 265
266 266 additional help topics:
267 267
268 268 dates Date Formats
269 269 patterns File Name Patterns
270 270 environment Environment Variables
271 271 revisions Specifying Single Revisions
272 272 multirevs Specifying Multiple Revisions
273 273 diffs Diff Formats
274 274 templating Template Usage
275 275 urls URL Paths
276 276
277 277 use "hg -v help" to show aliases and global options
278 278 %% not tested: --debugger
@@ -1,343 +1,344 b''
1 1 Mercurial Distributed SCM
2 2
3 3 basic commands:
4 4
5 5 add add the specified files on the next commit
6 annotate show changeset information per file line
6 annotate show changeset information by line for each file
7 7 clone make a copy of an existing repository
8 8 commit commit the specified files or all outstanding changes
9 9 diff diff repository (or selected files)
10 10 export dump the header and diffs for one or more changesets
11 11 init create a new repository in the given directory
12 12 log show revision history of entire repository or files
13 13 merge merge working directory with another revision
14 14 parents show the parents of the working directory or revision
15 15 pull pull changes from the specified source
16 16 push push changes to the specified destination
17 17 remove remove the specified files on the next commit
18 18 serve export the repository via HTTP
19 19 status show changed files in the working directory
20 20 update update working directory
21 21
22 22 use "hg help" for the full list of commands or "hg -v" for details
23 23 add add the specified files on the next commit
24 annotate show changeset information per file line
24 annotate show changeset information by line for each file
25 25 clone make a copy of an existing repository
26 26 commit commit the specified files or all outstanding changes
27 27 diff diff repository (or selected files)
28 28 export dump the header and diffs for one or more changesets
29 29 init create a new repository in the given directory
30 30 log show revision history of entire repository or files
31 31 merge merge working directory with another revision
32 32 parents show the parents of the working directory or revision
33 33 pull pull changes from the specified source
34 34 push push changes to the specified destination
35 35 remove remove the specified files on the next commit
36 36 serve export the repository via HTTP
37 37 status show changed files in the working directory
38 38 update update working directory
39 39 Mercurial Distributed SCM
40 40
41 41 list of commands:
42 42
43 43 add add the specified files on the next commit
44 44 addremove add all new files, delete all missing files
45 annotate show changeset information per file line
46 archive create unversioned archive of a repository revision
45 annotate show changeset information by line for each file
46 archive create an unversioned archive of a repository revision
47 47 backout reverse effect of earlier changeset
48 48 bisect subdivision search of changesets
49 49 branch set or show the current branch name
50 50 branches list repository named branches
51 51 bundle create a changegroup file
52 52 cat output the current or given revision of files
53 53 clone make a copy of an existing repository
54 54 commit commit the specified files or all outstanding changes
55 55 copy mark files as copied for the next commit
56 56 diff diff repository (or selected files)
57 57 export dump the header and diffs for one or more changesets
58 58 grep search for a pattern in specified files and revisions
59 59 heads show current repository heads or show branch heads
60 60 help show help for a given topic or a help overview
61 61 identify identify the working copy or specified revision
62 62 import import an ordered set of patches
63 63 incoming show new changesets found in source
64 64 init create a new repository in the given directory
65 65 locate locate files matching specific patterns
66 66 log show revision history of entire repository or files
67 67 manifest output the current or given revision of the project manifest
68 68 merge merge working directory with another revision
69 69 outgoing show changesets not found in destination
70 70 parents show the parents of the working directory or revision
71 71 paths show aliases for remote repositories
72 72 pull pull changes from the specified source
73 73 push push changes to the specified destination
74 74 recover roll back an interrupted transaction
75 75 remove remove the specified files on the next commit
76 76 rename rename files; equivalent of copy + remove
77 77 resolve retry file merges from a merge or update
78 78 revert restore individual files or directories to an earlier state
79 79 rollback roll back the last transaction
80 80 root print the root (top) of the current working directory
81 81 serve export the repository via HTTP
82 82 showconfig show combined config settings from all hgrc files
83 83 status show changed files in the working directory
84 84 tag add one or more tags for the current or given revision
85 85 tags list repository tags
86 86 tip show the tip revision
87 87 unbundle apply one or more changegroup files
88 88 update update working directory
89 89 verify verify the integrity of the repository
90 90 version output version and copyright information
91 91
92 92 additional help topics:
93 93
94 94 dates Date Formats
95 95 patterns File Name Patterns
96 96 environment Environment Variables
97 97 revisions Specifying Single Revisions
98 98 multirevs Specifying Multiple Revisions
99 99 diffs Diff Formats
100 100 templating Template Usage
101 101 urls URL Paths
102 102
103 103 use "hg -v help" to show aliases and global options
104 104 add add the specified files on the next commit
105 105 addremove add all new files, delete all missing files
106 annotate show changeset information per file line
107 archive create unversioned archive of a repository revision
106 annotate show changeset information by line for each file
107 archive create an unversioned archive of a repository revision
108 108 backout reverse effect of earlier changeset
109 109 bisect subdivision search of changesets
110 110 branch set or show the current branch name
111 111 branches list repository named branches
112 112 bundle create a changegroup file
113 113 cat output the current or given revision of files
114 114 clone make a copy of an existing repository
115 115 commit commit the specified files or all outstanding changes
116 116 copy mark files as copied for the next commit
117 117 diff diff repository (or selected files)
118 118 export dump the header and diffs for one or more changesets
119 119 grep search for a pattern in specified files and revisions
120 120 heads show current repository heads or show branch heads
121 121 help show help for a given topic or a help overview
122 122 identify identify the working copy or specified revision
123 123 import import an ordered set of patches
124 124 incoming show new changesets found in source
125 125 init create a new repository in the given directory
126 126 locate locate files matching specific patterns
127 127 log show revision history of entire repository or files
128 128 manifest output the current or given revision of the project manifest
129 129 merge merge working directory with another revision
130 130 outgoing show changesets not found in destination
131 131 parents show the parents of the working directory or revision
132 132 paths show aliases for remote repositories
133 133 pull pull changes from the specified source
134 134 push push changes to the specified destination
135 135 recover roll back an interrupted transaction
136 136 remove remove the specified files on the next commit
137 137 rename rename files; equivalent of copy + remove
138 138 resolve retry file merges from a merge or update
139 139 revert restore individual files or directories to an earlier state
140 140 rollback roll back the last transaction
141 141 root print the root (top) of the current working directory
142 142 serve export the repository via HTTP
143 143 showconfig show combined config settings from all hgrc files
144 144 status show changed files in the working directory
145 145 tag add one or more tags for the current or given revision
146 146 tags list repository tags
147 147 tip show the tip revision
148 148 unbundle apply one or more changegroup files
149 149 update update working directory
150 150 verify verify the integrity of the repository
151 151 version output version and copyright information
152 152
153 153 additional help topics:
154 154
155 155 dates Date Formats
156 156 patterns File Name Patterns
157 157 environment Environment Variables
158 158 revisions Specifying Single Revisions
159 159 multirevs Specifying Multiple Revisions
160 160 diffs Diff Formats
161 161 templating Template Usage
162 162 urls URL Paths
163 163 hg add [OPTION]... [FILE]...
164 164
165 165 add the specified files on the next commit
166 166
167 167 Schedule files to be version controlled and added to the
168 168 repository.
169 169
170 170 The files will be added to the repository at the next commit. To
171 171 undo an add before that, see hg revert.
172 172
173 173 If no names are given, add all files to the repository.
174 174
175 175 options:
176 176
177 177 -I --include include names matching the given patterns
178 178 -X --exclude exclude names matching the given patterns
179 179 -n --dry-run do not perform actions, just print output
180 180
181 181 use "hg -v help add" to show global options
182 182 hg add: option --skjdfks not recognized
183 183 hg add [OPTION]... [FILE]...
184 184
185 185 add the specified files on the next commit
186 186
187 187 Schedule files to be version controlled and added to the
188 188 repository.
189 189
190 190 The files will be added to the repository at the next commit. To
191 191 undo an add before that, see hg revert.
192 192
193 193 If no names are given, add all files to the repository.
194 194
195 195 options:
196 196
197 197 -I --include include names matching the given patterns
198 198 -X --exclude exclude names matching the given patterns
199 199 -n --dry-run do not perform actions, just print output
200 200
201 201 use "hg -v help add" to show global options
202 202 hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]...
203 203
204 204 diff repository (or selected files)
205 205
206 206 Show differences between revisions for the specified files.
207 207
208 208 Differences between files are shown using the unified diff format.
209 209
210 210 NOTE: diff may generate unexpected results for merges, as it will
211 211 default to comparing against the working directory's first parent
212 212 changeset if no revisions are specified.
213 213
214 214 When two revision arguments are given, then changes are shown
215 215 between those revisions. If only one revision is specified then
216 216 that revision is compared to the working directory, and, when no
217 217 revisions are specified, the working directory files are compared
218 218 to its parent.
219 219
220 220 Without the -a/--text option, diff will avoid generating diffs of
221 221 files it detects as binary. With -a, diff will generate a diff
222 222 anyway, probably with undesirable results.
223 223
224 224 Use the -g/--git option to generate diffs in the git extended diff
225 225 format. For more information, read 'hg help diffs'.
226 226
227 227 options:
228 228
229 229 -r --rev revision
230 230 -c --change change made by revision
231 231 -a --text treat all files as text
232 232 -g --git use git extended diff format
233 233 --nodates don't include dates in diff headers
234 234 -p --show-function show which function each change is in
235 235 -w --ignore-all-space ignore white space when comparing lines
236 236 -b --ignore-space-change ignore changes in the amount of white space
237 237 -B --ignore-blank-lines ignore changes whose lines are all blank
238 238 -U --unified number of lines of context to show
239 239 -I --include include names matching the given patterns
240 240 -X --exclude exclude names matching the given patterns
241 241
242 242 use "hg -v help diff" to show global options
243 243 hg status [OPTION]... [FILE]...
244 244
245 245 aliases: st
246 246
247 247 show changed files in the working directory
248 248
249 249 Show status of files in the repository. If names are given, only
250 250 files that match are shown. Files that are clean or ignored or
251 source of a copy/move operation, are not listed unless -c/--clean,
252 -i/--ignored, -C/--copies or -A/--all is given. Unless options
253 described with "show only ..." are given, the options -mardu are
254 used.
251 the source of a copy/move operation, are not listed unless
252 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
253 Unless options described with "show only ..." are given, the
254 options -mardu are used.
255 255
256 256 Option -q/--quiet hides untracked (unknown and ignored) files
257 257 unless explicitly requested with -u/--unknown or -i/--ignored.
258 258
259 259 NOTE: status may appear to disagree with diff if permissions have
260 260 changed or a merge has occurred. The standard diff format does not
261 261 report permission changes and diff only reports changes relative
262 262 to one merge parent.
263 263
264 264 If one revision is given, it is used as the base revision.
265 If two revisions are given, the difference between them is shown.
265 If two revisions are given, the differences between them are
266 shown.
266 267
267 268 The codes used to show the status of files are:
268 269 M = modified
269 270 A = added
270 271 R = removed
271 272 C = clean
272 273 ! = missing (deleted by non-hg command, but still tracked)
273 274 ? = not tracked
274 275 I = ignored
275 = the previous added file was copied from here
276 = origin of the previous file listed as A (added)
276 277
277 278 options:
278 279
279 280 -A --all show status of all files
280 281 -m --modified show only modified files
281 282 -a --added show only added files
282 283 -r --removed show only removed files
283 284 -d --deleted show only deleted (but tracked) files
284 285 -c --clean show only files without changes
285 286 -u --unknown show only unknown (not tracked) files
286 287 -i --ignored show only ignored files
287 288 -n --no-status hide status prefix
288 289 -C --copies show source of copied files
289 290 -0 --print0 end filenames with NUL, for use with xargs
290 291 --rev show difference from revision
291 292 -I --include include names matching the given patterns
292 293 -X --exclude exclude names matching the given patterns
293 294
294 295 use "hg -v help status" to show global options
295 296 hg status [OPTION]... [FILE]...
296 297
297 298 show changed files in the working directory
298 299 hg: unknown command 'foo'
299 300 Mercurial Distributed SCM
300 301
301 302 basic commands:
302 303
303 304 add add the specified files on the next commit
304 annotate show changeset information per file line
305 annotate show changeset information by line for each file
305 306 clone make a copy of an existing repository
306 307 commit commit the specified files or all outstanding changes
307 308 diff diff repository (or selected files)
308 309 export dump the header and diffs for one or more changesets
309 310 init create a new repository in the given directory
310 311 log show revision history of entire repository or files
311 312 merge merge working directory with another revision
312 313 parents show the parents of the working directory or revision
313 314 pull pull changes from the specified source
314 315 push push changes to the specified destination
315 316 remove remove the specified files on the next commit
316 317 serve export the repository via HTTP
317 318 status show changed files in the working directory
318 319 update update working directory
319 320
320 321 use "hg help" for the full list of commands or "hg -v" for details
321 322 hg: unknown command 'skjdfks'
322 323 Mercurial Distributed SCM
323 324
324 325 basic commands:
325 326
326 327 add add the specified files on the next commit
327 annotate show changeset information per file line
328 annotate show changeset information by line for each file
328 329 clone make a copy of an existing repository
329 330 commit commit the specified files or all outstanding changes
330 331 diff diff repository (or selected files)
331 332 export dump the header and diffs for one or more changesets
332 333 init create a new repository in the given directory
333 334 log show revision history of entire repository or files
334 335 merge merge working directory with another revision
335 336 parents show the parents of the working directory or revision
336 337 pull pull changes from the specified source
337 338 push push changes to the specified destination
338 339 remove remove the specified files on the next commit
339 340 serve export the repository via HTTP
340 341 status show changed files in the working directory
341 342 update update working directory
342 343
343 344 use "hg help" for the full list of commands or "hg -v" for details
@@ -1,208 +1,208 b''
1 1 % help (no mq, so no qrecord)
2 2 hg: unknown command 'qrecord'
3 3 Mercurial Distributed SCM
4 4
5 5 basic commands:
6 6
7 7 add add the specified files on the next commit
8 annotate show changeset information per file line
8 annotate show changeset information by line for each file
9 9 clone make a copy of an existing repository
10 10 commit commit the specified files or all outstanding changes
11 11 diff diff repository (or selected files)
12 12 export dump the header and diffs for one or more changesets
13 13 init create a new repository in the given directory
14 14 log show revision history of entire repository or files
15 15 merge merge working directory with another revision
16 16 parents show the parents of the working directory or revision
17 17 pull pull changes from the specified source
18 18 push push changes to the specified destination
19 19 remove remove the specified files on the next commit
20 20 serve export the repository via HTTP
21 21 status show changed files in the working directory
22 22 update update working directory
23 23
24 24 use "hg help" for the full list of commands or "hg -v" for details
25 25 % help (mq present)
26 26 hg qrecord [OPTION]... PATCH [FILE]...
27 27
28 28 interactively record a new patch
29 29
30 30 See 'hg help qnew' & 'hg help record' for more information and
31 31 usage.
32 32
33 33 options:
34 34
35 35 -e --edit edit commit message
36 36 -g --git use git extended diff format
37 37 -U --currentuser add "From: <current user>" to patch
38 38 -u --user add "From: <given user>" to patch
39 39 -D --currentdate add "Date: <current date>" to patch
40 40 -d --date add "Date: <given date>" to patch
41 41 -I --include include names matching the given patterns
42 42 -X --exclude exclude names matching the given patterns
43 43 -m --message use <text> as commit message
44 44 -l --logfile read commit message from <file>
45 45
46 46 use "hg -v help qrecord" to show global options
47 47 % base commit
48 48 % changing files
49 49 % whole diff
50 50 diff -r 1057167b20ef 1.txt
51 51 --- a/1.txt
52 52 +++ b/1.txt
53 53 @@ -1,5 +1,5 @@
54 54 1
55 55 -2
56 56 +2 2
57 57 3
58 58 -4
59 59 +4 4
60 60 5
61 61 diff -r 1057167b20ef 2.txt
62 62 --- a/2.txt
63 63 +++ b/2.txt
64 64 @@ -1,5 +1,5 @@
65 65 a
66 66 -b
67 67 +b b
68 68 c
69 69 d
70 70 e
71 71 diff -r 1057167b20ef dir/a.txt
72 72 --- a/dir/a.txt
73 73 +++ b/dir/a.txt
74 74 @@ -1,4 +1,4 @@
75 75 -hello world
76 76 +hello world!
77 77
78 78 someone
79 79 up
80 80 % qrecord a.patch
81 81 diff --git a/1.txt b/1.txt
82 82 2 hunks, 4 lines changed
83 83 examine changes to '1.txt'? [Ynsfdaq?] @@ -1,3 +1,3 @@
84 84 1
85 85 -2
86 86 +2 2
87 87 3
88 88 record change 1/6 to '1.txt'? [Ynsfdaq?] @@ -3,3 +3,3 @@
89 89 3
90 90 -4
91 91 +4 4
92 92 5
93 93 record change 2/6 to '1.txt'? [Ynsfdaq?] diff --git a/2.txt b/2.txt
94 94 1 hunks, 2 lines changed
95 95 examine changes to '2.txt'? [Ynsfdaq?] @@ -1,5 +1,5 @@
96 96 a
97 97 -b
98 98 +b b
99 99 c
100 100 d
101 101 e
102 102 record change 4/6 to '2.txt'? [Ynsfdaq?] diff --git a/dir/a.txt b/dir/a.txt
103 103 1 hunks, 2 lines changed
104 104 examine changes to 'dir/a.txt'? [Ynsfdaq?]
105 105 % after qrecord a.patch 'tip'
106 106 changeset: 1:5d1ca63427ee
107 107 tag: qtip
108 108 tag: tip
109 109 tag: a.patch
110 110 tag: qbase
111 111 user: test
112 112 date: Thu Jan 01 00:00:00 1970 +0000
113 113 summary: aaa
114 114
115 115 diff -r 1057167b20ef -r 5d1ca63427ee 1.txt
116 116 --- a/1.txt Thu Jan 01 00:00:00 1970 +0000
117 117 +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000
118 118 @@ -1,5 +1,5 @@
119 119 1
120 120 -2
121 121 +2 2
122 122 3
123 123 4
124 124 5
125 125 diff -r 1057167b20ef -r 5d1ca63427ee 2.txt
126 126 --- a/2.txt Thu Jan 01 00:00:00 1970 +0000
127 127 +++ b/2.txt Thu Jan 01 00:00:00 1970 +0000
128 128 @@ -1,5 +1,5 @@
129 129 a
130 130 -b
131 131 +b b
132 132 c
133 133 d
134 134 e
135 135
136 136
137 137 % after qrecord a.patch 'diff'
138 138 diff -r 5d1ca63427ee 1.txt
139 139 --- a/1.txt
140 140 +++ b/1.txt
141 141 @@ -1,5 +1,5 @@
142 142 1
143 143 2 2
144 144 3
145 145 -4
146 146 +4 4
147 147 5
148 148 diff -r 5d1ca63427ee dir/a.txt
149 149 --- a/dir/a.txt
150 150 +++ b/dir/a.txt
151 151 @@ -1,4 +1,4 @@
152 152 -hello world
153 153 +hello world!
154 154
155 155 someone
156 156 up
157 157 % qrecord b.patch
158 158 diff --git a/1.txt b/1.txt
159 159 1 hunks, 2 lines changed
160 160 examine changes to '1.txt'? [Ynsfdaq?] @@ -1,5 +1,5 @@
161 161 1
162 162 2 2
163 163 3
164 164 -4
165 165 +4 4
166 166 5
167 167 record change 1/3 to '1.txt'? [Ynsfdaq?] diff --git a/dir/a.txt b/dir/a.txt
168 168 1 hunks, 2 lines changed
169 169 examine changes to 'dir/a.txt'? [Ynsfdaq?] @@ -1,4 +1,4 @@
170 170 -hello world
171 171 +hello world!
172 172
173 173 someone
174 174 up
175 175 record change 3/3 to 'dir/a.txt'? [Ynsfdaq?]
176 176 % after qrecord b.patch 'tip'
177 177 changeset: 2:b056198bf878
178 178 tag: qtip
179 179 tag: tip
180 180 tag: b.patch
181 181 user: test
182 182 date: Thu Jan 01 00:00:00 1970 +0000
183 183 summary: bbb
184 184
185 185 diff -r 5d1ca63427ee -r b056198bf878 1.txt
186 186 --- a/1.txt Thu Jan 01 00:00:00 1970 +0000
187 187 +++ b/1.txt Thu Jan 01 00:00:00 1970 +0000
188 188 @@ -1,5 +1,5 @@
189 189 1
190 190 2 2
191 191 3
192 192 -4
193 193 +4 4
194 194 5
195 195 diff -r 5d1ca63427ee -r b056198bf878 dir/a.txt
196 196 --- a/dir/a.txt Thu Jan 01 00:00:00 1970 +0000
197 197 +++ b/dir/a.txt Thu Jan 01 00:00:00 1970 +0000
198 198 @@ -1,4 +1,4 @@
199 199 -hello world
200 200 +hello world!
201 201
202 202 someone
203 203 up
204 204
205 205
206 206 % after qrecord b.patch 'diff'
207 207
208 208 % --- end ---
@@ -1,28 +1,28 b''
1 1 adding a
2 2 0: a
3 3 hg: unknown command 'an'
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 annotate show changeset information per file line
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 init create a new repository in the given directory
15 15 log show revision history of entire repository or files
16 16 merge merge working directory with another revision
17 17 parents show the parents of the working directory or 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 export the repository via HTTP
22 22 status show changed files in the working directory
23 23 update update working directory
24 24
25 25 use "hg help" for the full list of commands or "hg -v" for details
26 26 0: a
27 27 % should succeed - up is an alias, not an abbreviation
28 28 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
General Comments 0
You need to be logged in to leave comments. Login now