Show More
@@ -1,44 +1,41 b'' | |||||
1 |
# hg.py - |
|
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 sys, struct, os |
|
8 | import os, time | |
9 | import util |
|
|||
10 | from revlog import * |
|
9 | from revlog import * | |
11 | from demandload import * |
|
|||
12 | demandload(globals(), "time") |
|
|||
13 |
|
10 | |||
14 | class changelog(revlog): |
|
11 | class changelog(revlog): | |
15 | def __init__(self, opener): |
|
12 | def __init__(self, opener): | |
16 | revlog.__init__(self, opener, "00changelog.i", "00changelog.d") |
|
13 | revlog.__init__(self, opener, "00changelog.i", "00changelog.d") | |
17 |
|
14 | |||
18 | def extract(self, text): |
|
15 | def extract(self, text): | |
19 | if not text: |
|
16 | if not text: | |
20 | return (nullid, "", "0", [], "") |
|
17 | return (nullid, "", "0", [], "") | |
21 | last = text.index("\n\n") |
|
18 | last = text.index("\n\n") | |
22 | desc = text[last + 2:] |
|
19 | desc = text[last + 2:] | |
23 | l = text[:last].splitlines() |
|
20 | l = text[:last].splitlines() | |
24 | manifest = bin(l[0]) |
|
21 | manifest = bin(l[0]) | |
25 | user = l[1] |
|
22 | user = l[1] | |
26 | date = l[2] |
|
23 | date = l[2] | |
27 | if " " not in date: |
|
24 | if " " not in date: | |
28 | date += " 0" # some tools used -d without a timezone |
|
25 | date += " 0" # some tools used -d without a timezone | |
29 | files = l[3:] |
|
26 | files = l[3:] | |
30 | return (manifest, user, date, files, desc) |
|
27 | return (manifest, user, date, files, desc) | |
31 |
|
28 | |||
32 | def read(self, node): |
|
29 | def read(self, node): | |
33 | return self.extract(self.revision(node)) |
|
30 | return self.extract(self.revision(node)) | |
34 |
|
31 | |||
35 | def add(self, manifest, list, desc, transaction, p1=None, p2=None, |
|
32 | def add(self, manifest, list, desc, transaction, p1=None, p2=None, | |
36 | user=None, date=None): |
|
33 | user=None, date=None): | |
37 | if not date: |
|
34 | if not date: | |
38 | if time.daylight: offset = time.altzone |
|
35 | if time.daylight: offset = time.altzone | |
39 | else: offset = time.timezone |
|
36 | else: offset = time.timezone | |
40 | date = "%d %d" % (time.time(), offset) |
|
37 | date = "%d %d" % (time.time(), offset) | |
41 | list.sort() |
|
38 | list.sort() | |
42 | l = [hex(manifest), user, date] + list + ["", desc] |
|
39 | l = [hex(manifest), user, date] + list + ["", desc] | |
43 | text = "\n".join(l) |
|
40 | text = "\n".join(l) | |
44 | return self.addrevision(text, transaction, self.count(), p1, p2) |
|
41 | return self.addrevision(text, transaction, self.count(), p1, p2) |
General Comments 0
You need to be logged in to leave comments.
Login now