[PATCH 1 of 2 V2] debuglocks: add tests
Paul Morelle
paul.morelle at octobus.net
Tue Nov 14 17:22:23 UTC 2017
# HG changeset patch
# User Paul Morelle <paul.morelle at octobus.net>
# Date 1510497259 -3600
# Sun Nov 12 15:34:19 2017 +0100
# Node ID b26aa142783235cddc7c90f2425aac53fbb612da
# Parent 602c168c0207c443ac61f7a7c727b31cfb0b86ad
# EXP-Topic debugsetlocks
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b26aa1427832
debuglocks: add tests
diff -r 602c168c0207 -r b26aa1427832 mercurial/debugcommands.py
--- a/mercurial/debugcommands.py Tue Nov 07 13:18:49 2017 -0500
+++ b/mercurial/debugcommands.py Sun Nov 12 15:34:19 2017 +0100
@@ -1200,7 +1200,7 @@
repo.svfs.unlink('lock')
if opts.get(r'force_wlock'):
repo.vfs.unlink('wlock')
- if opts.get(r'force_lock') or opts.get(r'force_lock'):
+ if opts.get(r'force_lock') or opts.get(r'force_wlock'):
return 0
now = time.time()
diff -r 602c168c0207 -r b26aa1427832 tests/test-debugcommands.t
--- a/tests/test-debugcommands.t Tue Nov 07 13:18:49 2017 -0500
+++ b/tests/test-debugcommands.t Sun Nov 12 15:34:19 2017 +0100
@@ -111,6 +111,126 @@
7 6 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 2 (glob)
8 7 -1 ??? ??? ??? ??? ??? 0 ??? ???? ? 1 3 (glob)
+Test debuglocks command:
+
+ $ hg debuglocks
+ lock: free
+ wlock: free
+
+* Test setting the lock
+
+ $ python <<EOF &
+ > from mercurial import hg, ui as uimod
+ > import time
+ >
+ > repo = hg.repository(uimod.ui.load(), path='$(pwd)')
+ > with repo.lock(False):
+ > time.sleep(1)
+ > EOF
+ $ sleep 0.5
+
+ $ hg debuglocks
+ lock: user *, process *, host * (*s) (glob)
+ wlock: free
+ [1]
+ $ kill -INT %1
+ $ wait
+
+* Test setting the wlock
+
+ $ python <<EOF &
+ > from mercurial import hg, ui as uimod
+ > import time
+ >
+ > repo = hg.repository(uimod.ui.load(), path='$(pwd)')
+ > with repo.wlock(False):
+ > time.sleep(1)
+ > EOF
+ $ sleep 0.5
+
+ $ hg debuglocks
+ lock: free
+ wlock: user *, process *, host * (*s) (glob)
+ [1]
+ $ kill -INT %1
+ $ wait
+
+* Test setting both locks
+
+ $ python <<EOF &
+ > from mercurial import hg, ui as uimod
+ > import time
+ >
+ > repo = hg.repository(uimod.ui.load(), path='$(pwd)')
+ > with repo.wlock(False):
+ > with repo.lock(False):
+ > time.sleep(1)
+ > EOF
+ $ sleep 0.5
+
+ $ hg debuglocks
+ lock: user *, process *, host * (*s) (glob)
+ wlock: user *, process *, host * (*s) (glob)
+ [2]
+ $ kill -INT %1
+ $ wait
+
+ $ hg debuglocks
+ lock: free
+ wlock: free
+
+* Test forcing the lock
+
+ $ python <<EOF &
+ > from mercurial import hg, ui as uimod
+ > import time
+ >
+ > repo = hg.repository(uimod.ui.load(), path='$(pwd)')
+ > with repo.lock(False):
+ > time.sleep(1)
+ > EOF
+ $ sleep 0.5
+
+ $ hg debuglocks
+ lock: user *, process *, host * (*s) (glob)
+ wlock: free
+ [1]
+
+ $ hg debuglocks -L
+
+ $ hg debuglocks
+ lock: free
+ wlock: free
+
+ $ kill -INT %1
+ $ wait
+
+* Test forcing the wlock
+
+ $ python <<EOF &
+ > from mercurial import hg, ui as uimod
+ > import time
+ >
+ > repo = hg.repository(uimod.ui.load(), path='$(pwd)')
+ > with repo.wlock(False):
+ > time.sleep(1)
+ > EOF
+ $ sleep 0.5
+
+ $ hg debuglocks
+ lock: free
+ wlock: user *, process *, host * (*s) (glob)
+ [1]
+
+ $ hg debuglocks -W
+
+ $ hg debuglocks
+ lock: free
+ wlock: free
+
+ $ kill -INT %1
+ $ wait
+
Test WdirUnsupported exception
$ hg debugdata -c ffffffffffffffffffffffffffffffffffffffff
More information about the Mercurial-devel
mailing list