Patchwork D10357: Add narrow capabilities for local repos, not just remote peers

login
register
mail settings
Submitter phabricator
Date April 9, 2021, 9:48 p.m.
Message ID <differential-rev-PHID-DREV-hwejjmvswkvmoogiht7u-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48674/
State Superseded
Headers show

Comments

phabricator - April 9, 2021, 9:48 p.m.
charlesetc created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This fixes the bug where running `hg clone --narrow ./local-repo`
  fails with
  
    abort: server does not support narrow clones
  
  even when the server has narrow enabled.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/localrepo.py
  tests/test-narrow-clone.t
  tests/test-narrow.t

CHANGE DETAILS




To: charlesetc, durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-narrow.t b/tests/test-narrow.t
--- a/tests/test-narrow.t
+++ b/tests/test-narrow.t
@@ -61,7 +61,7 @@ 
   [255]
 
 Names with '.' in them are OK.
-  $ hg clone --narrow ssh://user@dummy/master should-work --include a/.b/c
+  $ hg clone --narrow ./master should-work --include a/.b/c
   requesting all changes
   adding changesets
   adding manifests
diff --git a/tests/test-narrow-clone.t b/tests/test-narrow-clone.t
--- a/tests/test-narrow-clone.t
+++ b/tests/test-narrow-clone.t
@@ -62,15 +62,17 @@ 
 
   $ cd ..
 
-BUG: local-to-local narrow clones should work, but don't.
+local-to-local narrow clones work
 
   $ hg clone --narrow master narrow-via-localpeer --noupdate --include "dir/src/f10"
   requesting all changes
-  abort: server does not support narrow clones
-  [255]
+  adding changesets
+  adding manifests
+  adding file changes
+  added 3 changesets with 1 changes to 1 files
+  new changesets 5d21aaea77f8:26ce255d5b5d
   $ hg tracked -R narrow-via-localpeer
-  abort: repository narrow-via-localpeer not found
-  [255]
+  I path:dir/src/f10
   $ rm -Rf narrow-via-localpeer
 
 narrow clone with a newline should fail
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -71,6 +71,7 @@ 
     txnutil,
     util,
     vfs as vfsmod,
+    wireprototypes,
 )
 
 from .interfaces import (
@@ -1473,6 +1474,8 @@ 
                 bundle2.getrepocaps(self, role=b'client')
             )
             caps.add(b'bundle2=' + urlreq.quote(capsblob))
+        if self.ui.configbool(b'experimental', b'narrow'):
+            caps.add(wireprototypes.NARROWCAP)
         return caps
 
     # Don't cache auditor/nofsauditor, or you'll end up with reference cycle: