changeset 29878:d7de02efa47e

histedit: directly use node in 'verifyactions' It does not seem useful to convert to hex: it is an extra step and they are longer strings. So we stick to node for the logic. We only convert to short hex for error when needed. As a nice side effect this remove the explicit constant usage in'[12:]'. This will also help moving the code around later as we just have to access action.node.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 26 Aug 2016 20:54:32 +0200
parents 1c19d3efe15d
children b566c5992e07
files hgext/histedit.py
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Fri Aug 26 20:42:18 2016 +0200
+++ b/hgext/histedit.py	Fri Aug 26 20:54:32 2016 +0200
@@ -1373,7 +1373,7 @@
     Will abort if there are to many or too few rules, a malformed rule,
     or a rule on a changeset outside of the user-given range.
     """
-    expected = set(c.hex() for c in ctxs)
+    expected = set(c.node() for c in ctxs)
     seen = set()
     prev = None
     for action in actions:
@@ -1386,22 +1386,21 @@
                         constraint)
 
         if action.node is not None:
-            ha = node.hex(action.node)
-            if _constraints.noother in constrs and ha not in expected:
+            if _constraints.noother in constrs and action.node not in expected:
                 raise error.ParseError(
                     _('%s "%s" changeset was not a candidate')
-                     % (action.verb, ha[:12]),
+                     % (action.verb, node.short(action.node)),
                     hint=_('only use listed changesets'))
-            if _constraints.forceother in constrs and ha in expected:
+            if _constraints.forceother in constrs and action.node in expected:
                 raise error.ParseError(
                     _('%s "%s" changeset was not an edited list candidate')
-                     % (action.verb, ha[:12]),
+                     % (action.verb, node.short(action.node)),
                     hint=_('only use listed changesets'))
-            if _constraints.noduplicates in constrs and ha in seen:
+            if _constraints.noduplicates in constrs and action.node in seen:
                 raise error.ParseError(_(
                         'duplicated command for changeset %s') %
-                        ha[:12])
-            seen.add(ha)
+                        node.short(action.node))
+            seen.add(action.node)
     missing = sorted(expected - seen)  # sort to stabilize output
 
     if state.repo.ui.configbool('histedit', 'dropmissing'):
@@ -1409,15 +1408,16 @@
             raise error.ParseError(_('no rules provided'),
                     hint=_('use strip extension to remove commits'))
 
-        drops = [drop(state, node.bin(n)) for n in missing]
+        drops = [drop(state, n) for n in missing]
         # put the in the beginning so they execute immediately and
         # don't show in the edit-plan in the future
         actions[:0] = drops
     elif missing:
         raise error.ParseError(_('missing rules for changeset %s') %
-                missing[0][:12],
+                node.short(missing[0]),
                 hint=_('use "drop %s" to discard, see also: '
-                       '"hg help -e histedit.config"') % missing[0][:12])
+                       '"hg help -e histedit.config"')
+                       % node.short(missing[0]))
 
 def adjustreplacementsfrommarkers(repo, oldreplacements):
     """Adjust replacements from obsolescense markers