Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 4931:c4dd58af0fc8
issue 622: pull/unbundle -u updates to default branch if repo was empty
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Mon, 16 Jul 2007 18:01:20 -0700 |
parents | be5dc5e3ab2d |
children | 8535c1770dd3 e8c0b52c363c |
comparison
equal
deleted
inserted
replaced
4930:fc502517d68d | 4931:c4dd58af0fc8 |
---|---|
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): | 2016 def postincoming(ui, repo, modheads, optupdate, wasempty): |
2017 if modheads == 0: | 2017 if modheads == 0: |
2018 return | 2018 return |
2019 if optupdate: | 2019 if optupdate: |
2020 if modheads == 1: | 2020 if wasempty: |
2021 return hg.update(repo, repo.lookup('default')) | |
2022 elif modheads == 1: | |
2021 return hg.update(repo, repo.changelog.tip()) # update | 2023 return hg.update(repo, repo.changelog.tip()) # update |
2022 else: | 2024 else: |
2023 ui.status(_("not updating, since new heads added\n")) | 2025 ui.status(_("not updating, since new heads added\n")) |
2024 if modheads > 1: | 2026 if modheads > 1: |
2025 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) | 2027 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n")) |
2077 revs = [other.lookup(rev) for rev in revs] | 2079 revs = [other.lookup(rev) for rev in revs] |
2078 else: | 2080 else: |
2079 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.") | 2081 error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.") |
2080 raise util.Abort(error) | 2082 raise util.Abort(error) |
2081 | 2083 |
2084 wasempty = repo.changelog.count() == 0 | |
2082 modheads = repo.pull(other, heads=revs, force=opts['force']) | 2085 modheads = repo.pull(other, heads=revs, force=opts['force']) |
2083 return postincoming(ui, repo, modheads, opts['update']) | 2086 return postincoming(ui, repo, modheads, opts['update'], wasempty) |
2084 | 2087 |
2085 def push(ui, repo, dest=None, **opts): | 2088 def push(ui, repo, dest=None, **opts): |
2086 """push changes to the specified destination | 2089 """push changes to the specified destination |
2087 | 2090 |
2088 Push changes from the local repository to the given destination. | 2091 Push changes from the local repository to the given destination. |
2642 Apply one or more compressed changegroup files generated by the | 2645 Apply one or more compressed changegroup files generated by the |
2643 bundle command. | 2646 bundle command. |
2644 """ | 2647 """ |
2645 fnames = (fname1,) + fnames | 2648 fnames = (fname1,) + fnames |
2646 result = None | 2649 result = None |
2650 wasempty = repo.changelog.count() == 0 | |
2647 for fname in fnames: | 2651 for fname in fnames: |
2648 if os.path.exists(fname): | 2652 if os.path.exists(fname): |
2649 f = open(fname, "rb") | 2653 f = open(fname, "rb") |
2650 else: | 2654 else: |
2651 f = urllib.urlopen(fname) | 2655 f = urllib.urlopen(fname) |
2652 gen = changegroup.readbundle(f, fname) | 2656 gen = changegroup.readbundle(f, fname) |
2653 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) | 2657 modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname) |
2654 | 2658 |
2655 return postincoming(ui, repo, modheads, opts['update']) | 2659 return postincoming(ui, repo, modheads, opts['update'], wasempty) |
2656 | 2660 |
2657 def update(ui, repo, node=None, rev=None, clean=False, date=None): | 2661 def update(ui, repo, node=None, rev=None, clean=False, date=None): |
2658 """update working directory | 2662 """update working directory |
2659 | 2663 |
2660 Update the working directory to the specified revision, or the | 2664 Update the working directory to the specified revision, or the |