Patchwork [3,of,6] shelve: accept '--edit' like other commands creating new changeset

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 31, 2014, 3:26 p.m.
Message ID <ada6d06aa6bdf3edf5d0.1401549973@feefifofum>
Download mbox | patch
Permalink /patch/4905/
State Superseded
Commit 37a5decc6924d91be190f6e22e3b81f45843072c
Headers show

Comments

Katsunori FUJIWARA - May 31, 2014, 3:26 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1401548912 -32400
#      Sun Jun 01 00:08:32 2014 +0900
# Node ID ada6d06aa6bdf3edf5d0fca7acf7e1e5554e8f53
# Parent  83218ec9a3d9c1c9eb86b098272a10ecf52bc8bb
shelve: accept '--edit' like other commands creating new changeset

After this patch, users can invoke editor for the commit message by
'--edit' option regardless of '--message'.
Pierre-Yves David - June 5, 2014, 12:47 a.m.
On 05/31/2014 08:26 AM, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1401548912 -32400
> #      Sun Jun 01 00:08:32 2014 +0900
> # Node ID ada6d06aa6bdf3edf5d0fca7acf7e1e5554e8f53
> # Parent  83218ec9a3d9c1c9eb86b098272a10ecf52bc8bb
> shelve: accept '--edit' like other commands creating new changeset

Patch looks good to me, but depends on patch 2 that need a resend. 
Please includes this on in the resent.

>
> After this patch, users can invoke editor for the commit message by
> '--edit' option regardless of '--message'.
>
> diff --git a/hgext/shelve.py b/hgext/shelve.py
> --- a/hgext/shelve.py
> +++ b/hgext/shelve.py
> @@ -178,7 +178,8 @@
>           if hasmq:
>               saved, repo.mq.checkapplied = repo.mq.checkapplied, False
>           try:
> -            return repo.commit(message, user, opts.get('date'), match)
> +            return repo.commit(message, user, opts.get('date'), match,
> +                               editor=cmdutil.getcommiteditor(**opts))
>           finally:
>               if hasmq:
>                   repo.mq.checkapplied = saved
> @@ -635,6 +636,8 @@
>              _('shelve with the specified commit date'), _('DATE')),
>             ('d', 'delete', None,
>              _('delete the named shelved change(s)')),
> +          ('e', 'edit', False,
> +           _('invoke editor on commit messages')),
>             ('l', 'list', None,
>              _('list current shelves')),
>             ('m', 'message', '',
> @@ -680,6 +683,7 @@
>           'cleanup': 'cleanup',
>   #        'date': 'create', # ignored for '--date "0 0"' in default of tests
>           'delete': 'delete',
> +        'edit': 'create',
>           'list': 'list',
>           'message': 'create',
>           'name': 'create',
> diff --git a/tests/test-shelve.t b/tests/test-shelve.t
> --- a/tests/test-shelve.t
> +++ b/tests/test-shelve.t
> @@ -16,8 +16,10 @@
>     $ hg addremove -q
>
>   shelving in an empty repo should be possible
> -
> -  $ hg shelve
> +(this tests also that editor is not invoked, if '--edit' is not
> +specified)
> +
> +  $ HGEDITOR=cat hg shelve
>     shelved as default
>     0 files updated, 0 files merged, 5 files removed, 0 files unresolved
>
> @@ -132,6 +134,7 @@
>     [255]
>
>   named shelves, specific filenames, and "commit messages" should all work
> +(this tests also that editor is invoked, if '--edit' is specified)
>
>     $ hg status -C
>     M a/a
> @@ -140,7 +143,16 @@
>     A c.copy
>       c
>     R b/b
> -  $ hg shelve -q -n wibble -m wat a
> +  $ HGEDITOR=cat hg shelve -q -n wibble -m wat -e a
> +  wat
> +
> +
> +  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
> +  HG: Leave message empty to abort commit.
> +  HG: --
> +  HG: user: shelve@localhost
> +  HG: branch 'default'
> +  HG: changed a/a
>
>   expect "a" to no longer be present, but status otherwise unchanged
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -178,7 +178,8 @@ 
         if hasmq:
             saved, repo.mq.checkapplied = repo.mq.checkapplied, False
         try:
-            return repo.commit(message, user, opts.get('date'), match)
+            return repo.commit(message, user, opts.get('date'), match,
+                               editor=cmdutil.getcommiteditor(**opts))
         finally:
             if hasmq:
                 repo.mq.checkapplied = saved
@@ -635,6 +636,8 @@ 
            _('shelve with the specified commit date'), _('DATE')),
           ('d', 'delete', None,
            _('delete the named shelved change(s)')),
+          ('e', 'edit', False,
+           _('invoke editor on commit messages')),
           ('l', 'list', None,
            _('list current shelves')),
           ('m', 'message', '',
@@ -680,6 +683,7 @@ 
         'cleanup': 'cleanup',
 #        'date': 'create', # ignored for '--date "0 0"' in default of tests
         'delete': 'delete',
+        'edit': 'create',
         'list': 'list',
         'message': 'create',
         'name': 'create',
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -16,8 +16,10 @@ 
   $ hg addremove -q
 
 shelving in an empty repo should be possible
-
-  $ hg shelve
+(this tests also that editor is not invoked, if '--edit' is not
+specified)
+
+  $ HGEDITOR=cat hg shelve
   shelved as default
   0 files updated, 0 files merged, 5 files removed, 0 files unresolved
 
@@ -132,6 +134,7 @@ 
   [255]
 
 named shelves, specific filenames, and "commit messages" should all work
+(this tests also that editor is invoked, if '--edit' is specified)
 
   $ hg status -C
   M a/a
@@ -140,7 +143,16 @@ 
   A c.copy
     c
   R b/b
-  $ hg shelve -q -n wibble -m wat a
+  $ HGEDITOR=cat hg shelve -q -n wibble -m wat -e a
+  wat
+  
+  
+  HG: Enter commit message.  Lines beginning with 'HG:' are removed.
+  HG: Leave message empty to abort commit.
+  HG: --
+  HG: user: shelve@localhost
+  HG: branch 'default'
+  HG: changed a/a
 
 expect "a" to no longer be present, but status otherwise unchanged