Show More
@@ -18,6 +18,7 b' from ..node import (' | |||
|
18 | 18 | ) |
|
19 | 19 | from .. import ( |
|
20 | 20 | error, |
|
21 | mdiff, | |
|
21 | 22 | pycompat, |
|
22 | 23 | ) |
|
23 | 24 | |
@@ -263,8 +264,9 b' def resolvestripinfo(minlinkrev, tiprev,' | |||
|
263 | 264 | |
|
264 | 265 | return strippoint, brokenrevs |
|
265 | 266 | |
|
266 | def emitrevisions(store, revs, resultcls, deltaparentfn, candeltafn, | |
|
267 |
rawsizefn, revdifffn, flagsfn |
|
|
267 | def emitrevisions(store, revs, resultcls, deltaparentfn=None, candeltafn=None, | |
|
268 | rawsizefn=None, revdifffn=None, flagsfn=None, | |
|
269 | sendfulltext=False, | |
|
268 | 270 | revisiondata=False, assumehaveparentrevisions=False, |
|
269 | 271 | deltaprevious=False): |
|
270 | 272 | """Generic implementation of ifiledata.emitrevisions(). |
@@ -282,26 +284,40 b' def emitrevisions(store, revs, resultcls' | |||
|
282 | 284 | A type implementing the ``irevisiondelta`` interface that will be |
|
283 | 285 | constructed and returned. |
|
284 | 286 | |
|
285 | ``deltaparentfn`` | |
|
287 | ``deltaparentfn`` (optional) | |
|
286 | 288 | Callable receiving a revision number and returning the revision number |
|
287 | 289 | of a revision that the internal delta is stored against. This delta |
|
288 | 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 | 296 | Callable receiving a pair of revision numbers that returns a bool |
|
292 | 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 | 303 | Callable receiving a revision number and returning the length of the |
|
296 | 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 | 309 | Callable receiving a pair of revision numbers that returns a delta |
|
300 | 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 | 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 | 322 | ``sendfulltext`` |
|
307 | 323 | Whether to send fulltext revisions instead of deltas, if allowed. |
@@ -327,8 +343,12 b' def emitrevisions(store, revs, resultcls' | |||
|
327 | 343 | continue |
|
328 | 344 | |
|
329 | 345 | node = fnode(rev) |
|
346 | p1rev, p2rev = store.parentrevs(rev) | |
|
347 | ||
|
348 | if deltaparentfn: | |
|
330 | 349 | deltaparentrev = deltaparentfn(rev) |
|
331 | p1rev, p2rev = store.parentrevs(rev) | |
|
350 | else: | |
|
351 | deltaparentrev = nullrev | |
|
332 | 352 | |
|
333 | 353 | # Forced delta against previous mode. |
|
334 | 354 | if deltaprevious: |
@@ -373,7 +393,7 b' def emitrevisions(store, revs, resultcls' | |||
|
373 | 393 | |
|
374 | 394 | # But we can't actually use our chosen delta base for whatever |
|
375 | 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 | 397 | baserev = nullrev |
|
378 | 398 | |
|
379 | 399 | revision = None |
@@ -388,13 +408,22 b' def emitrevisions(store, revs, resultcls' | |||
|
388 | 408 | revision = e.tombstone |
|
389 | 409 | |
|
390 | 410 | if baserev != nullrev: |
|
411 | if rawsizefn: | |
|
391 | 412 | baserevisionsize = rawsizefn(baserev) |
|
413 | else: | |
|
414 | baserevisionsize = len(store.revision(baserev, | |
|
415 | raw=True)) | |
|
392 | 416 | |
|
393 | 417 | elif baserev == nullrev and not deltaprevious: |
|
394 | 418 | revision = store.revision(node, raw=True) |
|
395 | 419 | available.add(rev) |
|
396 | 420 | else: |
|
421 | if revdifffn: | |
|
397 | 422 | delta = revdifffn(baserev, rev) |
|
423 | else: | |
|
424 | delta = mdiff.textdiff(store.revision(baserev, raw=True), | |
|
425 | store.revision(rev, raw=True)) | |
|
426 | ||
|
398 | 427 | available.add(rev) |
|
399 | 428 | |
|
400 | 429 | yield resultcls( |
@@ -402,7 +431,7 b' def emitrevisions(store, revs, resultcls' | |||
|
402 | 431 | p1node=fnode(p1rev), |
|
403 | 432 | p2node=fnode(p2rev), |
|
404 | 433 | basenode=fnode(baserev), |
|
405 | flags=flagsfn(rev), | |
|
434 | flags=flagsfn(rev) if flagsfn else 0, | |
|
406 | 435 | baserevisionsize=baserevisionsize, |
|
407 | 436 | revision=revision, |
|
408 | 437 | delta=delta) |
General Comments 0
You need to be logged in to leave comments.
Login now