changeset 6739:c9fbd6ec3489

context: avoid using None for working parent
author Matt Mackall <mpm@selenic.com>
date Wed, 25 Jun 2008 17:35:20 -0500
parents 336fda65759a
children b148e9099133
files hgext/keyword.py mercurial/cmdutil.py mercurial/commands.py mercurial/localrepo.py
diffstat 4 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/keyword.py	Wed Jun 25 17:34:28 2008 -0500
+++ b/hgext/keyword.py	Wed Jun 25 17:35:20 2008 -0500
@@ -171,12 +171,14 @@
 
     def overwrite(self, node, expand, files):
         '''Overwrites selected files expanding/shrinking keywords.'''
-        ctx = self.repo.changectx(node)
-        mf = ctx.manifest()
         if node is not None:     # commit
+            ctx = self.repo.changectx(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('.')
+            mf = ctx.manifest()
             notify = self.ui.note
         candidates = [f for f in files if self.iskwfile(f, mf.linkf)]
         if candidates:
@@ -511,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.changectx('.').node():
             kwt.restrict = True
         patch_diff(repo, node1, node2, match, fp, changes, opts)
 
--- a/mercurial/cmdutil.py	Wed Jun 25 17:34:28 2008 -0500
+++ b/mercurial/cmdutil.py	Wed Jun 25 17:35:20 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.changectx('.')
     for a in added:
         aa = repo.wread(a)
         bestname, bestscore = None, threshold
@@ -992,7 +992,7 @@
         return [], m
 
     if follow:
-        defrange = '%s:0' % repo.changectx().rev()
+        defrange = '%s:0' % repo.changectx('.').rev()
     else:
         defrange = '-1:0'
     revs = revrange(repo, opts['rev'] or [defrange])
--- a/mercurial/commands.py	Wed Jun 25 17:34:28 2008 -0500
+++ b/mercurial/commands.py	Wed Jun 25 17:35:20 2008 -0500
@@ -189,7 +189,7 @@
     hand. The result of this merge is not committed, as for a normal
     merge.
 
-    See 'hg help dates' for a list of formats valid for -d/--date.
+    See \'hg help dates\' for a list of formats valid for -d/--date.
     '''
     if rev and node:
         raise util.Abort(_("please specify just one revision"))
@@ -2670,11 +2670,12 @@
     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
@@ -2713,7 +2714,7 @@
     See 'hg help dates' for a list of formats valid for -d/--date.
     """
 
-    rev_ = None
+    rev_ = "."
     names = (name1,) + names
     if len(names) != len(dict.fromkeys(names)):
         raise util.Abort(_('tag names must be unique'))
--- a/mercurial/localrepo.py	Wed Jun 25 17:34:28 2008 -0500
+++ b/mercurial/localrepo.py	Wed Jun 25 17:35:20 2008 -0500
@@ -483,7 +483,9 @@
             f = f[1:]
         return filelog.filelog(self.sopener, f)
 
-    def changectx(self, changeid=None):
+    def changectx(self, changeid):
+        if changeid == None:
+            raise "nope!"
         return context.changectx(self, changeid)
 
     def workingctx(self):
@@ -1018,7 +1020,7 @@
                 if lookup:
                     fixup = []
                     # do a full compare of any files that might have changed
-                    ctx = self.changectx()
+                    ctx = self.changectx('')
                     mexec = lambda f: 'x' in ctx.fileflags(f)
                     mlink = lambda f: 'l' in ctx.fileflags(f)
                     is_exec = util.execfunc(self.root, mexec)