[PATCH 2 of 4] keyword: don't delete possible wrappers for commictx() (see issue2254)

Dan Villiom Podlaski Christiansen danchr at gmail.com
Wed Jul 7 05:18:49 CDT 2010


# HG changeset patch
# User Dan Villiom Podlaski Christiansen <danchr at gmail.com>
# Date 1278497440 -7200
# Node ID 94f7469435b28e867861e0edd8da8dcccfd2e67e
# Parent  a571e430eaff35810fe174bee31abd0b984a12fb
keyword: don't delete possible wrappers for commictx() (see issue2254)

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -476,6 +476,9 @@ def reposetup(ui, repo):
     kwtools['templater'] = kwt = kwtemplater(ui, repo)
 
     class kwrepo(repo.__class__):
+        def _initkeyword(self):
+            self.__committing = False
+
         def file(self, f):
             if f[0] == '/':
                 f = f[1:]
@@ -486,18 +489,19 @@ def reposetup(ui, repo):
             return kwt.wread(filename, data)
 
         def commit(self, *args, **opts):
-            # use custom commitctx for user commands
-            # other extensions can still wrap repo.commitctx directly
-            self.commitctx = self.kwcommitctx
+            # enable commitctx() wrapping
+            orig = self.__committing
+            self.__committing = True
             try:
                 return super(kwrepo, self).commit(*args, **opts)
             finally:
-                del self.commitctx
+                self.__committing = orig
 
-        def kwcommitctx(self, ctx, error=False):
+        def commitctx(self, ctx, error=False):
             n = super(kwrepo, self).commitctx(ctx, error)
-            # no lock needed, only called from repo.commit() which already locks
-            if not kwt.record:
+            # no lock needed, __committing ensures that this is only called from
+            # repo.commit() which already locks
+            if self.__committing and not kwt.record:
                 kwt.overwrite(self[n], sorted(ctx.added() + ctx.modified()),
                               False, True)
             return n
@@ -542,6 +546,7 @@ def reposetup(ui, repo):
             wlock.release()
 
     repo.__class__ = kwrepo
+    repo._initkeyword()
 
     extensions.wrapfunction(patch.patchfile, '__init__', kwpatchfile_init)
     if not kwt.restrict:


More information about the Mercurial-devel mailing list