changeset 15321:e174353e8cda stable

subrepos: abort commit by default if a subrepo is dirty (BC) This changeset flips the default value of ui.commitsubrepos setting from True to False and adds a --subrepos flag to commit. The commit, status, and diff commands behave like this with regard to recusion and the ui.commitsubrepos setting: | recurses | recurses | by default | with --subrepos --------+---------------+---------------- commit: | commitsubrepo | True status: | False | True diff: | False | True By changing the default from True to False, the table becomes consistent in the two columns: * without --subrepos on the command line, commit will abort if a subrepo is dirty and status/diff wont show changes inside subrepos. * with --subrepos, all three commands will recurse. A --subrepos flag on the command line overrides the config settin.g
author Martin Geisler <mg@lazybytes.net>
date Fri, 21 Oct 2011 00:33:08 +0200
parents 681267a5f491
children c8e2a5ea7062
files mercurial/commands.py mercurial/help/config.txt mercurial/localrepo.py tests/test-debugcomplete.t tests/test-mq-subrepo.t tests/test-qrecord.t tests/test-subrepo-deep-nested-change.t tests/test-subrepo-git.t tests/test-subrepo-recursion.t tests/test-subrepo-svn.t tests/test-subrepo.t
diffstat 11 files changed, 41 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Oct 20 17:05:13 2011 -0400
+++ b/mercurial/commands.py	Fri Oct 21 00:33:08 2011 +0200
@@ -1143,7 +1143,7 @@
      _('mark new/missing files as added/removed before committing')),
     ('', 'close-branch', None,
      _('mark a branch as closed, hiding it from the branch list')),
-    ] + walkopts + commitopts + commitopts2,
+    ] + walkopts + commitopts + commitopts2 + subrepoopts,
     _('[OPTION]... [FILE]...'))
 def commit(ui, repo, *pats, **opts):
     """commit the specified files or all outstanding changes
@@ -1167,6 +1167,10 @@
 
     Returns 0 on success, 1 if nothing changed.
     """
+    if opts.get('subrepos'):
+        # Let --subrepos on the command line overide config setting.
+        ui.setconfig('ui', 'commitsubrepos', True)
+
     extra = {}
     if opts.get('close_branch'):
         if repo['.'].node() not in repo.branchheads():
--- a/mercurial/help/config.txt	Thu Oct 20 17:05:13 2011 -0400
+++ b/mercurial/help/config.txt	Fri Oct 21 00:33:08 2011 +0200
@@ -1010,7 +1010,7 @@
     Whether to commit modified subrepositories when committing the
     parent repository. If False and one subrepository has uncommitted
     changes, abort the commit.
-    Default is True.
+    Default is False.
 
 ``debug``
     Print debugging information. True or False. Default is False.
--- a/mercurial/localrepo.py	Thu Oct 20 17:05:13 2011 -0400
+++ b/mercurial/localrepo.py	Fri Oct 21 00:33:08 2011 +0200
@@ -1062,11 +1062,12 @@
                     '.hgsubstate' not in changes[0] + changes[1] + changes[2]):
                     changes[2].insert(0, '.hgsubstate')
 
-            if subs and not self.ui.configbool('ui', 'commitsubrepos', True):
+            if subs and not self.ui.configbool('ui', 'commitsubrepos', False):
                 changedsubs = [s for s in subs if wctx.sub(s).dirty(True)]
                 if changedsubs:
                     raise util.Abort(_("uncommitted changes in subrepo %s")
-                                     % changedsubs[0])
+                                     % changedsubs[0],
+                                     hint=_("use --subrepos for recursive commit"))
 
             # make sure all explicit patterns are matched
             if not force and match.files():
--- a/tests/test-debugcomplete.t	Thu Oct 20 17:05:13 2011 -0400
+++ b/tests/test-debugcomplete.t	Fri Oct 21 00:33:08 2011 +0200
@@ -191,7 +191,7 @@
   add: include, exclude, subrepos, dry-run
   annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, include, exclude
   clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
-  commit: addremove, close-branch, include, exclude, message, logfile, date, user
+  commit: addremove, close-branch, include, exclude, message, logfile, date, user, subrepos
   diff: rev, change, text, git, nodates, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
   export: output, switch-parent, rev, text, git, nodates
   forget: include, exclude
--- a/tests/test-mq-subrepo.t	Thu Oct 20 17:05:13 2011 -0400
+++ b/tests/test-mq-subrepo.t	Fri Oct 21 00:33:08 2011 +0200
@@ -1,3 +1,5 @@
+  $ echo "[ui]" >> $HGRCPATH
+  $ echo "commitsubrepos = Yes" >> $HGRCPATH
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "mq=" >> $HGRCPATH
   $ echo "record=" >> $HGRCPATH
--- a/tests/test-qrecord.t	Thu Oct 20 17:05:13 2011 -0400
+++ b/tests/test-qrecord.t	Fri Oct 21 00:33:08 2011 +0200
@@ -64,6 +64,7 @@
    -l --logfile FILE        read commit message from file
    -d --date DATE           record the specified date as commit date
    -u --user USER           record the specified user as committer
+   -S --subrepos            recurse into subrepositories
    -w --ignore-all-space    ignore white space when comparing lines
    -b --ignore-space-change ignore changes in the amount of white space
    -B --ignore-blank-lines  ignore changes whose lines are all blank
--- a/tests/test-subrepo-deep-nested-change.t	Thu Oct 20 17:05:13 2011 -0400
+++ b/tests/test-subrepo-deep-nested-change.t	Fri Oct 21 00:33:08 2011 +0200
@@ -77,7 +77,7 @@
 Modifying deeply nested 'sub2'
 
   $ echo modified > cloned/sub1/sub2/sub2
-  $ hg commit -m "deep nested modif should trigger a commit" -R cloned
+  $ hg commit --subrepos -m "deep nested modif should trigger a commit" -R cloned
   committing subrepository sub1
   committing subrepository sub1/sub2
 
--- a/tests/test-subrepo-git.t	Thu Oct 20 17:05:13 2011 -0400
+++ b/tests/test-subrepo-git.t	Fri Oct 21 00:33:08 2011 +0200
@@ -103,7 +103,7 @@
   $ echo ggg >> s/g
   $ hg status --subrepos
   M s/g
-  $ hg commit -m ggg
+  $ hg commit --subrepos -m ggg
   committing subrepository s
   $ hg debugsub
   path s
@@ -125,7 +125,7 @@
 
   $ hg status --subrepos
   A s/f
-  $ hg commit -m f
+  $ hg commit --subrepos -m f
   committing subrepository s
   $ hg debugsub
   path s
@@ -164,7 +164,7 @@
   g
   gg
   ggg
-  $ hg commit -m 'merge'
+  $ hg commit --subrepos -m 'merge'
   committing subrepository s
   $ hg status --subrepos --rev 1:5
   M .hgsubstate
@@ -294,7 +294,7 @@
   $ echo ffff >> inner/s/f
   $ hg status --subrepos
   M inner/s/f
-  $ hg commit -m nested
+  $ hg commit --subrepos -m nested
   committing subrepository inner
   committing subrepository inner/s
 
@@ -325,7 +325,7 @@
   $ hg push -q
   abort: subrepo s is missing
   [255]
-  $ hg commit -qm missing
+  $ hg commit --subrepos -qm missing
   abort: subrepo s is missing
   [255]
   $ hg update -C
--- a/tests/test-subrepo-recursion.t	Thu Oct 20 17:05:13 2011 -0400
+++ b/tests/test-subrepo-recursion.t	Fri Oct 21 00:33:08 2011 +0200
@@ -58,7 +58,14 @@
 
 Commits:
 
-  $ hg commit -m 0-0-0
+  $ hg commit -m fails
+  abort: uncommitted changes in subrepo foo
+  (use --subrepos for recursive commit)
+  [255]
+
+The --subrepos flag overwrite the config setting:
+
+  $ hg commit -m 0-0-0 --config ui.commitsubrepos=No --subrepos
   committing subrepository foo
   committing subrepository foo/bar
 
@@ -177,7 +184,7 @@
 Cleanup and final commit:
 
   $ rm -r dir
-  $ hg commit -m 2-3-2
+  $ hg commit --subrepos -m 2-3-2
   committing subrepository foo
   committing subrepository foo/bar
 
@@ -394,7 +401,7 @@
    y2
    y3
   +y4
-  $ hg commit -m 3-4-2
+  $ hg commit --subrepos -m 3-4-2
   committing subrepository foo
   $ hg outgoing -S
   comparing with $TESTTMP/repo
--- a/tests/test-subrepo-svn.t	Thu Oct 20 17:05:13 2011 -0400
+++ b/tests/test-subrepo-svn.t	Fri Oct 21 00:33:08 2011 +0200
@@ -105,7 +105,7 @@
   branch: default
   commit: 1 modified, 1 subrepos
   update: (current)
-  $ hg commit -m 'Message!'
+  $ hg commit --subrepos -m 'Message!'
   committing subrepository s
   Sending*s/alpha (glob)
   Transmitting file data .
@@ -171,7 +171,7 @@
 this commit from hg will fail
 
   $ echo zzz >> s/alpha
-  $ hg ci -m 'amend alpha from hg'
+  $ hg ci --subrepos -m 'amend alpha from hg'
   committing subrepository s
   abort: svn: Commit failed (details follow):
   svn: (Out of date)?.*/src/alpha.*(is out of date)? (re)
@@ -182,7 +182,7 @@
 
   $ svn propset svn:mime-type 'text/html' s/alpha
   property 'svn:mime-type' set on 's/alpha'
-  $ hg ci -m 'amend alpha from hg'
+  $ hg ci --subrepos -m 'amend alpha from hg'
   committing subrepository s
   abort: svn: Commit failed (details follow):
   svn: (Out of date)?.*/src/alpha.*(is out of date)? (re)
@@ -192,7 +192,7 @@
 this commit fails because of externals changes
 
   $ echo zzz > s/externals/other
-  $ hg ci -m 'amend externals from hg'
+  $ hg ci --subrepos -m 'amend externals from hg'
   committing subrepository s
   abort: cannot commit svn externals
   [255]
@@ -214,7 +214,7 @@
 
   $ svn propset svn:mime-type 'text/html' s/externals/other
   property 'svn:mime-type' set on 's/externals/other'
-  $ hg ci -m 'amend externals from hg'
+  $ hg ci --subrepos -m 'amend externals from hg'
   committing subrepository s
   abort: cannot commit svn externals
   [255]
@@ -523,7 +523,7 @@
 Point to a Subversion branch which has since been deleted and recreated
 First, create that condition in the repository.
 
-  $ hg ci -m cleanup
+  $ hg ci --subrepos -m cleanup
   committing subrepository obstruct
   Sending        obstruct/other
   Transmitting file data .
--- a/tests/test-subrepo.t	Thu Oct 20 17:05:13 2011 -0400
+++ b/tests/test-subrepo.t	Fri Oct 21 00:33:08 2011 +0200
@@ -1,3 +1,8 @@
+Let commit recurse into subrepos by default to match pre-2.0 behavior:
+
+  $ echo "[ui]" >> $HGRCPATH
+  $ echo "commitsubrepos = Yes" >> $HGRCPATH
+
   $ rm -rf sub
   $ mkdir sub
   $ cd sub
@@ -107,6 +112,7 @@
   $ echo c > s/a
   $ hg --config ui.commitsubrepos=no ci -m4
   abort: uncommitted changes in subrepo s
+  (use --subrepos for recursive commit)
   [255]
   $ hg ci -m4
   committing subrepository s