458 p2 = b |
458 p2 = b |
459 if base == p1 or base == p2: |
459 if base == p1 or base == p2: |
460 return False |
460 return False |
461 return self.issnapshot(base) |
461 return self.issnapshot(base) |
462 |
462 |
|
463 def _deltachain(self, rev, stoprev=None): |
|
464 """Obtain the delta chain for a revision. |
|
465 |
|
466 ``stoprev`` specifies a revision to stop at. If not specified, we |
|
467 stop at the base of the chain. |
|
468 |
|
469 Returns a 2-tuple of (chain, stopped) where ``chain`` is a list of |
|
470 revs in ascending order and ``stopped`` is a bool indicating whether |
|
471 ``stoprev`` was hit. |
|
472 """ |
|
473 generaldelta = self.delta_config.general_delta |
|
474 # Try C implementation. |
|
475 try: |
|
476 return self.index.deltachain(rev, stoprev, generaldelta) |
|
477 except AttributeError: |
|
478 pass |
|
479 |
|
480 chain = [] |
|
481 |
|
482 # Alias to prevent attribute lookup in tight loop. |
|
483 index = self.index |
|
484 |
|
485 iterrev = rev |
|
486 e = index[iterrev] |
|
487 while iterrev != e[3] and iterrev != stoprev: |
|
488 chain.append(iterrev) |
|
489 if generaldelta: |
|
490 iterrev = e[3] |
|
491 else: |
|
492 iterrev -= 1 |
|
493 e = index[iterrev] |
|
494 |
|
495 if iterrev == stoprev: |
|
496 stopped = True |
|
497 else: |
|
498 chain.append(iterrev) |
|
499 stopped = False |
|
500 |
|
501 chain.reverse() |
|
502 return chain, stopped |
|
503 |
463 @util.propertycache |
504 @util.propertycache |
464 def _compressor(self): |
505 def _compressor(self): |
465 engine = util.compengines[self.feature_config.compression_engine] |
506 engine = util.compengines[self.feature_config.compression_engine] |
466 return engine.revlogcompressor( |
507 return engine.revlogcompressor( |
467 self.feature_config.compression_engine_options |
508 self.feature_config.compression_engine_options |
1001 # prevent nesting of addgroup |
1042 # prevent nesting of addgroup |
1002 self._adding_group = None |
1043 self._adding_group = None |
1003 |
1044 |
1004 chunk_cache = self._loadindex() |
1045 chunk_cache = self._loadindex() |
1005 self._load_inner(chunk_cache) |
1046 self._load_inner(chunk_cache) |
1006 |
|
1007 self._concurrencychecker = concurrencychecker |
1047 self._concurrencychecker = concurrencychecker |
1008 |
1048 |
1009 @property |
1049 @property |
1010 def _generaldelta(self): |
1050 def _generaldelta(self): |
1011 """temporary compatibility proxy""" |
1051 """temporary compatibility proxy""" |
1821 r = (clen, compresseddeltalen) |
1861 r = (clen, compresseddeltalen) |
1822 chaininfocache[rev] = r |
1862 chaininfocache[rev] = r |
1823 return r |
1863 return r |
1824 |
1864 |
1825 def _deltachain(self, rev, stoprev=None): |
1865 def _deltachain(self, rev, stoprev=None): |
1826 """Obtain the delta chain for a revision. |
1866 return self._inner._deltachain(rev, stoprev=stoprev) |
1827 |
|
1828 ``stoprev`` specifies a revision to stop at. If not specified, we |
|
1829 stop at the base of the chain. |
|
1830 |
|
1831 Returns a 2-tuple of (chain, stopped) where ``chain`` is a list of |
|
1832 revs in ascending order and ``stopped`` is a bool indicating whether |
|
1833 ``stoprev`` was hit. |
|
1834 """ |
|
1835 generaldelta = self.delta_config.general_delta |
|
1836 # Try C implementation. |
|
1837 try: |
|
1838 return self.index.deltachain(rev, stoprev, generaldelta) |
|
1839 except AttributeError: |
|
1840 pass |
|
1841 |
|
1842 chain = [] |
|
1843 |
|
1844 # Alias to prevent attribute lookup in tight loop. |
|
1845 index = self.index |
|
1846 |
|
1847 iterrev = rev |
|
1848 e = index[iterrev] |
|
1849 while iterrev != e[3] and iterrev != stoprev: |
|
1850 chain.append(iterrev) |
|
1851 if generaldelta: |
|
1852 iterrev = e[3] |
|
1853 else: |
|
1854 iterrev -= 1 |
|
1855 e = index[iterrev] |
|
1856 |
|
1857 if iterrev == stoprev: |
|
1858 stopped = True |
|
1859 else: |
|
1860 chain.append(iterrev) |
|
1861 stopped = False |
|
1862 |
|
1863 chain.reverse() |
|
1864 return chain, stopped |
|
1865 |
1867 |
1866 def ancestors(self, revs, stoprev=0, inclusive=False): |
1868 def ancestors(self, revs, stoprev=0, inclusive=False): |
1867 """Generate the ancestors of 'revs' in reverse revision order. |
1869 """Generate the ancestors of 'revs' in reverse revision order. |
1868 Does not generate revs lower than stoprev. |
1870 Does not generate revs lower than stoprev. |
1869 |
1871 |
2494 |
2496 |
2495 def snapshotdepth(self, rev): |
2497 def snapshotdepth(self, rev): |
2496 """number of snapshot in the chain before this one""" |
2498 """number of snapshot in the chain before this one""" |
2497 if not self.issnapshot(rev): |
2499 if not self.issnapshot(rev): |
2498 raise error.ProgrammingError(b'revision %d not a snapshot') |
2500 raise error.ProgrammingError(b'revision %d not a snapshot') |
2499 return len(self._deltachain(rev)[0]) - 1 |
2501 return len(self._inner._deltachain(rev)[0]) - 1 |
2500 |
2502 |
2501 def revdiff(self, rev1, rev2): |
2503 def revdiff(self, rev1, rev2): |
2502 """return or calculate a delta between two revisions |
2504 """return or calculate a delta between two revisions |
2503 |
2505 |
2504 The delta calculated is in binary form and is intended to be written to |
2506 The delta calculated is in binary form and is intended to be written to |
2592 cachedrev = self._revisioncache[1] |
2594 cachedrev = self._revisioncache[1] |
2593 |
2595 |
2594 if rev is None: |
2596 if rev is None: |
2595 rev = self.rev(node) |
2597 rev = self.rev(node) |
2596 |
2598 |
2597 chain, stopped = self._deltachain(rev, stoprev=cachedrev) |
2599 chain, stopped = self._inner._deltachain(rev, stoprev=cachedrev) |
2598 if stopped: |
2600 if stopped: |
2599 basetext = self._revisioncache[2] |
2601 basetext = self._revisioncache[2] |
2600 |
2602 |
2601 # drop cache to save memory, the caller is expected to |
2603 # drop cache to save memory, the caller is expected to |
2602 # update self._revisioncache after validating the text |
2604 # update self._revisioncache after validating the text |