[PATCH 2 of 2 V2] debuglocks: allow setting a lock

Yuya Nishihara yuya at tcha.org
Wed Nov 15 08:27:14 EST 2017


On Tue, 14 Nov 2017 12:22:24 -0500, Paul Morelle wrote:
> # HG changeset patch
> # User Paul Morelle <paul.morelle at octobus.net>
> # Date 1510497286 -3600
> #      Sun Nov 12 15:34:46 2017 +0100
> # Node ID 61cf7ffd84b89889cbf6bbc2af13cdd67ba2d9f9
> # Parent  b26aa142783235cddc7c90f2425aac53fbb612da
> # EXP-Topic debugsetlocks
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 61cf7ffd84b8
> debuglocks: allow setting a lock
> 
> diff -r b26aa1427832 -r 61cf7ffd84b8 mercurial/debugcommands.py
> --- a/mercurial/debugcommands.py	Sun Nov 12 15:34:19 2017 +0100
> +++ b/mercurial/debugcommands.py	Sun Nov 12 15:34:46 2017 +0100
> @@ -14,6 +14,7 @@
>  import operator
>  import os
>  import random
> +import signal
>  import socket
>  import ssl
>  import string
> @@ -1173,7 +1174,10 @@
>  @command('debuglocks',
>           [('L', 'force-lock', None, _('free the store lock (DANGEROUS)')),
>            ('W', 'force-wlock', None,
> -           _('free the working state lock (DANGEROUS)'))],
> +           _('free the working state lock (DANGEROUS)')),
> +          ('s', 'set-lock', None, _('set the store lock until stopped')),
> +          ('S', 'set-wlock', None,
> +           _('set the working state lock until stopped'))],
>           _('[OPTION]...'))
>  def debuglocks(ui, repo, **opts):
>      """show or modify state of locks
> @@ -1192,6 +1196,10 @@
>      instance, on a shared filesystem). Removing locks may also be
>      blocked by filesystem permissions.
>  
> +    Setting a lock will prevent other commands from changing the data.
> +    The command will wait until an interruption (SIGINT, SIGTERM, ...) occurs.
> +    The set locks are removed when the command exits.
> +
>      Returns 0 if no locks are held.
>  
>      """
> @@ -1203,6 +1211,29 @@
>      if opts.get(r'force_lock') or opts.get(r'force_wlock'):
>          return 0
>  
> +    # Ensure that SIGINT wouldn't be ignored
> +    # see https://unix.stackexchange.com/a/372580
> +    if not pycompat.iswindows:
> +        signal.signal(signal.SIGINT, signal.SIG_DFL)

No. SIG_DFL means the signal won't be caught by Python and the process will
be killed. No lock won't be released.


More information about the Mercurial-devel mailing list