Mercurial > hg
comparison hgext/shelve.py @ 30453:2e736f01a710
shelve: move temporary commit creation to a separate function
Committing working copy changes before rebasing a shelved commit
on top of them is an independent piece of behavior, which fits
into its own function.
Similar to the previous series, this and a couple of following
patches are for unshelve refactoring.
author | Kostia Balytskyi <ikostia@fb.com> |
---|---|
date | Sun, 13 Nov 2016 03:35:52 -0800 |
parents | e1677cc29da6 |
children | 672026aece64 |
comparison
equal
deleted
inserted
replaced
30452:932b18c95e11 | 30453:2e736f01a710 |
---|---|
628 repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') | 628 repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') |
629 shelvedstate.clear(repo) | 629 shelvedstate.clear(repo) |
630 unshelvecleanup(ui, repo, state.name, opts) | 630 unshelvecleanup(ui, repo, state.name, opts) |
631 ui.status(_("unshelve of '%s' complete\n") % state.name) | 631 ui.status(_("unshelve of '%s' complete\n") % state.name) |
632 | 632 |
633 def _commitworkingcopychanges(ui, repo, opts, tmpwctx): | |
634 """Temporarily commit working copy changes before moving unshelve commit""" | |
635 # Store pending changes in a commit and remember added in case a shelve | |
636 # contains unknown files that are part of the pending change | |
637 s = repo.status() | |
638 addedbefore = frozenset(s.added) | |
639 if not (s.modified or s.added or s.removed or s.deleted): | |
640 return tmpwctx, addedbefore | |
641 ui.status(_("temporarily committing pending changes " | |
642 "(restore with 'hg unshelve --abort')\n")) | |
643 commitfunc = getcommitfunc(extra=None, interactive=False, | |
644 editor=False) | |
645 tempopts = {} | |
646 tempopts['message'] = "pending changes temporary commit" | |
647 tempopts['date'] = opts.get('date') | |
648 ui.quiet = True | |
649 node = cmdutil.commit(ui, repo, commitfunc, [], tempopts) | |
650 tmpwctx = repo[node] | |
651 return tmpwctx, addedbefore | |
652 | |
633 @command('unshelve', | 653 @command('unshelve', |
634 [('a', 'abort', None, | 654 [('a', 'abort', None, |
635 _('abort an incomplete unshelve operation')), | 655 _('abort an incomplete unshelve operation')), |
636 ('c', 'continue', None, | 656 ('c', 'continue', None, |
637 _('continue an incomplete unshelve operation')), | 657 _('continue an incomplete unshelve operation')), |
750 # ...-> pctx -> tmpwctx -> shelvectx | 770 # ...-> pctx -> tmpwctx -> shelvectx |
751 # where tmpwctx is an optional commit with the user's pending changes | 771 # where tmpwctx is an optional commit with the user's pending changes |
752 # and shelvectx is the unshelved changes. Then we merge it all down | 772 # and shelvectx is the unshelved changes. Then we merge it all down |
753 # to the original pctx. | 773 # to the original pctx. |
754 | 774 |
755 # Store pending changes in a commit and remember added in case a shelve | 775 tmpwctx, addedbefore = _commitworkingcopychanges(ui, repo, opts, |
756 # contains unknown files that are part of the pending change | 776 tmpwctx) |
757 s = repo.status() | |
758 addedbefore = frozenset(s.added) | |
759 if s.modified or s.added or s.removed or s.deleted: | |
760 ui.status(_("temporarily committing pending changes " | |
761 "(restore with 'hg unshelve --abort')\n")) | |
762 commitfunc = getcommitfunc(extra=None, interactive=False, | |
763 editor=False) | |
764 tempopts = {} | |
765 tempopts['message'] = "pending changes temporary commit" | |
766 tempopts['date'] = opts.get('date') | |
767 ui.quiet = True | |
768 node = cmdutil.commit(ui, repo, commitfunc, [], tempopts) | |
769 tmpwctx = repo[node] | |
770 | 777 |
771 ui.quiet = True | 778 ui.quiet = True |
772 shelvedfile(repo, basename, 'hg').applybundle() | 779 shelvedfile(repo, basename, 'hg').applybundle() |
773 | 780 |
774 ui.quiet = oldquiet | 781 ui.quiet = oldquiet |