# HG changeset patch # User Charles Chamberlain # Date 1618004508 14400 # Node ID 631001150e136d8c35f08a6aa6742eee308c03fd # Parent 51841b23670bbd659dfd9cc70bab27c325278ebe 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 diff -r 51841b23670b -r 631001150e13 mercurial/localrepo.py --- 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: diff -r 51841b23670b -r 631001150e13 tests/test-narrow-clone.t --- 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 diff -r 51841b23670b -r 631001150e13 tests/test-narrow.t --- 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