D4888: narrow: move the code to generate a widening bundle2 to core

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Fri Oct 5 14:04:45 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1ea80ac13f19: narrow: move the code to generate a widening bundle2 to core (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4888?vs=11704&id=11707

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

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

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -2266,3 +2266,37 @@
     repo.ui.debug('applying stream bundle\n')
     streamclone.applybundlev2(repo, part, filecount, bytecount,
                               requirements)
+
+def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses):
+    """generates bundle2 for widening a narrow clone
+
+    repo is the localrepository instance
+    diffmatcher is a differencemacther of '(newincludes, newexcludes) -
+    (oldincludes, oldexcludes)'
+    common is set of common heads between server and client
+    known is a set of revs known on the client side (used in ellipses)
+    cgversion is the changegroup version to send
+    ellipses is boolean value telling whether to send ellipses data or not
+
+    returns bundle2 of the data required for extending
+    """
+    bundler = bundle20(repo.ui)
+    commonnodes = set()
+    cl = repo.changelog
+    for r in repo.revs("::%ln", common):
+        commonnodes.add(cl.node(r))
+    if commonnodes:
+        # XXX: we should only send the filelogs (and treemanifest). user
+        # already has the changelog and manifest
+        packer = changegroup.getbundler(cgversion, repo,
+                                        filematcher=diffmatcher,
+                                        fullnodes=commonnodes)
+        cgdata = packer.generate(set([nodemod.nullid]), list(commonnodes),
+                                 False, 'narrow_widen', changelog=False)
+
+        part = bundler.newpart('changegroup', data=cgdata)
+        part.addparam('version', cgversion)
+        if 'treemanifest' in repo.requirements:
+            part.addparam('treemanifest', '1')
+
+    return bundler
diff --git a/hgext/narrow/narrowwirepeer.py b/hgext/narrow/narrowwirepeer.py
--- a/hgext/narrow/narrowwirepeer.py
+++ b/hgext/narrow/narrowwirepeer.py
@@ -21,8 +21,6 @@
     wireprotov1server,
 )
 
-from . import narrowbundle2
-
 def uisetup():
     extensions.wrapfunction(wireprotov1server, '_capabilities', addnarrowcap)
     wireprotov1peer.wirepeer.narrow_widen = peernarrowwiden
@@ -95,7 +93,7 @@
                                     exclude=oldexcludes)
         diffmatch = matchmod.differencematcher(newmatch, oldmatch)
 
-        bundler = narrowbundle2.widen_bundle(repo, diffmatch, common, known,
+        bundler = bundle2.widen_bundle(repo, diffmatch, common, known,
                                              cgversion, ellipses)
     except error.Abort as exc:
         bundler = bundle2.bundle20(repo.ui)
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -50,40 +50,6 @@
     caps[NARROWCAP] = ['v0']
     return caps
 
-def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses):
-    """generates bundle2 for widening a narrow clone
-
-    repo is the localrepository instance
-    diffmatcher is a differencemacther of '(newincludes, newexcludes) -
-    (oldincludes, oldexcludes)'
-    common is set of common heads between server and client
-    known is a set of revs known on the client side (used in ellipses)
-    cgversion is the changegroup version to send
-    ellipses is boolean value telling whether to send ellipses data or not
-
-    returns bundle2 of the data required for extending
-    """
-    bundler = bundle2.bundle20(repo.ui)
-    commonnodes = set()
-    cl = repo.changelog
-    for r in repo.revs("::%ln", common):
-        commonnodes.add(cl.node(r))
-    if commonnodes:
-        # XXX: we should only send the filelogs (and treemanifest). user
-        # already has the changelog and manifest
-        packer = changegroup.getbundler(cgversion, repo,
-                                        filematcher=diffmatcher,
-                                        fullnodes=commonnodes)
-        cgdata = packer.generate(set([nullid]), list(commonnodes), False,
-                                 'narrow_widen', changelog=False)
-
-        part = bundler.newpart('changegroup', data=cgdata)
-        part.addparam('version', cgversion)
-        if 'treemanifest' in repo.requirements:
-            part.addparam('treemanifest', '1')
-
-    return bundler
-
 # Serve a changegroup for a client with a narrow clone.
 def getbundlechangegrouppart_narrow(bundler, repo, source,
                                     bundlecaps=None, b2caps=None, heads=None,



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


More information about the Mercurial-devel mailing list