##// END OF EJS Templates
commands: make commit acquire locks before processing (issue4368)...
FUJIWARA Katsunori -
r27192:a01d3d32 default
parent child Browse files
Show More
@@ -1576,6 +1576,15 b' def commit(ui, repo, *pats, **opts):'
1576
1576
1577 Returns 0 on success, 1 if nothing changed.
1577 Returns 0 on success, 1 if nothing changed.
1578 """
1578 """
1579 wlock = lock = None
1580 try:
1581 wlock = repo.wlock()
1582 lock = repo.lock()
1583 return _docommit(ui, repo, *pats, **opts)
1584 finally:
1585 release(lock, wlock)
1586
1587 def _docommit(ui, repo, *pats, **opts):
1579 if opts.get('interactive'):
1588 if opts.get('interactive'):
1580 opts.pop('interactive')
1589 opts.pop('interactive')
1581 cmdutil.dorecord(ui, repo, commit, None, False,
1590 cmdutil.dorecord(ui, repo, commit, None, False,
@@ -205,7 +205,7 b' Aborting lock does not prevent fncache w'
205 $ cat > exceptionext.py <<EOF
205 $ cat > exceptionext.py <<EOF
206 > import os
206 > import os
207 > from mercurial import commands, error
207 > from mercurial import commands, error
208 > from mercurial.extensions import wrapfunction
208 > from mercurial.extensions import wrapcommand, wrapfunction
209 >
209 >
210 > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
210 > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
211 > def releasewrap():
211 > def releasewrap():
@@ -219,6 +219,22 b' Aborting lock does not prevent fncache w'
219 >
219 >
220 > cmdtable = {}
220 > cmdtable = {}
221 >
221 >
222 > # wrap "commit" command to prevent wlock from being '__del__()'-ed
223 > # at the end of dispatching (for intentional "forced lcok failure")
224 > def commitwrap(orig, ui, repo, *pats, **opts):
225 > repo = repo.unfiltered() # to use replaced repo._lock certainly
226 > wlock = repo.wlock()
227 > try:
228 > return orig(ui, repo, *pats, **opts)
229 > finally:
230 > # multiple 'relase()' is needed for complete releasing wlock,
231 > # because "forced" abort at last releasing store lock
232 > # prevents wlock from being released at same 'lockmod.release()'
233 > for i in range(wlock.held):
234 > wlock.release()
235 >
236 > def extsetup(ui):
237 > wrapcommand(commands.table, "commit", commitwrap)
222 > EOF
238 > EOF
223 $ extpath=`pwd`/exceptionext.py
239 $ extpath=`pwd`/exceptionext.py
224 $ hg init fncachetxn
240 $ hg init fncachetxn
@@ -81,10 +81,10 b' pretxncommit and commit hooks can see bo'
81 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
81 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
82 2:ee9deb46ab31
82 2:ee9deb46ab31
83 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
83 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
84 created new head
84 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
85 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
85 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
86 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
86 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
87 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
87 created new head
88 $ hg merge 1
88 $ hg merge 1
89 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
89 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
90 (branch merge, don't forget to commit)
90 (branch merge, don't forget to commit)
@@ -563,9 +563,9 b' make sure --traceback works'
563 foo
563 foo
564 committing manifest
564 committing manifest
565 committing changelog
565 committing changelog
566 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
566 calling hook commit.auto: hgext_hookext.autohook
567 calling hook commit.auto: hgext_hookext.autohook
567 Automatically installed hook
568 Automatically installed hook
568 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
569
569
570 $ hg showconfig hooks
570 $ hg showconfig hooks
571 hooks.commit.auto=<function autohook at *> (glob)
571 hooks.commit.auto=<function autohook at *> (glob)
@@ -141,8 +141,8 b' Commit with several checks'
141 committing manifest
141 committing manifest
142 committing changelog
142 committing changelog
143 overwriting a expanding keywords
143 overwriting a expanding keywords
144 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
144 running hook commit.test: cp a hooktest
145 running hook commit.test: cp a hooktest
145 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
146 $ hg status
146 $ hg status
147 ? hooktest
147 ? hooktest
148 $ hg debugrebuildstate
148 $ hg debugrebuildstate
General Comments 0
You need to be logged in to leave comments. Login now