comparison mercurial/commands.py @ 2822:30f59f4a327e

Introduce update helper functions: update, merge, clean, and revert
author Matt Mackall <mpm@selenic.com>
date Mon, 07 Aug 2006 22:54:33 -0500
parents 0bf22c109cc3
children 3aeab7bb5adc
comparison
equal deleted inserted replaced
2821:a8a7ce1a01a5 2822:30f59f4a327e
974 parent = p 974 parent = p
975 else: 975 else:
976 if opts['parent']: 976 if opts['parent']:
977 raise util.Abort(_('cannot use --parent on non-merge changeset')) 977 raise util.Abort(_('cannot use --parent on non-merge changeset'))
978 parent = p1 978 parent = p1
979 hg.update(repo, node, force=True, show_stats=False) # backout 979 hg.clean(repo, node, show_stats=False)
980 revert_opts = opts.copy() 980 revert_opts = opts.copy()
981 revert_opts['rev'] = hex(parent) 981 revert_opts['rev'] = hex(parent)
982 revert(ui, repo, **revert_opts) 982 revert(ui, repo, **revert_opts)
983 commit_opts = opts.copy() 983 commit_opts = opts.copy()
984 commit_opts['addremove'] = False 984 commit_opts['addremove'] = False
992 (nice(repo.changelog.tip()), nice(node))) 992 (nice(repo.changelog.tip()), nice(node)))
993 if op1 != node: 993 if op1 != node:
994 if opts['merge']: 994 if opts['merge']:
995 ui.status(_('merging with changeset %s\n') % nice(op1)) 995 ui.status(_('merging with changeset %s\n') % nice(op1))
996 n = _lookup(repo, hex(op1)) 996 n = _lookup(repo, hex(op1))
997 hg.update(repo, n, allow=True) # merge 997 hg.merge(repo, n)
998 else: 998 else:
999 ui.status(_('the backout changeset is a new head - ' 999 ui.status(_('the backout changeset is a new head - '
1000 'do not forget to merge\n')) 1000 'do not forget to merge\n'))
1001 ui.status(_('(use "backout --merge" ' 1001 ui.status(_('(use "backout --merge" '
1002 'if you want to auto-merge)\n')) 1002 'if you want to auto-merge)\n'))
2161 marked as changed for the next commit and a commit must be 2161 marked as changed for the next commit and a commit must be
2162 performed before any further updates are allowed. 2162 performed before any further updates are allowed.
2163 """ 2163 """
2164 2164
2165 node = _lookup(repo, node, branch) 2165 node = _lookup(repo, node, branch)
2166 hg.update(repo, node, allow=True, forcemerge=force) # merge 2166 return hg.merge(repo, node, force=force)
2167 2167
2168 def outgoing(ui, repo, dest=None, **opts): 2168 def outgoing(ui, repo, dest=None, **opts):
2169 """show changesets not found in destination 2169 """show changesets not found in destination
2170 2170
2171 Show changesets not found in the specified destination repository or 2171 Show changesets not found in the specified destination repository or
2604 else: 2604 else:
2605 handle(remove, False) 2605 handle(remove, False)
2606 2606
2607 if not opts.get('dry_run'): 2607 if not opts.get('dry_run'):
2608 repo.dirstate.forget(forget[0]) 2608 repo.dirstate.forget(forget[0])
2609 r = hg.update(repo, node, False, True, update.has_key, False, 2609 r = hg.revert(repo, node, update.has_key)
2610 wlock=wlock, show_stats=False) # revert
2611 repo.dirstate.update(add[0], 'a') 2610 repo.dirstate.update(add[0], 'a')
2612 repo.dirstate.update(undelete[0], 'n') 2611 repo.dirstate.update(undelete[0], 'n')
2613 repo.dirstate.update(remove[0], 'r') 2612 repo.dirstate.update(remove[0], 'r')
2614 return r 2613 return r
2615 2614
2903 merge command. 2902 merge command.
2904 2903
2905 By default, update will refuse to run if doing so would require 2904 By default, update will refuse to run if doing so would require
2906 merging or discarding local changes. 2905 merging or discarding local changes.
2907 """ 2906 """
2907 node = _lookup(repo, node, branch)
2908 if merge: 2908 if merge:
2909 ui.warn(_('(the -m/--merge option is deprecated; ' 2909 ui.warn(_('(the -m/--merge option is deprecated; '
2910 'use the merge command instead)\n')) 2910 'use the merge command instead)\n'))
2911 node = _lookup(repo, node, branch) 2911 return hg.merge(repo, node, force=force)
2912 return hg.update(repo, node, allow=merge, force=clean, forcemerge=force) 2912 elif clean:
2913 return hg.clean(repo, node)
2914 else:
2915 return hg.update(repo, node)
2913 2916
2914 def _lookup(repo, node, branch=None): 2917 def _lookup(repo, node, branch=None):
2915 if branch: 2918 if branch:
2916 br = repo.branchlookup(branch=branch) 2919 br = repo.branchlookup(branch=branch)
2917 found = [] 2920 found = []