D4838: narrow: start returning bundle2 from widen_bundle()

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Fri Oct 5 13:01:34 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe8132a8897da: narrow: start returning bundle2 from widen_bundle() (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4838?vs=11701&id=11703

REVISION DETAIL
  https://phab.mercurial-scm.org/D4838

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  hgext/narrow/narrowwirepeer.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowwirepeer.py b/hgext/narrow/narrowwirepeer.py
--- a/hgext/narrow/narrowwirepeer.py
+++ b/hgext/narrow/narrowwirepeer.py
@@ -69,7 +69,6 @@
     ellipses: whether to send ellipses data or not
     """
 
-    bundler = bundle2.bundle20(repo.ui)
     try:
         oldincludes = wireprototypes.decodelist(oldincludes)
         newincludes = wireprototypes.decodelist(newincludes)
@@ -96,15 +95,10 @@
                                     exclude=oldexcludes)
         diffmatch = matchmod.differencematcher(newmatch, oldmatch)
 
-        # get changegroup data
-        cg = narrowbundle2.widen_bundle(repo, diffmatch, common, known,
-                                        cgversion, ellipses)
-        if cg is not None:
-            part = bundler.newpart('changegroup', data=cg)
-            part.addparam('version', cgversion)
-            if 'treemanifest' in repo.requirements:
-                part.addparam('treemanifest', '1')
+        bundler = narrowbundle2.widen_bundle(repo, diffmatch, common, known,
+                                             cgversion, ellipses)
     except error.Abort as exc:
+        bundler = bundle2.bundle20(repo.ui)
         manargs = [('message', pycompat.bytestr(exc))]
         advargs = []
         if exc.hint is not None:
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -51,7 +51,7 @@
     return caps
 
 def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses):
-    """generates changegroup for widening a narrow clone
+    """generates bundle2 for widening a narrow clone
 
     repo is the localrepository instance
     diffmatcher is a differencemacther of '(newincludes, newexcludes) -
@@ -61,11 +61,9 @@
     cgversion is the changegroup version to send
     ellipses is boolean value telling whether to send ellipses data or not
 
-    returns changegroup data of the changegroup built or return None if there
-    are no common revs
+    returns bundle2 of the data required for extending
     """
-    # XXX: This patch will start sending bundle2 after couple of patches when
-    # called from the wireprotocol command
+    bundler = bundle2.bundle20(repo.ui)
     commonnodes = set()
     cl = repo.changelog
     for r in repo.revs("::%ln", common):
@@ -79,9 +77,12 @@
         cgdata = packer.generate(set([nullid]), list(commonnodes), False,
                                  'narrow_widen', changelog=False)
 
-        return cgdata
+        part = bundler.newpart('changegroup', data=cgdata)
+        part.addparam('version', cgversion)
+        if 'treemanifest' in repo.requirements:
+            part.addparam('treemanifest', '1')
 
-    return None
+    return bundler
 
 # Serve a changegroup for a client with a narrow clone.
 def getbundlechangegrouppart_narrow(bundler, repo, source,



To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list