narrow: add capabilities for local repos, not just remote peers
authorCharles Chamberlain <cchamberlain@janestreet.com>
Fri, 09 Apr 2021 17:41:48 -0400
changeset 46902 631001150e13
parent 46901 51841b23670b
child 46903 856820b497fc
narrow: add capabilities for local repos, not just remote peers 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. Differential Revision: https://phab.mercurial-scm.org/D10357
mercurial/localrepo.py
tests/test-narrow-clone.t
tests/test-narrow.t
--- a/mercurial/localrepo.py	Thu Mar 25 22:29:41 2021 -0400
+++ b/mercurial/localrepo.py	Fri Apr 09 17:41:48 2021 -0400
@@ -73,6 +73,7 @@
     txnutil,
     util,
     vfs as vfsmod,
+    wireprototypes,
 )
 
 from .interfaces import (
@@ -1495,6 +1496,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:
--- a/tests/test-narrow-clone.t	Thu Mar 25 22:29:41 2021 -0400
+++ b/tests/test-narrow-clone.t	Fri Apr 09 17:41:48 2021 -0400
@@ -64,15 +64,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
--- a/tests/test-narrow.t	Thu Mar 25 22:29:41 2021 -0400
+++ b/tests/test-narrow.t	Fri Apr 09 17:41:48 2021 -0400
@@ -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