Mercurial > hg
comparison hgext/shelve.py @ 31555:7c7d3ad7ca5c
shelve: rename stripnodes to nodestoprune
Since we are introducing obs-based shelve, we are no longer
stripping temporary nodes, we are obsoleting them. Therefore
it looks like stipnodes would be a misleading name, while
prune has a connotaion of "strip but with obsolescense", so
nodestoprune seems like a good rename.
author | Kostia Balytskyi <ikostia@fb.com> |
---|---|
date | Fri, 10 Mar 2017 16:18:43 -0800 |
parents | 7485e45807e4 |
children | 1cbeefa59343 |
comparison
equal
deleted
inserted
replaced
31554:7485e45807e4 | 31555:7c7d3ad7ca5c |
---|---|
182 'with the version used in this repo')) | 182 'with the version used in this repo')) |
183 name = fp.readline().strip() | 183 name = fp.readline().strip() |
184 wctx = nodemod.bin(fp.readline().strip()) | 184 wctx = nodemod.bin(fp.readline().strip()) |
185 pendingctx = nodemod.bin(fp.readline().strip()) | 185 pendingctx = nodemod.bin(fp.readline().strip()) |
186 parents = [nodemod.bin(h) for h in fp.readline().split()] | 186 parents = [nodemod.bin(h) for h in fp.readline().split()] |
187 stripnodes = [nodemod.bin(h) for h in fp.readline().split()] | 187 nodestoprune = [nodemod.bin(h) for h in fp.readline().split()] |
188 branchtorestore = fp.readline().strip() | 188 branchtorestore = fp.readline().strip() |
189 keep = fp.readline().strip() == cls._keep | 189 keep = fp.readline().strip() == cls._keep |
190 except (ValueError, TypeError) as err: | 190 except (ValueError, TypeError) as err: |
191 raise error.CorruptedState(str(err)) | 191 raise error.CorruptedState(str(err)) |
192 finally: | 192 finally: |
196 obj = cls() | 196 obj = cls() |
197 obj.name = name | 197 obj.name = name |
198 obj.wctx = repo[wctx] | 198 obj.wctx = repo[wctx] |
199 obj.pendingctx = repo[pendingctx] | 199 obj.pendingctx = repo[pendingctx] |
200 obj.parents = parents | 200 obj.parents = parents |
201 obj.stripnodes = stripnodes | 201 obj.nodestoprune = nodestoprune |
202 obj.branchtorestore = branchtorestore | 202 obj.branchtorestore = branchtorestore |
203 obj.keep = keep | 203 obj.keep = keep |
204 except error.RepoLookupError as err: | 204 except error.RepoLookupError as err: |
205 raise error.CorruptedState(str(err)) | 205 raise error.CorruptedState(str(err)) |
206 | 206 |
207 return obj | 207 return obj |
208 | 208 |
209 @classmethod | 209 @classmethod |
210 def save(cls, repo, name, originalwctx, pendingctx, stripnodes, | 210 def save(cls, repo, name, originalwctx, pendingctx, nodestoprune, |
211 branchtorestore, keep=False): | 211 branchtorestore, keep=False): |
212 fp = repo.vfs(cls._filename, 'wb') | 212 fp = repo.vfs(cls._filename, 'wb') |
213 fp.write('%i\n' % cls._version) | 213 fp.write('%i\n' % cls._version) |
214 fp.write('%s\n' % name) | 214 fp.write('%s\n' % name) |
215 fp.write('%s\n' % nodemod.hex(originalwctx.node())) | 215 fp.write('%s\n' % nodemod.hex(originalwctx.node())) |
216 fp.write('%s\n' % nodemod.hex(pendingctx.node())) | 216 fp.write('%s\n' % nodemod.hex(pendingctx.node())) |
217 fp.write('%s\n' % | 217 fp.write('%s\n' % |
218 ' '.join([nodemod.hex(p) for p in repo.dirstate.parents()])) | 218 ' '.join([nodemod.hex(p) for p in repo.dirstate.parents()])) |
219 fp.write('%s\n' % | 219 fp.write('%s\n' % |
220 ' '.join([nodemod.hex(n) for n in stripnodes])) | 220 ' '.join([nodemod.hex(n) for n in nodestoprune])) |
221 fp.write('%s\n' % branchtorestore) | 221 fp.write('%s\n' % branchtorestore) |
222 fp.write('%s\n' % (cls._keep if keep else cls._nokeep)) | 222 fp.write('%s\n' % (cls._keep if keep else cls._nokeep)) |
223 fp.close() | 223 fp.close() |
224 | 224 |
225 @classmethod | 225 @classmethod |
560 except Exception: | 560 except Exception: |
561 repo.vfs.rename('rebasestate', 'unshelverebasestate') | 561 repo.vfs.rename('rebasestate', 'unshelverebasestate') |
562 raise | 562 raise |
563 | 563 |
564 mergefiles(ui, repo, state.wctx, state.pendingctx) | 564 mergefiles(ui, repo, state.wctx, state.pendingctx) |
565 repair.strip(ui, repo, state.stripnodes, backup=False, | 565 repair.strip(ui, repo, state.nodestoprune, backup=False, |
566 topic='shelve') | 566 topic='shelve') |
567 finally: | 567 finally: |
568 shelvedstate.clear(repo) | 568 shelvedstate.clear(repo) |
569 ui.warn(_("unshelve of '%s' aborted\n") % state.name) | 569 ui.warn(_("unshelve of '%s' aborted\n") % state.name) |
570 | 570 |
631 if not shelvectx in state.pendingctx.children(): | 631 if not shelvectx in state.pendingctx.children(): |
632 # rebase was a no-op, so it produced no child commit | 632 # rebase was a no-op, so it produced no child commit |
633 shelvectx = state.pendingctx | 633 shelvectx = state.pendingctx |
634 else: | 634 else: |
635 # only strip the shelvectx if the rebase produced it | 635 # only strip the shelvectx if the rebase produced it |
636 state.stripnodes.append(shelvectx.node()) | 636 state.nodestoprune.append(shelvectx.node()) |
637 | 637 |
638 mergefiles(ui, repo, state.wctx, shelvectx) | 638 mergefiles(ui, repo, state.wctx, shelvectx) |
639 restorebranch(ui, repo, state.branchtorestore) | 639 restorebranch(ui, repo, state.branchtorestore) |
640 | 640 |
641 repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') | 641 repair.strip(ui, repo, state.nodestoprune, backup=False, topic='shelve') |
642 shelvedstate.clear(repo) | 642 shelvedstate.clear(repo) |
643 unshelvecleanup(ui, repo, state.name, opts) | 643 unshelvecleanup(ui, repo, state.name, opts) |
644 ui.status(_("unshelve of '%s' complete\n") % state.name) | 644 ui.status(_("unshelve of '%s' complete\n") % state.name) |
645 | 645 |
646 def _commitworkingcopychanges(ui, repo, opts, tmpwctx): | 646 def _commitworkingcopychanges(ui, repo, opts, tmpwctx): |
688 'tool': opts.get('tool', ''), | 688 'tool': opts.get('tool', ''), |
689 }) | 689 }) |
690 except error.InterventionRequired: | 690 except error.InterventionRequired: |
691 tr.close() | 691 tr.close() |
692 | 692 |
693 stripnodes = [repo.changelog.node(rev) | 693 nodestoprune = [repo.changelog.node(rev) |
694 for rev in xrange(oldtiprev, len(repo))] | 694 for rev in xrange(oldtiprev, len(repo))] |
695 shelvedstate.save(repo, basename, pctx, tmpwctx, stripnodes, | 695 shelvedstate.save(repo, basename, pctx, tmpwctx, nodestoprune, |
696 branchtorestore, opts.get('keep')) | 696 branchtorestore, opts.get('keep')) |
697 | 697 |
698 repo.vfs.rename('rebasestate', 'unshelverebasestate') | 698 repo.vfs.rename('rebasestate', 'unshelverebasestate') |
699 raise error.InterventionRequired( | 699 raise error.InterventionRequired( |
700 _("unresolved conflicts (see 'hg resolve', then " | 700 _("unresolved conflicts (see 'hg resolve', then " |