Patchwork D7891: nodemap: write new data from the expected current data length

login
register
mail settings
Submitter phabricator
Date Jan. 15, 2020, 2:58 p.m.
Message ID <differential-rev-PHID-DREV-vlc25ab7nrtmmp3qyq52-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44379/
State Superseded
Headers show

Comments

phabricator - Jan. 15, 2020, 2:58 p.m.
marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If the amount of data in the file exceed the expect amount, we will overwrite
  the extra data. This is a simple way to be safer.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -92,7 +92,8 @@ 
             datafile = _rawdata_filepath(revlog, target_docket)
             # EXP-TODO: if this is a cache, this should use a cache vfs, not a
             # store vfs
-            with revlog.opener(datafile, 'a') as fd:
+            with revlog.opener(datafile, 'r+') as fd:
+                fd.seek(target_docket.data_length)
                 fd.write(data)
             target_docket.data_length += len(data)
             target_docket.data_unused += data_changed_count