changeset 46321:d32e7ed81f4f

persistent-nodemap: catch the right exception on python On Python 2, Missing file are IOError, not OSError, apparently. Differential Revision: https://phab.mercurial-scm.org/D9809
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 17 Jan 2021 19:22:30 +0100
parents ef771d329961
children 7c1367c0b5bc
files mercurial/revlogutils/nodemap.py tests/test-persistent-nodemap.t
diffstat 2 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py	Sun Jan 17 02:50:26 2021 -0500
+++ b/mercurial/revlogutils/nodemap.py	Sun Jan 17 19:22:30 2021 +0100
@@ -56,7 +56,7 @@
                 data = util.buffer(util.mmapread(fd, data_length))
             else:
                 data = fd.read(data_length)
-    except OSError as e:
+    except (IOError, OSError) as e:
         if e.errno == errno.ENOENT:
             return None
         else:
--- a/tests/test-persistent-nodemap.t	Sun Jan 17 02:50:26 2021 -0500
+++ b/tests/test-persistent-nodemap.t	Sun Jan 17 19:22:30 2021 +0100
@@ -374,6 +374,38 @@
   $ hg log -r "$OTHERNODE" -T '{rev}\n'
   5002
 
+missing data file
+-----------------
+
+  $ UUID=`hg debugnodemap --metadata| grep 'uid:' | \
+  > sed 's/uid: //'`
+  $ FILE=.hg/store/00changelog-"${UUID}".nd
+  $ mv $FILE ../tmp-data-file
+  $ cp .hg/store/00changelog.n ../tmp-docket
+
+mercurial don't crash
+
+  $ hg log -r .
+  changeset:   5002:b355ef8adce0
+  tag:         tip
+  parent:      4998:d918ad6d18d3
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     babar
+  
+  $ hg debugnodemap --metadata
+
+  $ hg debugupdatecache
+  $ hg debugnodemap --metadata
+  uid: * (glob)
+  tip-rev: 5002
+  tip-node: b355ef8adce0949b8bdf6afc72ca853740d65944
+  data-length: 121088
+  data-unused: 0
+  data-unused: 0.000%
+  $ mv ../tmp-data-file $FILE
+  $ mv ../tmp-docket .hg/store/00changelog.n
+
 Check transaction related property
 ==================================