##// END OF EJS Templates
misc: replace .parents()[0] with p1()
Matt Mackall -
r13878:a8d13ee0 default
parent child Browse files
Show More
@@ -13,7 +13,7 b' def diffstat(ui, repo, **kwargs):'
13 if kwargs.get('parent2'):
13 if kwargs.get('parent2'):
14 return
14 return
15 node = kwargs['node']
15 node = kwargs['node']
16 first = repo[node].parents()[0].node()
16 first = repo[node].p1().node()
17 if 'url' in kwargs:
17 if 'url' in kwargs:
18 last = repo['tip'].node()
18 last = repo['tip'].node()
19 else:
19 else:
@@ -126,7 +126,7 b' def dodiff(ui, repo, diffcmd, diffopts, '
126 else:
126 else:
127 node1a, node2 = cmdutil.revpair(repo, revs)
127 node1a, node2 = cmdutil.revpair(repo, revs)
128 if not revs:
128 if not revs:
129 node1b = repo.dirstate.parents()[1]
129 node1b = repo.dirstate.p2()
130 else:
130 else:
131 node1b = nullid
131 node1b = nullid
132
132
@@ -75,7 +75,7 b' class ciamsg(object):'
75
75
76 def fileelems(self):
76 def fileelems(self):
77 n = self.ctx.node()
77 n = self.ctx.node()
78 f = self.cia.repo.status(self.ctx.parents()[0].node(), n)
78 f = self.cia.repo.status(self.ctx.p1().node(), n)
79 url = self.url or ''
79 url = self.url or ''
80 elems = []
80 elems = []
81 for path in f[0]:
81 for path in f[0]:
@@ -899,7 +899,7 b' class queue(object):'
899 else:
899 else:
900 p.write("# HG changeset patch\n")
900 p.write("# HG changeset patch\n")
901 p.write("# Parent "
901 p.write("# Parent "
902 + hex(repo[None].parents()[0].node()) + "\n")
902 + hex(repo[None].p1().node()) + "\n")
903 if user:
903 if user:
904 p.write("# User " + user + "\n")
904 p.write("# User " + user + "\n")
905 if date:
905 if date:
@@ -1054,7 +1054,7 b' class queue(object):'
1054 heads += ls
1054 heads += ls
1055 if not heads:
1055 if not heads:
1056 heads = [nullid]
1056 heads = [nullid]
1057 if repo.dirstate.parents()[0] not in heads and not exact:
1057 if repo.dirstate.p1() not in heads and not exact:
1058 self.ui.status(_("(working directory not at a head)\n"))
1058 self.ui.status(_("(working directory not at a head)\n"))
1059
1059
1060 if not self.series:
1060 if not self.series:
@@ -1148,7 +1148,7 b' class queue(object):'
1148 ret = self.apply(repo, s, list, all_files=all_files)
1148 ret = self.apply(repo, s, list, all_files=all_files)
1149 except:
1149 except:
1150 self.ui.warn(_('cleaning up working directory...'))
1150 self.ui.warn(_('cleaning up working directory...'))
1151 node = repo.dirstate.parents()[0]
1151 node = repo.dirstate.p1()
1152 hg.revert(repo, node, None)
1152 hg.revert(repo, node, None)
1153 # only remove unknown files that we know we touched or
1153 # only remove unknown files that we know we touched or
1154 # created while patching
1154 # created while patching
@@ -249,7 +249,7 b' class notifier(object):'
249 def diff(self, ctx, ref=None):
249 def diff(self, ctx, ref=None):
250
250
251 maxdiff = int(self.ui.config('notify', 'maxdiff', 300))
251 maxdiff = int(self.ui.config('notify', 'maxdiff', 300))
252 prev = ctx.parents()[0].node()
252 prev = ctx.p1().node()
253 ref = ref and ref.node() or ctx.node()
253 ref = ref and ref.node() or ctx.node()
254 chunks = patch.diff(self.repo, prev, ref, opts=patch.diffopts(self.ui))
254 chunks = patch.diff(self.repo, prev, ref, opts=patch.diffopts(self.ui))
255 difflines = ''.join(chunks).splitlines()
255 difflines = ''.join(chunks).splitlines()
@@ -300,7 +300,7 b' def rebasenode(repo, rev, p1, p2, state)'
300 repo.ui.debug(" merge against %d:%s\n" % (repo[rev].rev(), repo[rev]))
300 repo.ui.debug(" merge against %d:%s\n" % (repo[rev].rev(), repo[rev]))
301 base = None
301 base = None
302 if repo[rev].rev() != repo[min(state)].rev():
302 if repo[rev].rev() != repo[min(state)].rev():
303 base = repo[rev].parents()[0].node()
303 base = repo[rev].p1().node()
304 return merge.update(repo, rev, True, True, False, base)
304 return merge.update(repo, rev, True, True, False, base)
305
305
306 def defineparents(repo, rev, target, state, targetancestors):
306 def defineparents(repo, rev, target, state, targetancestors):
@@ -469,7 +469,7 b' def dorecord(ui, repo, commitfunc, *pats'
469
469
470 # 3a. apply filtered patch to clean repo (clean)
470 # 3a. apply filtered patch to clean repo (clean)
471 if backups:
471 if backups:
472 hg.revert(repo, repo.dirstate.parents()[0],
472 hg.revert(repo, repo.dirstate.p1(),
473 lambda key: key in backups)
473 lambda key: key in backups)
474
474
475 # 3b. (apply)
475 # 3b. (apply)
@@ -237,7 +237,7 b' class transplanter(object):'
237 seriespath = os.path.join(self.path, 'series')
237 seriespath = os.path.join(self.path, 'series')
238 if os.path.exists(seriespath):
238 if os.path.exists(seriespath):
239 os.unlink(seriespath)
239 os.unlink(seriespath)
240 p1 = repo.dirstate.parents()[0]
240 p1 = repo.dirstate.p1()
241 p2 = node
241 p2 = node
242 self.log(user, date, message, p1, p2, merge=merge)
242 self.log(user, date, message, p1, p2, merge=merge)
243 self.ui.write(str(inst) + '\n')
243 self.ui.write(str(inst) + '\n')
@@ -72,7 +72,7 b' def findrepo(p):'
72 return p
72 return p
73
73
74 def bail_if_changed(repo):
74 def bail_if_changed(repo):
75 if repo.dirstate.parents()[1] != nullid:
75 if repo.dirstate.p2() != nullid:
76 raise util.Abort(_('outstanding uncommitted merge'))
76 raise util.Abort(_('outstanding uncommitted merge'))
77 modified, added, removed, deleted = repo.status()[:4]
77 modified, added, removed, deleted = repo.status()[:4]
78 if modified or added or removed or deleted:
78 if modified or added or removed or deleted:
@@ -122,12 +122,12 b" def revsingle(repo, revspec, default='.'"
122
122
123 def revpair(repo, revs):
123 def revpair(repo, revs):
124 if not revs:
124 if not revs:
125 return repo.dirstate.parents()[0], None
125 return repo.dirstate.p1(), None
126
126
127 l = revrange(repo, revs)
127 l = revrange(repo, revs)
128
128
129 if len(l) == 0:
129 if len(l) == 0:
130 return repo.dirstate.parents()[0], None
130 return repo.dirstate.p1(), None
131
131
132 if len(l) == 1:
132 if len(l) == 1:
133 return repo.lookup(l[0]), None
133 return repo.lookup(l[0]), None
@@ -596,7 +596,7 b' def branch(ui, repo, label=None, **opts)'
596 """
596 """
597
597
598 if opts.get('clean'):
598 if opts.get('clean'):
599 label = repo[None].parents()[0].branch()
599 label = repo[None].p1().branch()
600 repo.dirstate.setbranch(label)
600 repo.dirstate.setbranch(label)
601 ui.status(_('reset working directory to branch %s\n') % label)
601 ui.status(_('reset working directory to branch %s\n') % label)
602 elif label:
602 elif label:
@@ -1678,7 +1678,7 b' def diff(ui, repo, *pats, **opts):'
1678 raise util.Abort(msg)
1678 raise util.Abort(msg)
1679 elif change:
1679 elif change:
1680 node2 = cmdutil.revsingle(repo, change, None).node()
1680 node2 = cmdutil.revsingle(repo, change, None).node()
1681 node1 = repo[node2].parents()[0].node()
1681 node1 = repo[node2].p1().node()
1682 else:
1682 else:
1683 node1, node2 = cmdutil.revpair(repo, revs)
1683 node1, node2 = cmdutil.revpair(repo, revs)
1684
1684
@@ -1905,7 +1905,7 b' def grep(ui, repo, pattern, *pats, **opt'
1905
1905
1906 def prep(ctx, fns):
1906 def prep(ctx, fns):
1907 rev = ctx.rev()
1907 rev = ctx.rev()
1908 pctx = ctx.parents()[0]
1908 pctx = ctx.p1()
1909 parent = pctx.rev()
1909 parent = pctx.rev()
1910 matches.setdefault(rev, {})
1910 matches.setdefault(rev, {})
1911 matches.setdefault(parent, {})
1911 matches.setdefault(parent, {})
@@ -1940,7 +1940,7 b' def grep(ui, repo, pattern, *pats, **opt'
1940
1940
1941 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
1941 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
1942 rev = ctx.rev()
1942 rev = ctx.rev()
1943 parent = ctx.parents()[0].rev()
1943 parent = ctx.p1().rev()
1944 for fn in sorted(revfiles.get(rev, [])):
1944 for fn in sorted(revfiles.get(rev, [])):
1945 states = matches[rev][fn]
1945 states = matches[rev][fn]
1946 copy = copies.get(rev, {}).get(fn)
1946 copy = copies.get(rev, {}).get(fn)
@@ -2840,7 +2840,7 b' def merge(ui, repo, node=None, **opts):'
2840 '(run \'hg heads .\' to see heads)')
2840 '(run \'hg heads .\' to see heads)')
2841 % (branch, len(bheads)))
2841 % (branch, len(bheads)))
2842
2842
2843 parent = repo.dirstate.parents()[0]
2843 parent = repo.dirstate.p1()
2844 if len(bheads) == 1:
2844 if len(bheads) == 1:
2845 if len(repo.heads()) > 1:
2845 if len(repo.heads()) > 1:
2846 raise util.Abort(_(
2846 raise util.Abort(_(
@@ -3751,7 +3751,7 b' def status(ui, repo, *pats, **opts):'
3751 raise util.Abort(msg)
3751 raise util.Abort(msg)
3752 elif change:
3752 elif change:
3753 node2 = repo.lookup(change)
3753 node2 = repo.lookup(change)
3754 node1 = repo[node2].parents()[0].node()
3754 node1 = repo[node2].p1().node()
3755 else:
3755 else:
3756 node1, node2 = cmdutil.revpair(repo, revs)
3756 node1, node2 = cmdutil.revpair(repo, revs)
3757
3757
@@ -93,7 +93,7 b' def copies(repo, c1, c2, ca, checkdirs=F'
93 return {}, {}
93 return {}, {}
94
94
95 # avoid silly behavior for parent -> working dir
95 # avoid silly behavior for parent -> working dir
96 if c2.node() is None and c1.node() == repo.dirstate.parents()[0]:
96 if c2.node() is None and c1.node() == repo.dirstate.p1():
97 return repo.dirstate.copies(), {}
97 return repo.dirstate.copies(), {}
98
98
99 limit = _findlimit(repo, c1.rev(), c2.rev())
99 limit = _findlimit(repo, c1.rev(), c2.rev())
@@ -522,7 +522,7 b' class localrepository(repo.repository):'
522 if isinstance(key, int):
522 if isinstance(key, int):
523 return self.changelog.node(key)
523 return self.changelog.node(key)
524 elif key == '.':
524 elif key == '.':
525 return self.dirstate.parents()[0]
525 return self.dirstate.p1()
526 elif key == 'null':
526 elif key == 'null':
527 return nullid
527 return nullid
528 elif key == 'tip':
528 elif key == 'tip':
@@ -268,7 +268,7 b' def applyupdates(repo, action, wctx, mct'
268
268
269 updated, merged, removed, unresolved = 0, 0, 0, 0
269 updated, merged, removed, unresolved = 0, 0, 0, 0
270 ms = mergestate(repo)
270 ms = mergestate(repo)
271 ms.reset(wctx.parents()[0].node())
271 ms.reset(wctx.p1().node())
272 moves = []
272 moves = []
273 action.sort(key=actionkey)
273 action.sort(key=actionkey)
274 substate = wctx.substate # prime
274 substate = wctx.substate # prime
@@ -286,7 +286,7 b' def applyupdates(repo, action, wctx, mct'
286 fco = mctx[f2]
286 fco = mctx[f2]
287 if mctx == actx: # backwards, use working dir parent as ancestor
287 if mctx == actx: # backwards, use working dir parent as ancestor
288 if fcl.parents():
288 if fcl.parents():
289 fca = fcl.parents()[0]
289 fca = fcl.p1()
290 else:
290 else:
291 fca = repo.filectx(f, fileid=nullrev)
291 fca = repo.filectx(f, fileid=nullrev)
292 else:
292 else:
@@ -1324,7 +1324,7 b' def diff(repo, node1=None, node2=None, m'
1324 opts = mdiff.defaultopts
1324 opts = mdiff.defaultopts
1325
1325
1326 if not node1 and not node2:
1326 if not node1 and not node2:
1327 node1 = repo.dirstate.parents()[0]
1327 node1 = repo.dirstate.p1()
1328
1328
1329 def lrugetfilectx():
1329 def lrugetfilectx():
1330 cache = {}
1330 cache = {}
@@ -207,7 +207,7 b' def p1(repo, subset, x):'
207 First parent of changesets in set, or the working directory.
207 First parent of changesets in set, or the working directory.
208 """
208 """
209 if x is None:
209 if x is None:
210 p = repo[x].parents()[0].rev()
210 p = repo[x].p1().rev()
211 return [r for r in subset if r == p]
211 return [r for r in subset if r == p]
212
212
213 ps = set()
213 ps = set()
@@ -73,8 +73,7 b' def showlist(name, values, plural=None, '
73
73
74 def getfiles(repo, ctx, revcache):
74 def getfiles(repo, ctx, revcache):
75 if 'files' not in revcache:
75 if 'files' not in revcache:
76 revcache['files'] = repo.status(ctx.parents()[0].node(),
76 revcache['files'] = repo.status(ctx.p1().node(), ctx.node())[:3]
77 ctx.node())[:3]
78 return revcache['files']
77 return revcache['files']
79
78
80 def getlatesttags(repo, ctx, cache):
79 def getlatesttags(repo, ctx, cache):
General Comments 0
You need to be logged in to leave comments. Login now