hgkw/keyword.py
branch0.9.2compat
changeset 366 b1105cc0982f
parent 360 ed06223f88fc
child 370 a8983fed9a9e
--- a/hgkw/keyword.py	Thu Jan 31 14:34:45 2008 +0100
+++ b/hgkw/keyword.py	Thu Jan 31 01:06:49 2008 +0100
@@ -100,6 +100,15 @@
 
 # backwards compatibility hacks
 
+try:
+    # templatefilters module introduced in 9f1e6ab76069
+    from mercurial import templatefilters
+    template_filters = templatefilters.filters
+    template_firstline = templatefilters.firstline
+except ImportError:
+    template_filters = templater.common_filters
+    template_firstline = templater.firstline
+
 def _normal(repo, files):
     '''Backwards compatible repo.dirstate.normal/update.'''
     # 6fd953d5faea introduced dirstate.normal()
@@ -109,12 +118,6 @@
     except AttributeError:
         repo.dirstate.update(files, 'n')
 
-def _link(repo, f):
-    try:
-        return repo._link(f)
-    except AttributeError:
-        return os.path.islink(repo.wjoin(f))
-
 def _pathto(repo, f, cwd=None):
     '''kwfiles behaves similar to status, using pathto since 78b6add1f966.'''
     try:
@@ -159,7 +162,7 @@
         kwpat = r'\$(%s)(: [^$\n\r]*? )??\$' % '|'.join(escaped)
         self.re_kw = re.compile(kwpat)
 
-        templater.common_filters['utcdate'] = utcdate
+        template_filters['utcdate'] = utcdate
         self.ct = self._changeset_templater()
 
     def _changeset_templater(self):
@@ -198,7 +201,8 @@
             self.ct.use_template(self.templates[kw])
             self.ui.pushbuffer()
             self.ct.show(changenode=node, root=self.repo.root, file=path)
-            return '$%s: %s $' % (kw, templater.firstline(self.ui.popbuffer()))
+            ekw = template_firstline(self.ui.popbuffer())
+            return '$%s: %s $' % (kw, ekw)
 
         return subfunc(kwsub, data)
 
@@ -412,7 +416,9 @@
     if opts.get('untracked'):
         files += unknown
     files.sort()
-    kwfiles = [f for f in files if not _link(repo, f) and repo._kwt.matcher(f)]
+    # use full def of repo._link for backwards compatibility
+    kwfiles = [f for f in files if
+               not os.path.islink(repo.wjoin(f)) and repo._kwt.matcher(f)]
     cwd = pats and repo.getcwd() or ''
     kwfstats = not opts.get('ignore') and (('K', kwfiles),) or ()
     if opts.get('all') or opts.get('ignore'):
@@ -435,7 +441,7 @@
 
 
 def reposetup(ui, repo):
-    if not repo.local():
+    if not repo.local() or repo.root.endswith('/.hg/patches'):
         return
 
     inc, exc = [], ['.hgtags', '.hg_archival.txt']