tags: do not abort if failed to write lock file to save cache stable
authorYuya Nishihara <yuya@tcha.org>
Fri, 17 Apr 2015 23:22:58 +0900
branchstable
changeset 24806 61aea11fb83d
parent 24805 82fe57213029
child 24807 fff8b779e63a
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
mercurial/tags.py
tests/test-tags.t
--- a/mercurial/tags.py	Thu Apr 16 20:58:41 2015 -0500
+++ b/mercurial/tags.py	Fri Apr 17 23:22:58 2015 +0900
@@ -502,9 +502,9 @@
 
         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
 
--- a/tests/test-tags.t	Thu Apr 16 20:58:41 2015 -0500
+++ b/tests/test-tags.t	Fri Apr 17 23:22:58 2015 +0900
@@ -114,7 +114,7 @@
   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 @@
   $ 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 @@
   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)