changeset 6747:f6c00b17387c

use repo[changeid] to get a changectx
author Matt Mackall <mpm@selenic.com>
date Thu, 26 Jun 2008 14:35:46 -0500
parents 1dca460e7d1e
children c6cc35a3d1de
files hgext/acl.py hgext/bugzilla.py hgext/children.py hgext/convert/hg.py hgext/extdiff.py hgext/hgk.py hgext/keyword.py hgext/mq.py hgext/win32text.py mercurial/archival.py mercurial/cmdutil.py mercurial/commands.py mercurial/context.py mercurial/graphmod.py mercurial/hgweb/hgweb_mod.py mercurial/hgweb/webcommands.py mercurial/hgweb/webutil.py mercurial/localrepo.py mercurial/merge.py mercurial/patch.py mercurial/repair.py tests/test-context.py
diffstat 22 files changed, 92 insertions(+), 94 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/acl.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/hgext/acl.py	Thu Jun 26 14:35:46 2008 -0500
@@ -91,7 +91,7 @@
 
     def check(self, node):
         '''return if access allowed, raise exception if not.'''
-        files = self.repo.changectx(node).files()
+        files = self.repo[node].files()
         if self.deniable:
             for f in files:
                 if self.deny(f):
--- a/hgext/bugzilla.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/hgext/bugzilla.py	Thu Jun 26 14:35:46 2008 -0500
@@ -300,7 +300,7 @@
                          hooktype)
     try:
         bz = bugzilla(ui, repo)
-        ctx = repo.changectx(node)
+        ctx = repo[node]
         ids = bz.find_bug_ids(ctx)
         if ids:
             for id in ids:
--- a/hgext/children.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/hgext/children.py	Thu Jun 26 14:35:46 2008 -0500
@@ -25,7 +25,7 @@
     if file_:
         ctx = repo.filectx(file_, changeid=rev)
     else:
-        ctx = repo.changectx(rev)
+        ctx = repo[rev]
 
     displayer = cmdutil.show_changeset(ui, repo, opts)
     for node in [cp.node() for cp in ctx.children()]:
--- a/hgext/convert/hg.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/hgext/convert/hg.py	Thu Jun 26 14:35:46 2008 -0500
@@ -157,7 +157,7 @@
 
     def puttags(self, tags):
          try:
-             parentctx = self.repo.changectx(self.tagsbranch)
+             parentctx = self.repo[self.tagsbranch]
              tagparent = parentctx.node()
          except RepoError, inst:
              parentctx = None
@@ -212,19 +212,19 @@
 
     def changectx(self, rev):
         if self.lastrev != rev:
-            self.lastctx = self.repo.changectx(rev)
+            self.lastctx = self.repo[rev]
             self.lastrev = rev
         return self.lastctx
 
     def getheads(self):
         if self.rev:
-            return [hex(self.repo.changectx(self.rev).node())]
+            return [hex(self.repo[self.rev].node())]
         else:
             return [hex(node) for node in self.repo.heads()]
 
     def getfile(self, name, rev):
         try:
-            return self.changectx(rev).filectx(name).data()
+            return self.changectx(rev)[name].data()
         except revlog.LookupError, err:
             raise IOError(err)
 
--- a/hgext/extdiff.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/hgext/extdiff.py	Thu Jun 26 14:35:46 2008 -0500
@@ -52,7 +52,6 @@
 
 def snapshot_node(ui, repo, files, node, tmproot):
     '''snapshot files as of some revision'''
-    mf = repo.changectx(node).manifest()
     dirname = os.path.basename(repo.root)
     if dirname == "":
         dirname = "root"
@@ -61,17 +60,18 @@
     os.mkdir(base)
     ui.note(_('making snapshot of %d files from rev %s\n') %
             (len(files), short(node)))
+    ctx = repo[node]
     for fn in files:
-        if not fn in mf:
+        wfn = util.pconvert(fn)
+        if not wfn in ctx:
             # skipping new file after a merge ?
             continue
-        wfn = util.pconvert(fn)
         ui.note('  %s\n' % wfn)
         dest = os.path.join(base, wfn)
         destdir = os.path.dirname(dest)
         if not os.path.isdir(destdir):
             os.makedirs(destdir)
-        data = repo.wwritedata(wfn, repo.file(wfn).read(mf[wfn]))
+        data = repo.wwritedata(wfn, ctx[wfn].data())
         open(dest, 'wb').write(data)
     return dirname
 
--- a/hgext/hgk.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/hgext/hgk.py	Thu Jun 26 14:35:46 2008 -0500
@@ -52,8 +52,8 @@
     """diff trees from two commits"""
     def __difftree(repo, node1, node2, files=[]):
         assert node2 is not None
-        mmap = repo.changectx(node1).manifest()
-        mmap2 = repo.changectx(node2).manifest()
+        mmap = repo[node1].manifest()
+        mmap2 = repo[node2].manifest()
         m = cmdutil.match(repo, files)
         status = repo.status(node1, node2, match=m)[:5]
         modified, added, removed, deleted, unknown = status
@@ -103,7 +103,7 @@
 def catcommit(ui, repo, n, prefix, ctx=None):
     nlprefix = '\n' + prefix;
     if ctx is None:
-        ctx = repo.changectx(n)
+        ctx = repo[n]
     (p1, p2) = ctx.parents()
     ui.write("tree %s\n" % short(ctx.changeset()[0])) # use ctx.node() instead ??
     if p1: ui.write("parent %s\n" % short(p1.node()))
@@ -191,7 +191,7 @@
                     l[chunk - x:] = [0] * (chunk - x)
                     break
                 if full != None:
-                    l[x] = repo.changectx(i + x)
+                    l[x] = repo[i + x]
                     l[x].changeset() # force reading
                 else:
                     l[x] = 1
--- a/hgext/keyword.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/hgext/keyword.py	Thu Jun 26 14:35:46 2008 -0500
@@ -172,12 +172,12 @@
     def overwrite(self, node, expand, files):
         '''Overwrites selected files expanding/shrinking keywords.'''
         if node is not None:     # commit
-            ctx = self.repo.changectx(node)
+            ctx = self.repo[node]
             mf = ctx.manifest()
             files = [f for f in ctx.files() if f in mf]
             notify = self.ui.debug
         else:                    # kwexpand/kwshrink
-            ctx = self.repo.changectx('.')
+            ctx = self.repo['.']
             mf = ctx.manifest()
             notify = self.ui.note
         candidates = [f for f in files if self.iskwfile(f, mf.linkf)]
@@ -386,7 +386,7 @@
     if opts.get('untracked'):
         files += unknown
     files.sort()
-    wctx = repo.changectx(None)
+    wctx = repo[None]
     islink = lambda p: 'l' in wctx.flags(p)
     kwfiles = [f for f in files if kwt.iskwfile(f, islink)]
     cwd = pats and repo.getcwd() or ''
@@ -513,7 +513,7 @@
         comparing against working dir.'''
         if node2 is not None:
             kwt.matcher = util.never
-        elif node1 is not None and node1 != repo.changectx('.').node():
+        elif node1 is not None and node1 != repo['.'].node():
             kwt.restrict = True
         patch_diff(repo, node1, node2, match, fp, changes, opts)
 
--- a/hgext/mq.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/hgext/mq.py	Thu Jun 26 14:35:46 2008 -0500
@@ -342,7 +342,7 @@
         hg.clean(repo, head)
         self.strip(repo, n, update=False, backup='strip')
 
-        ctx = repo.changectx(rev)
+        ctx = repo[rev]
         ret = hg.merge(repo, rev)
         if ret:
             raise util.Abort(_("update returned %d") % ret)
--- a/hgext/win32text.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/hgext/win32text.py	Thu Jun 26 14:35:46 2008 -0500
@@ -99,7 +99,7 @@
 def forbidnewline(ui, repo, hooktype, node, newline, **kwargs):
     halt = False
     for rev in xrange(repo.changelog.rev(bin(node)), repo.changelog.count()):
-        c = repo.changectx(rev)
+        c = repo[rev]
         for f in c.files():
             if f not in c:
                 continue
--- a/mercurial/archival.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/archival.py	Thu Jun 26 14:35:46 2008 -0500
@@ -208,7 +208,7 @@
             data = repo.wwritedata(name, data)
         archiver.addfile(name, mode, islink, data)
 
-    ctx = repo.changectx(node)
+    ctx = repo[node]
     if kind not in archivers:
         raise util.Abort(_("unknown archive type '%s'" % kind))
     archiver = archivers[kind](dest, prefix, mtime or ctx.date()[0])
--- a/mercurial/cmdutil.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/cmdutil.py	Thu Jun 26 14:35:46 2008 -0500
@@ -245,7 +245,7 @@
     '''find renamed files -- yields (before, after, score) tuples'''
     if added is None or removed is None:
         added, removed = repo.status()[1:3]
-    ctx = repo.changectx('.')
+    ctx = repo['.']
     for a in added:
         aa = repo.wread(a)
         bestname, bestscore = None, threshold
@@ -930,7 +930,7 @@
 def finddate(ui, repo, date):
     """Find the tipmost changeset that matches the given date spec"""
     df = util.matchdate(date)
-    get = util.cachefunc(lambda r: repo.changectx(r).changeset())
+    get = util.cachefunc(lambda r: repo[r].changeset())
     changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None})
     results = {}
     for st, rev, fns in changeiter:
@@ -992,7 +992,7 @@
         return [], m
 
     if follow:
-        defrange = '%s:0' % repo.changectx('.').rev()
+        defrange = '%s:0' % repo['.'].rev()
     else:
         defrange = '-1:0'
     revs = revrange(repo, opts['rev'] or [defrange])
--- a/mercurial/commands.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/commands.py	Thu Jun 26 14:35:46 2008 -0500
@@ -107,7 +107,7 @@
         lastfunc = funcmap[-1]
         funcmap[-1] = lambda x: "%s:%s" % (lastfunc(x), x[1])
 
-    ctx = repo.changectx(opts['rev'])
+    ctx = repo[opts['rev']]
 
     m = cmdutil.match(repo, pats, opts)
     for abs in repo.walk(m, ctx.node()):
@@ -154,7 +154,7 @@
     The default is the basename of the archive, with suffixes removed.
     '''
 
-    ctx = repo.changectx(opts['rev'])
+    ctx = repo[opts['rev']]
     if not ctx:
         raise util.Abort(_('repository has no revisions'))
     node = ctx.node()
@@ -359,7 +359,7 @@
 
     if label:
         if not opts.get('force') and label in repo.branchtags():
-            if label not in [p.branch() for p in repo.changectx(None).parents()]:
+            if label not in [p.branch() for p in repo.parents()]:
                 raise util.Abort(_('a branch of the same name already exists'
                                    ' (use --force to override)'))
         repo.dirstate.setbranch(util.fromlocal(label))
@@ -378,7 +378,7 @@
     Use the command 'hg update' to switch to an existing branch.
     """
     hexfunc = ui.debugflag and hex or short
-    activebranches = [util.tolocal(repo.changectx(n).branch())
+    activebranches = [util.tolocal(repo[n].branch())
                             for n in repo.heads()]
     branches = [(tag in activebranches, repo.changelog.rev(node), tag)
                             for tag, node in repo.branchtags().items()]
@@ -483,7 +483,7 @@
     %d   dirname of file being printed, or '.' if in repo root
     %p   root-relative path name of file being printed
     """
-    ctx = repo.changectx(opts['rev'])
+    ctx = repo[opts['rev']]
     err = 1
     m = cmdutil.match(repo, (file1,) + pats, opts)
     for abs in repo.walk(m, ctx.node()):
@@ -647,23 +647,20 @@
                                 and 'yes' or 'no'))
     os.unlink('.debugfsinfo')
 
-def debugrebuildstate(ui, repo, rev=""):
+def debugrebuildstate(ui, repo, rev="tip"):
     """rebuild the dirstate as it would look like for the given revision"""
-    if rev == "":
-        rev = repo.changelog.tip()
-    ctx = repo.changectx(rev)
-    files = ctx.manifest()
+    ctx = repo[rev]
     wlock = repo.wlock()
     try:
-        repo.dirstate.rebuild(rev, files)
+        repo.dirstate.rebuild(ctx.node(), ctx.manifest())
     finally:
         del wlock
 
 def debugcheckstate(ui, repo):
     """validate the correctness of the current dirstate"""
     parent1, parent2 = repo.dirstate.parents()
-    m1 = repo.changectx(parent1).manifest()
-    m2 = repo.changectx(parent2).manifest()
+    m1 = repo[parent1].manifest()
+    m2 = repo[parent2].manifest()
     errors = 0
     for f in repo.dirstate:
         state = repo.dirstate[f]
@@ -913,7 +910,7 @@
 def debugrename(ui, repo, file1, *pats, **opts):
     """dump rename information"""
 
-    ctx = repo.changectx(opts.get('rev', 'tip'))
+    ctx = repo[opts.get('rev', 'tip')]
     m = cmdutil.match(repo, (file1,) + pats, opts)
     for abs in repo.walk(m, ctx.node()):
         fctx = ctx.filectx(abs)
@@ -1122,7 +1119,7 @@
 
     fstate = {}
     skip = {}
-    get = util.cachefunc(lambda r: repo.changectx(r).changeset())
+    get = util.cachefunc(lambda r: repo[r].changeset())
     changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
     found = False
     follow = opts.get('follow')
@@ -1130,7 +1127,7 @@
         if st == 'window':
             matches.clear()
         elif st == 'add':
-            ctx = repo.changectx(rev)
+            ctx = repo[rev]
             matches[rev] = {}
             for fn in fns:
                 if fn in skip:
@@ -1202,7 +1199,7 @@
         heads = []
         visitedset = util.set()
         for branchrev in branchrevs:
-            branch = repo.changectx(branchrev).branch()
+            branch = repo[branchrev].branch()
             if branch in visitedset:
                 continue
             visitedset.add(branch)
@@ -1454,7 +1451,7 @@
                 "can't query remote revision number, branch, or tags")
         output = [hexfunc(srepo.lookup(rev))]
     elif not rev:
-        ctx = repo.changectx(None)
+        ctx = repo[None]
         parents = ctx.parents()
         changed = False
         if default or id or num:
@@ -1466,7 +1463,7 @@
             output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
                                     (changed) and "+" or ""))
     else:
-        ctx = repo.changectx(rev)
+        ctx = repo[rev]
         if default or id:
             output = [hexfunc(ctx.node())]
         if num:
@@ -1563,7 +1560,7 @@
                     message = None
                 ui.debug(_('message:\n%s\n') % message)
 
-                wp = repo.changectx(None).parents()
+                wp = repo.parents()
                 if opts.get('exact'):
                     if not nodeid or not p1:
                         raise util.Abort(_('not a mercurial patch'))
@@ -1756,7 +1753,7 @@
 
     """
 
-    get = util.cachefunc(lambda r: repo.changectx(r).changeset())
+    get = util.cachefunc(lambda r: repo[r].changeset())
     changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
 
     limit = cmdutil.loglimit(opts)
@@ -1793,7 +1790,7 @@
         # filectx logic.
 
         try:
-            return repo.changectx(rev).filectx(fn).renamed()
+            return repo[rev][fn].renamed()
         except revlog.LookupError:
             pass
         return None
@@ -1869,7 +1866,7 @@
     if not node:
         node = rev
 
-    m = repo.changectx(node).manifest()
+    m = repo[node].manifest()
     files = m.keys()
     files.sort()
 
@@ -1916,7 +1913,7 @@
                                    "please merge with an explicit rev") %
                                  branch)
             msg = _('there is nothing to merge')
-            if parent != repo.lookup(repo.changectx(None).branch()):
+            if parent != repo.lookup(repo[None].branch()):
                 msg = _('%s - use "hg update" instead') % msg
             raise util.Abort(msg)
 
@@ -1973,9 +1970,9 @@
     """
     rev = opts.get('rev')
     if rev:
-        ctx = repo.changectx(rev)
+        ctx = repo[rev]
     else:
-        ctx = repo.changectx(None)
+        ctx = repo[None]
 
     if file_:
         m = cmdutil.match(repo, (file_,), opts)
@@ -2297,7 +2294,7 @@
             elif opts.get("unmark"):
                 ms.mark(f, "u")
             else:
-                wctx = repo.changectx(None)
+                wctx = repo[None]
                 mctx = wctx.parents()[-1]
                 ms.resolve(f, wctx, mctx)
 
@@ -2348,7 +2345,7 @@
     if not opts['rev'] and p2 != nullid:
         raise util.Abort(_('uncommitted merge - please provide a '
                            'specific revision'))
-    ctx = repo.changectx(opts['rev'])
+    ctx = repo[opts['rev']]
     node = ctx.node()
     mf = ctx.manifest()
     if node == parent:
@@ -2466,7 +2463,7 @@
                 if pmf is None:
                     # only need parent manifest in this unlikely case,
                     # so do not read by default
-                    pmf = repo.changectx(parent).manifest()
+                    pmf = repo[parent].manifest()
                 if abs in pmf:
                     if mfentry:
                         # if version of file is same in parent and target
@@ -2668,9 +2665,9 @@
     changestates = zip(states, 'MAR!?IC', stat)
 
     if (opts['all'] or opts['copies']) and not opts['no_status']:
-        ctxn = repo.changectx(nullid)
-        ctx1 = repo.changectx(node1)
-        ctx2 = repo.changectx(node2)
+        ctxn = repo[nullid]
+        ctx1 = repo[node1]
+        ctx2 = repo[node2]
         added = stat[1]
         if node2 is None:
             added = stat[0] + stat[1] # merged?
@@ -2744,7 +2741,7 @@
     if not rev_ and repo.dirstate.parents()[1] != nullid:
         raise util.Abort(_('uncommitted merge - please provide a '
                            'specific revision'))
-    r = repo.changectx(rev_).node()
+    r = repo[rev_].node()
 
     if not message:
         message = (_('Added tag %s for changeset %s') %
--- a/mercurial/context.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/context.py	Thu Jun 26 14:35:46 2008 -0500
@@ -463,7 +463,7 @@
             self._user = self._repo.ui.username()
         if parents:
             p1, p2 = parents
-            self._parents = [self._repo.changectx(p) for p in (p1, p2)]
+            self._parents = [changectx(self._repo, p) for p in (p1, p2)]
         if changes:
             self._status = list(changes)
 
@@ -687,7 +687,7 @@
         self._user = user or self._repo.ui.username()
         parents = [(p or nullid) for p in parents]
         p1, p2 = parents
-        self._parents = [self._repo.changectx(p) for p in (p1, p2)]
+        self._parents = [changectx(self._repo, p) for p in (p1, p2)]
         files = list(files)
         files.sort()
         self._status = [files, [], [], [], []]
--- a/mercurial/graphmod.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/graphmod.py	Thu Jun 26 14:35:46 2008 -0500
@@ -69,6 +69,6 @@
                     edges.append((col, next.index(p), colors[p]))
 
         # Yield and move on
-        yield (repo.changectx(curr_rev), (idx, color), edges)
+        yield (repo[curr_rev], (idx, color), edges)
         revs = next
         curr_rev -= 1
--- a/mercurial/hgweb/hgweb_mod.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Jun 26 14:35:46 2008 -0500
@@ -331,8 +331,8 @@
                            linenumber="% 8s" % lineno)
 
         r = self.repo
-        c1 = r.changectx(node1)
-        c2 = r.changectx(node2)
+        c1 = r[node1]
+        c2 = r[node2]
         date1 = util.datestr(c1.date())
         date2 = util.datestr(c2.date())
 
--- a/mercurial/hgweb/webcommands.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/hgweb/webcommands.py	Thu Jun 26 14:35:46 2008 -0500
@@ -113,7 +113,7 @@
             for i in xrange(cl.count() - 1, 0, -100):
                 l = []
                 for j in xrange(max(0, i - 100), i + 1):
-                    ctx = web.repo.changectx(j)
+                    ctx = web.repo[j]
                     l.append(ctx)
                 l.reverse()
                 for e in l:
@@ -170,7 +170,7 @@
         else:
             hi = web.repo.changelog.count() - 1
         try:
-            ctx = web.repo.changectx(hi)
+            ctx = web.repo[hi]
         except RepoError:
             return _search(web, tmpl, hi) # XXX redirect to 404 page?
 
@@ -178,7 +178,7 @@
         cl = web.repo.changelog
         l = [] # build a list in forward order for efficiency
         for i in xrange(start, end):
-            ctx = web.repo.changectx(i)
+            ctx = web.repo[i]
             n = ctx.node()
             showtags = webutil.showtag(web.repo, tmpl, 'changelogtag', n)
 
@@ -299,7 +299,7 @@
             yield {"file": full,
                    "parity": parity.next(),
                    "basename": f,
-                   "date": fctx.changectx().date(),
+                   "date": fctx.date(),
                    "size": fctx.size(),
                    "permissions": mf.flags(full)}
 
@@ -343,7 +343,7 @@
             count = count + 1
             yield {"parity": parity.next(),
                    "tag": k,
-                   "date": web.repo.changectx(n).date(),
+                   "date": web.repo[n].date(),
                    "node": hex(n)}
 
     return tmpl("tags",
@@ -371,7 +371,7 @@
                        parity=parity.next(),
                        tag=k,
                        node=hex(n),
-                       date=web.repo.changectx(n).date())
+                       date=web.repo[n].date())
 
     def branches(**map):
         parity = paritygen(web.stripecount)
@@ -381,17 +381,16 @@
         l.sort()
 
         for r,n,t in l:
-            ctx = web.repo.changectx(n)
             yield {'parity': parity.next(),
                    'branch': t,
                    'node': hex(n),
-                   'date': ctx.date()}
+                   'date': web.repo[n].date()}
 
     def changelist(**map):
         parity = paritygen(web.stripecount, offset=start-end)
         l = [] # build a list in forward order for efficiency
         for i in xrange(start, end):
-            ctx = web.repo.changectx(i)
+            ctx = web.repo[i]
             n = ctx.node()
             hn = hex(n)
 
--- a/mercurial/hgweb/webutil.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/hgweb/webutil.py	Thu Jun 26 14:35:46 2008 -0500
@@ -120,11 +120,10 @@
         changeid = repo.changelog.count() - 1
 
     try:
-        ctx = repo.changectx(changeid)
+        ctx = repo[changeid]
     except RepoError:
         man = repo.manifest
-        mn = man.lookup(changeid)
-        ctx = repo.changectx(man.linkrev(mn))
+        ctx = repo[man.linkrev(man.lookup(changeid))]
 
     return ctx
 
@@ -135,8 +134,7 @@
     else:
         changeid = req.form['filenode'][0]
     try:
-        ctx = repo.changectx(changeid)
-        fctx = ctx.filectx(path)
+        fctx = repo[changeid][path]
     except RepoError:
         fctx = repo.filectx(path, fileid=changeid)
 
--- a/mercurial/localrepo.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/localrepo.py	Thu Jun 26 14:35:46 2008 -0500
@@ -117,6 +117,11 @@
         else:
             raise AttributeError, name
 
+    def __getitem__(self, changeid):
+        if changeid == None:
+            return context.workingctx(self)
+        return context.changectx(self, changeid)
+
     def url(self):
         return 'file:' + self.root
 
@@ -330,7 +335,7 @@
         last = {}
         ret = []
         for node in heads:
-            c = self.changectx(node)
+            c = self[node]
             rev = c.rev()
             try:
                 fnode = c.filenode('.hgtags')
@@ -436,7 +441,7 @@
 
     def _updatebranchcache(self, partial, start, end):
         for r in xrange(start, end):
-            c = self.changectx(r)
+            c = self[r]
             b = c.branch()
             partial[b] = c.node()
 
@@ -484,13 +489,11 @@
         return filelog.filelog(self.sopener, f)
 
     def changectx(self, changeid):
-        if changeid == None:
-            return context.workingctx(self)
-        return context.changectx(self, changeid)
+        return self[changeid]
 
     def parents(self, changeid=None):
         '''get list of changectxs for parents of changeid'''
-        return self.changectx(changeid).parents()
+        return self[changeid].parents()
 
     def filectx(self, path, changeid=None, fileid=None):
         """changeid can be a changeset revision, node, or tag.
@@ -1005,7 +1008,7 @@
                 if lookup:
                     fixup = []
                     # do a full compare of any files that might have changed
-                    ctx = self.changectx('')
+                    ctx = self['.']
                     ff = self.dirstate.flagfunc(ctx.flags)
                     for f in lookup:
                         if (f not in ctx or ff(f) != ctx.flags(f)
@@ -1181,7 +1184,8 @@
         return [n for (r, n) in heads]
 
     def branchheads(self, branch=None, start=None):
-        branch = branch is None and self.changectx(None).branch() or branch
+        if branch is None:
+            branch = self[None].branch()
         branches = self.branchtags()
         if branch not in branches:
             return []
@@ -1219,7 +1223,7 @@
             if rev in ancestors:
                 ancestors.update(self.changelog.parentrevs(rev))
                 ancestors.remove(rev)
-            elif self.changectx(rev).branch() == branch:
+            elif self[rev].branch() == branch:
                 heads.append(rev)
                 ancestors.update(self.changelog.parentrevs(rev))
         heads = [self.changelog.node(rev) for rev in heads]
--- a/mercurial/merge.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/merge.py	Thu Jun 26 14:35:46 2008 -0500
@@ -409,7 +409,7 @@
 
     wlock = repo.wlock()
     try:
-        wc = repo.changectx(None)
+        wc = repo[None]
         if node is None:
             # tip of current branch
             try:
@@ -421,7 +421,7 @@
                     raise util.Abort(_("branch %s not found") % wc.branch())
         overwrite = force and not branchmerge
         pl = wc.parents()
-        p1, p2 = pl[0], repo.changectx(node)
+        p1, p2 = pl[0], repo[node]
         pa = p1.ancestor(p2)
         fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
         fastforward = False
--- a/mercurial/patch.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/patch.py	Thu Jun 26 14:35:46 2008 -0500
@@ -1180,7 +1180,7 @@
 
     # reading the data for node1 early allows it to play nicely
     # with repo.status and the revlog cache.
-    ctx1 = repo.changectx(node1)
+    ctx1 = repo[node1]
     # force manifest reading
     man1 = ctx1.manifest()
     date1 = util.datestr(ctx1.date())
@@ -1192,7 +1192,7 @@
     if not modified and not added and not removed:
         return
 
-    ctx2 = repo.changectx(node2)
+    ctx2 = repo[node2]
 
     if repo.ui.quiet:
         r = None
@@ -1201,7 +1201,7 @@
         r = [hexfunc(node) for node in [node1, node2] if node]
 
     if opts.git:
-        copy, diverge = copies.copies(repo, ctx1, ctx2, repo.changectx(nullid))
+        copy, diverge = copies.copies(repo, ctx1, ctx2, repo[nullid])
         for k, v in copy.items():
             copy[v] = k
 
@@ -1280,7 +1280,7 @@
     revwidth = max([len(str(rev)) for rev in revs])
 
     def single(rev, seqno, fp):
-        ctx = repo.changectx(rev)
+        ctx = repo[rev]
         node = ctx.node()
         parents = [p.node() for p in ctx.parents() if p]
         branch = ctx.branch()
--- a/mercurial/repair.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/mercurial/repair.py	Thu Jun 26 14:35:46 2008 -0500
@@ -24,7 +24,7 @@
     files = {}
 
     for x in xrange(striprev, repo.changelog.count()):
-        for name in repo.changectx(x).files():
+        for name in repo[x].files():
             if name in files:
                 continue
             files[name] = 1
--- a/tests/test-context.py	Thu Jun 26 13:58:24 2008 -0500
+++ b/tests/test-context.py	Thu Jun 26 14:35:46 2008 -0500
@@ -16,4 +16,4 @@
 repo.add(['foo'])
 repo.commit(text='commit1', date="0 0")
 
-print "workingfilectx.date =", repo.changectx(None).filectx('foo').date()
+print "workingfilectx.date =", repo[None]['foo'].date()