##// END OF EJS Templates
shelve: drop pickle usage...
Pierre-Yves David -
r19904:5b327880 default
parent child Browse files
Show More
@@ -21,13 +21,8 b' shelved change has a distinct name. For '
21 21 shelve".
22 22 """
23 23
24 try:
25 import cPickle as pickle
26 pickle.dump # import now
27 except ImportError:
28 import pickle
29 24 from mercurial.i18n import _
30 from mercurial.node import nullid
25 from mercurial.node import nullid, bin, hex
31 26 from mercurial import changegroup, cmdutil, scmutil, phases
32 27 from mercurial import error, hg, mdiff, merge, patch, repair, util
33 28 from mercurial import templatefilters
@@ -88,11 +83,17 b' class shelvedstate(object):'
88 83 @classmethod
89 84 def load(cls, repo):
90 85 fp = repo.opener(cls._filename)
91 (version, name, parents, stripnodes) = pickle.load(fp)
86 try:
87 version = int(fp.readline().strip())
92 88
93 if version != cls._version:
94 raise util.Abort(_('this version of shelve is incompatible '
95 'with the version used in this repo'))
89 if version != cls._version:
90 raise util.Abort(_('this version of shelve is incompatible '
91 'with the version used in this repo'))
92 name = fp.readline().strip()
93 parents = [bin(h) for h in fp.readline().split()]
94 stripnodes = [bin(h) for h in fp.readline().split()]
95 finally:
96 fp.close()
96 97
97 98 obj = cls()
98 99 obj.name = name
@@ -104,9 +105,10 b' class shelvedstate(object):'
104 105 @classmethod
105 106 def save(cls, repo, name, stripnodes):
106 107 fp = repo.opener(cls._filename, 'wb')
107 pickle.dump((cls._version, name,
108 repo.dirstate.parents(),
109 stripnodes), fp)
108 fp.write('%i\n' % cls._version)
109 fp.write('%s\n' % name)
110 fp.write('%s\n' % ' '.join([hex(p) for p in repo.dirstate.parents()]))
111 fp.write('%s\n' % ' '.join([hex(n) for n in stripnodes]))
110 112 fp.close()
111 113
112 114 @staticmethod
General Comments 0
You need to be logged in to leave comments. Login now