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