Patchwork hgk: display committer name when set by hg-git

login
register
mail settings
Submitter Andrew Shadura
Date April 3, 2015, 8:44 p.m.
Message ID <0b1f173f545c2297614b.1428093876@localhost.localdomain>
Download mbox | patch
Permalink /patch/8483/
State Accepted
Headers show

Comments

Andrew Shadura - April 3, 2015, 8:44 p.m.
# HG changeset patch
# User Andrew Shadura <andrew@shadura.me>
# Date 1428093865 -7200
#      Fri Apr 03 22:44:25 2015 +0200
# Node ID 0b1f173f545c2297614b2735187fedea3eafa423
# Parent  1951a31019d39885a39db58a3a389b196d65cc63
hgk: display committer name when set by hg-git
Matt Mackall - April 3, 2015, 9:43 p.m.
On Fri, 2015-04-03 at 22:44 +0200, Andrew Shadura wrote:
> # HG changeset patch
> # User Andrew Shadura <andrew@shadura.me>
> # Date 1428093865 -7200
> #      Fri Apr 03 22:44:25 2015 +0200
> # Node ID 0b1f173f545c2297614b2735187fedea3eafa423
> # Parent  1951a31019d39885a39db58a3a389b196d65cc63
> hgk: display committer name when set by hg-git

Don't like it but going to let you do it anyway. Queued for default,
thanks.

We have better data in obsmarkers now, we should figure out how to use
it.
Andrew Shadura - April 4, 2015, 4:49 a.m.
Hello,

On Fri, 03 Apr 2015 16:43:07 -0500
Matt Mackall <mpm@selenic.com> wrote:

> On Fri, 2015-04-03 at 22:44 +0200, Andrew Shadura wrote:
> > # HG changeset patch
> > # User Andrew Shadura <andrew@shadura.me>
> > # Date 1428093865 -7200
> > #      Fri Apr 03 22:44:25 2015 +0200
> > # Node ID 0b1f173f545c2297614b2735187fedea3eafa423
> > # Parent  1951a31019d39885a39db58a3a389b196d65cc63
> > hgk: display committer name when set by hg-git

> Don't like it but going to let you do it anyway. Queued for default,
> thanks.

> We have better data in obsmarkers now, we should figure out how to use
> it.

The motivation in this case was:

 i) It was implemented there anyway
 ii) Existing implementation tried to parse metadata out of commit
     message, where nobody ever puts it, so it was never displayed
 iii) As hg-git actually does store committer in a different way, why
      not use that?
Gregory Szorc - April 4, 2015, 5:13 a.m.
> On Apr 3, 2015, at 21:49, Andrew Shadura <andrew@shadura.me> wrote:
> 
> Hello,
> 
> On Fri, 03 Apr 2015 16:43:07 -0500
> Matt Mackall <mpm@selenic.com> wrote:
> 
>>> On Fri, 2015-04-03 at 22:44 +0200, Andrew Shadura wrote:
>>> # HG changeset patch
>>> # User Andrew Shadura <andrew@shadura.me>
>>> # Date 1428093865 -7200
>>> #      Fri Apr 03 22:44:25 2015 +0200
>>> # Node ID 0b1f173f545c2297614b2735187fedea3eafa423
>>> # Parent  1951a31019d39885a39db58a3a389b196d65cc63
>>> hgk: display committer name when set by hg-git
> 
>> Don't like it but going to let you do it anyway. Queued for default,
>> thanks.
> 
>> We have better data in obsmarkers now, we should figure out how to use
>> it.
> 
> The motivation in this case was:
> 
> i) It was implemented there anyway
> ii) Existing implementation tried to parse metadata out of commit
>     message, where nobody ever puts it, so it was never displayed
> iii) As hg-git actually does store committer in a different way, why
>      not use that?

IIRC old versions of hg-git put extra fields in the commit message. Modern versions moved these fields into "extras."

Patch

diff --git a/contrib/hgk b/contrib/hgk
--- a/contrib/hgk
+++ b/contrib/hgk
@@ -2516,6 +2516,9 @@  proc selectline {l isnew} {
     }
     $ctext insert end "User: [lindex $info 1]\n"
     $ctext insert end "Date: [lindex $info 2]\n"
+    if {[lindex $info 3] ne ""} {
+	$ctext insert end "Committer: [lindex $info 3]\n"
+    }
     if {[info exists idbookmarks($id)]} {
 	$ctext insert end "Bookmarks:"
 	foreach bookmark $idbookmarks($id) {
diff --git a/hgext/hgk.py b/hgext/hgk.py
--- a/hgext/hgk.py
+++ b/hgext/hgk.py
@@ -118,14 +118,11 @@  def catcommit(ui, repo, n, prefix, ctx=N
     date = ctx.date()
     description = ctx.description().replace("\0", "")
     lines = description.splitlines()
-    if lines and lines[-1].startswith('committer:'):
-        committer = lines[-1].split(': ')[1].rstrip()
-    else:
-        committer = ""
+    ui.write(("author %s %s %s\n" % (ctx.user(), int(date[0]), date[1])))
 
-    ui.write(("author %s %s %s\n" % (ctx.user(), int(date[0]), date[1])))
-    if committer != '':
-        ui.write(("committer %s %s %s\n" % (committer, int(date[0]), date[1])))
+    if 'committer' in ctx.extra():
+        ui.write(("committer %s\n" % ctx.extra()['committer']))
+
     ui.write(("revision %d\n" % ctx.rev()))
     ui.write(("branch %s\n" % ctx.branch()))
     if obsolete.isenabled(repo, obsolete.createmarkersopt):