##// END OF EJS Templates
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]...
Martin von Zweigbergk -
r41442:0bd56c29 default
parent child Browse files
Show More
@@ -349,7 +349,7 b' def synthesize(ui, repo, descpath, **opt'
349 # to the modeled directory structure.
349 # to the modeled directory structure.
350 initcount = int(opts['initfiles'])
350 initcount = int(opts['initfiles'])
351 if initcount and initdirs:
351 if initcount and initdirs:
352 pctx = repo[None].parents()[0]
352 pctx = repo[None].p1()
353 dirs = set(pctx.dirs())
353 dirs = set(pctx.dirs())
354 files = {}
354 files = {}
355
355
@@ -575,7 +575,7 b' def commitfuncfor(repo, src):'
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
@@ -608,7 +608,7 b' def collapse(repo, firstctx, lastctx, co'
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
@@ -693,7 +693,7 b' def action(verbs, message, priority=Fals'
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
@@ -724,7 +724,7 b' class fold(histeditaction):'
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:
@@ -795,7 +795,7 b' class fold(histeditaction):'
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 = {}
@@ -1902,7 +1902,7 b' def _newhistedit(ui, repo, state, revs, '
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
@@ -288,8 +288,8 b' def _getchangedfiles(ctx, parents):'
288 files = set(ctx.files())
288 files = set(ctx.files())
289 if node.nullid not in parents:
289 if node.nullid not in parents:
290 mc = ctx.manifest()
290 mc = ctx.manifest()
291 mp1 = ctx.parents()[0].manifest()
291 mp1 = ctx.p1().manifest()
292 mp2 = ctx.parents()[1].manifest()
292 mp2 = ctx.p2().manifest()
293 files |= (set(mp1) | set(mp2)) - set(mc)
293 files |= (set(mp1) | set(mp2)) - set(mc)
294 for f in mc:
294 for f in mc:
295 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None):
295 if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None):
@@ -518,8 +518,8 b' def getlfilestoupload(repo, missing, add'
518 files = set(ctx.files())
518 files = set(ctx.files())
519 if len(parents) == 2:
519 if len(parents) == 2:
520 mc = ctx.manifest()
520 mc = ctx.manifest()
521 mp1 = ctx.parents()[0].manifest()
521 mp1 = ctx.p1().manifest()
522 mp2 = ctx.parents()[1].manifest()
522 mp2 = ctx.p2().manifest()
523 for f in mp1:
523 for f in mp1:
524 if f not in mc:
524 if f not in mc:
525 files.add(f)
525 files.add(f)
@@ -674,7 +674,7 b' def mergefiles(ui, repo, wctx, shelvectx'
674 hg.update(repo, wctx.node())
674 hg.update(repo, wctx.node())
675 files = []
675 files = []
676 files.extend(shelvectx.files())
676 files.extend(shelvectx.files())
677 files.extend(shelvectx.parents()[0].files())
677 files.extend(shelvectx.p1().files())
678
678
679 # revert will overwrite unknown files, so move them out of the way
679 # revert will overwrite unknown files, so move them out of the way
680 for file in repo.status(unknown=True).unknown:
680 for file in repo.status(unknown=True).unknown:
@@ -809,7 +809,7 b' def _rebaserestoredcommit(ui, repo, opts'
809 """Rebase restored commit from its original location to a destination"""
809 """Rebase restored commit from its original location to a destination"""
810 # If the shelve is not immediately on top of the commit
810 # If the shelve is not immediately on top of the commit
811 # we'll be merging with, rebase it to be on top.
811 # we'll be merging with, rebase it to be on top.
812 if tmpwctx.node() == shelvectx.parents()[0].node():
812 if tmpwctx.node() == shelvectx.p1().node():
813 return shelvectx
813 return shelvectx
814
814
815 overrides = {
815 overrides = {
@@ -39,7 +39,7 b' def checksubstate(repo, baserev=None):'
39 if baserev:
39 if baserev:
40 bctx = repo[baserev]
40 bctx = repo[baserev]
41 else:
41 else:
42 bctx = wctx.parents()[0]
42 bctx = wctx.p1()
43 for s in sorted(wctx.substate):
43 for s in sorted(wctx.substate):
44 wctx.sub(s).bailifchanged(True)
44 wctx.sub(s).bailifchanged(True)
45 if s not in bctx.substate or bctx.sub(s).dirty():
45 if s not in bctx.substate or bctx.sub(s).dirty():
@@ -67,7 +67,7 b' def _commitfiltered(repo, ctx, match, ke'
67 files = (initialfiles - exclude)
67 files = (initialfiles - exclude)
68 # return the p1 so that we don't create an obsmarker later
68 # return the p1 so that we don't create an obsmarker later
69 if not keepcommit:
69 if not keepcommit:
70 return ctx.parents()[0].node()
70 return ctx.p1().node()
71
71
72 # Filter copies
72 # Filter copies
73 copied = copiesmod.pathcopies(base, ctx)
73 copied = copiesmod.pathcopies(base, ctx)
@@ -1672,8 +1672,8 b' def _docommit(ui, repo, *pats, **opts):'
1672 if not bheads:
1672 if not bheads:
1673 raise error.Abort(_('can only close branch heads'))
1673 raise error.Abort(_('can only close branch heads'))
1674 elif opts.get('amend'):
1674 elif opts.get('amend'):
1675 if repo[None].parents()[0].p1().branch() != branch and \
1675 if repo[None].p1().p1().branch() != branch and \
1676 repo[None].parents()[0].p2().branch() != branch:
1676 repo[None].p1().p2().branch() != branch:
1677 raise error.Abort(_('can only close branch heads'))
1677 raise error.Abort(_('can only close branch heads'))
1678
1678
1679 if opts.get('amend'):
1679 if opts.get('amend'):
@@ -884,7 +884,7 b' def comparison(web):'
884 leftlines = filelines(pfctx)
884 leftlines = filelines(pfctx)
885 else:
885 else:
886 rightlines = ()
886 rightlines = ()
887 pfctx = ctx.parents()[0][path]
887 pfctx = ctx.p1()[path]
888 leftlines = filelines(pfctx)
888 leftlines = filelines(pfctx)
889
889
890 comparison = webutil.compare(context, leftlines, rightlines)
890 comparison = webutil.compare(context, leftlines, rightlines)
@@ -471,7 +471,7 b' def ancestorspec(repo, subset, x, n, ord'
471 try:
471 try:
472 r = cl.parentrevs(r)[0]
472 r = cl.parentrevs(r)[0]
473 except error.WdirUnsupported:
473 except error.WdirUnsupported:
474 r = repo[r].parents()[0].rev()
474 r = repo[r].p1().rev()
475 ps.add(r)
475 ps.add(r)
476 return subset & ps
476 return subset & ps
477
477
@@ -1572,7 +1572,7 b' def p1(repo, subset, x):'
1572 try:
1572 try:
1573 ps.add(cl.parentrevs(r)[0])
1573 ps.add(cl.parentrevs(r)[0])
1574 except error.WdirUnsupported:
1574 except error.WdirUnsupported:
1575 ps.add(repo[r].parents()[0].rev())
1575 ps.add(repo[r].p1().rev())
1576 ps -= {node.nullrev}
1576 ps -= {node.nullrev}
1577 # XXX we should turn this into a baseset instead of a set, smartset may do
1577 # XXX we should turn this into a baseset instead of a set, smartset may do
1578 # some optimizations from the fact this is a baseset.
1578 # some optimizations from the fact this is a baseset.
@@ -1691,7 +1691,7 b' def parentspec(repo, subset, x, n, order'
1691 try:
1691 try:
1692 ps.add(cl.parentrevs(r)[0])
1692 ps.add(cl.parentrevs(r)[0])
1693 except error.WdirUnsupported:
1693 except error.WdirUnsupported:
1694 ps.add(repo[r].parents()[0].rev())
1694 ps.add(repo[r].p1().rev())
1695 else:
1695 else:
1696 try:
1696 try:
1697 parents = cl.parentrevs(r)
1697 parents = cl.parentrevs(r)
@@ -336,7 +336,7 b' def filterupdatesactions(repo, wctx, mct'
336 if branchmerge:
336 if branchmerge:
337 # If we're merging, use the wctx filter, since we're merging into
337 # If we're merging, use the wctx filter, since we're merging into
338 # the wctx.
338 # the wctx.
339 sparsematch = matcher(repo, [wctx.parents()[0].rev()])
339 sparsematch = matcher(repo, [wctx.p1().rev()])
340 else:
340 else:
341 # If we're updating, use the target context's filter, since we're
341 # If we're updating, use the target context's filter, since we're
342 # moving to the target context.
342 # moving to the target context.
@@ -796,7 +796,7 b' def showsubrepos(context, mapping):'
796 substate = ctx.substate
796 substate = ctx.substate
797 if not substate:
797 if not substate:
798 return compatlist(context, mapping, 'subrepo', [])
798 return compatlist(context, mapping, 'subrepo', [])
799 psubstate = ctx.parents()[0].substate or {}
799 psubstate = ctx.p1().substate or {}
800 subrepos = []
800 subrepos = []
801 for sub in substate:
801 for sub in substate:
802 if sub not in psubstate or substate[sub] != psubstate[sub]:
802 if sub not in psubstate or substate[sub] != psubstate[sub]:
@@ -63,7 +63,7 b' for enc in "ASCII", "Latin-1", "UTF-8":'
63 # test performing a status
63 # test performing a status
64
64
65 def getfilectx(repo, memctx, f):
65 def getfilectx(repo, memctx, f):
66 fctx = memctx.parents()[0][f]
66 fctx = memctx.p1()[f]
67 data, flags = fctx.data(), fctx.flags()
67 data, flags = fctx.data(), fctx.flags()
68 if f == b'foo':
68 if f == b'foo':
69 data += b'bar\n'
69 data += b'bar\n'
General Comments 0
You need to be logged in to leave comments. Login now