[Commented On] D9809: persistent-nodemap: catch the right exception on python

baymax (Baymax, Your Personal Patch-care Companion) phabricator at mercurial-scm.org
Sun Jan 17 20:46:24 UTC 2021


baymax added a comment.
baymax updated this revision to Diff 25087.


  ✅ refresh by Heptapod after a successful CI run (🐙 💚)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D9809?vs=25085&id=25087

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D9809/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D9809

AFFECTED FILES
  mercurial/revlogutils/nodemap.py
  tests/test-persistent-nodemap.t

CHANGE DETAILS

diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -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
 ==================================
 
diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -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:



To: marmoute, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210117/9eeec64e/attachment-0002.html>


More information about the Mercurial-patches mailing list