Mercurial > hg
changeset 13878:a8d13ee0ce68
misc: replace .parents()[0] with p1()
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 04 Apr 2011 16:21:59 -0500 |
parents | 653121e6941f |
children | 5b0a3f6cbead |
files | contrib/python-hook-examples.py hgext/extdiff.py hgext/hgcia.py hgext/mq.py hgext/notify.py hgext/rebase.py hgext/record.py hgext/transplant.py mercurial/cmdutil.py mercurial/commands.py mercurial/copies.py mercurial/localrepo.py mercurial/merge.py mercurial/patch.py mercurial/revset.py mercurial/templatekw.py |
diffstat | 16 files changed, 26 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/python-hook-examples.py Mon Apr 04 16:21:57 2011 -0500 +++ b/contrib/python-hook-examples.py Mon Apr 04 16:21:59 2011 -0500 @@ -13,7 +13,7 @@ if kwargs.get('parent2'): return node = kwargs['node'] - first = repo[node].parents()[0].node() + first = repo[node].p1().node() if 'url' in kwargs: last = repo['tip'].node() else:
--- a/hgext/extdiff.py Mon Apr 04 16:21:57 2011 -0500 +++ b/hgext/extdiff.py Mon Apr 04 16:21:59 2011 -0500 @@ -126,7 +126,7 @@ else: node1a, node2 = cmdutil.revpair(repo, revs) if not revs: - node1b = repo.dirstate.parents()[1] + node1b = repo.dirstate.p2() else: node1b = nullid
--- a/hgext/hgcia.py Mon Apr 04 16:21:57 2011 -0500 +++ b/hgext/hgcia.py Mon Apr 04 16:21:59 2011 -0500 @@ -75,7 +75,7 @@ def fileelems(self): n = self.ctx.node() - f = self.cia.repo.status(self.ctx.parents()[0].node(), n) + f = self.cia.repo.status(self.ctx.p1().node(), n) url = self.url or '' elems = [] for path in f[0]:
--- a/hgext/mq.py Mon Apr 04 16:21:57 2011 -0500 +++ b/hgext/mq.py Mon Apr 04 16:21:59 2011 -0500 @@ -899,7 +899,7 @@ else: p.write("# HG changeset patch\n") p.write("# Parent " - + hex(repo[None].parents()[0].node()) + "\n") + + hex(repo[None].p1().node()) + "\n") if user: p.write("# User " + user + "\n") if date: @@ -1054,7 +1054,7 @@ heads += ls if not heads: heads = [nullid] - if repo.dirstate.parents()[0] not in heads and not exact: + if repo.dirstate.p1() not in heads and not exact: self.ui.status(_("(working directory not at a head)\n")) if not self.series: @@ -1148,7 +1148,7 @@ ret = self.apply(repo, s, list, all_files=all_files) except: self.ui.warn(_('cleaning up working directory...')) - node = repo.dirstate.parents()[0] + node = repo.dirstate.p1() hg.revert(repo, node, None) # only remove unknown files that we know we touched or # created while patching
--- a/hgext/notify.py Mon Apr 04 16:21:57 2011 -0500 +++ b/hgext/notify.py Mon Apr 04 16:21:59 2011 -0500 @@ -249,7 +249,7 @@ def diff(self, ctx, ref=None): maxdiff = int(self.ui.config('notify', 'maxdiff', 300)) - prev = ctx.parents()[0].node() + prev = ctx.p1().node() ref = ref and ref.node() or ctx.node() chunks = patch.diff(self.repo, prev, ref, opts=patch.diffopts(self.ui)) difflines = ''.join(chunks).splitlines()
--- a/hgext/rebase.py Mon Apr 04 16:21:57 2011 -0500 +++ b/hgext/rebase.py Mon Apr 04 16:21:59 2011 -0500 @@ -300,7 +300,7 @@ repo.ui.debug(" merge against %d:%s\n" % (repo[rev].rev(), repo[rev])) base = None if repo[rev].rev() != repo[min(state)].rev(): - base = repo[rev].parents()[0].node() + base = repo[rev].p1().node() return merge.update(repo, rev, True, True, False, base) def defineparents(repo, rev, target, state, targetancestors):
--- a/hgext/record.py Mon Apr 04 16:21:57 2011 -0500 +++ b/hgext/record.py Mon Apr 04 16:21:59 2011 -0500 @@ -469,7 +469,7 @@ # 3a. apply filtered patch to clean repo (clean) if backups: - hg.revert(repo, repo.dirstate.parents()[0], + hg.revert(repo, repo.dirstate.p1(), lambda key: key in backups) # 3b. (apply)
--- a/hgext/transplant.py Mon Apr 04 16:21:57 2011 -0500 +++ b/hgext/transplant.py Mon Apr 04 16:21:59 2011 -0500 @@ -237,7 +237,7 @@ seriespath = os.path.join(self.path, 'series') if os.path.exists(seriespath): os.unlink(seriespath) - p1 = repo.dirstate.parents()[0] + p1 = repo.dirstate.p1() p2 = node self.log(user, date, message, p1, p2, merge=merge) self.ui.write(str(inst) + '\n')
--- a/mercurial/cmdutil.py Mon Apr 04 16:21:57 2011 -0500 +++ b/mercurial/cmdutil.py Mon Apr 04 16:21:59 2011 -0500 @@ -72,7 +72,7 @@ return p def bail_if_changed(repo): - if repo.dirstate.parents()[1] != nullid: + if repo.dirstate.p2() != nullid: raise util.Abort(_('outstanding uncommitted merge')) modified, added, removed, deleted = repo.status()[:4] if modified or added or removed or deleted: @@ -122,12 +122,12 @@ def revpair(repo, revs): if not revs: - return repo.dirstate.parents()[0], None + return repo.dirstate.p1(), None l = revrange(repo, revs) if len(l) == 0: - return repo.dirstate.parents()[0], None + return repo.dirstate.p1(), None if len(l) == 1: return repo.lookup(l[0]), None
--- a/mercurial/commands.py Mon Apr 04 16:21:57 2011 -0500 +++ b/mercurial/commands.py Mon Apr 04 16:21:59 2011 -0500 @@ -596,7 +596,7 @@ """ if opts.get('clean'): - label = repo[None].parents()[0].branch() + label = repo[None].p1().branch() repo.dirstate.setbranch(label) ui.status(_('reset working directory to branch %s\n') % label) elif label: @@ -1678,7 +1678,7 @@ raise util.Abort(msg) elif change: node2 = cmdutil.revsingle(repo, change, None).node() - node1 = repo[node2].parents()[0].node() + node1 = repo[node2].p1().node() else: node1, node2 = cmdutil.revpair(repo, revs) @@ -1905,7 +1905,7 @@ def prep(ctx, fns): rev = ctx.rev() - pctx = ctx.parents()[0] + pctx = ctx.p1() parent = pctx.rev() matches.setdefault(rev, {}) matches.setdefault(parent, {}) @@ -1940,7 +1940,7 @@ for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep): rev = ctx.rev() - parent = ctx.parents()[0].rev() + parent = ctx.p1().rev() for fn in sorted(revfiles.get(rev, [])): states = matches[rev][fn] copy = copies.get(rev, {}).get(fn) @@ -2840,7 +2840,7 @@ '(run \'hg heads .\' to see heads)') % (branch, len(bheads))) - parent = repo.dirstate.parents()[0] + parent = repo.dirstate.p1() if len(bheads) == 1: if len(repo.heads()) > 1: raise util.Abort(_( @@ -3751,7 +3751,7 @@ raise util.Abort(msg) elif change: node2 = repo.lookup(change) - node1 = repo[node2].parents()[0].node() + node1 = repo[node2].p1().node() else: node1, node2 = cmdutil.revpair(repo, revs)
--- a/mercurial/copies.py Mon Apr 04 16:21:57 2011 -0500 +++ b/mercurial/copies.py Mon Apr 04 16:21:59 2011 -0500 @@ -93,7 +93,7 @@ return {}, {} # avoid silly behavior for parent -> working dir - if c2.node() is None and c1.node() == repo.dirstate.parents()[0]: + if c2.node() is None and c1.node() == repo.dirstate.p1(): return repo.dirstate.copies(), {} limit = _findlimit(repo, c1.rev(), c2.rev())
--- a/mercurial/localrepo.py Mon Apr 04 16:21:57 2011 -0500 +++ b/mercurial/localrepo.py Mon Apr 04 16:21:59 2011 -0500 @@ -522,7 +522,7 @@ if isinstance(key, int): return self.changelog.node(key) elif key == '.': - return self.dirstate.parents()[0] + return self.dirstate.p1() elif key == 'null': return nullid elif key == 'tip':
--- a/mercurial/merge.py Mon Apr 04 16:21:57 2011 -0500 +++ b/mercurial/merge.py Mon Apr 04 16:21:59 2011 -0500 @@ -268,7 +268,7 @@ updated, merged, removed, unresolved = 0, 0, 0, 0 ms = mergestate(repo) - ms.reset(wctx.parents()[0].node()) + ms.reset(wctx.p1().node()) moves = [] action.sort(key=actionkey) substate = wctx.substate # prime @@ -286,7 +286,7 @@ fco = mctx[f2] if mctx == actx: # backwards, use working dir parent as ancestor if fcl.parents(): - fca = fcl.parents()[0] + fca = fcl.p1() else: fca = repo.filectx(f, fileid=nullrev) else:
--- a/mercurial/patch.py Mon Apr 04 16:21:57 2011 -0500 +++ b/mercurial/patch.py Mon Apr 04 16:21:59 2011 -0500 @@ -1324,7 +1324,7 @@ opts = mdiff.defaultopts if not node1 and not node2: - node1 = repo.dirstate.parents()[0] + node1 = repo.dirstate.p1() def lrugetfilectx(): cache = {}
--- a/mercurial/revset.py Mon Apr 04 16:21:57 2011 -0500 +++ b/mercurial/revset.py Mon Apr 04 16:21:59 2011 -0500 @@ -207,7 +207,7 @@ First parent of changesets in set, or the working directory. """ if x is None: - p = repo[x].parents()[0].rev() + p = repo[x].p1().rev() return [r for r in subset if r == p] ps = set()
--- a/mercurial/templatekw.py Mon Apr 04 16:21:57 2011 -0500 +++ b/mercurial/templatekw.py Mon Apr 04 16:21:59 2011 -0500 @@ -73,8 +73,7 @@ def getfiles(repo, ctx, revcache): if 'files' not in revcache: - revcache['files'] = repo.status(ctx.parents()[0].node(), - ctx.node())[:3] + revcache['files'] = repo.status(ctx.p1().node(), ctx.node())[:3] return revcache['files'] def getlatesttags(repo, ctx, cache):