addremove: automatically process a subrepository's subrepos
Since addremove on the top of a directory tree will recursively handle sub
directories, it should be the same with deep subrepos, once the user has
explicitly asked to process a subrepo. This really only has an effect when a
path that is a subrepo (or is in a subrepo) is given, since -S causes all
subrepos to be processed already. An addremove without a path that crosses into
a subrepo, will still not enter any subrepos, per backward compatibility rules.
--- a/mercurial/subrepo.py Sun Nov 09 23:46:25 2014 -0500
+++ b/mercurial/subrepo.py Sun Nov 30 22:47:53 2014 -0500
@@ -5,6 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
+import copy
import errno, os, re, shutil, posixpath, sys
import xml.dom.minidom
import stat, subprocess, tarfile
@@ -624,6 +625,11 @@
os.path.join(prefix, self._path), explicitonly)
def addremove(self, m, prefix, opts, dry_run, similarity):
+ # In the same way as sub directories are processed, once in a subrepo,
+ # always entry any of its subrepos. Don't corrupt the options that will
+ # be used to process sibling subrepos however.
+ opts = copy.copy(opts)
+ opts['subrepos'] = True
return scmutil.addremove(self._repo, m,
os.path.join(prefix, self._path), opts,
dry_run, similarity)
--- a/tests/test-subrepo-deep-nested-change.t Sun Nov 09 23:46:25 2014 -0500
+++ b/tests/test-subrepo-deep-nested-change.t Sun Nov 30 22:47:53 2014 -0500
@@ -155,6 +155,10 @@
? foo/bar/abc
? sub1/foo
$ hg update -Cq
+ $ hg addremove sub1
+ adding sub1/sub2/folder/bar (glob)
+ adding sub1/foo (glob)
+ $ hg update -Cq
$ rm sub1/sub2/folder/test.txt
$ rm sub1/sub2/test.txt
$ hg ci -ASm "remove test.txt"