Mercurial > hg
comparison mercurial/changelog.py @ 1089:142b5d5ec9cc
Break apart hg.py
- move the various parts of hg.py into their own files
- create node.py to store node manipulation functions
author | mpm@selenic.com |
---|---|
date | Sat, 27 Aug 2005 14:21:25 -0700 |
parents | mercurial/hg.py@05dc7aba22eb |
children | 0a18374c0769 |
comparison
equal
deleted
inserted
replaced
1088:39b916b1d8e4 | 1089:142b5d5ec9cc |
---|---|
1 # hg.py - repository classes for mercurial | |
2 # | |
3 # Copyright 2005 Matt Mackall <mpm@selenic.com> | |
4 # | |
5 # This software may be used and distributed according to the terms | |
6 # of the GNU General Public License, incorporated herein by reference. | |
7 | |
8 import sys, struct, os | |
9 import util | |
10 from revlog import * | |
11 from demandload import * | |
12 demandload(globals(), "time") | |
13 | |
14 class changelog(revlog): | |
15 def __init__(self, opener): | |
16 revlog.__init__(self, opener, "00changelog.i", "00changelog.d") | |
17 | |
18 def extract(self, text): | |
19 if not text: | |
20 return (nullid, "", "0", [], "") | |
21 last = text.index("\n\n") | |
22 desc = text[last + 2:] | |
23 l = text[:last].splitlines() | |
24 manifest = bin(l[0]) | |
25 user = l[1] | |
26 date = l[2] | |
27 if " " not in date: | |
28 date += " 0" # some tools used -d without a timezone | |
29 files = l[3:] | |
30 return (manifest, user, date, files, desc) | |
31 | |
32 def read(self, node): | |
33 return self.extract(self.revision(node)) | |
34 | |
35 def add(self, manifest, list, desc, transaction, p1=None, p2=None, | |
36 user=None, date=None): | |
37 if not date: | |
38 if time.daylight: offset = time.altzone | |
39 else: offset = time.timezone | |
40 date = "%d %d" % (time.time(), offset) | |
41 list.sort() | |
42 l = [hex(manifest), user, date] + list + ["", desc] | |
43 text = "\n".join(l) | |
44 return self.addrevision(text, transaction, self.count(), p1, p2) |