summaryrefslogtreecommitdiff
path: root/mercurial/changelog.py
diff options
context:
space:
mode:
Diffstat (limited to 'mercurial/changelog.py')
-rw-r--r--mercurial/changelog.py38
1 files changed, 14 insertions, 24 deletions
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
index a3c6450..55e23c5 100644
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -9,8 +9,6 @@ from node import bin, hex, nullid
from i18n import _
import util, error, revlog, encoding
-_defaultextra = {'branch': 'default'}
-
def _string_escape(text):
"""
>>> d = {'nl': chr(10), 'bs': chr(92), 'cr': chr(13), 'nul': chr(0)}
@@ -26,20 +24,9 @@ def _string_escape(text):
return text.replace('\0', '\\0')
def decodeextra(text):
- """
- >>> decodeextra(encodeextra({'foo': 'bar', 'baz': chr(0) + '2'}))
- {'foo': 'bar', 'baz': '\\x002', 'branch': 'default'}
- >>> decodeextra(encodeextra({'foo': 'bar', 'baz': chr(92) + chr(0) + '2'}))
- {'foo': 'bar', 'baz': '\\\\\\x002', 'branch': 'default'}
- """
- extra = _defaultextra.copy()
+ extra = {}
for l in text.split('\0'):
if l:
- if '\\0' in l:
- # fix up \0 without getting into trouble with \\0
- l = l.replace('\\\\', '\\\\\n')
- l = l.replace('\\0', '\0')
- l = l.replace('\n', '')
k, v = l.decode('string_escape').split(':', 1)
extra[k] = v
return extra
@@ -120,6 +107,8 @@ class changelog(revlog.revlog):
self._realopener = opener
self._delayed = False
self._divert = False
+ # hiddenrevs: revs that should be hidden by command and tools
+ self.hiddenrevs = set()
def delayupdate(self):
"delay visibility of index updates to other readers"
@@ -151,7 +140,6 @@ class changelog(revlog.revlog):
r = revlog.revlog(self.opener, file)
self.index = r.index
self.nodemap = r.nodemap
- self._nodecache = r._nodecache
self._chunkcache = r._chunkcache
def writepending(self):
@@ -192,26 +180,28 @@ class changelog(revlog.revlog):
"""
text = self.revision(node)
if not text:
- return (nullid, "", (0, 0), [], "", _defaultextra)
+ return (nullid, "", (0, 0), [], "", {'branch': 'default'})
last = text.index("\n\n")
desc = encoding.tolocal(text[last + 2:])
l = text[:last].split('\n')
manifest = bin(l[0])
user = encoding.tolocal(l[1])
- tdata = l[2].split(' ', 2)
- if len(tdata) != 3:
- time = float(tdata[0])
+ extra_data = l[2].split(' ', 2)
+ if len(extra_data) != 3:
+ time = float(extra_data.pop(0))
try:
# various tools did silly things with the time zone field.
- timezone = int(tdata[1])
+ timezone = int(extra_data[0])
except ValueError:
timezone = 0
- extra = _defaultextra
+ extra = {}
else:
- time, timezone = float(tdata[0]), int(tdata[1])
- extra = decodeextra(tdata[2])
-
+ time, timezone, extra = extra_data
+ time, timezone = float(time), int(timezone)
+ extra = decodeextra(extra)
+ if not extra.get('branch'):
+ extra['branch'] = 'default'
files = l[3:]
return (manifest, user, (time, timezone), files, desc, extra)