##// END OF EJS Templates
use repo[changeid] to get a changectx
Matt Mackall -
r6747:f6c00b17 default
parent child Browse files
Show More
@@ -91,7 +91,7 b' class checker(object):'
91
91
92 def check(self, node):
92 def check(self, node):
93 '''return if access allowed, raise exception if not.'''
93 '''return if access allowed, raise exception if not.'''
94 files = self.repo.changectx(node).files()
94 files = self.repo[node].files()
95 if self.deniable:
95 if self.deniable:
96 for f in files:
96 for f in files:
97 if self.deny(f):
97 if self.deny(f):
@@ -300,7 +300,7 b' def hook(ui, repo, hooktype, node=None, '
300 hooktype)
300 hooktype)
301 try:
301 try:
302 bz = bugzilla(ui, repo)
302 bz = bugzilla(ui, repo)
303 ctx = repo.changectx(node)
303 ctx = repo[node]
304 ids = bz.find_bug_ids(ctx)
304 ids = bz.find_bug_ids(ctx)
305 if ids:
305 if ids:
306 for id in ids:
306 for id in ids:
@@ -25,7 +25,7 b' def children(ui, repo, file_=None, **opt'
25 if file_:
25 if file_:
26 ctx = repo.filectx(file_, changeid=rev)
26 ctx = repo.filectx(file_, changeid=rev)
27 else:
27 else:
28 ctx = repo.changectx(rev)
28 ctx = repo[rev]
29
29
30 displayer = cmdutil.show_changeset(ui, repo, opts)
30 displayer = cmdutil.show_changeset(ui, repo, opts)
31 for node in [cp.node() for cp in ctx.children()]:
31 for node in [cp.node() for cp in ctx.children()]:
@@ -157,7 +157,7 b' class mercurial_sink(converter_sink):'
157
157
158 def puttags(self, tags):
158 def puttags(self, tags):
159 try:
159 try:
160 parentctx = self.repo.changectx(self.tagsbranch)
160 parentctx = self.repo[self.tagsbranch]
161 tagparent = parentctx.node()
161 tagparent = parentctx.node()
162 except RepoError, inst:
162 except RepoError, inst:
163 parentctx = None
163 parentctx = None
@@ -212,19 +212,19 b' class mercurial_source(converter_source)'
212
212
213 def changectx(self, rev):
213 def changectx(self, rev):
214 if self.lastrev != rev:
214 if self.lastrev != rev:
215 self.lastctx = self.repo.changectx(rev)
215 self.lastctx = self.repo[rev]
216 self.lastrev = rev
216 self.lastrev = rev
217 return self.lastctx
217 return self.lastctx
218
218
219 def getheads(self):
219 def getheads(self):
220 if self.rev:
220 if self.rev:
221 return [hex(self.repo.changectx(self.rev).node())]
221 return [hex(self.repo[self.rev].node())]
222 else:
222 else:
223 return [hex(node) for node in self.repo.heads()]
223 return [hex(node) for node in self.repo.heads()]
224
224
225 def getfile(self, name, rev):
225 def getfile(self, name, rev):
226 try:
226 try:
227 return self.changectx(rev).filectx(name).data()
227 return self.changectx(rev)[name].data()
228 except revlog.LookupError, err:
228 except revlog.LookupError, err:
229 raise IOError(err)
229 raise IOError(err)
230
230
@@ -52,7 +52,6 b' import os, shlex, shutil, tempfile'
52
52
53 def snapshot_node(ui, repo, files, node, tmproot):
53 def snapshot_node(ui, repo, files, node, tmproot):
54 '''snapshot files as of some revision'''
54 '''snapshot files as of some revision'''
55 mf = repo.changectx(node).manifest()
56 dirname = os.path.basename(repo.root)
55 dirname = os.path.basename(repo.root)
57 if dirname == "":
56 if dirname == "":
58 dirname = "root"
57 dirname = "root"
@@ -61,17 +60,18 b' def snapshot_node(ui, repo, files, node,'
61 os.mkdir(base)
60 os.mkdir(base)
62 ui.note(_('making snapshot of %d files from rev %s\n') %
61 ui.note(_('making snapshot of %d files from rev %s\n') %
63 (len(files), short(node)))
62 (len(files), short(node)))
63 ctx = repo[node]
64 for fn in files:
64 for fn in files:
65 if not fn in mf:
65 wfn = util.pconvert(fn)
66 if not wfn in ctx:
66 # skipping new file after a merge ?
67 # skipping new file after a merge ?
67 continue
68 continue
68 wfn = util.pconvert(fn)
69 ui.note(' %s\n' % wfn)
69 ui.note(' %s\n' % wfn)
70 dest = os.path.join(base, wfn)
70 dest = os.path.join(base, wfn)
71 destdir = os.path.dirname(dest)
71 destdir = os.path.dirname(dest)
72 if not os.path.isdir(destdir):
72 if not os.path.isdir(destdir):
73 os.makedirs(destdir)
73 os.makedirs(destdir)
74 data = repo.wwritedata(wfn, repo.file(wfn).read(mf[wfn]))
74 data = repo.wwritedata(wfn, ctx[wfn].data())
75 open(dest, 'wb').write(data)
75 open(dest, 'wb').write(data)
76 return dirname
76 return dirname
77
77
@@ -52,8 +52,8 b' def difftree(ui, repo, node1=None, node2'
52 """diff trees from two commits"""
52 """diff trees from two commits"""
53 def __difftree(repo, node1, node2, files=[]):
53 def __difftree(repo, node1, node2, files=[]):
54 assert node2 is not None
54 assert node2 is not None
55 mmap = repo.changectx(node1).manifest()
55 mmap = repo[node1].manifest()
56 mmap2 = repo.changectx(node2).manifest()
56 mmap2 = repo[node2].manifest()
57 m = cmdutil.match(repo, files)
57 m = cmdutil.match(repo, files)
58 status = repo.status(node1, node2, match=m)[:5]
58 status = repo.status(node1, node2, match=m)[:5]
59 modified, added, removed, deleted, unknown = status
59 modified, added, removed, deleted, unknown = status
@@ -103,7 +103,7 b' def difftree(ui, repo, node1=None, node2'
103 def catcommit(ui, repo, n, prefix, ctx=None):
103 def catcommit(ui, repo, n, prefix, ctx=None):
104 nlprefix = '\n' + prefix;
104 nlprefix = '\n' + prefix;
105 if ctx is None:
105 if ctx is None:
106 ctx = repo.changectx(n)
106 ctx = repo[n]
107 (p1, p2) = ctx.parents()
107 (p1, p2) = ctx.parents()
108 ui.write("tree %s\n" % short(ctx.changeset()[0])) # use ctx.node() instead ??
108 ui.write("tree %s\n" % short(ctx.changeset()[0])) # use ctx.node() instead ??
109 if p1: ui.write("parent %s\n" % short(p1.node()))
109 if p1: ui.write("parent %s\n" % short(p1.node()))
@@ -191,7 +191,7 b' def revtree(ui, args, repo, full="tree",'
191 l[chunk - x:] = [0] * (chunk - x)
191 l[chunk - x:] = [0] * (chunk - x)
192 break
192 break
193 if full != None:
193 if full != None:
194 l[x] = repo.changectx(i + x)
194 l[x] = repo[i + x]
195 l[x].changeset() # force reading
195 l[x].changeset() # force reading
196 else:
196 else:
197 l[x] = 1
197 l[x] = 1
@@ -172,12 +172,12 b' class kwtemplater(object):'
172 def overwrite(self, node, expand, files):
172 def overwrite(self, node, expand, files):
173 '''Overwrites selected files expanding/shrinking keywords.'''
173 '''Overwrites selected files expanding/shrinking keywords.'''
174 if node is not None: # commit
174 if node is not None: # commit
175 ctx = self.repo.changectx(node)
175 ctx = self.repo[node]
176 mf = ctx.manifest()
176 mf = ctx.manifest()
177 files = [f for f in ctx.files() if f in mf]
177 files = [f for f in ctx.files() if f in mf]
178 notify = self.ui.debug
178 notify = self.ui.debug
179 else: # kwexpand/kwshrink
179 else: # kwexpand/kwshrink
180 ctx = self.repo.changectx('.')
180 ctx = self.repo['.']
181 mf = ctx.manifest()
181 mf = ctx.manifest()
182 notify = self.ui.note
182 notify = self.ui.note
183 candidates = [f for f in files if self.iskwfile(f, mf.linkf)]
183 candidates = [f for f in files if self.iskwfile(f, mf.linkf)]
@@ -386,7 +386,7 b' def files(ui, repo, *pats, **opts):'
386 if opts.get('untracked'):
386 if opts.get('untracked'):
387 files += unknown
387 files += unknown
388 files.sort()
388 files.sort()
389 wctx = repo.changectx(None)
389 wctx = repo[None]
390 islink = lambda p: 'l' in wctx.flags(p)
390 islink = lambda p: 'l' in wctx.flags(p)
391 kwfiles = [f for f in files if kwt.iskwfile(f, islink)]
391 kwfiles = [f for f in files if kwt.iskwfile(f, islink)]
392 cwd = pats and repo.getcwd() or ''
392 cwd = pats and repo.getcwd() or ''
@@ -513,7 +513,7 b' def reposetup(ui, repo):'
513 comparing against working dir.'''
513 comparing against working dir.'''
514 if node2 is not None:
514 if node2 is not None:
515 kwt.matcher = util.never
515 kwt.matcher = util.never
516 elif node1 is not None and node1 != repo.changectx('.').node():
516 elif node1 is not None and node1 != repo['.'].node():
517 kwt.restrict = True
517 kwt.restrict = True
518 patch_diff(repo, node1, node2, match, fp, changes, opts)
518 patch_diff(repo, node1, node2, match, fp, changes, opts)
519
519
@@ -342,7 +342,7 b' class queue:'
342 hg.clean(repo, head)
342 hg.clean(repo, head)
343 self.strip(repo, n, update=False, backup='strip')
343 self.strip(repo, n, update=False, backup='strip')
344
344
345 ctx = repo.changectx(rev)
345 ctx = repo[rev]
346 ret = hg.merge(repo, rev)
346 ret = hg.merge(repo, rev)
347 if ret:
347 if ret:
348 raise util.Abort(_("update returned %d") % ret)
348 raise util.Abort(_("update returned %d") % ret)
@@ -99,7 +99,7 b' def macencode(s, cmd):'
99 def forbidnewline(ui, repo, hooktype, node, newline, **kwargs):
99 def forbidnewline(ui, repo, hooktype, node, newline, **kwargs):
100 halt = False
100 halt = False
101 for rev in xrange(repo.changelog.rev(bin(node)), repo.changelog.count()):
101 for rev in xrange(repo.changelog.rev(bin(node)), repo.changelog.count()):
102 c = repo.changectx(rev)
102 c = repo[rev]
103 for f in c.files():
103 for f in c.files():
104 if f not in c:
104 if f not in c:
105 continue
105 continue
@@ -208,7 +208,7 b' def archive(repo, dest, node, kind, deco'
208 data = repo.wwritedata(name, data)
208 data = repo.wwritedata(name, data)
209 archiver.addfile(name, mode, islink, data)
209 archiver.addfile(name, mode, islink, data)
210
210
211 ctx = repo.changectx(node)
211 ctx = repo[node]
212 if kind not in archivers:
212 if kind not in archivers:
213 raise util.Abort(_("unknown archive type '%s'" % kind))
213 raise util.Abort(_("unknown archive type '%s'" % kind))
214 archiver = archivers[kind](dest, prefix, mtime or ctx.date()[0])
214 archiver = archivers[kind](dest, prefix, mtime or ctx.date()[0])
@@ -245,7 +245,7 b' def findrenames(repo, added=None, remove'
245 '''find renamed files -- yields (before, after, score) tuples'''
245 '''find renamed files -- yields (before, after, score) tuples'''
246 if added is None or removed is None:
246 if added is None or removed is None:
247 added, removed = repo.status()[1:3]
247 added, removed = repo.status()[1:3]
248 ctx = repo.changectx('.')
248 ctx = repo['.']
249 for a in added:
249 for a in added:
250 aa = repo.wread(a)
250 aa = repo.wread(a)
251 bestname, bestscore = None, threshold
251 bestname, bestscore = None, threshold
@@ -930,7 +930,7 b' def show_changeset(ui, repo, opts, buffe'
930 def finddate(ui, repo, date):
930 def finddate(ui, repo, date):
931 """Find the tipmost changeset that matches the given date spec"""
931 """Find the tipmost changeset that matches the given date spec"""
932 df = util.matchdate(date)
932 df = util.matchdate(date)
933 get = util.cachefunc(lambda r: repo.changectx(r).changeset())
933 get = util.cachefunc(lambda r: repo[r].changeset())
934 changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None})
934 changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None})
935 results = {}
935 results = {}
936 for st, rev, fns in changeiter:
936 for st, rev, fns in changeiter:
@@ -992,7 +992,7 b' def walkchangerevs(ui, repo, pats, chang'
992 return [], m
992 return [], m
993
993
994 if follow:
994 if follow:
995 defrange = '%s:0' % repo.changectx('.').rev()
995 defrange = '%s:0' % repo['.'].rev()
996 else:
996 else:
997 defrange = '-1:0'
997 defrange = '-1:0'
998 revs = revrange(repo, opts['rev'] or [defrange])
998 revs = revrange(repo, opts['rev'] or [defrange])
@@ -107,7 +107,7 b' def annotate(ui, repo, *pats, **opts):'
107 lastfunc = funcmap[-1]
107 lastfunc = funcmap[-1]
108 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
108 funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
109
109
110 ctx = repo.changectx(opts['rev'])
110 ctx = repo[opts['rev']]
111
111
112 m = cmdutil.match(repo, pats, opts)
112 m = cmdutil.match(repo, pats, opts)
113 for abs in repo.walk(m, ctx.node()):
113 for abs in repo.walk(m, ctx.node()):
@@ -154,7 +154,7 b' def archive(ui, repo, dest, **opts):'
154 The default is the basename of the archive, with suffixes removed.
154 The default is the basename of the archive, with suffixes removed.
155 '''
155 '''
156
156
157 ctx = repo.changectx(opts['rev'])
157 ctx = repo[opts['rev']]
158 if not ctx:
158 if not ctx:
159 raise util.Abort(_('repository has no revisions'))
159 raise util.Abort(_('repository has no revisions'))
160 node = ctx.node()
160 node = ctx.node()
@@ -359,7 +359,7 b' def branch(ui, repo, label=None, **opts)'
359
359
360 if label:
360 if label:
361 if not opts.get('force') and label in repo.branchtags():
361 if not opts.get('force') and label in repo.branchtags():
362 if label not in [p.branch() for p in repo.changectx(None).parents()]:
362 if label not in [p.branch() for p in repo.parents()]:
363 raise util.Abort(_('a branch of the same name already exists'
363 raise util.Abort(_('a branch of the same name already exists'
364 ' (use --force to override)'))
364 ' (use --force to override)'))
365 repo.dirstate.setbranch(util.fromlocal(label))
365 repo.dirstate.setbranch(util.fromlocal(label))
@@ -378,7 +378,7 b' def branches(ui, repo, active=False):'
378 Use the command 'hg update' to switch to an existing branch.
378 Use the command 'hg update' to switch to an existing branch.
379 """
379 """
380 hexfunc = ui.debugflag and hex or short
380 hexfunc = ui.debugflag and hex or short
381 activebranches = [util.tolocal(repo.changectx(n).branch())
381 activebranches = [util.tolocal(repo[n].branch())
382 for n in repo.heads()]
382 for n in repo.heads()]
383 branches = [(tag in activebranches, repo.changelog.rev(node), tag)
383 branches = [(tag in activebranches, repo.changelog.rev(node), tag)
384 for tag, node in repo.branchtags().items()]
384 for tag, node in repo.branchtags().items()]
@@ -483,7 +483,7 b' def cat(ui, repo, file1, *pats, **opts):'
483 %d dirname of file being printed, or '.' if in repo root
483 %d dirname of file being printed, or '.' if in repo root
484 %p root-relative path name of file being printed
484 %p root-relative path name of file being printed
485 """
485 """
486 ctx = repo.changectx(opts['rev'])
486 ctx = repo[opts['rev']]
487 err = 1
487 err = 1
488 m = cmdutil.match(repo, (file1,) + pats, opts)
488 m = cmdutil.match(repo, (file1,) + pats, opts)
489 for abs in repo.walk(m, ctx.node()):
489 for abs in repo.walk(m, ctx.node()):
@@ -647,23 +647,20 b' def debugfsinfo(ui, path = "."):'
647 and 'yes' or 'no'))
647 and 'yes' or 'no'))
648 os.unlink('.debugfsinfo')
648 os.unlink('.debugfsinfo')
649
649
650 def debugrebuildstate(ui, repo, rev=""):
650 def debugrebuildstate(ui, repo, rev="tip"):
651 """rebuild the dirstate as it would look like for the given revision"""
651 """rebuild the dirstate as it would look like for the given revision"""
652 if rev == "":
652 ctx = repo[rev]
653 rev = repo.changelog.tip()
654 ctx = repo.changectx(rev)
655 files = ctx.manifest()
656 wlock = repo.wlock()
653 wlock = repo.wlock()
657 try:
654 try:
658 repo.dirstate.rebuild(rev, files)
655 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
659 finally:
656 finally:
660 del wlock
657 del wlock
661
658
662 def debugcheckstate(ui, repo):
659 def debugcheckstate(ui, repo):
663 """validate the correctness of the current dirstate"""
660 """validate the correctness of the current dirstate"""
664 parent1, parent2 = repo.dirstate.parents()
661 parent1, parent2 = repo.dirstate.parents()
665 m1 = repo.changectx(parent1).manifest()
662 m1 = repo[parent1].manifest()
666 m2 = repo.changectx(parent2).manifest()
663 m2 = repo[parent2].manifest()
667 errors = 0
664 errors = 0
668 for f in repo.dirstate:
665 for f in repo.dirstate:
669 state = repo.dirstate[f]
666 state = repo.dirstate[f]
@@ -913,7 +910,7 b' def debuginstall(ui):'
913 def debugrename(ui, repo, file1, *pats, **opts):
910 def debugrename(ui, repo, file1, *pats, **opts):
914 """dump rename information"""
911 """dump rename information"""
915
912
916 ctx = repo.changectx(opts.get('rev', 'tip'))
913 ctx = repo[opts.get('rev', 'tip')]
917 m = cmdutil.match(repo, (file1,) + pats, opts)
914 m = cmdutil.match(repo, (file1,) + pats, opts)
918 for abs in repo.walk(m, ctx.node()):
915 for abs in repo.walk(m, ctx.node()):
919 fctx = ctx.filectx(abs)
916 fctx = ctx.filectx(abs)
@@ -1122,7 +1119,7 b' def grep(ui, repo, pattern, *pats, **opt'
1122
1119
1123 fstate = {}
1120 fstate = {}
1124 skip = {}
1121 skip = {}
1125 get = util.cachefunc(lambda r: repo.changectx(r).changeset())
1122 get = util.cachefunc(lambda r: repo[r].changeset())
1126 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1123 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1127 found = False
1124 found = False
1128 follow = opts.get('follow')
1125 follow = opts.get('follow')
@@ -1130,7 +1127,7 b' def grep(ui, repo, pattern, *pats, **opt'
1130 if st == 'window':
1127 if st == 'window':
1131 matches.clear()
1128 matches.clear()
1132 elif st == 'add':
1129 elif st == 'add':
1133 ctx = repo.changectx(rev)
1130 ctx = repo[rev]
1134 matches[rev] = {}
1131 matches[rev] = {}
1135 for fn in fns:
1132 for fn in fns:
1136 if fn in skip:
1133 if fn in skip:
@@ -1202,7 +1199,7 b' def heads(ui, repo, *branchrevs, **opts)'
1202 heads = []
1199 heads = []
1203 visitedset = util.set()
1200 visitedset = util.set()
1204 for branchrev in branchrevs:
1201 for branchrev in branchrevs:
1205 branch = repo.changectx(branchrev).branch()
1202 branch = repo[branchrev].branch()
1206 if branch in visitedset:
1203 if branch in visitedset:
1207 continue
1204 continue
1208 visitedset.add(branch)
1205 visitedset.add(branch)
@@ -1454,7 +1451,7 b' def identify(ui, repo, source=None,'
1454 "can't query remote revision number, branch, or tags")
1451 "can't query remote revision number, branch, or tags")
1455 output = [hexfunc(srepo.lookup(rev))]
1452 output = [hexfunc(srepo.lookup(rev))]
1456 elif not rev:
1453 elif not rev:
1457 ctx = repo.changectx(None)
1454 ctx = repo[None]
1458 parents = ctx.parents()
1455 parents = ctx.parents()
1459 changed = False
1456 changed = False
1460 if default or id or num:
1457 if default or id or num:
@@ -1466,7 +1463,7 b' def identify(ui, repo, source=None,'
1466 output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
1463 output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
1467 (changed) and "+" or ""))
1464 (changed) and "+" or ""))
1468 else:
1465 else:
1469 ctx = repo.changectx(rev)
1466 ctx = repo[rev]
1470 if default or id:
1467 if default or id:
1471 output = [hexfunc(ctx.node())]
1468 output = [hexfunc(ctx.node())]
1472 if num:
1469 if num:
@@ -1563,7 +1560,7 b' def import_(ui, repo, patch1, *patches, '
1563 message = None
1560 message = None
1564 ui.debug(_('message:\n%s\n') % message)
1561 ui.debug(_('message:\n%s\n') % message)
1565
1562
1566 wp = repo.changectx(None).parents()
1563 wp = repo.parents()
1567 if opts.get('exact'):
1564 if opts.get('exact'):
1568 if not nodeid or not p1:
1565 if not nodeid or not p1:
1569 raise util.Abort(_('not a mercurial patch'))
1566 raise util.Abort(_('not a mercurial patch'))
@@ -1756,7 +1753,7 b' def log(ui, repo, *pats, **opts):'
1756
1753
1757 """
1754 """
1758
1755
1759 get = util.cachefunc(lambda r: repo.changectx(r).changeset())
1756 get = util.cachefunc(lambda r: repo[r].changeset())
1760 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1757 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
1761
1758
1762 limit = cmdutil.loglimit(opts)
1759 limit = cmdutil.loglimit(opts)
@@ -1793,7 +1790,7 b' def log(ui, repo, *pats, **opts):'
1793 # filectx logic.
1790 # filectx logic.
1794
1791
1795 try:
1792 try:
1796 return repo.changectx(rev).filectx(fn).renamed()
1793 return repo[rev][fn].renamed()
1797 except revlog.LookupError:
1794 except revlog.LookupError:
1798 pass
1795 pass
1799 return None
1796 return None
@@ -1869,7 +1866,7 b' def manifest(ui, repo, node=None, rev=No'
1869 if not node:
1866 if not node:
1870 node = rev
1867 node = rev
1871
1868
1872 m = repo.changectx(node).manifest()
1869 m = repo[node].manifest()
1873 files = m.keys()
1870 files = m.keys()
1874 files.sort()
1871 files.sort()
1875
1872
@@ -1916,7 +1913,7 b' def merge(ui, repo, node=None, force=Non'
1916 "please merge with an explicit rev") %
1913 "please merge with an explicit rev") %
1917 branch)
1914 branch)
1918 msg = _('there is nothing to merge')
1915 msg = _('there is nothing to merge')
1919 if parent != repo.lookup(repo.changectx(None).branch()):
1916 if parent != repo.lookup(repo[None].branch()):
1920 msg = _('%s - use "hg update" instead') % msg
1917 msg = _('%s - use "hg update" instead') % msg
1921 raise util.Abort(msg)
1918 raise util.Abort(msg)
1922
1919
@@ -1973,9 +1970,9 b' def parents(ui, repo, file_=None, **opts'
1973 """
1970 """
1974 rev = opts.get('rev')
1971 rev = opts.get('rev')
1975 if rev:
1972 if rev:
1976 ctx = repo.changectx(rev)
1973 ctx = repo[rev]
1977 else:
1974 else:
1978 ctx = repo.changectx(None)
1975 ctx = repo[None]
1979
1976
1980 if file_:
1977 if file_:
1981 m = cmdutil.match(repo, (file_,), opts)
1978 m = cmdutil.match(repo, (file_,), opts)
@@ -2297,7 +2294,7 b' def resolve(ui, repo, *pats, **opts):'
2297 elif opts.get("unmark"):
2294 elif opts.get("unmark"):
2298 ms.mark(f, "u")
2295 ms.mark(f, "u")
2299 else:
2296 else:
2300 wctx = repo.changectx(None)
2297 wctx = repo[None]
2301 mctx = wctx.parents()[-1]
2298 mctx = wctx.parents()[-1]
2302 ms.resolve(f, wctx, mctx)
2299 ms.resolve(f, wctx, mctx)
2303
2300
@@ -2348,7 +2345,7 b' def revert(ui, repo, *pats, **opts):'
2348 if not opts['rev'] and p2 != nullid:
2345 if not opts['rev'] and p2 != nullid:
2349 raise util.Abort(_('uncommitted merge - please provide a '
2346 raise util.Abort(_('uncommitted merge - please provide a '
2350 'specific revision'))
2347 'specific revision'))
2351 ctx = repo.changectx(opts['rev'])
2348 ctx = repo[opts['rev']]
2352 node = ctx.node()
2349 node = ctx.node()
2353 mf = ctx.manifest()
2350 mf = ctx.manifest()
2354 if node == parent:
2351 if node == parent:
@@ -2466,7 +2463,7 b' def revert(ui, repo, *pats, **opts):'
2466 if pmf is None:
2463 if pmf is None:
2467 # only need parent manifest in this unlikely case,
2464 # only need parent manifest in this unlikely case,
2468 # so do not read by default
2465 # so do not read by default
2469 pmf = repo.changectx(parent).manifest()
2466 pmf = repo[parent].manifest()
2470 if abs in pmf:
2467 if abs in pmf:
2471 if mfentry:
2468 if mfentry:
2472 # if version of file is same in parent and target
2469 # if version of file is same in parent and target
@@ -2668,9 +2665,9 b' def status(ui, repo, *pats, **opts):'
2668 changestates = zip(states, 'MAR!?IC', stat)
2665 changestates = zip(states, 'MAR!?IC', stat)
2669
2666
2670 if (opts['all'] or opts['copies']) and not opts['no_status']:
2667 if (opts['all'] or opts['copies']) and not opts['no_status']:
2671 ctxn = repo.changectx(nullid)
2668 ctxn = repo[nullid]
2672 ctx1 = repo.changectx(node1)
2669 ctx1 = repo[node1]
2673 ctx2 = repo.changectx(node2)
2670 ctx2 = repo[node2]
2674 added = stat[1]
2671 added = stat[1]
2675 if node2 is None:
2672 if node2 is None:
2676 added = stat[0] + stat[1] # merged?
2673 added = stat[0] + stat[1] # merged?
@@ -2744,7 +2741,7 b' def tag(ui, repo, name1, *names, **opts)'
2744 if not rev_ and repo.dirstate.parents()[1] != nullid:
2741 if not rev_ and repo.dirstate.parents()[1] != nullid:
2745 raise util.Abort(_('uncommitted merge - please provide a '
2742 raise util.Abort(_('uncommitted merge - please provide a '
2746 'specific revision'))
2743 'specific revision'))
2747 r = repo.changectx(rev_).node()
2744 r = repo[rev_].node()
2748
2745
2749 if not message:
2746 if not message:
2750 message = (_('Added tag %s for changeset %s') %
2747 message = (_('Added tag %s for changeset %s') %
@@ -463,7 +463,7 b' class workingctx(changectx):'
463 self._user = self._repo.ui.username()
463 self._user = self._repo.ui.username()
464 if parents:
464 if parents:
465 p1, p2 = parents
465 p1, p2 = parents
466 self._parents = [self._repo.changectx(p) for p in (p1, p2)]
466 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
467 if changes:
467 if changes:
468 self._status = list(changes)
468 self._status = list(changes)
469
469
@@ -687,7 +687,7 b' class memctx(object):'
687 self._user = user or self._repo.ui.username()
687 self._user = user or self._repo.ui.username()
688 parents = [(p or nullid) for p in parents]
688 parents = [(p or nullid) for p in parents]
689 p1, p2 = parents
689 p1, p2 = parents
690 self._parents = [self._repo.changectx(p) for p in (p1, p2)]
690 self._parents = [changectx(self._repo, p) for p in (p1, p2)]
691 files = list(files)
691 files = list(files)
692 files.sort()
692 files.sort()
693 self._status = [files, [], [], [], []]
693 self._status = [files, [], [], [], []]
@@ -69,6 +69,6 b' def graph(repo, start_rev, stop_rev):'
69 edges.append((col, next.index(p), colors[p]))
69 edges.append((col, next.index(p), colors[p]))
70
70
71 # Yield and move on
71 # Yield and move on
72 yield (repo.changectx(curr_rev), (idx, color), edges)
72 yield (repo[curr_rev], (idx, color), edges)
73 revs = next
73 revs = next
74 curr_rev -= 1
74 curr_rev -= 1
@@ -331,8 +331,8 b' class hgweb(object):'
331 linenumber="% 8s" % lineno)
331 linenumber="% 8s" % lineno)
332
332
333 r = self.repo
333 r = self.repo
334 c1 = r.changectx(node1)
334 c1 = r[node1]
335 c2 = r.changectx(node2)
335 c2 = r[node2]
336 date1 = util.datestr(c1.date())
336 date1 = util.datestr(c1.date())
337 date2 = util.datestr(c2.date())
337 date2 = util.datestr(c2.date())
338
338
@@ -113,7 +113,7 b' def _search(web, tmpl, query):'
113 for i in xrange(cl.count() - 1, 0, -100):
113 for i in xrange(cl.count() - 1, 0, -100):
114 l = []
114 l = []
115 for j in xrange(max(0, i - 100), i + 1):
115 for j in xrange(max(0, i - 100), i + 1):
116 ctx = web.repo.changectx(j)
116 ctx = web.repo[j]
117 l.append(ctx)
117 l.append(ctx)
118 l.reverse()
118 l.reverse()
119 for e in l:
119 for e in l:
@@ -170,7 +170,7 b' def changelog(web, req, tmpl, shortlog ='
170 else:
170 else:
171 hi = web.repo.changelog.count() - 1
171 hi = web.repo.changelog.count() - 1
172 try:
172 try:
173 ctx = web.repo.changectx(hi)
173 ctx = web.repo[hi]
174 except RepoError:
174 except RepoError:
175 return _search(web, tmpl, hi) # XXX redirect to 404 page?
175 return _search(web, tmpl, hi) # XXX redirect to 404 page?
176
176
@@ -178,7 +178,7 b' def changelog(web, req, tmpl, shortlog ='
178 cl = web.repo.changelog
178 cl = web.repo.changelog
179 l = [] # build a list in forward order for efficiency
179 l = [] # build a list in forward order for efficiency
180 for i in xrange(start, end):
180 for i in xrange(start, end):
181 ctx = web.repo.changectx(i)
181 ctx = web.repo[i]
182 n = ctx.node()
182 n = ctx.node()
183 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
183 showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
184
184
@@ -299,7 +299,7 b' def manifest(web, req, tmpl):'
299 yield {"file": full,
299 yield {"file": full,
300 "parity": parity.next(),
300 "parity": parity.next(),
301 "basename": f,
301 "basename": f,
302 "date": fctx.changectx().date(),
302 "date": fctx.date(),
303 "size": fctx.size(),
303 "size": fctx.size(),
304 "permissions": mf.flags(full)}
304 "permissions": mf.flags(full)}
305
305
@@ -343,7 +343,7 b' def tags(web, req, tmpl):'
343 count = count + 1
343 count = count + 1
344 yield {"parity": parity.next(),
344 yield {"parity": parity.next(),
345 "tag": k,
345 "tag": k,
346 "date": web.repo.changectx(n).date(),
346 "date": web.repo[n].date(),
347 "node": hex(n)}
347 "node": hex(n)}
348
348
349 return tmpl("tags",
349 return tmpl("tags",
@@ -371,7 +371,7 b' def summary(web, req, tmpl):'
371 parity=parity.next(),
371 parity=parity.next(),
372 tag=k,
372 tag=k,
373 node=hex(n),
373 node=hex(n),
374 date=web.repo.changectx(n).date())
374 date=web.repo[n].date())
375
375
376 def branches(**map):
376 def branches(**map):
377 parity = paritygen(web.stripecount)
377 parity = paritygen(web.stripecount)
@@ -381,17 +381,16 b' def summary(web, req, tmpl):'
381 l.sort()
381 l.sort()
382
382
383 for r,n,t in l:
383 for r,n,t in l:
384 ctx = web.repo.changectx(n)
385 yield {'parity': parity.next(),
384 yield {'parity': parity.next(),
386 'branch': t,
385 'branch': t,
387 'node': hex(n),
386 'node': hex(n),
388 'date': ctx.date()}
387 'date': web.repo[n].date()}
389
388
390 def changelist(**map):
389 def changelist(**map):
391 parity = paritygen(web.stripecount, offset=start-end)
390 parity = paritygen(web.stripecount, offset=start-end)
392 l = [] # build a list in forward order for efficiency
391 l = [] # build a list in forward order for efficiency
393 for i in xrange(start, end):
392 for i in xrange(start, end):
394 ctx = web.repo.changectx(i)
393 ctx = web.repo[i]
395 n = ctx.node()
394 n = ctx.node()
396 hn = hex(n)
395 hn = hex(n)
397
396
@@ -120,11 +120,10 b' def changectx(repo, req):'
120 changeid = repo.changelog.count() - 1
120 changeid = repo.changelog.count() - 1
121
121
122 try:
122 try:
123 ctx = repo.changectx(changeid)
123 ctx = repo[changeid]
124 except RepoError:
124 except RepoError:
125 man = repo.manifest
125 man = repo.manifest
126 mn = man.lookup(changeid)
126 ctx = repo[man.linkrev(man.lookup(changeid))]
127 ctx = repo.changectx(man.linkrev(mn))
128
127
129 return ctx
128 return ctx
130
129
@@ -135,8 +134,7 b' def filectx(repo, req):'
135 else:
134 else:
136 changeid = req.form['filenode'][0]
135 changeid = req.form['filenode'][0]
137 try:
136 try:
138 ctx = repo.changectx(changeid)
137 fctx = repo[changeid][path]
139 fctx = ctx.filectx(path)
140 except RepoError:
138 except RepoError:
141 fctx = repo.filectx(path, fileid=changeid)
139 fctx = repo.filectx(path, fileid=changeid)
142
140
@@ -117,6 +117,11 b' class localrepository(repo.repository):'
117 else:
117 else:
118 raise AttributeError, name
118 raise AttributeError, name
119
119
120 def __getitem__(self, changeid):
121 if changeid == None:
122 return context.workingctx(self)
123 return context.changectx(self, changeid)
124
120 def url(self):
125 def url(self):
121 return 'file:' + self.root
126 return 'file:' + self.root
122
127
@@ -330,7 +335,7 b' class localrepository(repo.repository):'
330 last = {}
335 last = {}
331 ret = []
336 ret = []
332 for node in heads:
337 for node in heads:
333 c = self.changectx(node)
338 c = self[node]
334 rev = c.rev()
339 rev = c.rev()
335 try:
340 try:
336 fnode = c.filenode('.hgtags')
341 fnode = c.filenode('.hgtags')
@@ -436,7 +441,7 b' class localrepository(repo.repository):'
436
441
437 def _updatebranchcache(self, partial, start, end):
442 def _updatebranchcache(self, partial, start, end):
438 for r in xrange(start, end):
443 for r in xrange(start, end):
439 c = self.changectx(r)
444 c = self[r]
440 b = c.branch()
445 b = c.branch()
441 partial[b] = c.node()
446 partial[b] = c.node()
442
447
@@ -484,13 +489,11 b' class localrepository(repo.repository):'
484 return filelog.filelog(self.sopener, f)
489 return filelog.filelog(self.sopener, f)
485
490
486 def changectx(self, changeid):
491 def changectx(self, changeid):
487 if changeid == None:
492 return self[changeid]
488 return context.workingctx(self)
489 return context.changectx(self, changeid)
490
493
491 def parents(self, changeid=None):
494 def parents(self, changeid=None):
492 '''get list of changectxs for parents of changeid'''
495 '''get list of changectxs for parents of changeid'''
493 return self.changectx(changeid).parents()
496 return self[changeid].parents()
494
497
495 def filectx(self, path, changeid=None, fileid=None):
498 def filectx(self, path, changeid=None, fileid=None):
496 """changeid can be a changeset revision, node, or tag.
499 """changeid can be a changeset revision, node, or tag.
@@ -1005,7 +1008,7 b' class localrepository(repo.repository):'
1005 if lookup:
1008 if lookup:
1006 fixup = []
1009 fixup = []
1007 # do a full compare of any files that might have changed
1010 # do a full compare of any files that might have changed
1008 ctx = self.changectx('')
1011 ctx = self['.']
1009 ff = self.dirstate.flagfunc(ctx.flags)
1012 ff = self.dirstate.flagfunc(ctx.flags)
1010 for f in lookup:
1013 for f in lookup:
1011 if (f not in ctx or ff(f) != ctx.flags(f)
1014 if (f not in ctx or ff(f) != ctx.flags(f)
@@ -1181,7 +1184,8 b' class localrepository(repo.repository):'
1181 return [n for (r, n) in heads]
1184 return [n for (r, n) in heads]
1182
1185
1183 def branchheads(self, branch=None, start=None):
1186 def branchheads(self, branch=None, start=None):
1184 branch = branch is None and self.changectx(None).branch() or branch
1187 if branch is None:
1188 branch = self[None].branch()
1185 branches = self.branchtags()
1189 branches = self.branchtags()
1186 if branch not in branches:
1190 if branch not in branches:
1187 return []
1191 return []
@@ -1219,7 +1223,7 b' class localrepository(repo.repository):'
1219 if rev in ancestors:
1223 if rev in ancestors:
1220 ancestors.update(self.changelog.parentrevs(rev))
1224 ancestors.update(self.changelog.parentrevs(rev))
1221 ancestors.remove(rev)
1225 ancestors.remove(rev)
1222 elif self.changectx(rev).branch() == branch:
1226 elif self[rev].branch() == branch:
1223 heads.append(rev)
1227 heads.append(rev)
1224 ancestors.update(self.changelog.parentrevs(rev))
1228 ancestors.update(self.changelog.parentrevs(rev))
1225 heads = [self.changelog.node(rev) for rev in heads]
1229 heads = [self.changelog.node(rev) for rev in heads]
@@ -409,7 +409,7 b' def update(repo, node, branchmerge, forc'
409
409
410 wlock = repo.wlock()
410 wlock = repo.wlock()
411 try:
411 try:
412 wc = repo.changectx(None)
412 wc = repo[None]
413 if node is None:
413 if node is None:
414 # tip of current branch
414 # tip of current branch
415 try:
415 try:
@@ -421,7 +421,7 b' def update(repo, node, branchmerge, forc'
421 raise util.Abort(_("branch %s not found") % wc.branch())
421 raise util.Abort(_("branch %s not found") % wc.branch())
422 overwrite = force and not branchmerge
422 overwrite = force and not branchmerge
423 pl = wc.parents()
423 pl = wc.parents()
424 p1, p2 = pl[0], repo.changectx(node)
424 p1, p2 = pl[0], repo[node]
425 pa = p1.ancestor(p2)
425 pa = p1.ancestor(p2)
426 fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
426 fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
427 fastforward = False
427 fastforward = False
@@ -1180,7 +1180,7 b' def diff(repo, node1=None, node2=None, m'
1180
1180
1181 # reading the data for node1 early allows it to play nicely
1181 # reading the data for node1 early allows it to play nicely
1182 # with repo.status and the revlog cache.
1182 # with repo.status and the revlog cache.
1183 ctx1 = repo.changectx(node1)
1183 ctx1 = repo[node1]
1184 # force manifest reading
1184 # force manifest reading
1185 man1 = ctx1.manifest()
1185 man1 = ctx1.manifest()
1186 date1 = util.datestr(ctx1.date())
1186 date1 = util.datestr(ctx1.date())
@@ -1192,7 +1192,7 b' def diff(repo, node1=None, node2=None, m'
1192 if not modified and not added and not removed:
1192 if not modified and not added and not removed:
1193 return
1193 return
1194
1194
1195 ctx2 = repo.changectx(node2)
1195 ctx2 = repo[node2]
1196
1196
1197 if repo.ui.quiet:
1197 if repo.ui.quiet:
1198 r = None
1198 r = None
@@ -1201,7 +1201,7 b' def diff(repo, node1=None, node2=None, m'
1201 r = [hexfunc(node) for node in [node1, node2] if node]
1201 r = [hexfunc(node) for node in [node1, node2] if node]
1202
1202
1203 if opts.git:
1203 if opts.git:
1204 copy, diverge = copies.copies(repo, ctx1, ctx2, repo.changectx(nullid))
1204 copy, diverge = copies.copies(repo, ctx1, ctx2, repo[nullid])
1205 for k, v in copy.items():
1205 for k, v in copy.items():
1206 copy[v] = k
1206 copy[v] = k
1207
1207
@@ -1280,7 +1280,7 b" def export(repo, revs, template='hg-%h.p"
1280 revwidth = max([len(str(rev)) for rev in revs])
1280 revwidth = max([len(str(rev)) for rev in revs])
1281
1281
1282 def single(rev, seqno, fp):
1282 def single(rev, seqno, fp):
1283 ctx = repo.changectx(rev)
1283 ctx = repo[rev]
1284 node = ctx.node()
1284 node = ctx.node()
1285 parents = [p.node() for p in ctx.parents() if p]
1285 parents = [p.node() for p in ctx.parents() if p]
1286 branch = ctx.branch()
1286 branch = ctx.branch()
@@ -24,7 +24,7 b' def _collectfiles(repo, striprev):'
24 files = {}
24 files = {}
25
25
26 for x in xrange(striprev, repo.changelog.count()):
26 for x in xrange(striprev, repo.changelog.count()):
27 for name in repo.changectx(x).files():
27 for name in repo[x].files():
28 if name in files:
28 if name in files:
29 continue
29 continue
30 files[name] = 1
30 files[name] = 1
@@ -16,4 +16,4 b" os.utime('foo', (1000, 1000))"
16 repo.add(['foo'])
16 repo.add(['foo'])
17 repo.commit(text='commit1', date="0 0")
17 repo.commit(text='commit1', date="0 0")
18
18
19 print "workingfilectx.date =", repo.changectx(None).filectx('foo').date()
19 print "workingfilectx.date =", repo[None]['foo'].date()
General Comments 0
You need to be logged in to leave comments. Login now