comparison mercurial/localrepo.py @ 44558:fdc802f29b2c

transactions: convert changes['phases'] to list of ranges Consecutive revisions are often in the same phase, especially public revisions. This means that a dictionary keyed by the revision for the phase transitions is highly redundant. Build a list of (range, (old, new)) entries instead and aggressively merge ranges with the same transition. For the test case in issue5691, this reduces memory use by ~20MB. Differential Revision: https://phab.mercurial-scm.org/D8125
author Joerg Sonnenberger <joerg@bec.de>
date Fri, 08 Dec 2017 02:29:02 +0100
parents 21893ff382cd
children 1b8fd4af3318
comparison
equal deleted inserted replaced
44557:81a873477feb 44558:fdc802f29b2c
2176 throw=True, 2176 throw=True,
2177 **pycompat.strkwargs(args) 2177 **pycompat.strkwargs(args)
2178 ) 2178 )
2179 if hook.hashook(repo.ui, b'pretxnclose-phase'): 2179 if hook.hashook(repo.ui, b'pretxnclose-phase'):
2180 cl = repo.unfiltered().changelog 2180 cl = repo.unfiltered().changelog
2181 for rev, (old, new) in tr.changes[b'phases'].items(): 2181 for revs, (old, new) in tr.changes[b'phases']:
2182 args = tr.hookargs.copy() 2182 for rev in revs:
2183 node = hex(cl.node(rev)) 2183 args = tr.hookargs.copy()
2184 args.update(phases.preparehookargs(node, old, new)) 2184 node = hex(cl.node(rev))
2185 repo.hook( 2185 args.update(phases.preparehookargs(node, old, new))
2186 b'pretxnclose-phase', 2186 repo.hook(
2187 throw=True, 2187 b'pretxnclose-phase',
2188 **pycompat.strkwargs(args) 2188 throw=True,
2189 ) 2189 **pycompat.strkwargs(args)
2190 )
2190 2191
2191 repo.hook( 2192 repo.hook(
2192 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs) 2193 b'pretxnclose', throw=True, **pycompat.strkwargs(tr.hookargs)
2193 ) 2194 )
2194 2195
2229 checkambigfiles=_cachedfiles, 2230 checkambigfiles=_cachedfiles,
2230 name=desc, 2231 name=desc,
2231 ) 2232 )
2232 tr.changes[b'origrepolen'] = len(self) 2233 tr.changes[b'origrepolen'] = len(self)
2233 tr.changes[b'obsmarkers'] = set() 2234 tr.changes[b'obsmarkers'] = set()
2234 tr.changes[b'phases'] = {} 2235 tr.changes[b'phases'] = []
2235 tr.changes[b'bookmarks'] = {} 2236 tr.changes[b'bookmarks'] = {}
2236 2237
2237 tr.hookargs[b'txnid'] = txnid 2238 tr.hookargs[b'txnid'] = txnid
2238 tr.hookargs[b'txnname'] = desc 2239 tr.hookargs[b'txnname'] = desc
2239 # note: writing the fncache only during finalize mean that the file is 2240 # note: writing the fncache only during finalize mean that the file is
2263 **pycompat.strkwargs(args) 2264 **pycompat.strkwargs(args)
2264 ) 2265 )
2265 2266
2266 if hook.hashook(repo.ui, b'txnclose-phase'): 2267 if hook.hashook(repo.ui, b'txnclose-phase'):
2267 cl = repo.unfiltered().changelog 2268 cl = repo.unfiltered().changelog
2268 phasemv = sorted(tr.changes[b'phases'].items()) 2269 phasemv = sorted(
2269 for rev, (old, new) in phasemv: 2270 tr.changes[b'phases'], key=lambda r: r[0][0]
2270 args = tr.hookargs.copy() 2271 )
2271 node = hex(cl.node(rev)) 2272 for revs, (old, new) in phasemv:
2272 args.update(phases.preparehookargs(node, old, new)) 2273 for rev in revs:
2273 repo.hook( 2274 args = tr.hookargs.copy()
2274 b'txnclose-phase', 2275 node = hex(cl.node(rev))
2275 throw=False, 2276 args.update(phases.preparehookargs(node, old, new))
2276 **pycompat.strkwargs(args) 2277 repo.hook(
2277 ) 2278 b'txnclose-phase',
2279 throw=False,
2280 **pycompat.strkwargs(args)
2281 )
2278 2282
2279 repo.hook( 2283 repo.hook(
2280 b'txnclose', throw=False, **pycompat.strkwargs(hookargs) 2284 b'txnclose', throw=False, **pycompat.strkwargs(hookargs)
2281 ) 2285 )
2282 2286