changegroup: replace changegroup with makechangegroup
authorDurham Goode <durham@fb.com>
Sun, 10 Sep 2017 18:48:42 -0700
changeset 34100 1632999d4bed
parent 34099 6097a616178d
child 34101 5ede882c249c
changegroup: replace changegroup with makechangegroup As part of reducing the number of changegroup creation APIs, let's replace the changegroup function with makechangegroup. This pushes the responsibility of creating the outgoing set to the caller, but that seems like a simple and reasonable concept for the caller to be aware of. Differential Revision: https://phab.mercurial-scm.org/D668
mercurial/changegroup.py
mercurial/localrepo.py
mercurial/wireproto.py
--- a/mercurial/changegroup.py	Sun Sep 10 18:47:39 2017 -0700
+++ b/mercurial/changegroup.py	Sun Sep 10 18:48:42 2017 -0700
@@ -21,7 +21,6 @@
 
 from . import (
     dagutil,
-    discovery,
     error,
     mdiff,
     phases,
@@ -951,12 +950,6 @@
     return makechangegroup(repo, outgoing, version, source,
                            bundlecaps=bundlecaps)
 
-def changegroup(repo, basenodes, source):
-    # to avoid a race we use changegroupsubset() (issue1320)
-    outgoing = discovery.outgoing(repo, missingroots=basenodes,
-                                  missingheads=repo.heads())
-    return makechangegroup(repo, outgoing, '01', source)
-
 def _addchangegroupfiles(repo, source, revmap, trp, expectedfiles, needfiles):
     revisions = 0
     files = 0
--- a/mercurial/localrepo.py	Sun Sep 10 18:47:39 2017 -0700
+++ b/mercurial/localrepo.py	Sun Sep 10 18:48:42 2017 -0700
@@ -287,7 +287,9 @@
         return self._repo.branches(nodes)
 
     def changegroup(self, basenodes, source):
-        return changegroup.changegroup(self._repo, basenodes, source)
+        outgoing = discovery.outgoing(self._repo, missingroots=basenodes,
+                                      missingheads=self._repo.heads())
+        return changegroup.makechangegroup(self._repo, outgoing, '01', source)
 
     def changegroupsubset(self, bases, heads, source):
         outgoing = discovery.outgoing(self._repo, missingroots=bases,
--- a/mercurial/wireproto.py	Sun Sep 10 18:47:39 2017 -0700
+++ b/mercurial/wireproto.py	Sun Sep 10 18:48:42 2017 -0700
@@ -795,7 +795,9 @@
 @wireprotocommand('changegroup', 'roots')
 def changegroup(repo, proto, roots):
     nodes = decodelist(roots)
-    cg = changegroupmod.changegroup(repo, nodes, 'serve')
+    outgoing = discovery.outgoing(repo, missingroots=nodes,
+                                  missingheads=repo.heads())
+    cg = changegroupmod.makechangegroup(repo, outgoing, '01', 'serve')
     return streamres(reader=cg, v1compressible=True)
 
 @wireprotocommand('changegroupsubset', 'bases heads')