D3866: histedit: use cbor to write histedit-state file
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Sun Jul 1 17:11:02 EDT 2018
pulkit added a comment.
In https://phab.mercurial-scm.org/D3866#60421, @yuja wrote:
> Queued the first 4 patches, thanks.
>
> > $ HGEDITOR="sh $TESTTMP/editplan.sh" hg histedit --edit-plan
> > $ cat .hg/histedit-state
> >
> > - v1
> > - 055a42cdd88768532f9cf79daa407fc8d138de9b
> > - 3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
> > - False
> > - 3
> > - drop
> > - e860deea161a2f77de56603b340ebbb4536308ae
> > - drop
> > - 652413bf663ef2a641cab26574e46d5f5a64a55a
> > - drop
> > - 3c6a8ed2ebe862cc949d2caa30775dd6f16fb799
> > - 0
> > - strip-backup/177f92b77385-0ebe6a8f-histedit.hg + 2
>
> I know anything other than "v1" will make old hg crash, but I think the
> version syntax should stay "v%d" (i.e. "v2" in this case.)
Yeah, I think we need to pass version number in the state.cmdstate.read(). Supporting rebasestate will also need similar tweak.
>
>
>> def _write(self, fp):
>>
>> - fp.write('v1\n')
>> - fp.write('%s\n' % node.hex(self.parentctxnode))
>> - fp.write('%s\n' % node.hex(self.topmost))
>> - fp.write('%s\n' % ('True' if self.keep else 'False'))
>> - fp.write('%d\n' % len(self.actions)) + data = {'parentctxnode': self.parentctxnode, + 'topmost': self.topmost, + 'keep': self.keep, + 'backupfile': self.backupfile, + 'replacements': self.replacements} + rules = [] for action in self.actions:
>> - fp.write('%s\n' % action.tostate())
>> - 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)
>> - for r in replacement[1])))
>> - backupfile = self.backupfile
>> - if not backupfile:
>> - backupfile = ''
>> - fp.write('%s\n' % backupfile) + rules.append(action.tostate().split('\n')) + rules = "\n".join(["%s %s" % (verb, rest) for [verb, rest] in rules])
>
> Isn't it better to serialize `[(verb, rest)]` as is since CBOR can store that?
Yeah, it's better. I will do that.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D3866
To: pulkit, durin42, #hg-reviewers
Cc: yuja, mercurial-devel
More information about the Mercurial-devel
mailing list