Patchwork [9,of,9,changegroup-apis] exchange: implement _pushchangeset with changegroupemitter

login
register
mail settings
Submitter Gregory Szorc
Date Aug. 1, 2016, 6:18 p.m.
Message ID <73a579f776b0452b77d5.1470075506@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/16023/
State Changes Requested
Delegated to: Pierre-Yves David
Headers show

Comments

Gregory Szorc - Aug. 1, 2016, 6:18 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1469909696 25200
#      Sat Jul 30 13:14:56 2016 -0700
# Node ID 73a579f776b0452b77d579339330fcb8256ffed9
# Parent  bce10af41c89e164e5d74fabeb518fc9174205f9
exchange: implement _pushchangeset with changegroupemitter

Before, we called getlocalchangegroup() or getsubset().
getlocalchangegroup() calls getsubset() and getsubset() is 2
statements to obtain and call a function on a changegroupemitter.
So just avoid all the abstraction and use changegroupemitter
directly.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -884,30 +884,27 @@  def _pushchangeset(pushop):
     pushop.stepsdone.add('changesets')
     if not _pushcheckoutgoing(pushop):
         return
     pushop.repo.prepushoutgoinghooks(pushop)
     outgoing = pushop.outgoing
     unbundle = pushop.remote.capable('unbundle')
     # TODO: get bundlecaps from remote
     bundlecaps = None
-    # create a changegroup from local
+
+    fastpath = False
     if pushop.revs is None and not (outgoing.excluded
                             or pushop.repo.changelog.filteredrevs):
         # push everything,
         # use the fast path, no race possible on push
-        bundler = changegroup.cg1packer(pushop.repo, bundlecaps)
-        cg = changegroup.getsubset(pushop.repo,
-                                   outgoing,
-                                   bundler,
-                                   'push',
-                                   fastpath=True)
-    else:
-        cg = changegroup.getlocalchangegroup(pushop.repo, 'push', outgoing,
-                                        bundlecaps)
+        fastpath = True
+
+    emitter = changegroup.changegroupemitter.fromoutgoing(pushop.repo, outgoing)
+    cg = emitter.getunbundler('01', 'push', bundlecaps=bundlecaps,
+                              fastpathlinkrev=fastpath)
 
     # apply changegroup to remote
     if unbundle:
         # local repo finds heads on server, finds out what
         # revs it must push. once revs transferred, if server
         # finds it has different heads (someone else won
         # commit/push race), server aborts.
         if pushop.force: