diff --git a/hgext/acl.py b/hgext/acl.py --- a/hgext/acl.py +++ b/hgext/acl.py @@ -91,7 +91,7 @@ class checker(object): 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): diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py --- a/hgext/bugzilla.py +++ b/hgext/bugzilla.py @@ -300,7 +300,7 @@ def hook(ui, repo, hooktype, node=None, 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: diff --git a/hgext/children.py b/hgext/children.py --- a/hgext/children.py +++ b/hgext/children.py @@ -25,7 +25,7 @@ def children(ui, repo, file_=None, **opt 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()]: diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py --- a/hgext/convert/hg.py +++ b/hgext/convert/hg.py @@ -157,7 +157,7 @@ class mercurial_sink(converter_sink): 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 @@ class mercurial_source(converter_source) 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) diff --git a/hgext/extdiff.py b/hgext/extdiff.py --- a/hgext/extdiff.py +++ b/hgext/extdiff.py @@ -52,7 +52,6 @@ import os, shlex, shutil, tempfile 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 @@ def snapshot_node(ui, repo, files, node, 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 diff --git a/hgext/hgk.py b/hgext/hgk.py --- a/hgext/hgk.py +++ b/hgext/hgk.py @@ -52,8 +52,8 @@ def difftree(ui, repo, node1=None, node2 """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 difftree(ui, repo, node1=None, node2 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 @@ def revtree(ui, args, repo, full="tree", 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 diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -172,12 +172,12 @@ class kwtemplater(object): 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 @@ def files(ui, repo, *pats, **opts): 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 @@ def reposetup(ui, repo): 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) diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -342,7 +342,7 @@ class queue: 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) diff --git a/hgext/win32text.py b/hgext/win32text.py --- a/hgext/win32text.py +++ b/hgext/win32text.py @@ -99,7 +99,7 @@ def macencode(s, cmd): 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 diff --git a/mercurial/archival.py b/mercurial/archival.py --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -208,7 +208,7 @@ def archive(repo, dest, node, kind, deco 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]) diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -245,7 +245,7 @@ def findrenames(repo, added=None, remove '''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 show_changeset(ui, repo, opts, buffe 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 @@ def walkchangerevs(ui, repo, pats, chang 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]) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -107,7 +107,7 @@ def annotate(ui, repo, *pats, **opts): 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 @@ def archive(ui, repo, dest, **opts): 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 @@ def branch(ui, repo, label=None, **opts) 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 @@ def branches(ui, repo, active=False): 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 @@ def cat(ui, repo, file1, *pats, **opts): %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 @@ def debugfsinfo(ui, path = "."): 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 debuginstall(ui): 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 @@ def grep(ui, repo, pattern, *pats, **opt 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 @@ def grep(ui, repo, pattern, *pats, **opt 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 @@ def heads(ui, repo, *branchrevs, **opts) 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 @@ def identify(ui, repo, source=None, "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 @@ def identify(ui, repo, source=None, 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 @@ def import_(ui, repo, patch1, *patches, 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 @@ def log(ui, repo, *pats, **opts): """ - 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 @@ def log(ui, repo, *pats, **opts): # 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 @@ def manifest(ui, repo, node=None, rev=No if not node: node = rev - m = repo.changectx(node).manifest() + m = repo[node].manifest() files = m.keys() files.sort() @@ -1916,7 +1913,7 @@ def merge(ui, repo, node=None, force=Non "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 @@ def parents(ui, repo, file_=None, **opts """ 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 @@ def resolve(ui, repo, *pats, **opts): 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 @@ def revert(ui, repo, *pats, **opts): 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 @@ def revert(ui, repo, *pats, **opts): 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 @@ def status(ui, repo, *pats, **opts): 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 @@ def tag(ui, repo, name1, *names, **opts) 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') % diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -463,7 +463,7 @@ class workingctx(changectx): 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 @@ class memctx(object): 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, [], [], [], []] diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py --- a/mercurial/graphmod.py +++ b/mercurial/graphmod.py @@ -69,6 +69,6 @@ def graph(repo, start_rev, stop_rev): 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 diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -331,8 +331,8 @@ class hgweb(object): 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()) diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -113,7 +113,7 @@ def _search(web, tmpl, query): 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 @@ def changelog(web, req, tmpl, shortlog = 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 @@ def changelog(web, req, tmpl, shortlog = 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 @@ def manifest(web, req, tmpl): 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 @@ def tags(web, req, tmpl): 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 @@ def summary(web, req, tmpl): 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 @@ def summary(web, req, tmpl): 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) diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -120,11 +120,10 @@ def changectx(repo, req): 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 @@ def filectx(repo, req): 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) diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -117,6 +117,11 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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 @@ class localrepository(repo.repository): 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] diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -409,7 +409,7 @@ def update(repo, node, branchmerge, forc wlock = repo.wlock() try: - wc = repo.changectx(None) + wc = repo[None] if node is None: # tip of current branch try: @@ -421,7 +421,7 @@ def update(repo, node, branchmerge, forc 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 diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1180,7 +1180,7 @@ def diff(repo, node1=None, node2=None, m # 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 @@ def diff(repo, node1=None, node2=None, m 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 @@ def diff(repo, node1=None, node2=None, m 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 @@ def export(repo, revs, template='hg-%h.p 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() diff --git a/mercurial/repair.py b/mercurial/repair.py --- a/mercurial/repair.py +++ b/mercurial/repair.py @@ -24,7 +24,7 @@ def _collectfiles(repo, striprev): 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 diff --git a/tests/test-context.py b/tests/test-context.py --- a/tests/test-context.py +++ b/tests/test-context.py @@ -16,4 +16,4 @@ os.utime('foo', (1000, 1000)) 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()