--- a/hgkw/keyword.py Sat Feb 09 09:31:13 2008 +0100
+++ b/hgkw/keyword.py Sun Feb 10 01:28:16 2008 +0100
@@ -89,7 +89,7 @@
from mercurial import filelog, localrepo, revlog, templater, util
from mercurial.node import *
from mercurial.i18n import gettext as _
-import getopt, os.path, re, shutil, tempfile, time
+import getopt, os, re, shutil, tempfile, time
commands.optionalrepo += ' kwdemo'
@@ -106,7 +106,7 @@
return time.strftime('%Y/%m/%d %H:%M:%S', time.gmtime(date[0]))
-_kwtemplater, _cmd, _cmdoptions = None, None, None
+_kwtemplater = _cmd = _cmdoptions = None
# backwards compatibility hacks
@@ -265,11 +265,11 @@
'Header': '{root}/{file},v {node|short} {date|utcdate} {author|user}',
}
- def __init__(self, ui, repo, inc, exc, restrict):
+ def __init__(self, ui, repo, inc, exc, hgcmd):
self.ui = ui
self.repo = repo
self.matcher = util.matcher(repo.root, inc=inc, exc=exc)[1]
- self.restrict = restrict
+ self.restrict = hgcmd in restricted.split()
self.commitnode = None
self.path = ''
@@ -523,9 +523,13 @@
if opts.get('untracked'):
files += unknown
files.sort()
- # use the full definition of repo._link for backwards compatibility
- kwfiles = [f for f in files if _kwtemplater.matcher(f)
- and not os.path.islink(repo.wjoin(f))]
+ wctx = repo.workingctx()
+ if hasattr(wctx, 'fileflags'):
+ islink = lambda p: 'l' in wctx.fileflags(p)
+ else:
+ mf = wctx.manifest()
+ islink = mf.linkf
+ kwfiles = [f for f in files if _iskwfile(f, islink)]
cwd = pats and repo.getcwd() or ''
kwfstats = not opts.get('ignore') and (('K', kwfiles),) or ()
if opts.get('all') or opts.get('ignore'):
@@ -561,7 +565,7 @@
try:
if (not repo.local() or hgcmd in nokwcommands.split()
- or '.hg' in repo.root.split('/')
+ or '.hg' in repo.root.split(os.sep)
or repo._url.startswith('bundle:')):
return
except AttributeError:
@@ -585,8 +589,7 @@
if node1 is not None and node1 != repo.changectx().node():
hgcmd = 'diff1'
- restrict = hgcmd in restricted.split()
- _kwtemplater = kwtemplater(ui, repo, inc, exc, restrict)
+ _kwtemplater = kwtemplater(ui, repo, inc, exc, hgcmd)
class kwrepo(repo.__class__):
def file(self, f, kwmatch=False):
@@ -598,7 +601,7 @@
def wread(self, filename):
data = super(kwrepo, self).wread(filename)
- if restrict and _kwtemplater.matcher(filename):
+ if _kwtemplater.restrict and _kwtemplater.matcher(filename):
return _kwtemplater.shrink(data)
return data