Patchwork D10609: revlog: use `_writing` in `rewrite_sidedata`

login
register
mail settings
Submitter phabricator
Date May 3, 2021, 12:07 p.m.
Message ID <differential-rev-PHID-DREV-mgeixtgz4d23egmmu2ww-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48928/
State New
Headers show

Comments

phabricator - May 3, 2021, 12:07 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
  Special cases aren't special enough to break the rules.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -3157,8 +3157,8 @@ 
 
         new_entries = []
         # append the new sidedata
-        with self._datafp(b'a+') as dfh:
-            # Maybe this bug still exists, see revlog._writeentry
+        with self._writing(transaction):
+            ifh, dfh = self._writinghandles
             dfh.seek(0, os.SEEK_END)
             current_offset = dfh.tell()
             for rev in range(startrev, endrev + 1):
@@ -3192,9 +3192,8 @@ 
                 new_entries.append(entry)
                 current_offset += len(serialized_sidedata)
 
-        # rewrite the new index entries
-        with self._indexfp(b'r+') as ifh:
-            fp.seek(startrev * self.index.entry_size)
+            # rewrite the new index entries
+            ifh.seek(startrev * self.index.entry_size)
             for i, e in enumerate(new_entries):
                 rev = startrev + i
                 self.index.replace_sidedata_info(rev, e[8], e[9], e[0])