# HG changeset patch # User Matt Harbison # Date 2014-11-10 04:46:25 # Node ID cb42050f2dadfbb876452e23287441a937c20c5c # Parent ccfb56450f21e627d8d960a15e00b8d27176693a addremove: support addremove with explicit paths in subrepos Git and svn subrepos are currently not supported. diff --git a/mercurial/help/subrepos.txt b/mercurial/help/subrepos.txt --- a/mercurial/help/subrepos.txt +++ b/mercurial/help/subrepos.txt @@ -82,8 +82,10 @@ Interaction with Mercurial Commands ignored. :addremove: addremove does not recurse into subrepos unless - -S/--subrepos is specified. Git and Subversion subrepositories - will print a warning and continue. + -S/--subrepos is specified. However, if you specify the full + path of a directory in a subrepo, addremove will be performed on + it even without -S/--subrepos being specified. Git and + Subversion subrepositories will print a warning and continue. :archive: archive does not recurse in subrepositories unless -S/--subrepos is specified. diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -723,9 +723,17 @@ def addremove(repo, matcher, prefix, opt ret = 0 join = lambda f: os.path.join(prefix, f) + def matchessubrepo(matcher, subpath): + if matcher.exact(subpath): + return True + for f in matcher.files(): + if f.startswith(subpath): + return True + return False + wctx = repo[None] for subpath in sorted(wctx.substate): - if opts.get('subrepos'): + if opts.get('subrepos') or matchessubrepo(m, subpath): sub = wctx.sub(subpath) try: submatch = matchmod.narrowmatcher(subpath, m) 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 @@ -147,9 +147,18 @@ Test relative path printing + subrepos A sub1/foo R sub1/sub2/test.txt $ hg update -Cq + $ touch sub1/sub2/folder/bar + $ hg addremove sub1/sub2 + adding sub1/sub2/folder/bar (glob) + $ hg status -S + A sub1/sub2/folder/bar + ? foo/bar/abc + ? sub1/foo + $ hg update -Cq $ rm sub1/sub2/folder/test.txt $ rm sub1/sub2/test.txt $ hg ci -ASm "remove test.txt" + adding sub1/sub2/folder/bar (glob) removing sub1/sub2/folder/test.txt (glob) removing sub1/sub2/test.txt (glob) adding sub1/foo (glob)