Commit 3e1e2e5b authored by Gregory Szorc's avatar Gregory Szorc
Browse files

commands: pass include and exclude options to hg.clone()

These arguments are defined by the narrow extension. Let's teach
core to recognize them so we can delete some code from the narrow
extension and start to exercise the in-core code for performing a
narrow clone.

We have no way of easily testing it, but this change should result in
.hg/requires having the narrow requirement from the time the file
is written rather than added as part of pull. We'll confirm this when
we delete some monkeypatched functions from the narrow extension in
later commits.

Test output changed because hg.clone() is now receiving patterns
and validation of those values is occurring sooner, before the exchange
code runs and prints the message that was deleted.

Differential Revision: https://phab.mercurial-scm.org/D4538
parent 261f1e8dc300
......@@ -43,6 +43,7 @@ from . import (
hg,
logcmdutil,
merge as mergemod,
narrowspec,
obsolete,
obsutil,
patch,
......@@ -1466,13 +1467,29 @@ def clone(ui, source, dest=None, **opts):
if opts.get('noupdate') and opts.get('updaterev'):
raise error.Abort(_("cannot specify both --noupdate and --updaterev"))
# --include/--exclude can come from narrow or sparse.
includepats, excludepats = None, None
# hg.clone() differentiates between None and an empty set. So make sure
# patterns are sets if narrow is requested without patterns.
if opts.get('narrow'):
includepats = set()
excludepats = set()
if opts.get('include'):
includepats = narrowspec.parsepatterns(opts.get('include'))
if opts.get('exclude'):
excludepats = narrowspec.parsepatterns(opts.get('exclude'))
r = hg.clone(ui, opts, source, dest,
pull=opts.get('pull'),
stream=opts.get('stream') or opts.get('uncompressed'),
revs=opts.get('rev'),
update=opts.get('updaterev') or not opts.get('noupdate'),
branch=opts.get('branch'),
shareopts=opts.get('shareopts'))
shareopts=opts.get('shareopts'),
storeincludepats=includepats,
storeexcludepats=excludepats)
return r is None
......
......@@ -19,13 +19,11 @@
Only path: and rootfilesin: pattern prefixes are allowed
$ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --include 'glob:**'
requesting all changes
abort: invalid prefix on narrow pattern: glob:**
(narrow patterns must begin with one of the following: path:, rootfilesin:)
[255]
$ hg clone --narrow ssh://user@dummy/master badnarrow --noupdate --exclude 'set:ignored'
requesting all changes
abort: invalid prefix on narrow pattern: set:ignored
(narrow patterns must begin with one of the following: path:, rootfilesin:)
[255]
......@@ -67,7 +65,6 @@ narrow clone with a newline should fail
$ hg clone --narrow ssh://user@dummy/master narrow_fail --noupdate --include 'dir/src/f10
> '
requesting all changes
abort: newlines are not allowed in narrowspec paths
[255]
......
......@@ -38,15 +38,12 @@
Error if '.' or '..' are in the directory to track.
$ hg clone --narrow ssh://user@dummy/master foo --include ./asdf
requesting all changes
abort: "." and ".." are not allowed in narrowspec paths
[255]
$ hg clone --narrow ssh://user@dummy/master foo --include asdf/..
requesting all changes
abort: "." and ".." are not allowed in narrowspec paths
[255]
$ hg clone --narrow ssh://user@dummy/master foo --include a/./c
requesting all changes
abort: "." and ".." are not allowed in narrowspec paths
[255]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment