# HG changeset patch # User Christian Ebert # Date 1267991983 -3600 # Node ID 13bb123ad8945a3653f67a3508f8c6c351edb0e3 # Parent 857f2f9bd67f1c99b5cb6ceb7cfcca9d5f0e1147 Remove spurious locks, improve handling of wlock - kwcommitctx is inside the wlock of repo.commit: no lock - _kwfwrite only needs wlock wlock outside try block, so we don't need to import lock.release _kwfwrite should even be safer that way, as we moved the status call inside the try-except block. Thanks to Benoit Boissinot for help. diff -r 857f2f9bd67f -r 13bb123ad894 hgkw/keyword.py --- a/hgkw/keyword.py Sun Mar 07 19:56:37 2010 +0100 +++ b/hgkw/keyword.py Sun Mar 07 20:59:43 2010 +0100 @@ -79,7 +79,6 @@ from mercurial import commands, cmdutil, dispatch, filelog, revlog, extensions from mercurial import patch, localrepo, templater, templatefilters, util, match from mercurial.hgweb import webcommands -from mercurial.lock import release from mercurial.node import nullid from mercurial.i18n import _ import re, shutil, tempfile @@ -264,17 +263,15 @@ if repo.dirstate.parents()[1] != nullid: raise util.Abort(_('outstanding uncommitted merge')) kwt = kwtools['templater'] - status = _status(ui, repo, kwt, *pats, **opts) - modified, added, removed, deleted, unknown, ignored, clean = status - if modified or added or removed or deleted: - raise util.Abort(_('outstanding uncommitted changes')) - wlock = lock = None + wlock = repo.wlock() try: - wlock = repo.wlock() - lock = repo.lock() + status = _status(ui, repo, kwt, *pats, **opts) + modified, added, removed, deleted, unknown, ignored, clean = status + if modified or added or removed or deleted: + raise util.Abort(_('outstanding uncommitted changes')) kwt.overwrite(None, expand, clean) finally: - release(lock, wlock) + wlock.release() def demo(ui, repo, *args, **opts): '''print [keywordmaps] configuration and an expansion example @@ -485,15 +482,9 @@ del self.commitctx def kwcommitctx(self, ctx, error=False): - wlock = lock = None - try: - wlock = self.wlock() - lock = self.lock() - n = super(kwrepo, self).commitctx(ctx, error) - kwt.overwrite(n, True, None) - return n - finally: - release(lock, wlock) + n = super(kwrepo, self).commitctx(ctx, error) + kwt.overwrite(n, True, None) + return n # monkeypatches def kwpatchfile_init(orig, self, ui, fname, opener,