##// END OF EJS Templates
revlog: add an aggressivemergedelta option...
Durham Goode -
r26118:049005de default
parent child Browse files
Show More
@@ -354,6 +354,10 b' class localrepository(object):'
354 354 manifestcachesize = self.ui.configint('format', 'manifestcachesize')
355 355 if manifestcachesize is not None:
356 356 self.svfs.options['manifestcachesize'] = manifestcachesize
357 # experimental config: format.aggressivemergedeltas
358 aggressivemergedeltas = self.ui.configbool('format',
359 'aggressivemergedeltas', False)
360 self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas
357 361
358 362 def _writerequirements(self):
359 363 scmutil.writerequires(self.vfs, self.requirements)
@@ -210,6 +210,7 b' class revlog(object):'
210 210 self._chunkcache = (0, '')
211 211 self._chunkcachesize = 65536
212 212 self._maxchainlen = None
213 self._aggressivemergedeltas = False
213 214 self.index = []
214 215 self._pcache = {}
215 216 self._nodecache = {nullid: nullrev}
@@ -227,6 +228,8 b' class revlog(object):'
227 228 self._chunkcachesize = opts['chunkcachesize']
228 229 if 'maxchainlen' in opts:
229 230 self._maxchainlen = opts['maxchainlen']
231 if 'aggressivemergedeltas' in opts:
232 self._aggressivemergedeltas = opts['aggressivemergedeltas']
230 233
231 234 if self._chunkcachesize <= 0:
232 235 raise RevlogError(_('revlog chunk cache size %r is not greater '
@@ -1343,15 +1346,34 b' class revlog(object):'
1343 1346 # should we try to build a delta?
1344 1347 if prev != nullrev:
1345 1348 if self._generaldelta:
1346 # Pick whichever parent is closer to us (to minimize the
1347 # chance of having to build a fulltext). Since
1348 # nullrev == -1, any non-merge commit will always pick p1r.
1349 drev = p2r if p2r > p1r else p1r
1350 d = builddelta(drev)
1351 # If the chosen delta will result in us making a full text,
1352 # give it one last try against prev.
1353 if drev != prev and not self._isgooddelta(d, textlen):
1354 d = builddelta(prev)
1349 if p2r != nullrev and self._aggressivemergedeltas:
1350 d = builddelta(p1r)
1351 d2 = builddelta(p2r)
1352 p1good = self._isgooddelta(d, textlen)
1353 p2good = self._isgooddelta(d2, textlen)
1354 if p1good and p2good:
1355 # If both are good deltas, choose the smallest
1356 if d2[1] < d[1]:
1357 d = d2
1358 elif p2good:
1359 # If only p2 is good, use it
1360 d = d2
1361 elif p1good:
1362 pass
1363 else:
1364 # Neither is good, try against prev to hopefully save us
1365 # a fulltext.
1366 d = builddelta(prev)
1367 else:
1368 # Pick whichever parent is closer to us (to minimize the
1369 # chance of having to build a fulltext). Since
1370 # nullrev == -1, any non-merge commit will always pick p1r.
1371 drev = p2r if p2r > p1r else p1r
1372 d = builddelta(drev)
1373 # If the chosen delta will result in us making a full text,
1374 # give it one last try against prev.
1375 if drev != prev and not self._isgooddelta(d, textlen):
1376 d = builddelta(prev)
1355 1377 else:
1356 1378 d = builddelta(prev)
1357 1379 dist, l, data, base, chainbase, chainlen, compresseddeltalen = d
@@ -69,3 +69,37 b' commit.'
69 69 rev offset length base linkrev nodeid p1 p2
70 70 0 0 3 0 1 1406e7411862 000000000000 000000000000
71 71
72 $ cd ..
73
74 Test format.aggressivemergedeltas
75
76 $ hg init --config format.generaldelta=1 aggressive
77 $ cd aggressive
78 $ touch a b c d e
79 $ hg commit -Aqm side1
80 $ hg up -q null
81 $ touch x y
82 $ hg commit -Aqm side2
83
84 - Verify non-aggressive merge uses p1 (commit 1) as delta parent
85 $ hg merge -q 0
86 $ hg commit -q -m merge
87 $ hg debugindex -m
88 rev offset length delta linkrev nodeid p1 p2
89 0 0 59 -1 0 8dde941edb6e 000000000000 000000000000
90 1 59 59 -1 1 315c023f341d 000000000000 000000000000
91 2 118 65 1 2 2ab389a983eb 315c023f341d 8dde941edb6e
92
93 $ hg strip -q -r . --config extensions.strip=
94
95 - Verify aggressive merge uses p2 (commit 0) as delta parent
96 $ hg up -q -C 1
97 $ hg merge -q 0
98 $ hg commit -q -m merge --config format.aggressivemergedeltas=True
99 $ hg debugindex -m
100 rev offset length delta linkrev nodeid p1 p2
101 0 0 59 -1 0 8dde941edb6e 000000000000 000000000000
102 1 59 59 -1 1 315c023f341d 000000000000 000000000000
103 2 118 62 0 2 2ab389a983eb 315c023f341d 8dde941edb6e
104
105 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now