tags: don't crash if unable to write tag cache
This happens with hgweb in real life, if the httpd user is unable to
write in the repository directory. Another case is doing 'hg incoming'
on a repository in the filesystem owned by someone else.
--- a/mercurial/tags.py Wed Aug 19 12:51:07 2009 +0200
+++ b/mercurial/tags.py Tue Aug 18 22:07:43 2009 -0400
@@ -301,7 +301,10 @@
def _writetagcache(ui, repo, heads, tagfnode, cachetags):
- cachefile = repo.opener('tags.cache', 'w', atomictemp=True)
+ try:
+ cachefile = repo.opener('tags.cache', 'w', atomictemp=True)
+ except (OSError, IOError):
+ return
_debug(ui, 'writing cache file %s\n' % cachefile.name)
realheads = repo.heads() # for sanity checks below
--- a/tests/test-tags Wed Aug 19 12:51:07 2009 +0200
+++ b/tests/test-tags Tue Aug 18 22:07:43 2009 -0400
@@ -37,9 +37,17 @@
hg identify
# repeat with cold tag cache
+echo "% identify with cold cache"
rm -f .hg/tags.cache
hg identify
+# and again, but now unable to write tag cache
+echo "% identify with unwritable cache"
+rm -f .hg/tags.cache
+chmod 555 .hg
+hg identify
+chmod 755 .hg
+
echo "% create a branch"
echo bb > a
hg status
--- a/tests/test-tags.out Wed Aug 19 12:51:07 2009 +0200
+++ b/tests/test-tags.out Tue Aug 18 22:07:43 2009 -0400
@@ -13,6 +13,9 @@
tip 1:b9154636be93
first 0:acb14030fe0a
b9154636be93 tip
+% identify with cold cache
+b9154636be93 tip
+% identify with unwritable cache
b9154636be93 tip
% create a branch
M a