Mercurial > hg-stable
changeset 22178:70383c6961b4 stable
discovery: prevent crash on unknown remote heads with old repo (issue4337)
When a remote is not capable of the `branchmap` wireproto command, we denote
incoming heads with None. This leads to a crash in the code in charge of
displaying the list of unknown remote heads.
We now properly detect this case and display a shorter message in this case.
The reason for this `set([None])` value is now documented.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 14 Aug 2014 16:26:41 -0700 |
parents | a56038e6a3c9 |
children | 46308fadaa15 |
files | mercurial/discovery.py |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/discovery.py Thu Aug 14 14:59:42 2014 -0700 +++ b/mercurial/discovery.py Thu Aug 14 16:26:41 2014 -0700 @@ -217,6 +217,7 @@ # This explains why the new head are very simple to compute. r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing) newheads = list(c.node() for c in r) + # set some unsynced head to issue the "unsynced changes" warning unsynced = inc and set([None]) or set() return {None: (oldheads, newheads, unsynced)} @@ -313,12 +314,18 @@ newhs = candidate_newhs unsynced = sorted(h for h in unsyncedheads if h not in discardedheads) if unsynced: - if len(unsynced) <= 4 or repo.ui.verbose: + if None in unsynced: + # old remote, no heads data + heads = None + elif len(unsynced) <= 4 or repo.ui.verbose: heads = ' '.join(short(h) for h in unsynced) else: heads = (' '.join(short(h) for h in unsynced[:4]) + ' ' + _("and %s others") % (len(unsynced) - 4)) - if branch is None: + if heads is None: + repo.ui.status(_("remote has heads that are " + "not known locally\n")) + elif branch is None: repo.ui.status(_("remote has heads that are " "not known locally: %s\n") % heads) else: