163 |
163 |
164 if version != cls._version: |
164 if version != cls._version: |
165 raise error.Abort(_('this version of shelve is incompatible ' |
165 raise error.Abort(_('this version of shelve is incompatible ' |
166 'with the version used in this repo')) |
166 'with the version used in this repo')) |
167 name = fp.readline().strip() |
167 name = fp.readline().strip() |
168 wctx = fp.readline().strip() |
168 wctx = nodemod.bin(fp.readline().strip()) |
169 pendingctx = fp.readline().strip() |
169 pendingctx = nodemod.bin(fp.readline().strip()) |
170 parents = [nodemod.bin(h) for h in fp.readline().split()] |
170 parents = [nodemod.bin(h) for h in fp.readline().split()] |
171 stripnodes = [nodemod.bin(h) for h in fp.readline().split()] |
171 stripnodes = [nodemod.bin(h) for h in fp.readline().split()] |
172 branchtorestore = fp.readline().strip() |
172 branchtorestore = fp.readline().strip() |
|
173 except (ValueError, TypeError) as err: |
|
174 raise error.CorruptedState(str(err)) |
173 finally: |
175 finally: |
174 fp.close() |
176 fp.close() |
175 |
177 |
176 obj = cls() |
178 try: |
177 obj.name = name |
179 obj = cls() |
178 obj.wctx = repo[nodemod.bin(wctx)] |
180 obj.name = name |
179 obj.pendingctx = repo[nodemod.bin(pendingctx)] |
181 obj.wctx = repo[wctx] |
180 obj.parents = parents |
182 obj.pendingctx = repo[pendingctx] |
181 obj.stripnodes = stripnodes |
183 obj.parents = parents |
182 obj.branchtorestore = branchtorestore |
184 obj.stripnodes = stripnodes |
|
185 obj.branchtorestore = branchtorestore |
|
186 except error.RepoLookupError as err: |
|
187 raise error.CorruptedState(str(err)) |
183 |
188 |
184 return obj |
189 return obj |
185 |
190 |
186 @classmethod |
191 @classmethod |
187 def save(cls, repo, name, originalwctx, pendingctx, stripnodes, |
192 def save(cls, repo, name, originalwctx, pendingctx, stripnodes, |
664 state = shelvedstate.load(repo) |
669 state = shelvedstate.load(repo) |
665 except IOError as err: |
670 except IOError as err: |
666 if err.errno != errno.ENOENT: |
671 if err.errno != errno.ENOENT: |
667 raise |
672 raise |
668 cmdutil.wrongtooltocontinue(repo, _('unshelve')) |
673 cmdutil.wrongtooltocontinue(repo, _('unshelve')) |
|
674 except error.CorruptedState as err: |
|
675 ui.debug(str(err) + '\n') |
|
676 if continuef: |
|
677 msg = _('corrupted shelved state file') |
|
678 hint = _('please run hg unshelve --abort to abort unshelve ' |
|
679 'operation') |
|
680 raise error.Abort(msg, hint=hint) |
|
681 elif abortf: |
|
682 msg = _('could not read shelved state file, your working copy ' |
|
683 'may be in an unexpected state\nplease update to some ' |
|
684 'commit\n') |
|
685 ui.warn(msg) |
|
686 shelvedstate.clear(repo) |
|
687 return |
669 |
688 |
670 if abortf: |
689 if abortf: |
671 return unshelveabort(ui, repo, state, opts) |
690 return unshelveabort(ui, repo, state, opts) |
672 elif continuef: |
691 elif continuef: |
673 return unshelvecontinue(ui, repo, state, opts) |
692 return unshelvecontinue(ui, repo, state, opts) |