Patchwork [STABLE] histedit: change state format to allow non-hash lines

login
register
mail settings
Submitter Durham Goode
Date April 17, 2015, 5:32 p.m.
Message ID <2bd479201893ea1975e4.1429291950@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8733/
State Accepted
Headers show

Comments

Durham Goode - April 17, 2015, 5:32 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1429289203 25200
#      Fri Apr 17 09:46:43 2015 -0700
# Branch stable
# Node ID 2bd479201893ea1975e45b02b8c9d6c8a611dc3e
# Parent  82fe5721302973f90b594239772a05f447c493aa
histedit: change state format to allow non-hash lines

The existing state serialization format assumed the rule line consisted of an
action and a hash. In our external extension that adds 'exec' this is not the
case (there is no hash, just the shell command). So let's change the format to
be more generic with just an action and a remainder, and the various commands
can handle it as they wish.

Flagged for stable since we want to get this format tweak in before the new
format goes live in the release.
Matt Mackall - April 17, 2015, 10:23 p.m.
On Fri, 2015-04-17 at 10:32 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1429289203 25200
> #      Fri Apr 17 09:46:43 2015 -0700
> # Branch stable
> # Node ID 2bd479201893ea1975e45b02b8c9d6c8a611dc3e
> # Parent  82fe5721302973f90b594239772a05f447c493aa
> histedit: change state format to allow non-hash lines

Queued for stable, thanks.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -246,7 +246,8 @@  class histeditstate(object):
         fp.write('%s\n' % self.keep)
         fp.write('%d\n' % len(self.rules))
         for rule in self.rules:
-            fp.write('%s%s\n' % (rule[1], rule[0]))
+            fp.write('%s\n' % rule[0]) # action
+            fp.write('%s\n' % rule[1]) # remainder
         fp.write('%d\n' % len(self.replacements))
         for replacement in self.replacements:
             fp.write('%s%s\n' % (node.hex(replacement[0]), ''.join(node.hex(r)
@@ -276,11 +277,11 @@  class histeditstate(object):
         rulelen = int(lines[index])
         index += 1
         for i in xrange(rulelen):
+            ruleaction = lines[index]
+            index += 1
             rule = lines[index]
-            rulehash = rule[:40]
-            ruleaction = rule[40:]
-            rules.append((ruleaction, rulehash))
             index += 1
+            rules.append((ruleaction, rule))
 
         # Replacements
         replacements = []