##// END OF EJS Templates
[extendedchangelog] add extra metadata in the changelog entry...
Benoit Boissinot -
r3233:2f359618 default
parent child Browse files
Show More
@@ -32,41 +32,69 b' class changelog(revlog):'
32 32 revlog.__init__(self, opener, "00changelog.i", "00changelog.d",
33 33 defversion)
34 34
35 def decode_extra(self, text):
36 extra = {}
37 for l in text.split('\0'):
38 if not l:
39 continue
40 k, v = _string_unescape(l).split(':', 1)
41 extra[k] = v
42 return extra
43
44 def encode_extra(self, d):
45 items = [_string_escape(":".join(t)) for t in d.iteritems()]
46 return "\0".join(items)
47
35 48 def extract(self, text):
36 49 """
37 50 format used:
38 51 nodeid\n : manifest node in ascii
39 52 user\n : user, no \n or \r allowed
40 time tz\n : date (time is int or float, timezone is int)
53 time tz extra\n : date (time is int or float, timezone is int)
54 : extra is metadatas, encoded and separated by '\0'
55 : older versions ignore it
41 56 files\n\n : files modified by the cset, no \n or \r allowed
42 57 (.*) : comment (free text, ideally utf-8)
58
59 changelog v0 doesn't use extra
43 60 """
44 61 if not text:
45 62 return (nullid, "", (0, 0), [], "")
46 63 last = text.index("\n\n")
47 64 desc = text[last + 2:]
48 l = text[:last].splitlines()
65 l = text[:last].split('\n')
49 66 manifest = bin(l[0])
50 67 user = l[1]
51 date = l[2].split(' ')
52 time = float(date.pop(0))
68
69 extra_data = l[2].split(' ', 2)
70 if len(extra_data) != 3:
71 time = float(extra_data.pop(0))
53 72 try:
54 73 # various tools did silly things with the time zone field.
55 timezone = int(date[0])
74 timezone = int(extra_data[0])
56 75 except:
57 76 timezone = 0
77 extra = {}
78 else:
79 time, timezone, extra = extra_data
80 time, timezone = float(time), int(timezone)
81 extra = self.decode_extra(extra)
58 82 files = l[3:]
59 return (manifest, user, (time, timezone), files, desc)
83 return (manifest, user, (time, timezone), files, desc, extra)
60 84
61 85 def read(self, node):
62 86 return self.extract(self.revision(node))
63 87
64 88 def add(self, manifest, list, desc, transaction, p1=None, p2=None,
65 user=None, date=None):
89 user=None, date=None, extra={}):
90
66 91 if date:
67 92 parseddate = "%d %d" % util.parsedate(date)
68 93 else:
69 94 parseddate = "%d %d" % util.makedate()
95 if extra:
96 extra = self.encode_extra(extra)
97 parseddate = "%s %s" % (parseddate, extra)
70 98 list.sort()
71 99 l = [hex(manifest), user, parseddate] + list + ["", desc]
72 100 text = "\n".join(l)
General Comments 0
You need to be logged in to leave comments. Login now