##// END OF EJS Templates
localrepo: experimental support for non-zlib revlog compression...
Gregory Szorc -
r30818:4c0a5a25 default
parent child Browse files
Show More
@@ -0,0 +1,78 b''
1 A new repository uses zlib storage, which doesn't need a requirement
2
3 $ hg init default
4 $ cd default
5 $ cat .hg/requires
6 dotencode
7 fncache
8 generaldelta
9 revlogv1
10 store
11
12 $ touch foo
13 $ hg -q commit -A -m 'initial commit with a lot of repeated repeated repeated text to trigger compression'
14 $ hg debugrevlog -c | grep 0x78
15 0x78 (x) : 1 (100.00%)
16 0x78 (x) : 110 (100.00%)
17
18 $ cd ..
19
20 Unknown compression engine to format.compression aborts
21
22 $ hg --config experimental.format.compression=unknown init unknown
23 abort: compression engine unknown defined by experimental.format.compression not available
24 (run "hg debuginstall" to list available compression engines)
25 [255]
26
27 A requirement specifying an unknown compression engine results in bail
28
29 $ hg init unknownrequirement
30 $ cd unknownrequirement
31 $ echo exp-compression-unknown >> .hg/requires
32 $ hg log
33 abort: repository requires features unknown to this Mercurial: exp-compression-unknown!
34 (see https://mercurial-scm.org/wiki/MissingRequirement for more information)
35 [255]
36
37 $ cd ..
38
39 #if zstd
40
41 $ hg --config experimental.format.compression=zstd init zstd
42 $ cd zstd
43 $ cat .hg/requires
44 dotencode
45 exp-compression-zstd
46 fncache
47 generaldelta
48 revlogv1
49 store
50
51 $ touch foo
52 $ hg -q commit -A -m 'initial commit with a lot of repeated repeated repeated text'
53
54 $ hg debugrevlog -c | grep 0x28
55 0x28 : 1 (100.00%)
56 0x28 : 98 (100.00%)
57
58 $ cd ..
59
60 Specifying a new format.compression on an existing repo won't introduce data
61 with that engine or a requirement
62
63 $ cd default
64 $ touch bar
65 $ hg --config experimental.format.compression=zstd -q commit -A -m 'add bar with a lot of repeated repeated repeated text'
66
67 $ cat .hg/requires
68 dotencode
69 fncache
70 generaldelta
71 revlogv1
72 store
73
74 $ hg debugrevlog -c | grep 0x78
75 0x78 (x) : 2 (100.00%)
76 0x78 (x) : 199 (100.00%)
77
78 #endif
@@ -284,6 +284,12 b' class localrepository(object):'
284 else:
284 else:
285 self.supported = self._basesupported
285 self.supported = self._basesupported
286
286
287 # Add compression engines.
288 for name in util.compengines:
289 engine = util.compengines[name]
290 if engine.revlogheader():
291 self.supported.add('exp-compression-%s' % name)
292
287 if not self.vfs.isdir():
293 if not self.vfs.isdir():
288 if create:
294 if create:
289 self.requirements = newreporequirements(self)
295 self.requirements = newreporequirements(self)
@@ -397,6 +403,10 b' class localrepository(object):'
397 self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas
403 self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas
398 self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui)
404 self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui)
399
405
406 for r in self.requirements:
407 if r.startswith('exp-compression-'):
408 self.svfs.options['compengine'] = r[len('exp-compression-'):]
409
400 def _writerequirements(self):
410 def _writerequirements(self):
401 scmutil.writerequires(self.vfs, self.requirements)
411 scmutil.writerequires(self.vfs, self.requirements)
402
412
@@ -1994,6 +2004,18 b' def newreporequirements(repo):'
1994 if ui.configbool('format', 'dotencode', True):
2004 if ui.configbool('format', 'dotencode', True):
1995 requirements.add('dotencode')
2005 requirements.add('dotencode')
1996
2006
2007 compengine = ui.config('experimental', 'format.compression', 'zlib')
2008 if compengine not in util.compengines:
2009 raise error.Abort(_('compression engine %s defined by '
2010 'experimental.format.compression not available') %
2011 compengine,
2012 hint=_('run "hg debuginstall" to list available '
2013 'compression engines'))
2014
2015 # zlib is the historical default and doesn't need an explicit requirement.
2016 if compengine != 'zlib':
2017 requirements.add('exp-compression-%s' % compengine)
2018
1997 if scmutil.gdinitconfig(ui):
2019 if scmutil.gdinitconfig(ui):
1998 requirements.add('generaldelta')
2020 requirements.add('generaldelta')
1999 if ui.configbool('experimental', 'treemanifest', False):
2021 if ui.configbool('experimental', 'treemanifest', False):
@@ -272,6 +272,7 b' class revlog(object):'
272 # Mapping of revision integer to full node.
272 # Mapping of revision integer to full node.
273 self._nodecache = {nullid: nullrev}
273 self._nodecache = {nullid: nullrev}
274 self._nodepos = None
274 self._nodepos = None
275 self._compengine = 'zlib'
275
276
276 v = REVLOG_DEFAULT_VERSION
277 v = REVLOG_DEFAULT_VERSION
277 opts = getattr(opener, 'options', None)
278 opts = getattr(opener, 'options', None)
@@ -288,6 +289,8 b' class revlog(object):'
288 if 'aggressivemergedeltas' in opts:
289 if 'aggressivemergedeltas' in opts:
289 self._aggressivemergedeltas = opts['aggressivemergedeltas']
290 self._aggressivemergedeltas = opts['aggressivemergedeltas']
290 self._lazydeltabase = bool(opts.get('lazydeltabase', False))
291 self._lazydeltabase = bool(opts.get('lazydeltabase', False))
292 if 'compengine' in opts:
293 self._compengine = opts['compengine']
291
294
292 if self._chunkcachesize <= 0:
295 if self._chunkcachesize <= 0:
293 raise RevlogError(_('revlog chunk cache size %r is not greater '
296 raise RevlogError(_('revlog chunk cache size %r is not greater '
@@ -345,7 +348,7 b' class revlog(object):'
345
348
346 @util.propertycache
349 @util.propertycache
347 def _compressor(self):
350 def _compressor(self):
348 return util.compengines['zlib'].revlogcompressor()
351 return util.compengines[self._compengine].revlogcompressor()
349
352
350 def tip(self):
353 def tip(self):
351 return self.node(len(self.index) - 2)
354 return self.node(len(self.index) - 2)
General Comments 0
You need to be logged in to leave comments. Login now