comparison mercurial/commands.py @ 4923:e8c0b52c363c

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 c4dd58af0fc8
children b8076522e889
comparison
equal deleted inserted replaced
4914:5fb8f5992a3d 4923:e8c0b52c363c
2011 return 1 2011 return 1
2012 else: 2012 else:
2013 for name, path in ui.configitems("paths"): 2013 for name, path in ui.configitems("paths"):
2014 ui.write("%s = %s\n" % (name, path)) 2014 ui.write("%s = %s\n" % (name, path))
2015 2015
2016 def postincoming(ui, repo, modheads, optupdate, wasempty): 2016 def postincoming(ui, repo, modheads, optupdate):
2017 if modheads == 0: 2017 if modheads == 0:
2018 return 2018 return
2019 if optupdate: 2019 if optupdate:
2020 if wasempty: 2020 if modheads == 1:
2021 return hg.update(repo, repo.lookup('default'))
2022 elif modheads == 1:
2023 return hg.update(repo, repo.changelog.tip()) # update 2021 return hg.update(repo, repo.changelog.tip()) # update
2024 else: 2022 else:
2025 ui.status(_("not updating, since new heads added\n")) 2023 ui.status(_("not updating, since new heads added\n"))
2026 if modheads > 1: 2024 if modheads > 1:
2027 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) 2025 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
2079 revs = [other.lookup(rev) for rev in revs] 2077 revs = [other.lookup(rev) for rev in revs]
2080 else: 2078 else:
2081 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.") 2079 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
2082 raise util.Abort(error) 2080 raise util.Abort(error)
2083 2081
2084 wasempty = repo.changelog.count() == 0
2085 modheads = repo.pull(other, heads=revs, force=opts['force']) 2082 modheads = repo.pull(other, heads=revs, force=opts['force'])
2086 return postincoming(ui, repo, modheads, opts['update'], wasempty) 2083 return postincoming(ui, repo, modheads, opts['update'])
2087 2084
2088 def push(ui, repo, dest=None, **opts): 2085 def push(ui, repo, dest=None, **opts):
2089 """push changes to the specified destination 2086 """push changes to the specified destination
2090 2087
2091 Push changes from the local repository to the given destination. 2088 Push changes from the local repository to the given destination.
2645 Apply one or more compressed changegroup files generated by the 2642 Apply one or more compressed changegroup files generated by the
2646 bundle command. 2643 bundle command.
2647 """ 2644 """
2648 fnames = (fname1,) + fnames 2645 fnames = (fname1,) + fnames
2649 result = None 2646 result = None
2650 wasempty = repo.changelog.count() == 0
2651 for fname in fnames: 2647 for fname in fnames:
2652 if os.path.exists(fname): 2648 if os.path.exists(fname):
2653 f = open(fname, "rb") 2649 f = open(fname, "rb")
2654 else: 2650 else:
2655 f = urllib.urlopen(fname) 2651 f = urllib.urlopen(fname)
2656 gen = changegroup.readbundle(f, fname) 2652 gen = changegroup.readbundle(f, fname)
2657 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) 2653 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
2658 2654
2659 return postincoming(ui, repo, modheads, opts['update'], wasempty) 2655 return postincoming(ui, repo, modheads, opts['update'])
2660 2656
2661 def update(ui, repo, node=None, rev=None, clean=False, date=None): 2657 def update(ui, repo, node=None, rev=None, clean=False, date=None):
2662 """update working directory 2658 """update working directory
2663 2659
2664 Update the working directory to the specified revision, or the 2660 Update the working directory to the specified revision, or the