Patchwork Graft: (V2) '--log' options adds username of person who did the graft

login
register
mail settings
Submitter Martin Rieser
Date Dec. 30, 2012, 10:19 a.m.
Message ID <aaaf4bc76340c1aaa9c7.1356862784@johanna-MM061>
Download mbox | patch
Permalink /patch/335/
State Changes Requested
Headers show

Comments

Martin Rieser - Dec. 30, 2012, 10:19 a.m.
# HG changeset patch
# User Martin Rieser
# Date 1356862619 -3600
# Branch stable
# Node ID aaaf4bc76340c1aaa9c76a45498f9dfa922df08a
# Parent  777084ac84167e3bdea45b5c00de1106cca36eef
Graft: (V2) '--log' options adds username of person who did the graft.

At the moment it is impossible to find out, who did the graft. Per default,
the username of the person, who made the code change is also set as author to
the grafted version. But there is no trace about the person, who executed
the 'hg graft...' command. If the --log option is used, it is possilbe to
document both persons who where involved in the graft.
Sean Farley - Dec. 30, 2012, 4:48 p.m.
On Sun, Dec 30, 2012 at 4:19 AM, Martin Rieser
<martin.h.rieser at gmail.com> wrote:
> # HG changeset patch
> # User Martin Rieser
> # Date 1356862619 -3600
> # Branch stable
> # Node ID aaaf4bc76340c1aaa9c76a45498f9dfa922df08a
> # Parent  777084ac84167e3bdea45b5c00de1106cca36eef
> Graft: (V2) '--log' options adds username of person who did the graft.

I'm sure others will help review this patch but first thing you might
want to do is take a look at,

http://mercurial.selenic.com/wiki/ContributingChanges

which has a bulleted item: first line of commit message is of the form
"topic: uncapitalized, no trailing period". So your summary should
probably something like, "graft: '--log' options adds username of the
person who did the graft".

Hope that helps!

>
> At the moment it is impossible to find out, who did the graft. Per default,
> the username of the person, who made the code change is also set as author to
> the grafted version. But there is no trace about the person, who executed
> the 'hg graft...' command. If the --log option is used, it is possilbe to
> document both persons who where involved in the graft.
>
> diff -r 777084ac8416 -r aaaf4bc76340 mercurial/commands.py
> --- a/mercurial/commands.py     Don Nov 29 08:44:54 2012 -0500
> +++ b/mercurial/commands.py     Son Dez 30 11:16:59 2012 +0100
> @@ -2713,7 +2713,7 @@
>      If --log is specified, log messages will have a comment appended
>      of the form::
>
> -      (grafted from CHANGESETHASH)
> +      (grafted from CHANGESETHASH by USERNAME)
>
>      If a graft merge results in conflicts, the graft process is
>      interrupted so that the current merge can be manually resolved.
> @@ -2870,7 +2870,11 @@
>                  date = opts['date']
>              message = ctx.description()
>              if opts.get('log'):
> -                message += '\n(grafted from %s)' % ctx.hex()
> +                message += '\n(grafted from %s ' % ctx.hex()
> +                if ui.username():
> +                    message += 'by %s)' % ui.username()
> +                else:
> +                    message += ')'
>              node = repo.commit(text=message, user=user,
>                          date=date, extra=extra, editor=editor)
>              if node is None:
> diff -r 777084ac8416 -r aaaf4bc76340 tests/test-graft.t
> --- a/tests/test-graft.t        Don Nov 29 08:44:54 2012 -0500
> +++ b/tests/test-graft.t        Son Dez 30 11:16:59 2012 +0100
> @@ -297,12 +297,19 @@
>  Graft with --log
>
>    $ hg up -Cq 1
> -  $ hg graft 3 --log -u foo
> +  $ hg graft 3 --log
>    grafting revision 3
>    warning: can't find ancestor for 'c' copied from 'b'!
>    $ hg log --template '{rev} {parents} {desc}\n' -r tip
>    14 1:5d205f8b35b6  3
> -  (grafted from 4c60f11aa304a54ae1c199feb94e7fc771e51ed8)
> +  (grafted from 4c60f11aa304a54ae1c199feb94e7fc771e51ed8 by test)
> +
> +  $ hg up -Cq 1
> +  $ hg graft 4 --log -u foo
> +  grafting revision 4
> +  $ hg log --template '{rev} {parents} {desc}\n' -r tip
> +  15 1:5d205f8b35b6  4
> +  (grafted from 9c233e8e184d39ccaaae9bb17d7b1074d73c9e15 by test)
>
>  Resolve conflicted graft
>    $ hg up -q 0
> @@ -438,23 +445,29 @@
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     2
>
> -  changeset:   14:f64defefacee
> +  changeset:   14:112b661e40dc
> +  parent:      1:5d205f8b35b6
> +  user:        baz
> +  date:        Thu Jan 01 00:00:00 1970 +0000
> +  summary:     3
> +
> +  changeset:   15:fab24ed925cb
>    parent:      1:5d205f8b35b6
>    user:        foo
>    date:        Thu Jan 01 00:00:00 1970 +0000
> -  summary:     3
> +  summary:     4
>
> -  changeset:   17:64ecd9071ce8
> +  changeset:   18:64ecd9071ce8
>    user:        bar
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     1
>
> -  changeset:   19:2e80e1351d6e
> +  changeset:   20:2e80e1351d6e
>    user:        test
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     2
>
> -  changeset:   21:7e61b508e709
> +  changeset:   22:7e61b508e709
>    branch:      dev
>    tag:         tip
>    user:        foo
> @@ -473,12 +486,12 @@
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     2
>
> -  changeset:   19:2e80e1351d6e
> +  changeset:   20:2e80e1351d6e
>    user:        test
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     2
>
> -  changeset:   21:7e61b508e709
> +  changeset:   22:7e61b508e709
>    branch:      dev
>    tag:         tip
>    user:        foo
> @@ -487,7 +500,7 @@
>
>  Transplants of grafts can find a destination...
>    $ hg log -r 'destination(7)'
> -  changeset:   21:7e61b508e709
> +  changeset:   22:7e61b508e709
>    branch:      dev
>    tag:         tip
>    user:        foo
> @@ -515,18 +528,18 @@
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     2
>
> -  changeset:   19:2e80e1351d6e
> +  changeset:   20:2e80e1351d6e
>    user:        test
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     2
>
> -  changeset:   21:7e61b508e709
> +  changeset:   22:7e61b508e709
>    branch:      dev
>    user:        foo
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     2
>
> -  changeset:   22:1313d0a825e2
> +  changeset:   23:1313d0a825e2
>    branch:      dev
>    tag:         tip
>    user:        foo
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Kevin Bullock - Dec. 31, 2012, 4:26 a.m.
On 30 Dec 2012, at 4:19 AM, Martin Rieser wrote:

> # HG changeset patch
> # User Martin Rieser
> # Date 1356862619 -3600
> # Branch stable
> # Node ID aaaf4bc76340c1aaa9c76a45498f9dfa922df08a
> # Parent  777084ac84167e3bdea45b5c00de1106cca36eef
> Graft: (V2) '--log' options adds username of person who did the graft.

The 'V2' belongs in a --flag option to patchbomb, not in the commit message. And as others have pointed out, we have a defined format for the first line of a commit message.

> At the moment it is impossible to find out, who did the graft. Per default,
> the username of the person, who made the code change is also set as author to
> the grafted version. But there is no trace about the person, who executed
> the 'hg graft...' command. If the --log option is used, it is possilbe to
> document both persons who where involved in the graft.
> 
> diff -r 777084ac8416 -r aaaf4bc76340 mercurial/commands.py
> --- a/mercurial/commands.py	Don Nov 29 08:44:54 2012 -0500
> +++ b/mercurial/commands.py	Son Dez 30 11:16:59 2012 +0100
> @@ -2713,7 +2713,7 @@
>     If --log is specified, log messages will have a comment appended
>     of the form::
> 
> -      (grafted from CHANGESETHASH)
> +      (grafted from CHANGESETHASH by USERNAME)
> 
>     If a graft merge results in conflicts, the graft process is
>     interrupted so that the current merge can be manually resolved.
> @@ -2870,7 +2870,11 @@
>                 date = opts['date']
>             message = ctx.description()
>             if opts.get('log'):
> -                message += '\n(grafted from %s)' % ctx.hex()
> +                message += '\n(grafted from %s ' % ctx.hex()
> +                if ui.username():
> +                    message += 'by %s)' % ui.username()
> +                else:
> +                    message += ')'
>             node = repo.commit(text=message, user=user,
>                         date=date, extra=extra, editor=editor)
>             if node is None:
> diff -r 777084ac8416 -r aaaf4bc76340 tests/test-graft.t
> --- a/tests/test-graft.t	Don Nov 29 08:44:54 2012 -0500
> +++ b/tests/test-graft.t	Son Dez 30 11:16:59 2012 +0100
> @@ -297,12 +297,19 @@
> Graft with --log
> 
>   $ hg up -Cq 1
> -  $ hg graft 3 --log -u foo
> +  $ hg graft 3 --log

The extra graft isn't necessary to test this feature.

pacem in terris / ??? / ?????? / ????????? / ??
Kevin R. Bullock

Patch

diff -r 777084ac8416 -r aaaf4bc76340 mercurial/commands.py
--- a/mercurial/commands.py	Don Nov 29 08:44:54 2012 -0500
+++ b/mercurial/commands.py	Son Dez 30 11:16:59 2012 +0100
@@ -2713,7 +2713,7 @@ 
     If --log is specified, log messages will have a comment appended
     of the form::
 
-      (grafted from CHANGESETHASH)
+      (grafted from CHANGESETHASH by USERNAME)
 
     If a graft merge results in conflicts, the graft process is
     interrupted so that the current merge can be manually resolved.
@@ -2870,7 +2870,11 @@ 
                 date = opts['date']
             message = ctx.description()
             if opts.get('log'):
-                message += '\n(grafted from %s)' % ctx.hex()
+                message += '\n(grafted from %s ' % ctx.hex()
+                if ui.username():
+                    message += 'by %s)' % ui.username()
+                else:
+                    message += ')'
             node = repo.commit(text=message, user=user,
                         date=date, extra=extra, editor=editor)
             if node is None:
diff -r 777084ac8416 -r aaaf4bc76340 tests/test-graft.t
--- a/tests/test-graft.t	Don Nov 29 08:44:54 2012 -0500
+++ b/tests/test-graft.t	Son Dez 30 11:16:59 2012 +0100
@@ -297,12 +297,19 @@ 
 Graft with --log
 
   $ hg up -Cq 1
-  $ hg graft 3 --log -u foo
+  $ hg graft 3 --log
   grafting revision 3
   warning: can't find ancestor for 'c' copied from 'b'!
   $ hg log --template '{rev} {parents} {desc}\n' -r tip
   14 1:5d205f8b35b6  3
-  (grafted from 4c60f11aa304a54ae1c199feb94e7fc771e51ed8)
+  (grafted from 4c60f11aa304a54ae1c199feb94e7fc771e51ed8 by test)
+
+  $ hg up -Cq 1
+  $ hg graft 4 --log -u foo
+  grafting revision 4
+  $ hg log --template '{rev} {parents} {desc}\n' -r tip
+  15 1:5d205f8b35b6  4
+  (grafted from 9c233e8e184d39ccaaae9bb17d7b1074d73c9e15 by test)
 
 Resolve conflicted graft
   $ hg up -q 0
@@ -438,23 +445,29 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   14:f64defefacee
+  changeset:   14:112b661e40dc
+  parent:      1:5d205f8b35b6
+  user:        baz
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     3
+  
+  changeset:   15:fab24ed925cb
   parent:      1:5d205f8b35b6
   user:        foo
   date:        Thu Jan 01 00:00:00 1970 +0000
-  summary:     3
+  summary:     4
   
-  changeset:   17:64ecd9071ce8
+  changeset:   18:64ecd9071ce8
   user:        bar
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     1
   
-  changeset:   19:2e80e1351d6e
+  changeset:   20:2e80e1351d6e
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   21:7e61b508e709
+  changeset:   22:7e61b508e709
   branch:      dev
   tag:         tip
   user:        foo
@@ -473,12 +486,12 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   19:2e80e1351d6e
+  changeset:   20:2e80e1351d6e
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   21:7e61b508e709
+  changeset:   22:7e61b508e709
   branch:      dev
   tag:         tip
   user:        foo
@@ -487,7 +500,7 @@ 
   
 Transplants of grafts can find a destination...
   $ hg log -r 'destination(7)'
-  changeset:   21:7e61b508e709
+  changeset:   22:7e61b508e709
   branch:      dev
   tag:         tip
   user:        foo
@@ -515,18 +528,18 @@ 
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   19:2e80e1351d6e
+  changeset:   20:2e80e1351d6e
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   21:7e61b508e709
+  changeset:   22:7e61b508e709
   branch:      dev
   user:        foo
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     2
   
-  changeset:   22:1313d0a825e2
+  changeset:   23:1313d0a825e2
   branch:      dev
   tag:         tip
   user:        foo