##// END OF EJS Templates
Factor doupdate into _lookup + hg.update
Matt Mackall -
r2806:0bf22c10 default
parent child Browse files
Show More
@@ -976,7 +976,7 b' def backout(ui, repo, rev, **opts):'
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)
979 hg.update(repo, node, force=True, show_stats=False) # backout
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)
@@ -993,7 +993,8 b' def backout(ui, repo, rev, **opts):'
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 doupdate(ui, repo, hex(op1), merge=True)
996 n = _lookup(repo, hex(op1))
997 hg.update(repo, n, allow=True) # merge
997 else:
998 else:
998 ui.status(_('the backout changeset is a new head - '
999 ui.status(_('the backout changeset is a new head - '
999 'do not forget to merge\n'))
1000 'do not forget to merge\n'))
@@ -2152,7 +2153,7 b' def manifest(ui, repo, rev=None):'
2152 for f in files:
2153 for f in files:
2153 ui.write("%40s %3s %s\n" % (hex(m[f]), mf[f] and "755" or "644", f))
2154 ui.write("%40s %3s %s\n" % (hex(m[f]), mf[f] and "755" or "644", f))
2154
2155
2155 def merge(ui, repo, node=None, **opts):
2156 def merge(ui, repo, node=None, force=None, branch=None):
2156 """Merge working directory with another revision
2157 """Merge working directory with another revision
2157
2158
2158 Merge the contents of the current working directory and the
2159 Merge the contents of the current working directory and the
@@ -2160,7 +2161,9 b' def merge(ui, repo, node=None, **opts):'
2160 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
2161 performed before any further updates are allowed.
2162 performed before any further updates are allowed.
2162 """
2163 """
2163 return doupdate(ui, repo, node=node, merge=True, **opts)
2164
2165 node = _lookup(repo, node, branch)
2166 hg.update(repo, node, allow=True, forcemerge=force) # merge
2164
2167
2165 def outgoing(ui, repo, dest=None, **opts):
2168 def outgoing(ui, repo, dest=None, **opts):
2166 """show changesets not found in destination
2169 """show changesets not found in destination
@@ -2254,7 +2257,7 b' def postincoming(ui, repo, modheads, opt'
2254 return
2257 return
2255 if optupdate:
2258 if optupdate:
2256 if modheads == 1:
2259 if modheads == 1:
2257 return doupdate(ui, repo)
2260 return hg.update(repo, repo.changelog.tip()) # update
2258 else:
2261 else:
2259 ui.status(_("not updating, since new heads added\n"))
2262 ui.status(_("not updating, since new heads added\n"))
2260 if modheads > 1:
2263 if modheads > 1:
@@ -2604,7 +2607,7 b' def revert(ui, repo, *pats, **opts):'
2604 if not opts.get('dry_run'):
2607 if not opts.get('dry_run'):
2605 repo.dirstate.forget(forget[0])
2608 repo.dirstate.forget(forget[0])
2606 r = hg.update(repo, node, False, True, update.has_key, False,
2609 r = hg.update(repo, node, False, True, update.has_key, False,
2607 wlock=wlock, show_stats=False)
2610 wlock=wlock, show_stats=False) # revert
2608 repo.dirstate.update(add[0], 'a')
2611 repo.dirstate.update(add[0], 'a')
2609 repo.dirstate.update(undelete[0], 'n')
2612 repo.dirstate.update(undelete[0], 'n')
2610 repo.dirstate.update(remove[0], 'r')
2613 repo.dirstate.update(remove[0], 'r')
@@ -2905,10 +2908,10 b' def update(ui, repo, node=None, merge=Fa'
2905 if merge:
2908 if merge:
2906 ui.warn(_('(the -m/--merge option is deprecated; '
2909 ui.warn(_('(the -m/--merge option is deprecated; '
2907 'use the merge command instead)\n'))
2910 'use the merge command instead)\n'))
2908 return doupdate(ui, repo, node, merge, clean, force, branch)
2911 node = _lookup(repo, node, branch)
2909
2912 return hg.update(repo, node, allow=merge, force=clean, forcemerge=force)
2910 def doupdate(ui, repo, node=None, merge=False, clean=False, force=None,
2913
2911 branch=None):
2914 def _lookup(repo, node, branch=None):
2912 if branch:
2915 if branch:
2913 br = repo.branchlookup(branch=branch)
2916 br = repo.branchlookup(branch=branch)
2914 found = []
2917 found = []
@@ -2916,19 +2919,19 b' def doupdate(ui, repo, node=None, merge='
2916 if branch in br[x]:
2919 if branch in br[x]:
2917 found.append(x)
2920 found.append(x)
2918 if len(found) > 1:
2921 if len(found) > 1:
2919 ui.warn(_("Found multiple heads for %s\n") % branch)
2922 repo.ui.warn(_("Found multiple heads for %s\n") % branch)
2920 for x in found:
2923 for x in found:
2921 show_changeset(ui, repo, {}).show(changenode=x, brinfo=br)
2924 show_changeset(ui, repo, {}).show(changenode=x, brinfo=br)
2922 return 1
2925 raise util.Abort("")
2923 if len(found) == 1:
2926 if len(found) == 1:
2924 node = found[0]
2927 node = found[0]
2925 ui.warn(_("Using head %s for branch %s\n") % (short(node), branch))
2928 repo.ui.warn(_("Using head %s for branch %s\n")
2929 % (short(node), branch))
2926 else:
2930 else:
2927 ui.warn(_("branch %s not found\n") % (branch))
2931 raise util.Abort(_("branch %s not found\n") % (branch))
2928 return 1
2929 else:
2932 else:
2930 node = node and repo.lookup(node) or repo.changelog.tip()
2933 node = node and repo.lookup(node) or repo.changelog.tip()
2931 return hg.update(repo, node, allow=merge, force=clean, forcemerge=force)
2934 return node
2932
2935
2933 def verify(ui, repo):
2936 def verify(ui, repo):
2934 """verify the integrity of the repository
2937 """verify the integrity of the repository
General Comments 0
You need to be logged in to leave comments. Login now