Patchwork [8,of,8,V3] addremove: automatically process a subrepository's subrepos

login
register
mail settings
Submitter Matt Harbison
Date Dec. 12, 2014, 3:35 a.m.
Message ID <cba08c31e07cc302688c.1418355320@Envy>
Download mbox | patch
Permalink /patch/7061/
State Accepted
Commit f274d27f199492d239f7f2a5641f7ade7b25a8d9
Headers show

Comments

Matt Harbison - Dec. 12, 2014, 3:35 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1417405673 18000
#      Sun Nov 30 22:47:53 2014 -0500
# Node ID cba08c31e07cc302688cd220d201e33be454e466
# Parent  e2f70cc71434d6cca73e48544b7ed48576f37c64
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.
Matt Mackall - Dec. 12, 2014, 9:09 p.m.
On Thu, 2014-12-11 at 22:35 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1417405673 18000
> #      Sun Nov 30 22:47:53 2014 -0500
> # Node ID cba08c31e07cc302688cd220d201e33be454e466
> # Parent  e2f70cc71434d6cca73e48544b7ed48576f37c64
> addremove: automatically process a subrepository's subrepos

These are queued for default, thanks.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -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)
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
@@ -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"