[PATCH 2 of 4] keyword: don't delete possible wrappers for commictx() (see issue2254)
Christian Ebert
blacktrash at gmx.net
Wed Jul 7 17:18:50 CDT 2010
* Dan Villiom Podlaski Christiansen on Wednesday, July 07, 2010 at 12:18:49 +0200
> # 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:
As this is still somehow way over my head, may I just say that
from a "pure keyword extension perspective" the following passes
test-keyword:
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -485,16 +485,7 @@
data = super(kwrepo, self).wread(filename)
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
- try:
- return super(kwrepo, self).commit(*args, **opts)
- finally:
- del self.commitctx
-
- 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:
Of course this looks much simpler to my simpleton eyes because
I don't know where else besides from within commit commitctx is
needed. Sorry if I overlooked something obvious.
c
--
theatre - books - texts - movies
Black Trash Productions at home: http://www.blacktrash.org/
Black Trash Productions on Facebook:
http://www.facebook.com/blacktrashproductions
More information about the Mercurial-devel
mailing list