diff --git a/mercurial/tags.py b/mercurial/tags.py --- a/mercurial/tags.py +++ b/mercurial/tags.py @@ -301,7 +301,10 @@ def _readtagcache(ui, repo): 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 diff --git a/tests/test-tags b/tests/test-tags --- a/tests/test-tags +++ b/tests/test-tags @@ -37,9 +37,17 @@ hg tags 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 diff --git a/tests/test-tags.out b/tests/test-tags.out --- a/tests/test-tags.out +++ b/tests/test-tags.out @@ -13,6 +13,9 @@ acb14030fe0a21b60322c440ad2d20cf7685a376 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