[PATCH 5 of 8 cleanup] histedit: directly use node in 'verifyactions'

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Aug 26 15:35:30 EDT 2016


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1472237672 -7200
#      Fri Aug 26 20:54:32 2016 +0200
# Node ID a68e7fe3611263c9a45b0ffa9a0a0eaef00f90ff
# Parent  de96a0de61f31c76df2a5315e443ab781299ab45
# EXP-Topic histedit.constraint
histedit: directly use node in 'verifyactions'

It does not seem useful to convert to hex, it is an extra step and they are
longer string. 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 explicite constant
usage in'[12:]'. This will also help moving the code around later as we just
have to access action.node.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1373,7 +1373,7 @@ def verifyactions(actions, state, ctxs):
     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 @@ def verifyactions(actions, state, ctxs):
                         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 @@ def verifyactions(actions, state, ctxs):
             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


More information about the Mercurial-devel mailing list