changeset 6740:b148e9099133

use repo.changectx(None) to get a workingctx
author Matt Mackall <mpm@selenic.com>
date Thu, 26 Jun 2008 13:46:29 -0500
parents c9fbd6ec3489
children 5918e2b79859
files hgext/keyword.py mercurial/commands.py mercurial/localrepo.py mercurial/merge.py mercurial/patch.py tests/test-context.py
diffstat 6 files changed, 15 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/keyword.py	Wed Jun 25 17:35:20 2008 -0500
+++ b/hgext/keyword.py	Thu Jun 26 13:46:29 2008 -0500
@@ -386,7 +386,7 @@
     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 ''
--- a/mercurial/commands.py	Wed Jun 25 17:35:20 2008 -0500
+++ b/mercurial/commands.py	Thu Jun 26 13:46:29 2008 -0500
@@ -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.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 @@
                 "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 @@
                     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 @@
         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 @@
                                    "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 @@
     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 @@
             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 @@
     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
--- a/mercurial/localrepo.py	Wed Jun 25 17:35:20 2008 -0500
+++ b/mercurial/localrepo.py	Thu Jun 26 13:46:29 2008 -0500
@@ -485,12 +485,9 @@
 
     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 @@
         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 []
--- a/mercurial/merge.py	Wed Jun 25 17:35:20 2008 -0500
+++ b/mercurial/merge.py	Thu Jun 26 13:46:29 2008 -0500
@@ -409,7 +409,7 @@
 
     wlock = repo.wlock()
     try:
-        wc = repo.workingctx()
+        wc = repo.changectx(None)
         if node is None:
             # tip of current branch
             try:
--- a/mercurial/patch.py	Wed Jun 25 17:35:20 2008 -0500
+++ b/mercurial/patch.py	Thu Jun 26 13:46:29 2008 -0500
@@ -1192,12 +1192,11 @@
     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:
--- a/tests/test-context.py	Wed Jun 25 17:35:20 2008 -0500
+++ b/tests/test-context.py	Thu Jun 26 13:46:29 2008 -0500
@@ -16,4 +16,4 @@
 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()