Mercurial > hg
comparison hgext/histedit.py @ 41397:0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
We have had these methods on both contexts and dirstate for a long
time now.
Differential Revision: https://phab.mercurial-scm.org/D5706
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 25 Jan 2019 23:36:23 -0800 |
parents | 32ef47b3c91c |
children | 5cb8158a61f7 |
comparison
equal
deleted
inserted
replaced
41396:3461814417f3 | 41397:0bd56c291359 |
---|---|
573 return repo.commit(**kwargs) | 573 return repo.commit(**kwargs) |
574 return commitfunc | 574 return commitfunc |
575 | 575 |
576 def applychanges(ui, repo, ctx, opts): | 576 def applychanges(ui, repo, ctx, opts): |
577 """Merge changeset from ctx (only) in the current working directory""" | 577 """Merge changeset from ctx (only) in the current working directory""" |
578 wcpar = repo.dirstate.parents()[0] | 578 wcpar = repo.dirstate.p1() |
579 if ctx.p1().node() == wcpar: | 579 if ctx.p1().node() == wcpar: |
580 # edits are "in place" we do not need to make any merge, | 580 # edits are "in place" we do not need to make any merge, |
581 # just applies changes on parent for editing | 581 # just applies changes on parent for editing |
582 cmdutil.revert(ui, repo, ctx, (wcpar, node.nullid), all=True) | 582 cmdutil.revert(ui, repo, ctx, (wcpar, node.nullid), all=True) |
583 stats = mergemod.updateresult(0, 0, 0, 0) | 583 stats = mergemod.updateresult(0, 0, 0, 0) |
606 return None | 606 return None |
607 for c in ctxs: | 607 for c in ctxs: |
608 if not c.mutable(): | 608 if not c.mutable(): |
609 raise error.ParseError( | 609 raise error.ParseError( |
610 _("cannot fold into public change %s") % node.short(c.node())) | 610 _("cannot fold into public change %s") % node.short(c.node())) |
611 base = firstctx.parents()[0] | 611 base = firstctx.p1() |
612 | 612 |
613 # commit a new version of the old changeset, including the update | 613 # commit a new version of the old changeset, including the update |
614 # collect all files which might be affected | 614 # collect all files which might be affected |
615 files = set() | 615 files = set() |
616 for ctx in ctxs: | 616 for ctx in ctxs: |
691 _('use commit'), | 691 _('use commit'), |
692 priority=True) | 692 priority=True) |
693 class pick(histeditaction): | 693 class pick(histeditaction): |
694 def run(self): | 694 def run(self): |
695 rulectx = self.repo[self.node] | 695 rulectx = self.repo[self.node] |
696 if rulectx.parents()[0].node() == self.state.parentctxnode: | 696 if rulectx.p1().node() == self.state.parentctxnode: |
697 self.repo.ui.debug('node %s unchanged\n' % node.short(self.node)) | 697 self.repo.ui.debug('node %s unchanged\n' % node.short(self.node)) |
698 return rulectx, [] | 698 return rulectx, [] |
699 | 699 |
700 return super(pick, self).run() | 700 return super(pick, self).run() |
701 | 701 |
722 def verify(self, prev, expected, seen): | 722 def verify(self, prev, expected, seen): |
723 """ Verifies semantic correctness of the fold rule""" | 723 """ Verifies semantic correctness of the fold rule""" |
724 super(fold, self).verify(prev, expected, seen) | 724 super(fold, self).verify(prev, expected, seen) |
725 repo = self.repo | 725 repo = self.repo |
726 if not prev: | 726 if not prev: |
727 c = repo[self.node].parents()[0] | 727 c = repo[self.node].p1() |
728 elif not prev.verb in ('pick', 'base'): | 728 elif not prev.verb in ('pick', 'base'): |
729 return | 729 return |
730 else: | 730 else: |
731 c = repo[prev.node] | 731 c = repo[prev.node] |
732 if not c.mutable(): | 732 if not c.mutable(): |
793 'fold'. | 793 'fold'. |
794 """ | 794 """ |
795 return False | 795 return False |
796 | 796 |
797 def finishfold(self, ui, repo, ctx, oldctx, newnode, internalchanges): | 797 def finishfold(self, ui, repo, ctx, oldctx, newnode, internalchanges): |
798 parent = ctx.parents()[0].node() | 798 parent = ctx.p1().node() |
799 hg.updaterepo(repo, parent, overwrite=False) | 799 hg.updaterepo(repo, parent, overwrite=False) |
800 ### prepare new commit data | 800 ### prepare new commit data |
801 commitopts = {} | 801 commitopts = {} |
802 commitopts['user'] = ctx.user() | 802 commitopts['user'] = ctx.user() |
803 # commit message | 803 # commit message |
1900 else: | 1900 else: |
1901 rules = _readfile(ui, rules) | 1901 rules = _readfile(ui, rules) |
1902 actions = parserules(rules, state) | 1902 actions = parserules(rules, state) |
1903 warnverifyactions(ui, repo, actions, state, ctxs) | 1903 warnverifyactions(ui, repo, actions, state, ctxs) |
1904 | 1904 |
1905 parentctxnode = repo[root].parents()[0].node() | 1905 parentctxnode = repo[root].p1().node() |
1906 | 1906 |
1907 state.parentctxnode = parentctxnode | 1907 state.parentctxnode = parentctxnode |
1908 state.actions = actions | 1908 state.actions = actions |
1909 state.topmost = topmost | 1909 state.topmost = topmost |
1910 state.replacements = [] | 1910 state.replacements = [] |