##// END OF EJS Templates
changegroup: refactor emitrevision to use a `deltamode` argument...
Boris Feld -
r40456:59a870a4 default
parent child Browse files
Show More
@@ -39,6 +39,10 b' REVISION_FLAG_EXTSTORED = 1 << 13'
39 39 REVISION_FLAGS_KNOWN = (
40 40 REVISION_FLAG_CENSORED | REVISION_FLAG_ELLIPSIS | REVISION_FLAG_EXTSTORED)
41 41
42 CG_DELTAMODE_STD = b'default'
43 CG_DELTAMODE_PREV = b'previous'
44 CG_DELTAMODE_FULL = b'fulltext'
45
42 46 class ipeerconnection(interfaceutil.Interface):
43 47 """Represents a "connection" to a repository.
44 48
@@ -2213,6 +2213,12 b' class revlog(object):'
2213 2213 if nodesorder is None and not self._generaldelta:
2214 2214 nodesorder = 'storage'
2215 2215
2216 deltamode = repository.CG_DELTAMODE_STD
2217 if deltaprevious:
2218 deltamode = repository.CG_DELTAMODE_PREV
2219 elif not self._storedeltachains:
2220 deltamode = repository.CG_DELTAMODE_FULL
2221
2216 2222 return storageutil.emitrevisions(
2217 2223 self, nodes, nodesorder, revlogrevisiondelta,
2218 2224 deltaparentfn=self.deltaparent,
@@ -2220,10 +2226,9 b' class revlog(object):'
2220 2226 rawsizefn=self.rawsize,
2221 2227 revdifffn=self.revdiff,
2222 2228 flagsfn=self.flags,
2223 sendfulltext=not self._storedeltachains,
2229 deltamode=deltamode,
2224 2230 revisiondata=revisiondata,
2225 assumehaveparentrevisions=assumehaveparentrevisions,
2226 deltaprevious=deltaprevious)
2231 assumehaveparentrevisions=assumehaveparentrevisions)
2227 2232
2228 2233 DELTAREUSEALWAYS = 'always'
2229 2234 DELTAREUSESAMEREVS = 'samerevs'
@@ -22,6 +22,7 b' from .. import ('
22 22 error,
23 23 mdiff,
24 24 pycompat,
25 repository,
25 26 )
26 27
27 28 _nullhash = hashlib.sha1(nullid)
@@ -269,9 +270,8 b' def resolvestripinfo(minlinkrev, tiprev,'
269 270
270 271 def emitrevisions(store, nodes, nodesorder, resultcls, deltaparentfn=None,
271 272 candeltafn=None, rawsizefn=None, revdifffn=None, flagsfn=None,
272 sendfulltext=False,
273 revisiondata=False, assumehaveparentrevisions=False,
274 deltaprevious=False):
273 deltamode=repository.CG_DELTAMODE_STD,
274 revisiondata=False, assumehaveparentrevisions=False):
275 275 """Generic implementation of ifiledata.emitrevisions().
276 276
277 277 Emitting revision data is subtly complex. This function attempts to
@@ -322,14 +322,17 b' def emitrevisions(store, nodes, nodesord'
322 322 Callable receiving a revision number and returns the integer flags
323 323 value for it. If not defined, flags value will be 0.
324 324
325 ``sendfulltext``
325 ``deltamode``
326 constaint on delta to be sent:
327 * CG_DELTAMODE_STD - normal mode, try to reuse storage deltas,
328 * CG_DELTAMODE_PREV - only delta against "prev",
329 * CG_DELTAMODE_FULL - only issue full snapshot.
330
326 331 Whether to send fulltext revisions instead of deltas, if allowed.
327 332
328 333 ``nodesorder``
329 334 ``revisiondata``
330 335 ``assumehaveparentrevisions``
331 ``deltaprevious``
332 See ``ifiledata.emitrevisions()`` interface documentation.
333 336 """
334 337
335 338 fnode = store.node
@@ -345,7 +348,7 b' def emitrevisions(store, nodes, nodesord'
345 348
346 349 prevrev = None
347 350
348 if deltaprevious or assumehaveparentrevisions:
351 if deltamode == repository.CG_DELTAMODE_PREV or assumehaveparentrevisions:
349 352 prevrev = store.parentrevs(revs[0])[0]
350 353
351 354 # Set of revs available to delta against.
@@ -364,11 +367,11 b' def emitrevisions(store, nodes, nodesord'
364 367 deltaparentrev = nullrev
365 368
366 369 # Forced delta against previous mode.
367 if deltaprevious:
370 if deltamode == repository.CG_DELTAMODE_PREV:
368 371 baserev = prevrev
369 372
370 373 # We're instructed to send fulltext. Honor that.
371 elif sendfulltext:
374 elif deltamode == repository.CG_DELTAMODE_FULL:
372 375 baserev = nullrev
373 376
374 377 # There is a delta in storage. We try to use that because it
@@ -427,7 +430,8 b' def emitrevisions(store, nodes, nodesord'
427 430 baserevisionsize = len(store.revision(baserev,
428 431 raw=True))
429 432
430 elif baserev == nullrev and not deltaprevious:
433 elif (baserev == nullrev
434 and deltamode != repository.CG_DELTAMODE_PREV):
431 435 revision = store.revision(node, raw=True)
432 436 available.add(rev)
433 437 else:
General Comments 0
You need to be logged in to leave comments. Login now