##// END OF EJS Templates
document changelog format
Benoit Boissinot -
r3077:ad6aecaf default
parent child Browse files
Show More
@@ -1,48 +1,56 b''
1 1 # changelog.py - changelog class for mercurial
2 2 #
3 3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms
6 6 # of the GNU General Public License, incorporated herein by reference.
7 7
8 8 from revlog import *
9 9 from i18n import gettext as _
10 10 from demandload import demandload
11 11 demandload(globals(), "os time util")
12 12
13 13 class changelog(revlog):
14 14 def __init__(self, opener, defversion=REVLOGV0):
15 15 revlog.__init__(self, opener, "00changelog.i", "00changelog.d",
16 16 defversion)
17 17
18 18 def extract(self, text):
19 """
20 format used:
21 nodeid\n : manifest node in ascii
22 user\n : user, no \n or \r allowed
23 time tz\n : date (time is int or float, timezone is int)
24 files\n\n : files modified by the cset, no \n or \r allowed
25 (.*) : comment (free text, ideally utf-8)
26 """
19 27 if not text:
20 28 return (nullid, "", (0, 0), [], "")
21 29 last = text.index("\n\n")
22 30 desc = text[last + 2:]
23 31 l = text[:last].splitlines()
24 32 manifest = bin(l[0])
25 33 user = l[1]
26 34 date = l[2].split(' ')
27 35 time = float(date.pop(0))
28 36 try:
29 37 # various tools did silly things with the time zone field.
30 38 timezone = int(date[0])
31 39 except:
32 40 timezone = 0
33 41 files = l[3:]
34 42 return (manifest, user, (time, timezone), files, desc)
35 43
36 44 def read(self, node):
37 45 return self.extract(self.revision(node))
38 46
39 47 def add(self, manifest, list, desc, transaction, p1=None, p2=None,
40 48 user=None, date=None):
41 49 if date:
42 50 parseddate = "%d %d" % util.parsedate(date)
43 51 else:
44 52 parseddate = "%d %d" % util.makedate()
45 53 list.sort()
46 54 l = [hex(manifest), user, parseddate] + list + ["", desc]
47 55 text = "\n".join(l)
48 56 return self.addrevision(text, transaction, self.count(), p1, p2)
General Comments 0
You need to be logged in to leave comments. Login now