Patchwork [STABLE] tags: do not abort if failed to write lock file to save cache

login
register
mail settings
Submitter Yuya Nishihara
Date April 17, 2015, 2:59 p.m.
Message ID <6dedda260a8f457f7a7b.1429282759@mimosa>
Download mbox | patch
Permalink /patch/8730/
State Accepted
Headers show

Comments

Yuya Nishihara - April 17, 2015, 2:59 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1429280578 -32400
#      Fri Apr 17 23:22:58 2015 +0900
# Branch stable
# Node ID 6dedda260a8f457f7a7b0d7b93fd1037d8c23557
# Parent  82fe5721302973f90b594239772a05f447c493aa
tags: do not abort if failed to write lock file to save cache

LockHeld wasn't enough to suppress error during acquiring lock. If .hg directory
is read-only, LockUnavailable will be raised.

  $ chmod ugo-w .hg
  $ hg identify
  abort: could not lock working directory of ...: Permission denied
Matt Mackall - April 17, 2015, 3:01 p.m.
On Fri, 2015-04-17 at 23:59 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1429280578 -32400
> #      Fri Apr 17 23:22:58 2015 +0900
> # Branch stable
> # Node ID 6dedda260a8f457f7a7b0d7b93fd1037d8c23557
> # Parent  82fe5721302973f90b594239772a05f447c493aa
> tags: do not abort if failed to write lock file to save cache

Queued for stable, thanks.

Patch

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -502,9 +502,9 @@  class hgtagsfnodescache(object):
 
         try:
             lock = repo.wlock(wait=False)
-        except error.LockHeld:
+        except error.LockError:
             repo.ui.log('tagscache',
-                        'not writing .hg/%s because lock held\n' %
+                        'not writing .hg/%s because lock cannot be acquired\n' %
                         (_fnodescachefile))
             return
 
diff --git a/tests/test-tags.t b/tests/test-tags.t
--- a/tests/test-tags.t
+++ b/tests/test-tags.t
@@ -114,7 +114,7 @@  Repeat with cold tag cache:
   0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
   0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
 
-And again, but now unable to write tag cache:
+And again, but now unable to write tag cache or lock file:
 
 #if unix-permissions
   $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
@@ -122,6 +122,11 @@  And again, but now unable to write tag c
   $ hg identify
   b9154636be93 tip
   $ chmod 755 .hg/cache
+
+  $ chmod 555 .hg
+  $ hg identify
+  b9154636be93 tip
+  $ chmod 755 .hg
 #endif
 
 Tag cache debug info written to blackbox log
@@ -144,7 +149,7 @@  Failure to acquire lock results in no wr
   b9154636be93 tip
   $ hg blackbox -l 5
   1970/01/01 00:00:00 bob> identify
-  1970/01/01 00:00:00 bob> not writing .hg/cache/hgtagsfnodes1 because lock held
+  1970/01/01 00:00:00 bob> not writing .hg/cache/hgtagsfnodes1 because lock cannot be acquired
   1970/01/01 00:00:00 bob> 0/1 cache hits/lookups in * seconds (glob)
   1970/01/01 00:00:00 bob> writing .hg/cache/tags2-visible with 1 tags
   1970/01/01 00:00:00 bob> identify exited 0 after * seconds (glob)