Mercurial > hg
comparison mercurial/localrepo.py @ 2072:74d3f5336b66
Implement revlogng.
revlogng results in smaller indexes, can address larger data files, and
supports flags and version numbers.
By default the original revlog format is used. To use the new format,
use the following .hgrc field:
[revlog]
# format choices are 0 (classic revlog format) and 1 revlogng
format=1
author | mason@suse.com |
---|---|
date | Tue, 04 Apr 2006 16:38:43 -0400 |
parents | a514c7509fa9 |
children | 1e6745f78989 |
comparison
equal
deleted
inserted
replaced
2042:a514c7509fa9 | 2072:74d3f5336b66 |
---|---|
8 import os, util | 8 import os, util |
9 import filelog, manifest, changelog, dirstate, repo | 9 import filelog, manifest, changelog, dirstate, repo |
10 from node import * | 10 from node import * |
11 from i18n import gettext as _ | 11 from i18n import gettext as _ |
12 from demandload import * | 12 from demandload import * |
13 demandload(globals(), "re lock transaction tempfile stat mdiff errno ui") | |
14 demandload(globals(), "appendfile changegroup") | 13 demandload(globals(), "appendfile changegroup") |
14 demandload(globals(), "re lock transaction tempfile stat mdiff errno ui revlog") | |
15 | 15 |
16 class localrepository(object): | 16 class localrepository(object): |
17 def __del__(self): | 17 def __del__(self): |
18 self.transhandle = None | 18 self.transhandle = None |
19 def __init__(self, parentui, path=None, create=0): | 19 def __init__(self, parentui, path=None, create=0): |
33 self.root = os.path.abspath(path) | 33 self.root = os.path.abspath(path) |
34 self.origroot = path | 34 self.origroot = path |
35 self.ui = ui.ui(parentui=parentui) | 35 self.ui = ui.ui(parentui=parentui) |
36 self.opener = util.opener(self.path) | 36 self.opener = util.opener(self.path) |
37 self.wopener = util.opener(self.root) | 37 self.wopener = util.opener(self.root) |
38 self.manifest = manifest.manifest(self.opener) | 38 |
39 self.changelog = changelog.changelog(self.opener) | 39 try: |
40 self.ui.readconfig(self.join("hgrc"), self.root) | |
41 except IOError: | |
42 pass | |
43 | |
44 v = self.ui.revlogopts | |
45 self.revlogversion = int(v.get('format', 0)) | |
46 for x in v.get('flags', "").split(): | |
47 self.revlogversion |= revlog.flagstr(x) | |
48 | |
49 self.manifest = manifest.manifest(self.opener, self.revlogversion) | |
50 self.changelog = changelog.changelog(self.opener, self.revlogversion) | |
51 self.revlogversion = self.changelog.version | |
40 self.tagscache = None | 52 self.tagscache = None |
41 self.nodetagscache = None | 53 self.nodetagscache = None |
42 self.encodepats = None | 54 self.encodepats = None |
43 self.decodepats = None | 55 self.decodepats = None |
44 self.transhandle = None | 56 self.transhandle = None |
46 if create: | 58 if create: |
47 os.mkdir(self.path) | 59 os.mkdir(self.path) |
48 os.mkdir(self.join("data")) | 60 os.mkdir(self.join("data")) |
49 | 61 |
50 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root) | 62 self.dirstate = dirstate.dirstate(self.opener, self.ui, self.root) |
51 try: | |
52 self.ui.readconfig(self.join("hgrc"), self.root) | |
53 except IOError: | |
54 pass | |
55 | |
56 def hook(self, name, throw=False, **args): | 63 def hook(self, name, throw=False, **args): |
57 def runhook(name, cmd): | 64 def runhook(name, cmd): |
58 self.ui.note(_("running hook %s: %s\n") % (name, cmd)) | 65 self.ui.note(_("running hook %s: %s\n") % (name, cmd)) |
59 env = dict([('HG_' + k.upper(), v) for k, v in args.iteritems()] + | 66 env = dict([('HG_' + k.upper(), v) for k, v in args.iteritems()] + |
60 [(k.upper(), v) for k, v in args.iteritems()]) | 67 [(k.upper(), v) for k, v in args.iteritems()]) |
165 return os.path.join(self.root, f) | 172 return os.path.join(self.root, f) |
166 | 173 |
167 def file(self, f): | 174 def file(self, f): |
168 if f[0] == '/': | 175 if f[0] == '/': |
169 f = f[1:] | 176 f = f[1:] |
170 return filelog.filelog(self.opener, f) | 177 return filelog.filelog(self.opener, f, self.revlogversion) |
171 | 178 |
172 def getcwd(self): | 179 def getcwd(self): |
173 return self.dirstate.getcwd() | 180 return self.dirstate.getcwd() |
174 | 181 |
175 def wfile(self, f, mode='r'): | 182 def wfile(self, f, mode='r'): |