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.
--- 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: