Show More
@@ -1,47 +1,50 | |||||
1 | # changelog.py - changelog class for mercurial |
|
1 | # changelog.py - changelog class for mercurial | |
2 | # |
|
2 | # | |
3 | # Copyright 2005 Matt Mackall <mpm@selenic.com> |
|
3 | # Copyright 2005 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 | import os, time |
|
8 | import os, time | |
9 | from revlog import * |
|
9 | from revlog import * | |
10 |
|
10 | |||
11 | class changelog(revlog): |
|
11 | class changelog(revlog): | |
12 | def __init__(self, opener): |
|
12 | def __init__(self, opener): | |
13 | revlog.__init__(self, opener, "00changelog.i", "00changelog.d") |
|
13 | revlog.__init__(self, opener, "00changelog.i", "00changelog.d") | |
14 |
|
14 | |||
15 | def extract(self, text): |
|
15 | def extract(self, text): | |
16 | if not text: |
|
16 | if not text: | |
17 | return (nullid, "", "0", [], "") |
|
17 | return (nullid, "", "0", [], "") | |
18 | last = text.index("\n\n") |
|
18 | last = text.index("\n\n") | |
19 | desc = text[last + 2:] |
|
19 | desc = text[last + 2:] | |
20 | l = text[:last].splitlines() |
|
20 | l = text[:last].splitlines() | |
21 | manifest = bin(l[0]) |
|
21 | manifest = bin(l[0]) | |
22 | user = l[1] |
|
22 | user = l[1] | |
23 | date = l[2] |
|
23 | date = l[2] | |
24 | if " " not in date: |
|
24 | if " " not in date: | |
25 | date += " 0" # some tools used -d without a timezone |
|
25 | date += " 0" # some tools used -d without a timezone | |
26 | files = l[3:] |
|
26 | files = l[3:] | |
27 | return (manifest, user, date, files, desc) |
|
27 | return (manifest, user, date, files, desc) | |
28 |
|
28 | |||
29 | def read(self, node): |
|
29 | def read(self, node): | |
30 | return self.extract(self.revision(node)) |
|
30 | return self.extract(self.revision(node)) | |
31 |
|
31 | |||
32 | def add(self, manifest, list, desc, transaction, p1=None, p2=None, |
|
32 | def add(self, manifest, list, desc, transaction, p1=None, p2=None, | |
33 | user=None, date=None): |
|
33 | user=None, date=None): | |
34 | if date: |
|
34 | if date: | |
35 | # validate explicit (probably user-specified) date and |
|
35 | # validate explicit (probably user-specified) date and | |
36 | # time zone offset |
|
36 | # time zone offset. values must fit in signed 32 bits for | |
|
37 | # current 32-bit linux runtimes. | |||
37 | when, offset = map(int, date.split(' ')) |
|
38 | when, offset = map(int, date.split(' ')) | |
38 | time.localtime(when) |
|
39 | if abs(when) > 0x7fffffff: | |
39 | assert abs(offset) < 43200, 'bad time zone offset: %d' % offset |
|
40 | raise ValueError('date exceeds 32 bits: %d' % when) | |
|
41 | if abs(offset) >= 43200: | |||
|
42 | raise ValueError('impossible time zone offset: %d' % offset) | |||
40 | else: |
|
43 | else: | |
41 | if time.daylight: offset = time.altzone |
|
44 | if time.daylight: offset = time.altzone | |
42 | else: offset = time.timezone |
|
45 | else: offset = time.timezone | |
43 | date = "%d %d" % (time.time(), offset) |
|
46 | date = "%d %d" % (time.time(), offset) | |
44 | list.sort() |
|
47 | list.sort() | |
45 | l = [hex(manifest), user, date] + list + ["", desc] |
|
48 | l = [hex(manifest), user, date] + list + ["", desc] | |
46 | text = "\n".join(l) |
|
49 | text = "\n".join(l) | |
47 | return self.addrevision(text, transaction, self.count(), p1, p2) |
|
50 | return self.addrevision(text, transaction, self.count(), p1, p2) |
General Comments 0
You need to be logged in to leave comments.
Login now