[PATCH] subrepos: abort commit by default if a subrepo is dirty

Matt Mackall mpm at selenic.com
Thu Oct 20 17:42:29 CDT 2011


On Fri, 2011-10-21 at 00:33 +0200, Martin Geisler wrote:
> # HG changeset patch
> # User Martin Geisler <mg at lazybytes.net>
> # Date 1319149988 -7200
> # Branch stable
> # Node ID 8c3a6c9007041b90ec7ed7dc8c77d95e5185acb6
> # Parent  1ae824142c0157f350e1e01cf3e23fbf01a1f722
> subrepos: abort commit by default if a subrepo is dirty
> 
> 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

This doesn't appear to match the code. Which is good: making diff and
status recurse is way out of scope.

> 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.

Great.

> * with --subrepos, all three commands will recurse.

This is not at all what I want, but also 

> A --subrepos flag on the command line overrides the config settin.g
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -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():
> diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
> --- a/mercurial/help/config.txt
> +++ b/mercurial/help/config.txt
> @@ -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.
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -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():
> diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
> --- a/tests/test-debugcomplete.t
> +++ b/tests/test-debugcomplete.t
> @@ -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
> diff --git a/tests/test-mq-subrepo.t b/tests/test-mq-subrepo.t
> --- a/tests/test-mq-subrepo.t
> +++ b/tests/test-mq-subrepo.t
> @@ -1,3 +1,5 @@
> +  $ echo "[ui]" >> $HGRCPATH
> +  $ echo "commitsubrepos = Yes" >> $HGRCPATH
>    $ echo "[extensions]" >> $HGRCPATH
>    $ echo "mq=" >> $HGRCPATH
>    $ echo "record=" >> $HGRCPATH
> diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
> --- a/tests/test-qrecord.t
> +++ b/tests/test-qrecord.t
> @@ -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
> 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
> @@ -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
>  
> diff --git a/tests/test-subrepo-git.t b/tests/test-subrepo-git.t
> --- a/tests/test-subrepo-git.t
> +++ b/tests/test-subrepo-git.t
> @@ -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
> diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-recursion.t
> --- a/tests/test-subrepo-recursion.t
> +++ b/tests/test-subrepo-recursion.t
> @@ -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
> diff --git a/tests/test-subrepo-svn.t b/tests/test-subrepo-svn.t
> --- a/tests/test-subrepo-svn.t
> +++ b/tests/test-subrepo-svn.t
> @@ -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 .
> diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
> --- a/tests/test-subrepo.t
> +++ b/tests/test-subrepo.t
> @@ -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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list