narrow: check for servers' narrow support before doing anything (BC)
Recently we introduced narrow capabilities for the server. So we can check
whether a server has narrow clone support or not before doing anything. This is
BC because new clients won't be able to extend from old narrow-enabled servers.
I *think* narrow is not used much (maybe just inside Google), also it's
experimental so I think we can change this. We will need to this someday anyway.
The "doesn't" in error is changed to "does not" because I think that's we do in
core. I also changed one more instance of the error message to use 'does not'
for consistency.
Differential Revision: https://phab.mercurial-scm.org/D4789
--- a/hgext/narrow/narrowcommands.py Sun Sep 30 18:59:27 2018 +0300
+++ b/hgext/narrow/narrowcommands.py Fri Sep 28 23:53:09 2018 +0300
@@ -134,7 +134,7 @@
return orig(pullop, kwargs)
if wireprotoserver.NARROWCAP not in pullop.remote.capabilities():
- raise error.Abort(_("server doesn't support narrow clones"))
+ raise error.Abort(_("server does not support narrow clones"))
orig(pullop, kwargs)
kwargs['narrow'] = True
include, exclude = repo.narrowpats
@@ -408,6 +408,13 @@
url, branches = hg.parseurl(remotepath)
ui.status(_('comparing with %s\n') % util.hidepassword(url))
remote = hg.peer(repo, opts, url)
+
+ # check narrow support before doing anything if widening needs to be
+ # performed. In future we should also abort if client is ellipses and
+ # server does not support ellipses
+ if widening and wireprotoserver.NARROWCAP not in remote.capabilities():
+ raise error.Abort(_("server does not support narrow clones"))
+
commoninc = discovery.findcommonincoming(repo, remote)
oldincludes, oldexcludes = repo.narrowpats
--- a/tests/test-narrow-clone-non-narrow-server.t Sun Sep 30 18:59:27 2018 +0300
+++ b/tests/test-narrow-clone-non-narrow-server.t Fri Sep 28 23:53:09 2018 +0300
@@ -39,7 +39,7 @@
$ hg clone --narrow --include f1 http://localhost:$HGPORT1/ narrowclone
requesting all changes
- abort: server doesn't support narrow clones
+ abort: server does not support narrow clones
[255]
Make a narrow clone (via HGPORT2), then try to narrow and widen
@@ -60,7 +60,5 @@
looking for local changes to affected paths
$ hg tracked --addinclude f1 http://localhost:$HGPORT1/
comparing with http://localhost:$HGPORT1/
- searching for changes
- no changes found
- abort: server doesn't support narrow clones
+ abort: server does not support narrow clones
[255]
--- a/tests/test-narrow-clone.t Sun Sep 30 18:59:27 2018 +0300
+++ b/tests/test-narrow-clone.t Fri Sep 28 23:53:09 2018 +0300
@@ -65,7 +65,7 @@
$ hg clone --narrow master narrow-via-localpeer --noupdate --include "dir/src/f10"
requesting all changes
- abort: server doesn't support narrow clones
+ abort: server does not support narrow clones
[255]
$ hg tracked -R narrow-via-localpeer
abort: repository narrow-via-localpeer not found!