diff --git a/contrib/synthrepo.py b/contrib/synthrepo.py --- a/contrib/synthrepo.py +++ b/contrib/synthrepo.py @@ -349,7 +349,7 @@ # to the modeled directory structure. initcount = int(opts['initfiles']) if initcount and initdirs: - pctx = repo[None].parents()[0] + pctx = repo[None].p1() dirs = set(pctx.dirs()) files = {} diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -575,7 +575,7 @@ def applychanges(ui, repo, ctx, opts): """Merge changeset from ctx (only) in the current working directory""" - wcpar = repo.dirstate.parents()[0] + wcpar = repo.dirstate.p1() if ctx.p1().node() == wcpar: # edits are "in place" we do not need to make any merge, # just applies changes on parent for editing @@ -608,7 +608,7 @@ if not c.mutable(): raise error.ParseError( _("cannot fold into public change %s") % node.short(c.node())) - base = firstctx.parents()[0] + base = firstctx.p1() # commit a new version of the old changeset, including the update # collect all files which might be affected @@ -693,7 +693,7 @@ class pick(histeditaction): def run(self): rulectx = self.repo[self.node] - if rulectx.parents()[0].node() == self.state.parentctxnode: + if rulectx.p1().node() == self.state.parentctxnode: self.repo.ui.debug('node %s unchanged\n' % node.short(self.node)) return rulectx, [] @@ -724,7 +724,7 @@ super(fold, self).verify(prev, expected, seen) repo = self.repo if not prev: - c = repo[self.node].parents()[0] + c = repo[self.node].p1() elif not prev.verb in ('pick', 'base'): return else: @@ -795,7 +795,7 @@ return False def finishfold(self, ui, repo, ctx, oldctx, newnode, internalchanges): - parent = ctx.parents()[0].node() + parent = ctx.p1().node() hg.updaterepo(repo, parent, overwrite=False) ### prepare new commit data commitopts = {} @@ -1902,7 +1902,7 @@ actions = parserules(rules, state) warnverifyactions(ui, repo, actions, state, ctxs) - parentctxnode = repo[root].parents()[0].node() + parentctxnode = repo[root].p1().node() state.parentctxnode = parentctxnode state.actions = actions diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py --- a/hgext/largefiles/lfcommands.py +++ b/hgext/largefiles/lfcommands.py @@ -288,8 +288,8 @@ files = set(ctx.files()) if node.nullid not in parents: mc = ctx.manifest() - mp1 = ctx.parents()[0].manifest() - mp2 = ctx.parents()[1].manifest() + mp1 = ctx.p1().manifest() + mp2 = ctx.p2().manifest() files |= (set(mp1) | set(mp2)) - set(mc) for f in mc: if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None): diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -518,8 +518,8 @@ files = set(ctx.files()) if len(parents) == 2: mc = ctx.manifest() - mp1 = ctx.parents()[0].manifest() - mp2 = ctx.parents()[1].manifest() + mp1 = ctx.p1().manifest() + mp2 = ctx.p2().manifest() for f in mp1: if f not in mc: files.add(f) diff --git a/hgext/shelve.py b/hgext/shelve.py --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -674,7 +674,7 @@ hg.update(repo, wctx.node()) files = [] files.extend(shelvectx.files()) - files.extend(shelvectx.parents()[0].files()) + files.extend(shelvectx.p1().files()) # revert will overwrite unknown files, so move them out of the way for file in repo.status(unknown=True).unknown: @@ -809,7 +809,7 @@ """Rebase restored commit from its original location to a destination""" # If the shelve is not immediately on top of the commit # we'll be merging with, rebase it to be on top. - if tmpwctx.node() == shelvectx.parents()[0].node(): + if tmpwctx.node() == shelvectx.p1().node(): return shelvectx overrides = { diff --git a/hgext/strip.py b/hgext/strip.py --- a/hgext/strip.py +++ b/hgext/strip.py @@ -39,7 +39,7 @@ if baserev: bctx = repo[baserev] else: - bctx = wctx.parents()[0] + bctx = wctx.p1() for s in sorted(wctx.substate): wctx.sub(s).bailifchanged(True) if s not in bctx.substate or bctx.sub(s).dirty(): diff --git a/hgext/uncommit.py b/hgext/uncommit.py --- a/hgext/uncommit.py +++ b/hgext/uncommit.py @@ -67,7 +67,7 @@ files = (initialfiles - exclude) # return the p1 so that we don't create an obsmarker later if not keepcommit: - return ctx.parents()[0].node() + return ctx.p1().node() # Filter copies copied = copiesmod.pathcopies(base, ctx) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1672,8 +1672,8 @@ if not bheads: raise error.Abort(_('can only close branch heads')) elif opts.get('amend'): - if repo[None].parents()[0].p1().branch() != branch and \ - repo[None].parents()[0].p2().branch() != branch: + if repo[None].p1().p1().branch() != branch and \ + repo[None].p1().p2().branch() != branch: raise error.Abort(_('can only close branch heads')) if opts.get('amend'): diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -884,7 +884,7 @@ leftlines = filelines(pfctx) else: rightlines = () - pfctx = ctx.parents()[0][path] + pfctx = ctx.p1()[path] leftlines = filelines(pfctx) comparison = webutil.compare(context, leftlines, rightlines) diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -471,7 +471,7 @@ try: r = cl.parentrevs(r)[0] except error.WdirUnsupported: - r = repo[r].parents()[0].rev() + r = repo[r].p1().rev() ps.add(r) return subset & ps @@ -1572,7 +1572,7 @@ try: ps.add(cl.parentrevs(r)[0]) except error.WdirUnsupported: - ps.add(repo[r].parents()[0].rev()) + ps.add(repo[r].p1().rev()) ps -= {node.nullrev} # XXX we should turn this into a baseset instead of a set, smartset may do # some optimizations from the fact this is a baseset. @@ -1691,7 +1691,7 @@ try: ps.add(cl.parentrevs(r)[0]) except error.WdirUnsupported: - ps.add(repo[r].parents()[0].rev()) + ps.add(repo[r].p1().rev()) else: try: parents = cl.parentrevs(r) diff --git a/mercurial/sparse.py b/mercurial/sparse.py --- a/mercurial/sparse.py +++ b/mercurial/sparse.py @@ -336,7 +336,7 @@ if branchmerge: # If we're merging, use the wctx filter, since we're merging into # the wctx. - sparsematch = matcher(repo, [wctx.parents()[0].rev()]) + sparsematch = matcher(repo, [wctx.p1().rev()]) else: # If we're updating, use the target context's filter, since we're # moving to the target context. diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -796,7 +796,7 @@ substate = ctx.substate if not substate: return compatlist(context, mapping, 'subrepo', []) - psubstate = ctx.parents()[0].substate or {} + psubstate = ctx.p1().substate or {} subrepos = [] for sub in substate: if sub not in psubstate or substate[sub] != psubstate[sub]: diff --git a/tests/test-context.py b/tests/test-context.py --- a/tests/test-context.py +++ b/tests/test-context.py @@ -63,7 +63,7 @@ # test performing a status def getfilectx(repo, memctx, f): - fctx = memctx.parents()[0][f] + fctx = memctx.p1()[f] data, flags = fctx.data(), fctx.flags() if f == b'foo': data += b'bar\n'