D6185: changelog: pass default extras into decodeextra()

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Sat Apr 13 18:17:05 EDT 2019


martinvonz updated this revision to Diff 14735.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6185?vs=14626&id=14735

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

AFFECTED FILES
  mercurial/changelog.py

CHANGE DETAILS

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -54,18 +54,18 @@
         text = text.replace('\n', '')
     return stringutil.unescapestr(text)
 
-def decodeextra(text):
+def decodeextra(text, default):
     """
     >>> from .pycompat import bytechr as chr
-    >>> sorted(decodeextra(encodeextra({b'foo': b'bar', b'baz': chr(0) + b'2'})
-    ...                    ).items())
+    >>> sorted(decodeextra(encodeextra({b'foo': b'bar', b'baz': chr(0) + b'2'}),
+    ...                    _defaultextra).items())
     [('baz', '\\x002'), ('branch', 'default'), ('foo', 'bar')]
     >>> sorted(decodeextra(encodeextra({b'foo': b'bar',
-    ...                                 b'baz': chr(92) + chr(0) + b'2'})
-    ...                    ).items())
+    ...                                 b'baz': chr(92) + chr(0) + b'2'}),
+    ...                    _defaultextra).items())
     [('baz', '\\\\\\x002'), ('branch', 'default'), ('foo', 'bar')]
     """
-    extra = _defaultextra.copy()
+    extra = default.copy()
     for l in text.split('\0'):
         if l:
             k, v = _string_unescape(l).split(':', 1)
@@ -275,7 +275,7 @@
         if raw is None:
             return _defaultextra
 
-        return decodeextra(raw)
+        return decodeextra(raw, _defaultextra)
 
     @property
     def files(self):



To: martinvonz, #hg-reviewers
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list