diff --git a/hgext/keyword.py b/hgext/keyword.py --- a/hgext/keyword.py +++ b/hgext/keyword.py @@ -386,7 +386,7 @@ def files(ui, repo, *pats, **opts): if opts.get('untracked'): files += unknown files.sort() - wctx = repo.workingctx() + wctx = repo.changectx(None) islink = lambda p: 'l' in wctx.fileflags(p) kwfiles = [f for f in files if kwt.iskwfile(f, islink)] cwd = pats and repo.getcwd() or '' diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -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.workingctx().parents()]: + if label not in [p.branch() for p in repo.changectx(None).parents()]: raise util.Abort(_('a branch of the same name already exists' ' (use --force to override)')) repo.dirstate.setbranch(util.fromlocal(label)) @@ -1454,7 +1454,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.workingctx() + ctx = repo.changectx(None) parents = ctx.parents() changed = False if default or id or num: @@ -1563,7 +1563,7 @@ def import_(ui, repo, patch1, *patches, message = None ui.debug(_('message:\n%s\n') % message) - wp = repo.workingctx().parents() + wp = repo.changectx(None).parents() if opts.get('exact'): if not nodeid or not p1: raise util.Abort(_('not a mercurial patch')) @@ -1902,7 +1902,7 @@ def merge(ui, repo, node=None, force=Non node = rev if not node: - branch = repo.workingctx().branch() + branch = repo.changectx(None).branch() bheads = repo.branchheads() if len(bheads) > 2: raise util.Abort(_("branch '%s' has %d heads - " @@ -1916,7 +1916,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.workingctx().branch()): + if parent != repo.lookup(repo.changectx(None).branch()): msg = _('%s - use "hg update" instead') % msg raise util.Abort(msg) @@ -1975,7 +1975,7 @@ def parents(ui, repo, file_=None, **opts if rev: ctx = repo.changectx(rev) else: - ctx = repo.workingctx() + ctx = repo.changectx(None) if file_: m = cmdutil.match(repo, (file_,), opts) @@ -2297,7 +2297,7 @@ def resolve(ui, repo, *pats, **opts): elif opts.get("unmark"): ms.mark(f, "u") else: - wctx = repo.workingctx() + wctx = repo.changectx(None) mctx = wctx.parents()[-1] ms.resolve(f, wctx, mctx) @@ -2670,12 +2670,11 @@ def status(ui, repo, *pats, **opts): if (opts['all'] or opts['copies']) and not opts['no_status']: ctxn = repo.changectx(nullid) ctx1 = repo.changectx(node1) + ctx2 = repo.changectx(node2) added = stat[1] if node2 is None: added = stat[0] + stat[1] # merged? - ctx2 = repo.workingctx() - else: - ctx2 = repo.changectx(node2) + for k, v in copies.copies(repo, ctx1, ctx2, ctxn)[0].items(): if k in added: copy[k] = v diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -485,12 +485,9 @@ class localrepository(repo.repository): def changectx(self, changeid): if changeid == None: - raise "nope!" + return context.workingctx(self) return context.changectx(self, changeid) - def workingctx(self): - return context.workingctx(self) - def parents(self, changeid=None): ''' get list of changectxs for parents of changeid or working directory @@ -1202,7 +1199,7 @@ class localrepository(repo.repository): return [n for (r, n) in heads] def branchheads(self, branch=None, start=None): - branch = branch is None and self.workingctx().branch() or branch + branch = branch is None and self.changectx(None).branch() or branch branches = self.branchtags() if branch not in branches: return [] 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.workingctx() + wc = repo.changectx(None) if node is None: # tip of current branch try: diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1192,12 +1192,11 @@ def diff(repo, node1=None, node2=None, m if not modified and not added and not removed: return + ctx2 = repo.changectx(node2) if node2: - ctx2 = repo.changectx(node2) execf2 = ctx2.manifest().execf linkf2 = ctx2.manifest().linkf else: - ctx2 = repo.workingctx() execf2 = util.execfunc(repo.root, None) linkf2 = util.linkfunc(repo.root, None) if execf2 is None: 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.workingctx().filectx('foo').date() +print "workingfilectx.date =", repo.changectx(None).filectx('foo').date()