##// END OF EJS Templates
changelog: turn {de,en}code_extra methods into functions...
Martin Geisler -
r8443:53ff4a5a default
parent child Browse files
Show More
@@ -23,6 +23,19 b' def _string_escape(text):'
23 text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r')
23 text = text.replace('\\', '\\\\').replace('\n', '\\n').replace('\r', '\\r')
24 return text.replace('\0', '\\0')
24 return text.replace('\0', '\\0')
25
25
26 def decodeextra(text):
27 extra = {}
28 for l in text.split('\0'):
29 if l:
30 k, v = l.decode('string_escape').split(':', 1)
31 extra[k] = v
32 return extra
33
34 def encodeextra(d):
35 # keys must be sorted to produce a deterministic changelog entry
36 items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)]
37 return "\0".join(items)
38
26 class appender:
39 class appender:
27 '''the changelog index must be updated last on disk, so we use this class
40 '''the changelog index must be updated last on disk, so we use this class
28 to delay writes to it'''
41 to delay writes to it'''
@@ -145,19 +158,6 b' class changelog(revlog.revlog):'
145 return
158 return
146 return revlog.revlog.checkinlinesize(self, tr, fp)
159 return revlog.revlog.checkinlinesize(self, tr, fp)
147
160
148 def decode_extra(self, text):
149 extra = {}
150 for l in text.split('\0'):
151 if l:
152 k, v = l.decode('string_escape').split(':', 1)
153 extra[k] = v
154 return extra
155
156 def encode_extra(self, d):
157 # keys must be sorted to produce a deterministic changelog entry
158 items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)]
159 return "\0".join(items)
160
161 def read(self, node):
161 def read(self, node):
162 """
162 """
163 format used:
163 format used:
@@ -192,7 +192,7 b' class changelog(revlog.revlog):'
192 else:
192 else:
193 time, timezone, extra = extra_data
193 time, timezone, extra = extra_data
194 time, timezone = float(time), int(timezone)
194 time, timezone = float(time), int(timezone)
195 extra = self.decode_extra(extra)
195 extra = decodeextra(extra)
196 if not extra.get('branch'):
196 if not extra.get('branch'):
197 extra['branch'] = 'default'
197 extra['branch'] = 'default'
198 files = l[3:]
198 files = l[3:]
@@ -218,7 +218,7 b' class changelog(revlog.revlog):'
218 if extra and extra.get("branch") in ("default", ""):
218 if extra and extra.get("branch") in ("default", ""):
219 del extra["branch"]
219 del extra["branch"]
220 if extra:
220 if extra:
221 extra = self.encode_extra(extra)
221 extra = encodeextra(extra)
222 parseddate = "%s %s" % (parseddate, extra)
222 parseddate = "%s %s" % (parseddate, extra)
223 l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
223 l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
224 text = "\n".join(l)
224 text = "\n".join(l)
General Comments 0
You need to be logged in to leave comments. Login now