Patchwork D556: show: pass the minimum length for nodes as a template keyword

login
register
mail settings
Submitter phabricator
Date Sept. 15, 2017, 2:14 p.m.
Message ID <059164af7ae0e482817dda4ad7ca04b9@localhost.localdomain>
Download mbox | patch
Permalink /patch/23907/
State Not Applicable
Headers show

Comments

phabricator - Sept. 15, 2017, 2:14 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb93658d7b2d5: show: pass the minimum length for nodes as a template keyword (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D556?vs=1383&id=1844

REVISION DETAIL
  https://phab.mercurial-scm.org/D556

AFFECTED FILES
  hgext/show.py
  mercurial/templates/map-cmdline.show
  tests/test-show.t

CHANGE DETAILS




To: indygreg, #hg-reviewers, quark
Cc: mercurial-devel

Patch

diff --git a/tests/test-show.t b/tests/test-show.t
--- a/tests/test-show.t
+++ b/tests/test-show.t
@@ -112,13 +112,15 @@ 
     "active": true,
     "bookmark": "a-longer-bookmark",
     "longestbookmarklen": 17,
-    "node": "7b5709ab64cbc34da9b4367b64afff47f2c4ee83"
+    "node": "7b5709ab64cbc34da9b4367b64afff47f2c4ee83",
+    "nodelen": 5
    },
    {
     "active": false,
     "bookmark": "book1",
     "longestbookmarklen": 17,
-    "node": "b757f780b8ffd71267c6ccb32e0882d9d32a8cc0"
+    "node": "b757f780b8ffd71267c6ccb32e0882d9d32a8cc0",
+    "nodelen": 5
    }
   ]
 
diff --git a/mercurial/templates/map-cmdline.show b/mercurial/templates/map-cmdline.show
--- a/mercurial/templates/map-cmdline.show
+++ b/mercurial/templates/map-cmdline.show
@@ -3,12 +3,12 @@ 
 #   piggyback on existing values so color works.
 # * Obsolescence isn't considered for node labels. See _cset_labels in
 #   map-cmdline.default.
-showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, 5)}\n'
+showbookmarks = '{if(active, "*", " ")} {pad(bookmark, longestbookmarklen + 4)}{shortest(node, nodelen)}\n'
 
 showwork = '{cset_shortnode}{namespaces % cset_namespace} {cset_shortdesc}'
 showstack = '{showwork}'
 
-cset_shortnode = '{label("log.changeset changeset.{phase}", shortest(node, 5))}'
+cset_shortnode = '{label("log.changeset changeset.{phase}", shortest(node, nodelen))}'
 
 # Treat branch and tags specially so we don't display "default" or "tip"
 cset_namespace = '{ifeq(namespace, "branches", names_branches, ifeq(namespace, "tags", names_tags, names_others))}'
diff --git a/hgext/show.py b/hgext/show.py
--- a/hgext/show.py
+++ b/hgext/show.py
@@ -171,7 +171,8 @@ 
         fm.write('bookmark', '%s', bm)
         fm.write('node', fm.hexfunc(node), fm.hexfunc(node))
         fm.data(active=bm == active,
-                longestbookmarklen=longestname)
+                longestbookmarklen=longestname,
+                nodelen=5)
 
 @showview('stack', csettopic='stack')
 def showstack(ui, repo, displayer):
@@ -277,7 +278,7 @@ 
                 ui.write('  ')
 
             ui.write(('o  '))
-            displayer.show(ctx)
+            displayer.show(ctx, nodelen=5)
             displayer.flush(ctx)
             ui.write('\n')
 
@@ -317,7 +318,7 @@ 
             ui.write('  ')
 
         ui.write(symbol, '  ')
-        displayer.show(ctx)
+        displayer.show(ctx, nodelen=5)
         displayer.flush(ctx)
         ui.write('\n')
 
@@ -334,7 +335,7 @@ 
         ui.write(_('(stack base)'), '\n', label='stack.label')
         ui.write(('o  '))
 
-        displayer.show(basectx)
+        displayer.show(basectx, nodelen=5)
         displayer.flush(basectx)
         ui.write('\n')
 
@@ -397,7 +398,8 @@ 
     revdag = graphmod.dagwalker(repo, revs)
 
     ui.setconfig('experimental', 'graphshorten', True)
-    cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges)
+    cmdutil.displaygraph(ui, repo, revdag, displayer, graphmod.asciiedges,
+                         props={'nodelen': 5})
 
 def extsetup(ui):
     # Alias `hg <prefix><view>` to `hg show <view>`.