D4538: commands: pass include and exclude options to hg.clone()
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Wed Sep 12 09:03:10 EDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4c807ec07888: commands: pass include and exclude options to hg.clone() (authored by indygreg, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D4538?vs=10915&id=10928
REVISION DETAIL
https://phab.mercurial-scm.org/D4538
AFFECTED FILES
mercurial/commands.py
tests/test-narrow-clone.t
tests/test-narrow.t
CHANGE DETAILS
diff --git a/tests/test-narrow.t b/tests/test-narrow.t
--- a/tests/test-narrow.t
+++ b/tests/test-narrow.t
@@ -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]
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
@@ -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 @@
$ 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]
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -43,6 +43,7 @@
hg,
logcmdutil,
merge as mergemod,
+ narrowspec,
obsolete,
obsutil,
patch,
@@ -1466,13 +1467,29 @@
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
To: indygreg, durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list