[PATCH 2 of 3 V2] remove: support remove with explicit paths in subrepos
Matt Harbison
matt_harbison at yahoo.com
Sun Nov 16 00:16:32 CST 2014
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1415852120 18000
# Wed Nov 12 23:15:20 2014 -0500
# Node ID 39371efb61771bea0759c1e2238b43ec60d394a4
# Parent a35171de7e3c42d7bdcbc3717e6f8fb620a76bb0
remove: support remove with explicit paths in subrepos
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2060,8 +2060,16 @@
wctx = repo[None]
- if subrepos:
- for subpath in sorted(wctx.substate):
+ for subpath in sorted(wctx.substate):
+ def matchessubrepo(matcher, subpath):
+ if matcher.exact(subpath):
+ return True
+ for f in matcher.files():
+ if f.startswith(subpath):
+ return True
+ return False
+
+ if subrepos or matchessubrepo(m, subpath):
sub = wctx.sub(subpath)
try:
submatch = matchmod.narrowmatcher(subpath, m)
@@ -2080,7 +2088,7 @@
return True
return False
- if f in repo.dirstate or f in wctx.dirs() or (subrepos and insubrepo()):
+ if f in repo.dirstate or f in wctx.dirs() or insubrepo():
continue
if os.path.exists(m.rel(join(f))):
diff --git a/mercurial/help/subrepos.txt b/mercurial/help/subrepos.txt
--- a/mercurial/help/subrepos.txt
+++ b/mercurial/help/subrepos.txt
@@ -130,8 +130,10 @@
ignored.
:remove: remove does not recurse into subrepositories unless
- -S/--subrepos is specified. Git and Subversion subrepositories
- are currently silently ignored.
+ -S/--subrepos is specified. However, if you specify a file or
+ directory path in a subrepo, it will be removed even without
+ -S/--subrepos. Git and Subversion subrepositories are currently
+ silently ignored.
:update: update restores the subrepos in the state they were
originally committed in target changeset. If the recorded
diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t
--- a/tests/test-subrepo-deep-nested-change.t
+++ b/tests/test-subrepo-deep-nested-change.t
@@ -120,6 +120,14 @@
R sub1/sub2/folder/test.txt
R sub1/sub2/test.txt
$ hg update -Cq
+ $ hg remove -I 're:.*.txt' sub1
+ $ hg status -S
+ $ hg remove sub1/sub2/folder/test.txt
+ $ hg remove sub1/.hgsubstate
+ $ hg status -S
+ R sub1/.hgsubstate
+ R sub1/sub2/folder/test.txt
+ $ hg update -Cq
$ hg --config extensions.largefiles=! archive -S ../archive_all
$ find ../archive_all | sort
More information about the Mercurial-devel
mailing list