changeset 34097:f7d41b85bbf6

changegroup: replace changegroupsubset with makechangegroup As part of getting rid of all the permutations of changegroup creation, let's remove changegroupsubset and call makechangegroup instead. This moves the responsibility of creating the outgoing set to the caller, but that seems like a relatively reasonable unit of functionality for the caller to have to care about (i.e. what commits should be bundled). Differential Revision: https://phab.mercurial-scm.org/D665
author Durham Goode <durham@fb.com>
date Sun, 10 Sep 2017 18:43:59 -0700
parents f85dfde1731a
children d8245139e720
files hgext/shelve.py mercurial/changegroup.py mercurial/localrepo.py mercurial/wireproto.py
diffstat 4 files changed, 17 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/shelve.py	Sun Sep 10 18:39:02 2017 -0700
+++ b/hgext/shelve.py	Sun Sep 10 18:43:59 2017 -0700
@@ -33,6 +33,7 @@
     bundlerepo,
     changegroup,
     cmdutil,
+    discovery,
     error,
     exchange,
     hg,
@@ -145,8 +146,11 @@
             btype = 'HG20'
             compression = 'BZ'
 
-        cg = changegroup.changegroupsubset(self.repo, bases, [node], 'shelve',
-                                           version=cgversion)
+        outgoing = discovery.outgoing(self.repo, missingroots=bases,
+                                      missingheads=[node])
+        cg = changegroup.makechangegroup(self.repo, outgoing, cgversion,
+                                         'shelve')
+
         bundle2.writebundle(self.ui, cg, self.fname, btype, self.vfs,
                                 compression=compression)
 
--- a/mercurial/changegroup.py	Sun Sep 10 18:39:02 2017 -0700
+++ b/mercurial/changegroup.py	Sun Sep 10 18:43:59 2017 -0700
@@ -940,22 +940,6 @@
     _changegroupinfo(repo, csets, source)
     return bundler.generate(commonrevs, csets, fastpathlinkrev, source)
 
-def changegroupsubset(repo, roots, heads, source, version='01'):
-    """Compute a changegroup consisting of all the nodes that are
-    descendants of any of the roots and ancestors of any of the heads.
-    Return a chunkbuffer object whose read() method will return
-    successive changegroup chunks.
-
-    It is fairly complex as determining which filenodes and which
-    manifest nodes need to be included for the changeset to be complete
-    is non-trivial.
-
-    Another wrinkle is doing the reverse, figuring out which changeset in
-    the changegroup a particular filenode or manifestnode belongs to.
-    """
-    outgoing = discovery.outgoing(repo, missingroots=roots, missingheads=heads)
-    return makechangegroup(repo, outgoing, version, source)
-
 def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None,
                            version='01'):
     """Like getbundle, but taking a discovery.outgoing as an argument.
@@ -985,7 +969,9 @@
 
 def changegroup(repo, basenodes, source):
     # to avoid a race we use changegroupsubset() (issue1320)
-    return changegroupsubset(repo, basenodes, repo.heads(), source)
+    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
--- a/mercurial/localrepo.py	Sun Sep 10 18:39:02 2017 -0700
+++ b/mercurial/localrepo.py	Sun Sep 10 18:43:59 2017 -0700
@@ -31,6 +31,7 @@
     context,
     dirstate,
     dirstateguard,
+    discovery,
     encoding,
     error,
     exchange,
@@ -289,7 +290,9 @@
         return changegroup.changegroup(self._repo, basenodes, source)
 
     def changegroupsubset(self, bases, heads, source):
-        return changegroup.changegroupsubset(self._repo, bases, heads, source)
+        outgoing = discovery.outgoing(self._repo, missingroots=bases,
+                                      missingheads=heads)
+        return changegroup.makechangegroup(self._repo, outgoing, '01', source)
 
     # End of baselegacywirecommands interface.
 
--- a/mercurial/wireproto.py	Sun Sep 10 18:39:02 2017 -0700
+++ b/mercurial/wireproto.py	Sun Sep 10 18:43:59 2017 -0700
@@ -21,6 +21,7 @@
 from . import (
     bundle2,
     changegroup as changegroupmod,
+    discovery,
     encoding,
     error,
     exchange,
@@ -801,7 +802,9 @@
 def changegroupsubset(repo, proto, bases, heads):
     bases = decodelist(bases)
     heads = decodelist(heads)
-    cg = changegroupmod.changegroupsubset(repo, bases, heads, 'serve')
+    outgoing = discovery.outgoing(repo, missingroots=bases,
+                                  missingheads=heads)
+    cg = changegroupmod.makechangegroup(repo, outgoing, '01', 'serve')
     return streamres(reader=cg, v1compressible=True)
 
 @wireprotocommand('debugwireargs', 'one two *')