comparison mercurial/commands.py @ 4918:bcba70b8006d

Better fix for issue 622 than we had in c4dd58af0fc8.
author Bryan O'Sullivan <bos@serpentine.com>
date Wed, 18 Jul 2007 13:56:08 -0700
parents 8535c1770dd3
children 53a1847a99d1
comparison
equal deleted inserted replaced
4917:7d745e9d2cf0 4918:bcba70b8006d
2026 return 1 2026 return 1
2027 else: 2027 else:
2028 for name, path in ui.configitems("paths"): 2028 for name, path in ui.configitems("paths"):
2029 ui.write("%s = %s\n" % (name, path)) 2029 ui.write("%s = %s\n" % (name, path))
2030 2030
2031 def postincoming(ui, repo, modheads, optupdate, wasempty): 2031 def postincoming(ui, repo, modheads, optupdate):
2032 if modheads == 0: 2032 if modheads == 0:
2033 return 2033 return
2034 if optupdate: 2034 if optupdate:
2035 if wasempty: 2035 if modheads == 1:
2036 return hg.update(repo, repo.lookup('default'))
2037 elif modheads == 1:
2038 return hg.update(repo, repo.changelog.tip()) # update 2036 return hg.update(repo, repo.changelog.tip()) # update
2039 else: 2037 else:
2040 ui.status(_("not updating, since new heads added\n")) 2038 ui.status(_("not updating, since new heads added\n"))
2041 if modheads > 1: 2039 if modheads > 1:
2042 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) 2040 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
2094 revs = [other.lookup(rev) for rev in revs] 2092 revs = [other.lookup(rev) for rev in revs]
2095 else: 2093 else:
2096 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.") 2094 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
2097 raise util.Abort(error) 2095 raise util.Abort(error)
2098 2096
2099 wasempty = repo.changelog.count() == 0
2100 modheads = repo.pull(other, heads=revs, force=opts['force']) 2097 modheads = repo.pull(other, heads=revs, force=opts['force'])
2101 return postincoming(ui, repo, modheads, opts['update'], wasempty) 2098 return postincoming(ui, repo, modheads, opts['update'])
2102 2099
2103 def push(ui, repo, dest=None, **opts): 2100 def push(ui, repo, dest=None, **opts):
2104 """push changes to the specified destination 2101 """push changes to the specified destination
2105 2102
2106 Push changes from the local repository to the given destination. 2103 Push changes from the local repository to the given destination.
2660 Apply one or more compressed changegroup files generated by the 2657 Apply one or more compressed changegroup files generated by the
2661 bundle command. 2658 bundle command.
2662 """ 2659 """
2663 fnames = (fname1,) + fnames 2660 fnames = (fname1,) + fnames
2664 result = None 2661 result = None
2665 wasempty = repo.changelog.count() == 0
2666 for fname in fnames: 2662 for fname in fnames:
2667 if os.path.exists(fname): 2663 if os.path.exists(fname):
2668 f = open(fname, "rb") 2664 f = open(fname, "rb")
2669 else: 2665 else:
2670 f = urllib.urlopen(fname) 2666 f = urllib.urlopen(fname)
2671 gen = changegroup.readbundle(f, fname) 2667 gen = changegroup.readbundle(f, fname)
2672 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) 2668 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
2673 2669
2674 return postincoming(ui, repo, modheads, opts['update'], wasempty) 2670 return postincoming(ui, repo, modheads, opts['update'])
2675 2671
2676 def update(ui, repo, node=None, rev=None, clean=False, date=None): 2672 def update(ui, repo, node=None, rev=None, clean=False, date=None):
2677 """update working directory 2673 """update working directory
2678 2674
2679 Update the working directory to the specified revision, or the 2675 Update the working directory to the specified revision, or the