revlog: simplify revlog version handling
- pass the default version as an attribute on the opener
- eliminate config option mess
--- a/mercurial/appendfile.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/appendfile.py Thu Mar 22 19:52:38 2007 -0500
@@ -147,15 +147,15 @@
# not mixed up together.
class appendchangelog(changelog.changelog, appendopener):
- def __init__(self, opener, version):
+ def __init__(self, opener):
appendopener.__init__(self, opener)
- changelog.changelog.__init__(self, self, version)
+ changelog.changelog.__init__(self, self)
def checkinlinesize(self, fp, tr):
return
class appendmanifest(manifest.manifest, appendopener):
- def __init__(self, opener, version):
+ def __init__(self, opener):
appendopener.__init__(self, opener)
- manifest.manifest.__init__(self, self, version)
+ manifest.manifest.__init__(self, self)
def checkinlinesize(self, fp, tr):
return
--- a/mercurial/changelog.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/changelog.py Thu Mar 22 19:52:38 2007 -0500
@@ -27,8 +27,8 @@
return text.decode('string_escape')
class changelog(revlog):
- def __init__(self, opener, defversion=REVLOGV0):
- revlog.__init__(self, opener, "00changelog.i", defversion)
+ def __init__(self, opener):
+ revlog.__init__(self, opener, "00changelog.i")
def decode_extra(self, text):
extra = {}
--- a/mercurial/commands.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/commands.py Thu Mar 22 19:52:38 2007 -0500
@@ -666,7 +666,7 @@
def debugancestor(ui, index, rev1, rev2):
"""find the ancestor revision of two revisions in a given index"""
- r = revlog.revlog(util.opener(os.getcwd(), audit=False), index, 0)
+ r = revlog.revlog(util.opener(os.getcwd(), audit=False), index)
a = r.ancestor(r.lookup(rev1), r.lookup(rev2))
ui.write("%d:%s\n" % (r.rev(a), hex(a)))
@@ -794,9 +794,8 @@
ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
def debugdata(ui, file_, rev):
- """dump the contents of an data file revision"""
- r = revlog.revlog(util.opener(os.getcwd(), audit=False),
- file_[:-2] + ".i", 0)
+ """dump the contents of a data file revision"""
+ r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
try:
ui.write(r.revision(r.lookup(rev)))
except KeyError:
@@ -816,7 +815,7 @@
def debugindex(ui, file_):
"""dump the contents of an index file"""
- r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, 0)
+ r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
ui.write(" rev offset length base linkrev" +
" nodeid p1 p2\n")
for i in xrange(r.count()):
@@ -828,7 +827,7 @@
def debugindexdot(ui, file_):
"""dump an index DAG as a .dot file"""
- r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_, 0)
+ r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_)
ui.write("digraph G {\n")
for i in xrange(r.count()):
node = r.node(i)
--- a/mercurial/filelog.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/filelog.py Thu Mar 22 19:52:38 2007 -0500
@@ -9,10 +9,9 @@
import os
class filelog(revlog):
- def __init__(self, opener, path, defversion=REVLOG_DEFAULT_VERSION):
+ def __init__(self, opener, path):
revlog.__init__(self, opener,
- "/".join(("data", self.encodedir(path + ".i"))),
- defversion)
+ "/".join(("data", self.encodedir(path + ".i"))))
# This avoids a collision between a file named foo and a dir named
# foo.i or foo.d
--- a/mercurial/hgweb/hgweb_mod.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/hgweb/hgweb_mod.py Thu Mar 22 19:52:38 2007 -0500
@@ -1018,7 +1018,7 @@
def do_capabilities(self, req):
caps = ['lookup', 'changegroupsubset']
if self.configbool('server', 'uncompressed'):
- caps.append('stream=%d' % self.repo.revlogversion)
+ caps.append('stream=%d' % self.repo.changelog.version)
# XXX: make configurable and/or share code with do_unbundle:
unbundleversions = ['HG10GZ', 'HG10BZ', 'HG10UN']
if unbundleversions:
--- a/mercurial/localrepo.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/localrepo.py Thu Mar 22 19:52:38 2007 -0500
@@ -88,34 +88,14 @@
except IOError:
pass
- v = self.ui.configrevlog()
- self.revlogversion = int(v.get('format', revlog.REVLOG_DEFAULT_FORMAT))
- self.revlogv1 = self.revlogversion != revlog.REVLOGV0
- fl = v.get('flags', None)
- flags = 0
- if fl != None:
- for x in fl.split():
- flags |= revlog.flagstr(x)
- elif self.revlogv1:
- flags = revlog.REVLOG_DEFAULT_FLAGS
-
- v = self.revlogversion | flags
- self.manifest = manifest.manifest(self.sopener, v)
- self.changelog = changelog.changelog(self.sopener, v)
+ self.changelog = changelog.changelog(self.sopener)
+ self.sopener.defversion = self.changelog.version
+ self.manifest = manifest.manifest(self.sopener)
fallback = self.ui.config('ui', 'fallbackencoding')
if fallback:
util._fallbackencoding = fallback
- # the changelog might not have the inline index flag
- # on. If the format of the changelog is the same as found in
- # .hgrc, apply any flags found in the .hgrc as well.
- # Otherwise, just version from the changelog
- v = self.changelog.version
- if v == self.revlogversion:
- v |= flags
- self.revlogversion = v
-
self.tagscache = None
self.branchcache = None
self.nodetagscache = None
@@ -493,7 +473,7 @@
def file(self, f):
if f[0] == '/':
f = f[1:]
- return filelog.filelog(self.sopener, f, self.revlogversion)
+ return filelog.filelog(self.sopener, f)
def changectx(self, changeid=None):
return context.changectx(self, changeid)
@@ -1804,9 +1784,7 @@
# inconsistent view
cl = None
try:
- cl = appendfile.appendchangelog(self.sopener,
- self.changelog.version)
-
+ cl = appendfile.appendchangelog(self.sopener)
oldheads = len(cl.heads())
# pull off the changeset group
@@ -1848,8 +1826,7 @@
cl.cleanup()
# make changelog see real files again
- self.changelog = changelog.changelog(self.sopener,
- self.changelog.version)
+ self.changelog = changelog.changelog(self.sopener)
self.changelog.checkinlinesize(tr)
newheads = len(self.changelog.heads())
--- a/mercurial/manifest.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/manifest.py Thu Mar 22 19:52:38 2007 -0500
@@ -35,10 +35,10 @@
return manifestdict(dict.copy(self), dict.copy(self._flags))
class manifest(revlog):
- def __init__(self, opener, defversion=REVLOGV0):
+ def __init__(self, opener):
self.mapcache = None
self.listcache = None
- revlog.__init__(self, opener, "00manifest.i", defversion)
+ revlog.__init__(self, opener, "00manifest.i")
def parselines(self, lines):
for l in lines.splitlines(1):
--- a/mercurial/revlog.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/revlog.py Thu Mar 22 19:52:38 2007 -0500
@@ -311,7 +311,7 @@
remove data, and can use some simple techniques to avoid the need
for locking while reading.
"""
- def __init__(self, opener, indexfile, defversion=REVLOG_DEFAULT_VERSION):
+ def __init__(self, opener, indexfile):
"""
create a revlog object
@@ -325,7 +325,9 @@
self.indexstat = None
self.cache = None
self.chunkcache = None
- self.defversion = defversion
+ self.defversion=REVLOG_DEFAULT_VERSION
+ if hasattr(opener, "defversion"):
+ self.defversion = opener.defversion
self.load()
def load(self):
--- a/mercurial/sshserver.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/sshserver.py Thu Mar 22 19:52:38 2007 -0500
@@ -73,7 +73,7 @@
caps = ['unbundle', 'lookup', 'changegroupsubset']
if self.ui.configbool('server', 'uncompressed'):
- caps.append('stream=%d' % self.repo.revlogversion)
+ caps.append('stream=%d' % self.repo.changelog.version)
self.respond("capabilities: %s\n" % (' '.join(caps),))
def do_lock(self):
--- a/mercurial/statichttprepo.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/statichttprepo.py Thu Mar 22 19:52:38 2007 -0500
@@ -32,7 +32,6 @@
def __init__(self, ui, path):
self._url = path
self.ui = ui
- self.revlogversion = 0
self.path = (path + "/.hg")
self.opener = opener(self.path)
--- a/mercurial/ui.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/ui.py Thu Mar 22 19:52:38 2007 -0500
@@ -325,12 +325,6 @@
result.append(os.path.expanduser(value))
return result
- def configrevlog(self):
- result = {}
- for key, value in self.configitems("revlog"):
- result[key.lower()] = value
- return result
-
def username(self):
"""Return default username to be used in commits.
--- a/mercurial/verify.py Thu Mar 22 19:12:03 2007 -0500
+++ b/mercurial/verify.py Thu Mar 22 19:52:38 2007 -0500
@@ -39,8 +39,8 @@
elif revlogv1:
warn(_("warning: `%s' uses revlog format 0") % name)
- revlogv1 = repo.revlogversion != revlog.REVLOGV0
- if repo.ui.verbose or revlogv1 != repo.revlogv1:
+ revlogv1 = repo.changelog.version != revlog.REVLOGV0
+ if repo.ui.verbose or not revlogv1:
repo.ui.status(_("repository uses revlog format %d\n") %
(revlogv1 and 1 or 0))