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

login
register
mail settings
Submitter phabricator
Date April 12, 2019, 2:25 p.m.
Message ID <ba9bdacaf47cf5e5c9e453c03c8b8d2e@localhost.localdomain>
Download mbox | patch
Permalink /patch/39562/
State Not Applicable
Headers show

Comments

phabricator - April 12, 2019, 2:25 p.m.
pulkit updated this revision to Diff 14711.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6218?vs=14691&id=14711

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

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

CHANGE DETAILS




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

Patch

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,15 @@ 
 def _handlechangespec_2(op, inpart):
     includepats = set(inpart.params.get(_SPECPART_INCLUDE, '').splitlines())
     excludepats = set(inpart.params.get(_SPECPART_EXCLUDE, '').splitlines())
+    data = inpart.read()
+    # old servers don't send includes and excludes using bundle2 data, they use
+    # bundle2 parameters instead.
+    if data:
+        inc, exc = data.split('\0')
+        if inc:
+            includepats |= set(inc.splitlines())
+        if exc:
+            excludepats |= set(exc.splitlines())
     narrowspec.validatepatterns(includepats)
     narrowspec.validatepatterns(excludepats)