Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 8387:50b6af595e0c
merge: add -S/--show option to review revisions without merging
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Thu, 14 May 2009 16:03:17 +0200 |
parents | 0bf0045000b5 |
children | 613ac2856535 |
comparison
equal
deleted
inserted
replaced
8386:4aad982111b6 | 8387:50b6af595e0c |
---|---|
2023 ui.write("%40s " % hex(ctx.manifest()[f])) | 2023 ui.write("%40s " % hex(ctx.manifest()[f])) |
2024 if ui.verbose: | 2024 if ui.verbose: |
2025 ui.write(decor[ctx.flags(f)]) | 2025 ui.write(decor[ctx.flags(f)]) |
2026 ui.write("%s\n" % f) | 2026 ui.write("%s\n" % f) |
2027 | 2027 |
2028 def merge(ui, repo, node=None, force=None, rev=None): | 2028 def merge(ui, repo, node=None, **opts): |
2029 """merge working directory with another revision | 2029 """merge working directory with another revision |
2030 | 2030 |
2031 The contents of the current working directory is updated with all | 2031 The contents of the current working directory is updated with all |
2032 changes made in the requested revision since the last common | 2032 changes made in the requested revision since the last common |
2033 predecessor revision. | 2033 predecessor revision. |
2040 head revision, and the current branch contains exactly one other | 2040 head revision, and the current branch contains exactly one other |
2041 head, the other head is merged with by default. Otherwise, an | 2041 head, the other head is merged with by default. Otherwise, an |
2042 explicit revision to merge with must be provided. | 2042 explicit revision to merge with must be provided. |
2043 """ | 2043 """ |
2044 | 2044 |
2045 if rev and node: | 2045 if opts.get('rev') and node: |
2046 raise util.Abort(_("please specify just one revision")) | 2046 raise util.Abort(_("please specify just one revision")) |
2047 if not node: | 2047 if not node: |
2048 node = rev | 2048 node = opts.get('rev') |
2049 | 2049 |
2050 if not node: | 2050 if not node: |
2051 branch = repo.changectx(None).branch() | 2051 branch = repo.changectx(None).branch() |
2052 bheads = repo.branchheads(branch) | 2052 bheads = repo.branchheads(branch) |
2053 if len(bheads) > 2: | 2053 if len(bheads) > 2: |
2068 | 2068 |
2069 if parent not in bheads: | 2069 if parent not in bheads: |
2070 raise util.Abort(_('working dir not at a head rev - ' | 2070 raise util.Abort(_('working dir not at a head rev - ' |
2071 'use "hg update" or merge with an explicit rev')) | 2071 'use "hg update" or merge with an explicit rev')) |
2072 node = parent == bheads[0] and bheads[-1] or bheads[0] | 2072 node = parent == bheads[0] and bheads[-1] or bheads[0] |
2073 return hg.merge(repo, node, force=force) | 2073 |
2074 if opts.get('show'): | |
2075 p1 = repo['.'] | |
2076 p2 = repo[node] | |
2077 common = p1.ancestor(p2) | |
2078 roots, heads = [common.node()], [p2.node()] | |
2079 displayer = cmdutil.show_changeset(ui, repo, opts) | |
2080 for node in repo.changelog.nodesbetween(roots=roots, heads=heads)[0]: | |
2081 displayer.show(repo[node]) | |
2082 return 0 | |
2083 | |
2084 return hg.merge(repo, node, force=opts.get('force')) | |
2074 | 2085 |
2075 def outgoing(ui, repo, dest=None, **opts): | 2086 def outgoing(ui, repo, dest=None, **opts): |
2076 """show changesets not found in destination | 2087 """show changesets not found in destination |
2077 | 2088 |
2078 Show changesets not found in the specified destination repository | 2089 Show changesets not found in the specified destination repository |
3322 _('[-r REV]')), | 3333 _('[-r REV]')), |
3323 "^merge": | 3334 "^merge": |
3324 (merge, | 3335 (merge, |
3325 [('f', 'force', None, _('force a merge with outstanding changes')), | 3336 [('f', 'force', None, _('force a merge with outstanding changes')), |
3326 ('r', 'rev', '', _('revision to merge')), | 3337 ('r', 'rev', '', _('revision to merge')), |
3327 ], | 3338 ('S', 'show', None, |
3339 _('review revisions to merge (no merge is performed)'))], | |
3328 _('[-f] [[-r] REV]')), | 3340 _('[-f] [[-r] REV]')), |
3329 "outgoing|out": | 3341 "outgoing|out": |
3330 (outgoing, | 3342 (outgoing, |
3331 [('f', 'force', None, | 3343 [('f', 'force', None, |
3332 _('run even when remote repository is unrelated')), | 3344 _('run even when remote repository is unrelated')), |