D6218: narrow: send specs as bundle2 data instead of param (issue5952) (issue6019)

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Mon Apr 8 15:23:32 UTC 2019


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

REVISION SUMMARY
  Before this patch, when ACL is involved, narrowspecs are send as bundle2
  parameter for narrow:spec bundle2 part. The limitation of bundle2 parts are they
  cannot send data larger than 255 bytes. Includes and excludes in narrow are not
  limited by size and they can grow over 255 bytes.
  
  This patch start sending them as bundle2 data. After this change, we try to read
  specs both from parameters and data, making it compatible with older servers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py
  mercurial/exchange.py

CHANGE DETAILS

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -2214,12 +2214,14 @@
     if (kwargs.get(r'narrow', False) and kwargs.get(r'narrow_acl', False)
         and (include or exclude)):
         narrowspecpart = bundler.newpart('narrow:spec')
+        data = ''
         if include:
-            narrowspecpart.addparam(
-                'include', '\n'.join(include), mandatory=True)
+            data += '\n'.join(include)
+        data += '\0'
         if exclude:
-            narrowspecpart.addparam(
-                'exclude', '\n'.join(exclude), mandatory=True)
+            data += '\n'.join(exclude)
+
+        narrowspecpart.data = data
 
 @getbundle2partsgenerator('bookmarks')
 def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None,
diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -144,6 +144,12 @@
 def _handlechangespec_2(op, inpart):
     includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines())
     excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines())
+    data = inpart.read()
+    inc, exc = data.split('\0')
+    if inc:
+        includepats |= set(inc.splitlines())
+    if exc:
+        excludepats |= set(exc.splitlines())
     narrowspec.validatepatterns(includepats)
     narrowspec.validatepatterns(excludepats)
 



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


More information about the Mercurial-devel mailing list