comparison mercurial/commands.py @ 9656:2ae3758526d8

Merge with crew
author Matt Mackall <mpm@selenic.com>
date Tue, 27 Oct 2009 17:14:19 -0500
parents 6d7d3f849062 20b91f91f9ca
children f3d60543924f
comparison
equal deleted inserted replaced
9655:6d7d3f849062 9656:2ae3758526d8
1083 format. For more information, read 'hg help diffs'. 1083 format. For more information, read 'hg help diffs'.
1084 """ 1084 """
1085 1085
1086 revs = opts.get('rev') 1086 revs = opts.get('rev')
1087 change = opts.get('change') 1087 change = opts.get('change')
1088 stat = opts.get('stat')
1088 1089
1089 if revs and change: 1090 if revs and change:
1090 msg = _('cannot specify --rev and --change at the same time') 1091 msg = _('cannot specify --rev and --change at the same time')
1091 raise util.Abort(msg) 1092 raise util.Abort(msg)
1092 elif change: 1093 elif change:
1093 node2 = repo.lookup(change) 1094 node2 = repo.lookup(change)
1094 node1 = repo[node2].parents()[0].node() 1095 node1 = repo[node2].parents()[0].node()
1095 else: 1096 else:
1096 node1, node2 = cmdutil.revpair(repo, revs) 1097 node1, node2 = cmdutil.revpair(repo, revs)
1097 1098
1099 if stat:
1100 opts['unified'] = '0'
1101 diffopts = patch.diffopts(ui, opts)
1102
1098 m = cmdutil.match(repo, pats, opts) 1103 m = cmdutil.match(repo, pats, opts)
1099 it = patch.diff(repo, node1, node2, match=m, opts=patch.diffopts(ui, opts)) 1104 it = patch.diff(repo, node1, node2, match=m, opts=diffopts)
1100 for chunk in it: 1105 if stat:
1101 ui.write(chunk) 1106 width = ui.interactive() and util.termwidth() or 80
1107 ui.write(patch.diffstat(util.iterlines(it), width=width,
1108 git=diffopts.git))
1109 else:
1110 for chunk in it:
1111 ui.write(chunk)
1102 1112
1103 def export(ui, repo, *changesets, **opts): 1113 def export(ui, repo, *changesets, **opts):
1104 """dump the header and diffs for one or more changesets 1114 """dump the header and diffs for one or more changesets
1105 1115
1106 Print the changeset header and diffs for one or more revisions. 1116 Print the changeset header and diffs for one or more revisions.
1602 # list all option lists 1612 # list all option lists
1603 opt_output = [] 1613 opt_output = []
1604 for title, options in option_lists: 1614 for title, options in option_lists:
1605 opt_output.append(("\n%s" % title, None)) 1615 opt_output.append(("\n%s" % title, None))
1606 for shortopt, longopt, default, desc in options: 1616 for shortopt, longopt, default, desc in options:
1607 if "DEPRECATED" in desc and not ui.verbose: continue 1617 if _("DEPRECATED") in desc and not ui.verbose: continue
1608 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, 1618 opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt,
1609 longopt and " --%s" % longopt), 1619 longopt and " --%s" % longopt),
1610 "%s%s" % (desc, 1620 "%s%s" % (desc,
1611 default 1621 default
1612 and _(" (default: %s)") % default 1622 and _(" (default: %s)") % default
1706 ui.write("%s\n" % ' '.join(output)) 1716 ui.write("%s\n" % ' '.join(output))
1707 1717
1708 def import_(ui, repo, patch1, *patches, **opts): 1718 def import_(ui, repo, patch1, *patches, **opts):
1709 """import an ordered set of patches 1719 """import an ordered set of patches
1710 1720
1711 Import a list of patches and commit them individually. 1721 Import a list of patches and commit them individually (unless
1722 --no-commit is specified).
1712 1723
1713 If there are outstanding changes in the working directory, import 1724 If there are outstanding changes in the working directory, import
1714 will abort unless given the -f/--force flag. 1725 will abort unless given the -f/--force flag.
1715 1726
1716 You can import a patch straight from a mail message. Even patches 1727 You can import a patch straight from a mail message. Even patches
2295 err = _("Other repository doesn't support revision lookup, " 2306 err = _("Other repository doesn't support revision lookup, "
2296 "so a rev cannot be specified.") 2307 "so a rev cannot be specified.")
2297 raise util.Abort(err) 2308 raise util.Abort(err)
2298 2309
2299 modheads = repo.pull(other, heads=revs, force=opts.get('force')) 2310 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
2311 if checkout:
2312 checkout = str(repo.changelog.rev(other.lookup(checkout)))
2300 return postincoming(ui, repo, modheads, opts.get('update'), checkout) 2313 return postincoming(ui, repo, modheads, opts.get('update'), checkout)
2301 2314
2302 def push(ui, repo, dest=None, **opts): 2315 def push(ui, repo, dest=None, **opts):
2303 """push changes to the specified destination 2316 """push changes to the specified destination
2304 2317
2430 wlock.release() 2443 wlock.release()
2431 2444
2432 def resolve(ui, repo, *pats, **opts): 2445 def resolve(ui, repo, *pats, **opts):
2433 """retry file merges from a merge or update 2446 """retry file merges from a merge or update
2434 2447
2435 This command will cleanly retry unresolved file merges using file 2448 This command can cleanly retry unresolved file merges using file
2436 revisions preserved from the last update or merge. To attempt to 2449 revisions preserved from the last update or merge. To attempt to
2437 resolve all unresolved files, use the -a/--all switch. 2450 resolve all unresolved files, use the -a/--all switch.
2438 2451
2439 If a conflict is resolved manually, please note that the changes 2452 If a conflict is resolved manually, please note that the changes
2440 will be overwritten if the merge is retried with resolve. The 2453 will be overwritten if the merge is retried with resolve. The
2448 2461
2449 U = unresolved 2462 U = unresolved
2450 R = resolved 2463 R = resolved
2451 """ 2464 """
2452 2465
2453 all, mark, unmark, show = [opts.get(o) for o in 'all mark unmark list'.split()] 2466 all, mark, unmark, show, nostatus = \
2467 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
2454 2468
2455 if (show and (mark or unmark)) or (mark and unmark): 2469 if (show and (mark or unmark)) or (mark and unmark):
2456 raise util.Abort(_("too many options specified")) 2470 raise util.Abort(_("too many options specified"))
2457 if pats and all: 2471 if pats and all:
2458 raise util.Abort(_("can't specify --all and patterns")) 2472 raise util.Abort(_("can't specify --all and patterns"))
2464 m = cmdutil.match(repo, pats, opts) 2478 m = cmdutil.match(repo, pats, opts)
2465 2479
2466 for f in ms: 2480 for f in ms:
2467 if m(f): 2481 if m(f):
2468 if show: 2482 if show:
2469 ui.write("%s %s\n" % (ms[f].upper(), f)) 2483 if nostatus:
2484 ui.write("%s\n" % f)
2485 else:
2486 ui.write("%s %s\n" % (ms[f].upper(), f))
2470 elif mark: 2487 elif mark:
2471 ms.mark(f, "r") 2488 ms.mark(f, "r")
2472 elif unmark: 2489 elif unmark:
2473 ms.mark(f, "u") 2490 ms.mark(f, "u")
2474 else: 2491 else:
3257 _('ignore white space when comparing lines')), 3274 _('ignore white space when comparing lines')),
3258 ('b', 'ignore-space-change', None, 3275 ('b', 'ignore-space-change', None,
3259 _('ignore changes in the amount of white space')), 3276 _('ignore changes in the amount of white space')),
3260 ('B', 'ignore-blank-lines', None, 3277 ('B', 'ignore-blank-lines', None,
3261 _('ignore changes whose lines are all blank')), 3278 _('ignore changes whose lines are all blank')),
3262 ('U', 'unified', '', _('number of lines of context to show')) 3279 ('U', 'unified', '', _('number of lines of context to show')),
3280 ('', 'stat', None, _('output diffstat-style summary of changes')),
3263 ] 3281 ]
3264 3282
3265 similarityopts = [ 3283 similarityopts = [
3266 ('s', 'similarity', '', 3284 ('s', 'similarity', '',
3267 _('guess renamed files by similarity (0<=s<=100)')) 3285 _('guess renamed files by similarity (0<=s<=100)'))
3472 [('f', 'force', None, 3490 [('f', 'force', None,
3473 _('run even when remote repository is unrelated')), 3491 _('run even when remote repository is unrelated')),
3474 ('n', 'newest-first', None, _('show newest record first')), 3492 ('n', 'newest-first', None, _('show newest record first')),
3475 ('', 'bundle', '', _('file to store the bundles into')), 3493 ('', 'bundle', '', _('file to store the bundles into')),
3476 ('r', 'rev', [], 3494 ('r', 'rev', [],
3477 _('a specific revision up to which you would like to pull')), 3495 _('a specific remote revision up to which you would like to pull')),
3478 ] + logopts + remoteopts, 3496 ] + logopts + remoteopts,
3479 _('[-p] [-n] [-M] [-f] [-r REV]...' 3497 _('[-p] [-n] [-M] [-f] [-r REV]...'
3480 ' [--bundle FILENAME] [SOURCE]')), 3498 ' [--bundle FILENAME] [SOURCE]')),
3481 "^init": 3499 "^init":
3482 (init, 3500 (init,
3540 [('u', 'update', None, 3558 [('u', 'update', None,
3541 _('update to new tip if changesets were pulled')), 3559 _('update to new tip if changesets were pulled')),
3542 ('f', 'force', None, 3560 ('f', 'force', None,
3543 _('run even when remote repository is unrelated')), 3561 _('run even when remote repository is unrelated')),
3544 ('r', 'rev', [], 3562 ('r', 'rev', [],
3545 _('a specific revision up to which you would like to pull')), 3563 _('a specific remote revision up to which you would like to pull')),
3546 ] + remoteopts, 3564 ] + remoteopts,
3547 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')), 3565 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]')),
3548 "^push": 3566 "^push":
3549 (push, 3567 (push,
3550 [('f', 'force', None, _('force push')), 3568 [('f', 'force', None, _('force push')),
3570 "resolve": 3588 "resolve":
3571 (resolve, 3589 (resolve,
3572 [('a', 'all', None, _('remerge all unresolved files')), 3590 [('a', 'all', None, _('remerge all unresolved files')),
3573 ('l', 'list', None, _('list state of files needing merge')), 3591 ('l', 'list', None, _('list state of files needing merge')),
3574 ('m', 'mark', None, _('mark files as resolved')), 3592 ('m', 'mark', None, _('mark files as resolved')),
3575 ('u', 'unmark', None, _('unmark files as resolved'))] 3593 ('u', 'unmark', None, _('unmark files as resolved')),
3594 ('n', 'no-status', None, _('hide status prefix'))]
3576 + walkopts, 3595 + walkopts,
3577 _('[OPTION]... [FILE]...')), 3596 _('[OPTION]... [FILE]...')),
3578 "revert": 3597 "revert":
3579 (revert, 3598 (revert,
3580 [('a', 'all', None, _('revert all changes when no arguments given')), 3599 [('a', 'all', None, _('revert all changes when no arguments given')),