[PATCH 1 of 2 V2] debuglocks: add tests

Yuya Nishihara yuya at tcha.org
Wed Nov 15 08:24:31 EST 2017


On Tue, 14 Nov 2017 12:22:23 -0500, Paul Morelle wrote:
> # 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

Thanks for adding extensive 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

Nit: Can you at least describe that this patch fixes a typo in early return?

> +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

Using sleep would make tests unstable. Instead, maybe we can test the
existence of the lock file?

  while [ ! -f path/to/lockfile ]; do
      sleep 0.5
  doen

> +  $ kill -INT %1
> +  $ wait

And I suspect this wouldn't work on Windows. Needs '#if no-windows'.


More information about the Mercurial-devel mailing list