[PATCH 01 of 12] histedit: remove all usages of hex[:12]

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Thu Sep 27 07:23:20 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1348657043 -7200
# Node ID 441f1f1d9e251ffc25164bb727018e470f07f468
# Parent  d34ba4991188fdfa4f8322b9a32c4c08aaf6ff27
histedit: remove all usages of hex[:12]

- `node.hex(n)[:12]` is the same as `node.short(n)`
- `ctx.hex()[:12]` is the same as `str(ctx)`

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -481,13 +481,13 @@ def histedit(ui, repo, *parent, **opts):
         (parentctxnode, created, replaced, tmpnodes,
          existing, rules, keep, tip, replacemap) = readstate(repo)
         ui.debug('restore wc to old tip %s\n' % node.hex(tip))
         hg.clean(repo, tip)
         ui.debug('should strip created nodes %s\n' %
-                 ', '.join([node.hex(n)[:12] for n in created]))
+                 ', '.join([node.short(n) for n in created]))
         ui.debug('should strip temp nodes %s\n' %
-                 ', '.join([node.hex(n)[:12] for n in tmpnodes]))
+                 ', '.join([node.short(n) for n in tmpnodes]))
         for nodes in (created, tmpnodes):
             lock = None
             try:
                 lock = repo.lock()
                 for n in reversed(nodes):
@@ -519,11 +519,11 @@ def histedit(ui, repo, *parent, **opts):
         existing = [r.node() for r in ctxs]
         rules = opts.get('commands', '')
         if not rules:
             rules = '\n'.join([makedesc(c) for c in ctxs])
             rules += '\n\n'
-            rules += editcomment % (node.hex(parent)[:12], node.hex(tip)[:12])
+            rules += editcomment % (node.short(parent), node.short(tip))
             rules = ui.edit(rules, ui.username())
             # Save edit rules in .hg/histedit-last-edit.txt in case
             # the user needs to ask for help after something
             # surprising happens.
             f = open(repo.join('histedit-last-edit.txt'), 'w')
@@ -634,11 +634,11 @@ def histedit(ui, repo, *parent, **opts):
             for old, new in sorted(replacemap.iteritems()):
                 copybms(old, new)
                 # TODO update mq state
 
         ui.debug('should strip replaced nodes %s\n' %
-                 ', '.join([node.hex(n)[:12] for n in replaced]))
+                 ', '.join([node.short(n) for n in replaced]))
         lock = None
         try:
             lock = repo.lock()
             for n in sorted(replaced, key=lambda x: repo[x].rev()):
                 try:
@@ -647,11 +647,11 @@ def histedit(ui, repo, *parent, **opts):
                     pass
         finally:
             lockmod.release(lock)
 
     ui.debug('should strip temp nodes %s\n' %
-             ', '.join([node.hex(n)[:12] for n in tmpnodes]))
+             ', '.join([node.short(n) for n in tmpnodes]))
     lock = None
     try:
         lock = repo.lock()
         for n in reversed(tmpnodes):
             try:
@@ -711,11 +711,11 @@ def makedesc(c):
       pick <hash> <rev> <summary>
     """
     summary = ''
     if c.description():
         summary = c.description().splitlines()[0]
-    line = 'pick %s %d %s' % (c.hex()[:12], c.rev(), summary)
+    line = 'pick %s %d %s' % (c, c.rev(), summary)
     return line[:80]  # trim to 80 chars so it's not stupidly wide in my editor
 
 def verifyrules(rules, repo, ctxs):
     """Verify that there exists exactly one edit rule per given changeset.
 


More information about the Mercurial-devel mailing list