[PATCH] rebase: add -m/--message to rebase --collapse (issue2389)

Patrick Mézard pmezard at gmail.com
Tue Mar 15 15:46:36 CDT 2011


Le 15/03/11 19:51, Radomir Dopieralski a écrit :
> # HG changeset patch
> # User Radomir Dopieralski <sheep at stxnext.pl>
> # Date 1300210416 -3600
> # Node ID 17a637aefc033030932d276620f03784d24c2b4f
> # Parent  0652b2da832daada866a68f7a4359227570c2447
> rebase: add -m/--message to rebase --collapse (issue2389)
> 
> When collapsing changesets with rebase, you get a chance to edit the commit
> message manually, but there is no way to pass this message from the command
> line. This patch adds a `--message` (and a short form `-m`) option to the
> rebase command. This option suppresses the generation of the default commit
> message, and instead uses the message provided in the option.
> 
> If you use this option without the `--collapse` option, it will raise an
> error.

Rebase help should mention --message (and implicitely --logfile, see below) work only with --collapse.
 
> diff -r 0652b2da832d -r 17a637aefc03 hgext/rebase.py
> --- a/hgext/rebase.py	Mon Mar 14 22:37:50 2011 +0100
> +++ b/hgext/rebase.py	Tue Mar 15 18:33:36 2011 +0100
> @@ -90,6 +90,7 @@
>          contf = opts.get('continue')
>          abortf = opts.get('abort')
>          collapsef = opts.get('collapse', False)
> +        collapsemsg = opts.get('message', '')
>          extrafn = opts.get('extrafn') # internal, used by e.g. hgsubversion
>          keepf = opts.get('keep', False)
>          keepbranchesf = opts.get('keepbranches', False)
> @@ -98,6 +99,10 @@
>          # other extensions
>          keepopen = opts.get('keepopen', False)
>  
> +        if collapsemsg and not collapsef:
> +            raise util.Abort(
> +                _('message can only be specified with collapse'))
> +
>          if contf or abortf:
>              if contf and abortf:
>                  raise util.Abort(_('cannot use both abort and continue'))
> @@ -189,11 +194,14 @@
>          if collapsef and not keepopen:
>              p1, p2 = defineparents(repo, min(state), target,
>                                                          state, targetancestors)
> -            commitmsg = 'Collapsed revision'
> -            for rebased in state:
> -                if rebased not in skipped and state[rebased] != nullmerge:
> -                    commitmsg += '\n* %s' % repo[rebased].description()
> -            commitmsg = ui.edit(commitmsg, repo.ui.username())
> +            if collapsemsg:
> +                commitmsg = collapsemsg

Could you reuse cmdutil.logmessage() here?

And support the --logfile option as well?

> +            else:
> +                commitmsg = 'Collapsed revision'
> +                for rebased in state:
> +                    if rebased not in skipped and state[rebased] != nullmerge:
> +                        commitmsg += '\n* %s' % repo[rebased].description()
> +                commitmsg = ui.edit(commitmsg, repo.ui.username())
>              newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
>                                    extrafn=extrafn)
>  
> @@ -564,6 +572,7 @@
>          ('d', 'dest', '',
>           _('rebase onto the specified changeset'), _('REV')),
>          ('', 'collapse', False, _('collapse the rebased changesets')),
> +        ('m', 'message', '', _('commit message to use with collapse')),

Take a look at commands.commitopts

>          ('', 'keep', False, _('keep original changesets')),
>          ('', 'keepbranches', False, _('keep original branch names')),
>          ('', 'detach', False, _('force detaching of source from its original '

Looks good otherwise.

--
Patrick Mézard



More information about the Mercurial-devel mailing list