narrow: pass 'narrow_widen' as source while generating changegroup
authorPulkit Goyal <pulkit@yandex-team.ru>
Fri, 28 Sep 2018 19:21:24 +0300
changeset 39962 fa2395659828
parent 39961 ad9ca365738b
child 39963 693dda764efe
narrow: pass 'narrow_widen' as source while generating changegroup Extensions inspect the `source` parameter and add some custom logic on the basis of value of that parameter. The parameter is also passed to hooks. So let's pass the value as 'narrow_widen' to differentiate widening from pull. Differential Revision: https://phab.mercurial-scm.org/D4787
hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py	Fri Sep 28 19:18:17 2018 +0300
+++ b/hgext/narrow/narrowbundle2.py	Fri Sep 28 19:21:24 2018 +0300
@@ -51,7 +51,7 @@
     caps[NARROWCAP] = ['v0']
     return caps
 
-def widen_bundle(repo, diffmatcher, common, known, cgversion, source, ellipses):
+def widen_bundle(repo, diffmatcher, common, known, cgversion, ellipses):
     """generates changegroup for widening a narrow clone
 
     repo is the localrepository instance
@@ -60,7 +60,6 @@
     common is set of common revs 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
-    source is the command which called this codepath
     ellipses is boolean value telling whether to send ellipses data or not
 
     returns changegroup data of the changegroup built or return None if there
@@ -80,7 +79,7 @@
                                         filematcher=diffmatcher,
                                         fullnodes=commonnodes)
         cgdata = packer.generate(set([nullid]), list(commonnodes), False,
-                                 source, changelog=False)
+                                 'narrow_widen', changelog=False)
 
         return cgdata
 
@@ -114,8 +113,7 @@
     common = set(common or [nullid])
 
     if (oldinclude != include or oldexclude != exclude):
-        cgdata = widen_bundle(repo, diffmatch, common, [], version,
-                              source, False)
+        cgdata = widen_bundle(repo, diffmatch, common, [], version, False)
         if cgdata is not None:
             part = bundler.newpart('changegroup', data=cgdata)
             part.addparam('version', version)
@@ -194,7 +192,7 @@
                                             shallow=depth is not None,
                                             ellipsisroots=newellipsis,
                                             fullnodes=newfull)
-            cgdata = packer.generate(common, newvisit, False, source)
+            cgdata = packer.generate(common, newvisit, False, 'narrow_widen')
 
             part = bundler.newpart('changegroup', data=cgdata)
             part.addparam('version', version)
@@ -212,7 +210,7 @@
                                         shallow=depth is not None,
                                         ellipsisroots=ellipsisroots,
                                         fullnodes=relevant_nodes)
-        cgdata = packer.generate(common, visitnodes, False, source)
+        cgdata = packer.generate(common, visitnodes, False, 'narrow_widen')
 
         part = bundler.newpart('changegroup', data=cgdata)
         part.addparam('version', version)