diff hgext3rd/topic/discovery.py @ 5623:fe31179e1941 stable

branching: merge into stable in preparation for release
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 31 Oct 2020 17:25:32 +0800
parents 36ccafa69095
children 1dece375d2ab
line wrap: on
line diff
--- a/hgext3rd/topic/discovery.py	Sat Oct 31 02:36:21 2020 +0800
+++ b/hgext3rd/topic/discovery.py	Sat Oct 31 17:25:32 2020 +0800
@@ -10,6 +10,7 @@
     error,
     exchange,
     extensions,
+    scmutil,
     util,
 )
 from . import (
@@ -186,7 +187,7 @@
             continue
         oldheads = [repo[n].rev() for n in b[1]]
         newheads = _filter_obsolete_heads(repo, oldheads)
-        data[b[0]] = len(newheads)
+        data[b[0]] = newheads
     return data
 
 def handlecheckheads(orig, op, inpart):
@@ -211,15 +212,27 @@
             repo.invalidatecaches()
             finalheads = _nbheads(repo)
             for branch, oldnb in tr._prepushheads.items():
-                newnb = finalheads.pop(branch, 0)
-                if oldnb < newnb:
-                    msg = _(b'push create a new head on branch "%s"' % branch)
+                newheads = finalheads.pop(branch, [])
+                if len(oldnb) < len(newheads):
+                    cl = repo.changelog
+                    newheads = sorted(set(newheads).difference(oldnb))
+                    heads = scmutil.nodesummaries(repo, [cl.node(r) for r in newheads])
+                    msg = _(
+                        b"push creates new heads on branch '%s': %s"
+                        % (branch, heads)
+                    )
                     raise error.Abort(msg)
             for branch, newnb in finalheads.items():
-                if 1 < newnb:
-                    msg = _(b'push create more than 1 head on new branch "%s"'
-                            % branch)
-                    raise error.Abort(msg)
+                if 1 < len(newnb):
+                    cl = repo.changelog
+                    heads = scmutil.nodesummaries(repo, [cl.node(r) for r in newnb])
+                    msg = _(
+                        b"push creates new branch '%s' with multiple heads: %s"
+                        % (branch, heads)
+                    )
+                    hint = _(b"merge or see 'hg help push' for details about "
+                             b"pushing new heads")
+                    raise error.Abort(msg, hint=hint)
 
     def validator(tr):
         _validate(tr)