[PATCH 5 of 5] keyword: disable expansion in kwfilelog.read() if file renamed in node

Christian Ebert blacktrash at gmx.net
Fri Oct 1 11:35:24 CDT 2010


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1285950917 -7200
# Node ID c28dd8e2bbc58dc6d5c549b09ed3a335e59c0ede
# Parent  76eefe6fd45e8172f5b7d9a4ca216ef061ed60a6
keyword: disable expansion in kwfilelog.read() if file renamed in node

Simplifies kwfilelog.cmp() and avoids fiddling with/importing revlog.

Reorder imports alphabetically.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -82,8 +82,8 @@
 {desc}" expands to the first line of the changeset description.
 '''
 
-from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions
-from mercurial import patch, localrepo, templater, templatefilters, util, match
+from mercurial import commands, cmdutil, dispatch, filelog, extensions
+from mercurial import localrepo, match, patch, templatefilters, templater, util
 from mercurial.hgweb import webcommands
 from mercurial.i18n import _
 import re, shutil, tempfile
@@ -266,6 +266,8 @@
     def read(self, node):
         '''Expands keywords when reading filelog.'''
         data = super(kwfilelog, self).read(node)
+        if self.renamed(node):
+            return data
         return self.kwt.expand(self.path, node, data)
 
     def add(self, text, meta, tr, link, p1=None, p2=None):
@@ -276,10 +278,7 @@
     def cmp(self, node, text):
         '''Removes keyword substitutions for comparison.'''
         text = self.kwt.shrink(self.path, text)
-        if self.renamed(node):
-            t2 = super(kwfilelog, self).read(node)
-            return t2 != text
-        return revlog.revlog.cmp(self, node, text)
+        return super(kwfilelog, self).cmp(node, text)
 
 def _status(ui, repo, kwt, *pats, **opts):
     '''Bails out if [keyword] configuration is not active.


More information about the Mercurial-devel mailing list