pulkit created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch takes out the logic which generates a changegroup for widening a
  narrow clone when ellipses are disabled. This is done because future patches
  will introduce a narrow_widen() wireprotocol command which will send a
  changegroup and will use this function.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py

CHANGE DETAILS

diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -51,6 +51,37 @@
     caps[NARROWCAP] = ['v0']
     return caps
 
+def widen_changegroup(repo, diffmatcher, common, cgversion, source):
+    """generates changegroup for widening a narrow clone
+
+    repo is the localrepository instance
+    diffmatcher is a differencemacther of '(newincludes, newexcludes) -
+    (oldincludes, oldexcludes)'
+    common is set of common revs between server and client
+    cgversion is the changegroup version to send
+    source is the command which called this codepath
+
+    returns changegroup data of the changegroup built or return None if there
+    are no common revs
+    """
+    common = repo.revs("::%ln", common)
+    commonnodes = set()
+    cl = repo.changelog
+    for c in common:
+        commonnodes.add(cl.node(c))
+    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,
+                                 source, changelog=False)
+
+        return cgdata
+
+    return None
+
 def getbundlechangegrouppart_widen(bundler, repo, source, bundlecaps=None,
                                    b2caps=None, heads=None, common=None,
                                    **kwargs):
@@ -79,20 +110,8 @@
     common = set(common or [nullid])
 
     if (oldinclude != include or oldexclude != exclude):
-        common = repo.revs("::%ln", common)
-        commonnodes = set()
-        cl = repo.changelog
-        for c in common:
-            commonnodes.add(cl.node(c))
-        if commonnodes:
-            # XXX: we should only send the filelogs (and treemanifest). user
-            # already has the changelog and manifest
-            packer = changegroup.getbundler(version, repo,
-                                            filematcher=diffmatch,
-                                            fullnodes=commonnodes)
-            cgdata = packer.generate(set([nullid]), list(commonnodes), False,
-                                     source, changelog=False)
-
+        cgdata = widen_changegroup(repo, diffmatch, common, version, source)
+        if cgdata is not None:
             part = bundler.newpart('changegroup', data=cgdata)
             part.addparam('version', version)
             if 'treemanifest' in repo.requirements:



To: pulkit, durin42, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to