##// END OF EJS Templates
storageutil: make all callables optional...
Gregory Szorc -
r40045:631c6f50 default
parent child Browse files
Show More
@@ -18,6 +18,7 b' from ..node import ('
18 )
18 )
19 from .. import (
19 from .. import (
20 error,
20 error,
21 mdiff,
21 pycompat,
22 pycompat,
22 )
23 )
23
24
@@ -263,8 +264,9 b' def resolvestripinfo(minlinkrev, tiprev,'
263
264
264 return strippoint, brokenrevs
265 return strippoint, brokenrevs
265
266
266 def emitrevisions(store, revs, resultcls, deltaparentfn, candeltafn,
267 def emitrevisions(store, revs, resultcls, deltaparentfn=None, candeltafn=None,
267 rawsizefn, revdifffn, flagsfn, sendfulltext=False,
268 rawsizefn=None, revdifffn=None, flagsfn=None,
269 sendfulltext=False,
268 revisiondata=False, assumehaveparentrevisions=False,
270 revisiondata=False, assumehaveparentrevisions=False,
269 deltaprevious=False):
271 deltaprevious=False):
270 """Generic implementation of ifiledata.emitrevisions().
272 """Generic implementation of ifiledata.emitrevisions().
@@ -282,26 +284,40 b' def emitrevisions(store, revs, resultcls'
282 A type implementing the ``irevisiondelta`` interface that will be
284 A type implementing the ``irevisiondelta`` interface that will be
283 constructed and returned.
285 constructed and returned.
284
286
285 ``deltaparentfn``
287 ``deltaparentfn`` (optional)
286 Callable receiving a revision number and returning the revision number
288 Callable receiving a revision number and returning the revision number
287 of a revision that the internal delta is stored against. This delta
289 of a revision that the internal delta is stored against. This delta
288 will be preferred over computing a new arbitrary delta.
290 will be preferred over computing a new arbitrary delta.
289
291
290 ``candeltafn``
292 If not defined, a delta will always be computed from raw revision
293 data.
294
295 ``candeltafn`` (optional)
291 Callable receiving a pair of revision numbers that returns a bool
296 Callable receiving a pair of revision numbers that returns a bool
292 indicating whether a delta between them can be produced.
297 indicating whether a delta between them can be produced.
293
298
294 ``rawsizefn``
299 If not defined, it is assumed that any two revisions can delta with
300 each other.
301
302 ``rawsizefn`` (optional)
295 Callable receiving a revision number and returning the length of the
303 Callable receiving a revision number and returning the length of the
296 ``store.revision(rev, raw=True)``.
304 ``store.revision(rev, raw=True)``.
297
305
298 ``revdifffn``
306 If not defined, ``len(store.revision(rev, raw=True))`` will be called.
307
308 ``revdifffn`` (optional)
299 Callable receiving a pair of revision numbers that returns a delta
309 Callable receiving a pair of revision numbers that returns a delta
300 between them.
310 between them.
301
311
302 ``flagsfn``
312 If not defined, a delta will be computed by invoking mdiff code
313 on ``store.revision()`` results.
314
315 Defining this function allows a precomputed or stored delta to be
316 used without having to compute on.
317
318 ``flagsfn`` (optional)
303 Callable receiving a revision number and returns the integer flags
319 Callable receiving a revision number and returns the integer flags
304 value for it.
320 value for it. If not defined, flags value will be 0.
305
321
306 ``sendfulltext``
322 ``sendfulltext``
307 Whether to send fulltext revisions instead of deltas, if allowed.
323 Whether to send fulltext revisions instead of deltas, if allowed.
@@ -327,9 +343,13 b' def emitrevisions(store, revs, resultcls'
327 continue
343 continue
328
344
329 node = fnode(rev)
345 node = fnode(rev)
330 deltaparentrev = deltaparentfn(rev)
331 p1rev, p2rev = store.parentrevs(rev)
346 p1rev, p2rev = store.parentrevs(rev)
332
347
348 if deltaparentfn:
349 deltaparentrev = deltaparentfn(rev)
350 else:
351 deltaparentrev = nullrev
352
333 # Forced delta against previous mode.
353 # Forced delta against previous mode.
334 if deltaprevious:
354 if deltaprevious:
335 baserev = prevrev
355 baserev = prevrev
@@ -373,7 +393,7 b' def emitrevisions(store, revs, resultcls'
373
393
374 # But we can't actually use our chosen delta base for whatever
394 # But we can't actually use our chosen delta base for whatever
375 # reason. Reset to fulltext.
395 # reason. Reset to fulltext.
376 if baserev != nullrev and not candeltafn(baserev, rev):
396 if baserev != nullrev and (candeltafn and not candeltafn(baserev, rev)):
377 baserev = nullrev
397 baserev = nullrev
378
398
379 revision = None
399 revision = None
@@ -388,13 +408,22 b' def emitrevisions(store, revs, resultcls'
388 revision = e.tombstone
408 revision = e.tombstone
389
409
390 if baserev != nullrev:
410 if baserev != nullrev:
391 baserevisionsize = rawsizefn(baserev)
411 if rawsizefn:
412 baserevisionsize = rawsizefn(baserev)
413 else:
414 baserevisionsize = len(store.revision(baserev,
415 raw=True))
392
416
393 elif baserev == nullrev and not deltaprevious:
417 elif baserev == nullrev and not deltaprevious:
394 revision = store.revision(node, raw=True)
418 revision = store.revision(node, raw=True)
395 available.add(rev)
419 available.add(rev)
396 else:
420 else:
397 delta = revdifffn(baserev, rev)
421 if revdifffn:
422 delta = revdifffn(baserev, rev)
423 else:
424 delta = mdiff.textdiff(store.revision(baserev, raw=True),
425 store.revision(rev, raw=True))
426
398 available.add(rev)
427 available.add(rev)
399
428
400 yield resultcls(
429 yield resultcls(
@@ -402,7 +431,7 b' def emitrevisions(store, revs, resultcls'
402 p1node=fnode(p1rev),
431 p1node=fnode(p1rev),
403 p2node=fnode(p2rev),
432 p2node=fnode(p2rev),
404 basenode=fnode(baserev),
433 basenode=fnode(baserev),
405 flags=flagsfn(rev),
434 flags=flagsfn(rev) if flagsfn else 0,
406 baserevisionsize=baserevisionsize,
435 baserevisionsize=baserevisionsize,
407 revision=revision,
436 revision=revision,
408 delta=delta)
437 delta=delta)
General Comments 0
You need to be logged in to leave comments. Login now