Patchwork D10543: revlog: adjust rewrite_sidedata code to not delete existing revlog content

login
register
mail settings
Submitter phabricator
Date May 2, 2021, 1:29 p.m.
Message ID <differential-rev-PHID-DREV-fhsh3knfm3nfnwk42r6d-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48862/
State New
Headers show

Comments

phabricator - May 2, 2021, 1:29 p.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The "w+" file mode is deleting all the content of the opened file. Which is bad…
  
  This is not caught by the test because the test only check for a full, initial
  pull where not pre-existing content exists. So we need to fix our test coverage
  here.
  
  However they are another issue that prevent "incremental" pull to work here. See
  next changeset for details.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -3247,7 +3247,7 @@ 
                 current_offset += len(serialized_sidedata)
 
         # rewrite the new index entries
-        with self._indexfp(b'w+') as fp:
+        with self._indexfp(b'r+') as fp:
             fp.seek(startrev * self.index.entry_size)
             for i, e in enumerate(new_entries):
                 rev = startrev + i