Patchwork [7,of,8,RFC] annotate: use context methods to get short/long hex of changeset hash

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 19, 2014, 10:56 p.m.
Message ID <c8ad2080d3f4031851a8.1408488981@mimosa>
Download mbox | patch
Permalink /patch/5530/
State Changes Requested
Headers show

Comments

Yuya Nishihara - Aug. 19, 2014, 10:56 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1408180120 -32400
#      Sat Aug 16 18:08:40 2014 +0900
# Node ID c8ad2080d3f4031851a84f12cee37439da405048
# Parent  5b82336b237f8f45a01f31d4d0788464a1198843
annotate: use context methods to get short/long hex of changeset hash

This prepares for workingctx support.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -268,13 +268,16 @@  def annotate(ui, repo, *pats, **opts):
         # to mimic the behavior of Mercurial before version 1.5
         opts['file'] = True
 
+    if ui.debugflag:
+        getchangeset = lambda x: x[0].hex()
+    else:
+        getchangeset = lambda x: str(x[0].changectx())
     datefunc = ui.quiet and util.shortdate or util.datestr
     getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
-    hexfn = ui.debugflag and hex or short
 
     opmap = [('user', ' ', lambda x: ui.shortuser(x[0].user())),
              ('number', ' ', lambda x: str(x[0].rev())),
-             ('changeset', ' ', lambda x: hexfn(x[0].node())),
+             ('changeset', ' ', getchangeset),
              ('date', ' ', getdate),
              ('file', ' ', lambda x: x[0].path()),
              ('line_number', ':', lambda x: str(x[1])),
diff --git a/tests/test-annotate.t b/tests/test-annotate.t
--- a/tests/test-annotate.t
+++ b/tests/test-annotate.t
@@ -16,6 +16,9 @@  annotate -c
   $ hg annotate -c a
   8435f90966e4: a
 
+  $ hg annotate --debug -c a
+  8435f90966e442695d2ded29fdade2bac5ad8065: a
+
 annotate -cl
 
   $ hg annotate -cl a