[PATCH 04 of 10 PyPy] histedit: only use pickle if not using the modern save format

Yuya Nishihara yuya at tcha.org
Sun Dec 27 10:10:10 CST 2015


On Wed, 23 Dec 2015 16:22:19 -0800, Bryan O'Sullivan wrote:
> This avoids a case where PyPy's cPickle module throws a more confusing
> error than CPython's.

I've queued the first 4, thanks. I'll read the remainder tomorrow.

BTW, do you know why patch headers were lost?

> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -252,19 +252,19 @@ class histeditstate(object):
>      def read(self):
>          """Load histedit state from disk and set fields appropriately."""
>          try:
> -            fp = self.repo.vfs('histedit-state', 'r')
> +            state = self.repo.vfs.read('histedit-state')
>          except IOError as err:
>              if err.errno != errno.ENOENT:
>                  raise
>              raise error.Abort(_('no histedit in progress'))
>  
> -        try:
> -            data = pickle.load(fp)
> +        if state.startswith('v1\n'):
> +            data = self._load()
> +            parentctxnode, rules, keep, topmost, replacements, backupfile = data
> +        else:
> +            data = pickle.loads(state)
>              parentctxnode, rules, keep, topmost, replacements = data
>              backupfile = None
> -        except pickle.UnpicklingError:
> -            data = self._load()
> -            parentctxnode, rules, keep, topmost, replacements, backupfile = data

This is off topic, but the old pickle format seems not work anymore probably
because the old format doesn't keep a full hash.

  % hg-3.3/hg clone https://selenic.com/repo/hello/
  % cd hello
  % hg-3.3/hg phase -fdr0
  % hg-3.3/hg histedit 0  # edit all
  % hg-dev/hg histedit --continue
  abort: unknown revision 'xxx'!  # xxx: binary data

I've tried it because pickle.loads() isn't covered by our tests.


More information about the Mercurial-devel mailing list