changegroup: replace getchangegroup with makechangegroup
authorDurham Goode <durham@fb.com>
Sun, 10 Sep 2017 18:50:12 -0700
changeset 34101 5ede882c249c
parent 34100 1632999d4bed
child 34102 dbf598196f05
changegroup: replace getchangegroup with makechangegroup As part of reducing the number of changegroup creation APIs, let's replace getchangegroup with calls to makechangegroup. This is mostly a drop in replacement, but it does change the version specifier to be required, so it's more obvious which callers are creating old version 1 changegroups still. Differential Revision: https://phab.mercurial-scm.org/D669
mercurial/bundle2.py
mercurial/changegroup.py
mercurial/exchange.py
tests/test-bundle2-format.t
tests/test-bundle2-multiple-changegroups.t
tests/test-bundle2-remote-changegroup.t
--- a/mercurial/bundle2.py	Sun Sep 10 18:48:42 2017 -0700
+++ b/mercurial/bundle2.py	Sun Sep 10 18:50:12 2017 -0700
@@ -1393,7 +1393,7 @@
 def writenewbundle(ui, repo, source, filename, bundletype, outgoing, opts,
                    vfs=None, compression=None, compopts=None):
     if bundletype.startswith('HG10'):
-        cg = changegroup.getchangegroup(repo, source, outgoing, version='01')
+        cg = changegroup.makechangegroup(repo, outgoing, '01', source)
         return writebundle(ui, cg, filename, bundletype, vfs=vfs,
                            compression=compression, compopts=compopts)
     elif not bundletype.startswith('HG20'):
@@ -1421,8 +1421,7 @@
     cgversion = opts.get('cg.version')
     if cgversion is None:
         cgversion = changegroup.safeversion(repo)
-    cg = changegroup.getchangegroup(repo, source, outgoing,
-                                    version=cgversion)
+    cg = changegroup.makechangegroup(repo, outgoing, cgversion, source)
     part = bundler.newpart('changegroup', data=cg.getchunks())
     part.addparam('version', cg.version)
     if 'clcount' in cg.extras:
--- a/mercurial/changegroup.py	Sun Sep 10 18:48:42 2017 -0700
+++ b/mercurial/changegroup.py	Sun Sep 10 18:50:12 2017 -0700
@@ -939,17 +939,6 @@
     _changegroupinfo(repo, csets, source)
     return bundler.generate(commonrevs, csets, fastpathlinkrev, source)
 
-def getchangegroup(repo, source, outgoing, bundlecaps=None,
-                   version='01'):
-    """Like getbundle, but taking a discovery.outgoing as an argument.
-
-    This is only implemented for local repos and reuses potentially
-    precomputed sets in outgoing."""
-    if not outgoing.missing:
-        return None
-    return makechangegroup(repo, outgoing, version, source,
-                           bundlecaps=bundlecaps)
-
 def _addchangegroupfiles(repo, source, revmap, trp, expectedfiles, needfiles):
     revisions = 0
     files = 0
--- a/mercurial/exchange.py	Sun Sep 10 18:48:42 2017 -0700
+++ b/mercurial/exchange.py	Sun Sep 10 18:50:12 2017 -0700
@@ -965,8 +965,8 @@
         cg = changegroup.makechangegroup(pushop.repo, outgoing, '01', 'push',
                 fastpath=True, bundlecaps=bundlecaps)
     else:
-        cg = changegroup.getchangegroup(pushop.repo, 'push', outgoing,
-                                        bundlecaps=bundlecaps)
+        cg = changegroup.makechangegroup(pushop.repo, outgoing, '01',
+                                        'push', bundlecaps=bundlecaps)
 
     # apply changegroup to remote
     # local repo finds heads on server, finds out what
--- a/tests/test-bundle2-format.t	Sun Sep 10 18:48:42 2017 -0700
+++ b/tests/test-bundle2-format.t	Sun Sep 10 18:50:12 2017 -0700
@@ -114,7 +114,8 @@
   >             headmissing = [c.node() for c in repo.set('heads(%ld)', revs)]
   >             headcommon  = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)]
   >             outgoing = discovery.outgoing(repo, headcommon, headmissing)
-  >             cg = changegroup.getchangegroup(repo, 'test:bundle2', outgoing, None)
+  >             cg = changegroup.makechangegroup(repo, outgoing, '01',
+  >                                              'test:bundle2')
   >             bundler.newpart('changegroup', data=cg.getchunks(),
   >                             mandatory=False)
   > 
--- a/tests/test-bundle2-multiple-changegroups.t	Sun Sep 10 18:48:42 2017 -0700
+++ b/tests/test-bundle2-multiple-changegroups.t	Sun Sep 10 18:50:12 2017 -0700
@@ -13,13 +13,13 @@
   >     # in 'heads' as intermediate heads for the first changegroup.
   >     intermediates = [repo[r].p1().node() for r in heads]
   >     outgoing = discovery.outgoing(repo, common, intermediates)
-  >     cg = changegroup.getchangegroup(repo, source, outgoing,
-  >                                     bundlecaps=bundlecaps)
+  >     cg = changegroup.makechangegroup(repo, outgoing, '01',
+  >                                      source, bundlecaps=bundlecaps)
   >     bundler.newpart('output', data='changegroup1')
   >     bundler.newpart('changegroup', data=cg.getchunks())
   >     outgoing = discovery.outgoing(repo, common + intermediates, heads)
-  >     cg = changegroup.getchangegroup(repo, source, outgoing,
-  >                                     bundlecaps=bundlecaps)
+  >     cg = changegroup.makechangegroup(repo, outgoing, '01',
+  >                                      source, bundlecaps=bundlecaps)
   >     bundler.newpart('output', data='changegroup2')
   >     bundler.newpart('changegroup', data=cg.getchunks())
   > 
--- a/tests/test-bundle2-remote-changegroup.t	Sun Sep 10 18:48:42 2017 -0700
+++ b/tests/test-bundle2-remote-changegroup.t	Sun Sep 10 18:50:12 2017 -0700
@@ -64,7 +64,8 @@
   >             common.extend(repo.lookup(r) for r in repo.revs(_common))
   >             heads = [repo.lookup(r) for r in repo.revs(heads)]
   >             outgoing = discovery.outgoing(repo, common, heads)
-  >             cg = changegroup.getchangegroup(repo, 'changegroup', outgoing)
+  >             cg = changegroup.makechangegroup(repo, outgoing, '01',
+  >                                              'changegroup')
   >             newpart('changegroup', cg.getchunks())
   >         else:
   >             raise Exception('unknown verb')