##// END OF EJS Templates
revlog: simplify revlog version handling...
Matt Mackall -
r4258:b11a2fb5 default
parent child Browse files
Show More
@@ -147,15 +147,15 b' class appendopener(object):'
147 # not mixed up together.
147 # not mixed up together.
148
148
149 class appendchangelog(changelog.changelog, appendopener):
149 class appendchangelog(changelog.changelog, appendopener):
150 def __init__(self, opener, version):
150 def __init__(self, opener):
151 appendopener.__init__(self, opener)
151 appendopener.__init__(self, opener)
152 changelog.changelog.__init__(self, self, version)
152 changelog.changelog.__init__(self, self)
153 def checkinlinesize(self, fp, tr):
153 def checkinlinesize(self, fp, tr):
154 return
154 return
155
155
156 class appendmanifest(manifest.manifest, appendopener):
156 class appendmanifest(manifest.manifest, appendopener):
157 def __init__(self, opener, version):
157 def __init__(self, opener):
158 appendopener.__init__(self, opener)
158 appendopener.__init__(self, opener)
159 manifest.manifest.__init__(self, self, version)
159 manifest.manifest.__init__(self, self)
160 def checkinlinesize(self, fp, tr):
160 def checkinlinesize(self, fp, tr):
161 return
161 return
@@ -27,8 +27,8 b' def _string_unescape(text):'
27 return text.decode('string_escape')
27 return text.decode('string_escape')
28
28
29 class changelog(revlog):
29 class changelog(revlog):
30 def __init__(self, opener, defversion=REVLOGV0):
30 def __init__(self, opener):
31 revlog.__init__(self, opener, "00changelog.i", defversion)
31 revlog.__init__(self, opener, "00changelog.i")
32
32
33 def decode_extra(self, text):
33 def decode_extra(self, text):
34 extra = {}
34 extra = {}
@@ -666,7 +666,7 b' def copy(ui, repo, *pats, **opts):'
666
666
667 def debugancestor(ui, index, rev1, rev2):
667 def debugancestor(ui, index, rev1, rev2):
668 """find the ancestor revision of two revisions in a given index"""
668 """find the ancestor revision of two revisions in a given index"""
669 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index, 0)
669 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
670 a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
670 a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
671 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
671 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
672
672
@@ -794,9 +794,8 b' def debugstate(ui, repo):'
794 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
794 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
795
795
796 def debugdata(ui, file_, rev):
796 def debugdata(ui, file_, rev):
797 """dump the contents of an data file revision"""
797 """dump the contents of a data file revision"""
798 r = revlog.revlog(util.opener(os.getcwd(), audit=False),
798 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
799 file_[:-2] + ".i", 0)
800 try:
799 try:
801 ui.write(r.revision(r.lookup(rev)))
800 ui.write(r.revision(r.lookup(rev)))
802 except KeyError:
801 except KeyError:
@@ -816,7 +815,7 b' def debugdate(ui, date, range=None, **op'
816
815
817 def debugindex(ui, file_):
816 def debugindex(ui, file_):
818 """dump the contents of an index file"""
817 """dump the contents of an index file"""
819 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, 0)
818 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
820 ui.write(" rev offset length base linkrev" +
819 ui.write(" rev offset length base linkrev" +
821 " nodeid p1 p2\n")
820 " nodeid p1 p2\n")
822 for i in xrange(r.count()):
821 for i in xrange(r.count()):
@@ -828,7 +827,7 b' def debugindex(ui, file_):'
828
827
829 def debugindexdot(ui, file_):
828 def debugindexdot(ui, file_):
830 """dump an index DAG as a .dot file"""
829 """dump an index DAG as a .dot file"""
831 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, 0)
830 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
832 ui.write("digraph G {\n")
831 ui.write("digraph G {\n")
833 for i in xrange(r.count()):
832 for i in xrange(r.count()):
834 node = r.node(i)
833 node = r.node(i)
@@ -9,10 +9,9 b' from revlog import *'
9 import os
9 import os
10
10
11 class filelog(revlog):
11 class filelog(revlog):
12 def __init__(self, opener, path, defversion=REVLOG_DEFAULT_VERSION):
12 def __init__(self, opener, path):
13 revlog.__init__(self, opener,
13 revlog.__init__(self, opener,
14 "/".join(("data", self.encodedir(path + ".i"))),
14 "/".join(("data", self.encodedir(path + ".i"))))
15 defversion)
16
15
17 # This avoids a collision between a file named foo and a dir named
16 # This avoids a collision between a file named foo and a dir named
18 # foo.i or foo.d
17 # foo.i or foo.d
@@ -1018,7 +1018,7 b' class hgweb(object):'
1018 def do_capabilities(self, req):
1018 def do_capabilities(self, req):
1019 caps = ['lookup', 'changegroupsubset']
1019 caps = ['lookup', 'changegroupsubset']
1020 if self.configbool('server', 'uncompressed'):
1020 if self.configbool('server', 'uncompressed'):
1021 caps.append('stream=%d' % self.repo.revlogversion)
1021 caps.append('stream=%d' % self.repo.changelog.version)
1022 # XXX: make configurable and/or share code with do_unbundle:
1022 # XXX: make configurable and/or share code with do_unbundle:
1023 unbundleversions = ['HG10GZ', 'HG10BZ', 'HG10UN']
1023 unbundleversions = ['HG10GZ', 'HG10BZ', 'HG10UN']
1024 if unbundleversions:
1024 if unbundleversions:
@@ -88,34 +88,14 b' class localrepository(repo.repository):'
88 except IOError:
88 except IOError:
89 pass
89 pass
90
90
91 v = self.ui.configrevlog()
91 self.changelog = changelog.changelog(self.sopener)
92 self.revlogversion = int(v.get('format', revlog.REVLOG_DEFAULT_FORMAT))
92 self.sopener.defversion = self.changelog.version
93 self.revlogv1 = self.revlogversion != revlog.REVLOGV0
93 self.manifest = manifest.manifest(self.sopener)
94 fl = v.get('flags', None)
95 flags = 0
96 if fl != None:
97 for x in fl.split():
98 flags |= revlog.flagstr(x)
99 elif self.revlogv1:
100 flags = revlog.REVLOG_DEFAULT_FLAGS
101
102 v = self.revlogversion | flags
103 self.manifest = manifest.manifest(self.sopener, v)
104 self.changelog = changelog.changelog(self.sopener, v)
105
94
106 fallback = self.ui.config('ui', 'fallbackencoding')
95 fallback = self.ui.config('ui', 'fallbackencoding')
107 if fallback:
96 if fallback:
108 util._fallbackencoding = fallback
97 util._fallbackencoding = fallback
109
98
110 # the changelog might not have the inline index flag
111 # on. If the format of the changelog is the same as found in
112 # .hgrc, apply any flags found in the .hgrc as well.
113 # Otherwise, just version from the changelog
114 v = self.changelog.version
115 if v == self.revlogversion:
116 v |= flags
117 self.revlogversion = v
118
119 self.tagscache = None
99 self.tagscache = None
120 self.branchcache = None
100 self.branchcache = None
121 self.nodetagscache = None
101 self.nodetagscache = None
@@ -493,7 +473,7 b' class localrepository(repo.repository):'
493 def file(self, f):
473 def file(self, f):
494 if f[0] == '/':
474 if f[0] == '/':
495 f = f[1:]
475 f = f[1:]
496 return filelog.filelog(self.sopener, f, self.revlogversion)
476 return filelog.filelog(self.sopener, f)
497
477
498 def changectx(self, changeid=None):
478 def changectx(self, changeid=None):
499 return context.changectx(self, changeid)
479 return context.changectx(self, changeid)
@@ -1804,9 +1784,7 b' class localrepository(repo.repository):'
1804 # inconsistent view
1784 # inconsistent view
1805 cl = None
1785 cl = None
1806 try:
1786 try:
1807 cl = appendfile.appendchangelog(self.sopener,
1787 cl = appendfile.appendchangelog(self.sopener)
1808 self.changelog.version)
1809
1810 oldheads = len(cl.heads())
1788 oldheads = len(cl.heads())
1811
1789
1812 # pull off the changeset group
1790 # pull off the changeset group
@@ -1848,8 +1826,7 b' class localrepository(repo.repository):'
1848 cl.cleanup()
1826 cl.cleanup()
1849
1827
1850 # make changelog see real files again
1828 # make changelog see real files again
1851 self.changelog = changelog.changelog(self.sopener,
1829 self.changelog = changelog.changelog(self.sopener)
1852 self.changelog.version)
1853 self.changelog.checkinlinesize(tr)
1830 self.changelog.checkinlinesize(tr)
1854
1831
1855 newheads = len(self.changelog.heads())
1832 newheads = len(self.changelog.heads())
@@ -35,10 +35,10 b' class manifestdict(dict):'
35 return manifestdict(dict.copy(self), dict.copy(self._flags))
35 return manifestdict(dict.copy(self), dict.copy(self._flags))
36
36
37 class manifest(revlog):
37 class manifest(revlog):
38 def __init__(self, opener, defversion=REVLOGV0):
38 def __init__(self, opener):
39 self.mapcache = None
39 self.mapcache = None
40 self.listcache = None
40 self.listcache = None
41 revlog.__init__(self, opener, "00manifest.i", defversion)
41 revlog.__init__(self, opener, "00manifest.i")
42
42
43 def parselines(self, lines):
43 def parselines(self, lines):
44 for l in lines.splitlines(1):
44 for l in lines.splitlines(1):
@@ -311,7 +311,7 b' class revlog(object):'
311 remove data, and can use some simple techniques to avoid the need
311 remove data, and can use some simple techniques to avoid the need
312 for locking while reading.
312 for locking while reading.
313 """
313 """
314 def __init__(self, opener, indexfile, defversion=REVLOG_DEFAULT_VERSION):
314 def __init__(self, opener, indexfile):
315 """
315 """
316 create a revlog object
316 create a revlog object
317
317
@@ -325,7 +325,9 b' class revlog(object):'
325 self.indexstat = None
325 self.indexstat = None
326 self.cache = None
326 self.cache = None
327 self.chunkcache = None
327 self.chunkcache = None
328 self.defversion = defversion
328 self.defversion=REVLOG_DEFAULT_VERSION
329 if hasattr(opener, "defversion"):
330 self.defversion = opener.defversion
329 self.load()
331 self.load()
330
332
331 def load(self):
333 def load(self):
@@ -73,7 +73,7 b' class sshserver(object):'
73
73
74 caps = ['unbundle', 'lookup', 'changegroupsubset']
74 caps = ['unbundle', 'lookup', 'changegroupsubset']
75 if self.ui.configbool('server', 'uncompressed'):
75 if self.ui.configbool('server', 'uncompressed'):
76 caps.append('stream=%d' % self.repo.revlogversion)
76 caps.append('stream=%d' % self.repo.changelog.version)
77 self.respond("capabilities: %s\n" % (' '.join(caps),))
77 self.respond("capabilities: %s\n" % (' '.join(caps),))
78
78
79 def do_lock(self):
79 def do_lock(self):
@@ -32,7 +32,6 b' class statichttprepository(localrepo.loc'
32 def __init__(self, ui, path):
32 def __init__(self, ui, path):
33 self._url = path
33 self._url = path
34 self.ui = ui
34 self.ui = ui
35 self.revlogversion = 0
36
35
37 self.path = (path + "/.hg")
36 self.path = (path + "/.hg")
38 self.opener = opener(self.path)
37 self.opener = opener(self.path)
@@ -325,12 +325,6 b' class ui(object):'
325 result.append(os.path.expanduser(value))
325 result.append(os.path.expanduser(value))
326 return result
326 return result
327
327
328 def configrevlog(self):
329 result = {}
330 for key, value in self.configitems("revlog"):
331 result[key.lower()] = value
332 return result
333
334 def username(self):
328 def username(self):
335 """Return default username to be used in commits.
329 """Return default username to be used in commits.
336
330
@@ -39,8 +39,8 b' def verify(repo):'
39 elif revlogv1:
39 elif revlogv1:
40 warn(_("warning: `%s' uses revlog format 0") % name)
40 warn(_("warning: `%s' uses revlog format 0") % name)
41
41
42 revlogv1 = repo.revlogversion != revlog.REVLOGV0
42 revlogv1 = repo.changelog.version != revlog.REVLOGV0
43 if repo.ui.verbose or revlogv1 != repo.revlogv1:
43 if repo.ui.verbose or not revlogv1:
44 repo.ui.status(_("repository uses revlog format %d\n") %
44 repo.ui.status(_("repository uses revlog format %d\n") %
45 (revlogv1 and 1 or 0))
45 (revlogv1 and 1 or 0))
46
46
General Comments 0
You need to be logged in to leave comments. Login now