Patchwork D7831: changelog: fix the diverted opener to accept more kwargs

login
register
mail settings
Submitter phabricator
Date Jan. 11, 2020, 5:02 p.m.
Message ID <differential-rev-PHID-DREV-sv6trpcgduu33urvbz5s-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44256/
State Superseded
Headers show

Comments

phabricator - Jan. 11, 2020, 5:02 p.m.
marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The current code prevent the use of `atomictemp` file with the changelog
  opener. I do not see a good reason for this limitation.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/changelog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -167,10 +167,10 @@ 
 def _divertopener(opener, target):
     """build an opener that writes in 'target.a' instead of 'target'"""
 
-    def _divert(name, mode=b'r', checkambig=False):
+    def _divert(name, mode=b'r', checkambig=False, **kwargs):
         if name != target:
-            return opener(name, mode)
-        return opener(name + b".a", mode)
+            return opener(name, mode, **kwargs)
+        return opener(name + b".a", mode, **kwargs)
 
     return _divert
 
@@ -178,9 +178,10 @@ 
 def _delayopener(opener, target, buf):
     """build an opener that stores chunks in 'buf' instead of 'target'"""
 
-    def _delay(name, mode=b'r', checkambig=False):
+    def _delay(name, mode=b'r', checkambig=False, **kwargs):
         if name != target:
-            return opener(name, mode)
+            return opener(name, mode, **kwargs)
+        assert not kwargs
         return appender(opener, name, mode, buf)
 
     return _delay