equal
deleted
inserted
replaced
75 REVIDX_ISCENSORED, |
75 REVIDX_ISCENSORED, |
76 REVIDX_ELLIPSIS, |
76 REVIDX_ELLIPSIS, |
77 REVIDX_EXTSTORED, |
77 REVIDX_EXTSTORED, |
78 ] |
78 ] |
79 REVIDX_KNOWN_FLAGS = util.bitsfrom(REVIDX_FLAGS_ORDER) |
79 REVIDX_KNOWN_FLAGS = util.bitsfrom(REVIDX_FLAGS_ORDER) |
|
80 # bitmark for flags that could cause rawdata content change |
|
81 REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_ISCENSORED | REVIDX_EXTSTORED |
80 |
82 |
81 # max size of revlog with inline data |
83 # max size of revlog with inline data |
82 _maxinline = 131072 |
84 _maxinline = 131072 |
83 _chunksize = 1048576 |
85 _chunksize = 1048576 |
84 |
86 |
94 |
96 |
95 def addflagprocessor(flag, processor): |
97 def addflagprocessor(flag, processor): |
96 """Register a flag processor on a revision data flag. |
98 """Register a flag processor on a revision data flag. |
97 |
99 |
98 Invariant: |
100 Invariant: |
99 - Flags need to be defined in REVIDX_KNOWN_FLAGS and REVIDX_FLAGS_ORDER. |
101 - Flags need to be defined in REVIDX_KNOWN_FLAGS and REVIDX_FLAGS_ORDER, |
|
102 and REVIDX_RAWTEXT_CHANGING_FLAGS if they can alter rawtext. |
100 - Only one flag processor can be registered on a specific flag. |
103 - Only one flag processor can be registered on a specific flag. |
101 - flagprocessors must be 3-tuples of functions (read, write, raw) with the |
104 - flagprocessors must be 3-tuples of functions (read, write, raw) with the |
102 following signatures: |
105 following signatures: |
103 - (read) f(self, rawtext) -> text, bool |
106 - (read) f(self, rawtext) -> text, bool |
104 - (write) f(self, text) -> rawtext, bool |
107 - (write) f(self, text) -> rawtext, bool |
710 try: |
713 try: |
711 self.rev(node) |
714 self.rev(node) |
712 return True |
715 return True |
713 except KeyError: |
716 except KeyError: |
714 return False |
717 return False |
|
718 |
|
719 def candelta(self, baserev, rev): |
|
720 """whether two revisions (baserev, rev) can be delta-ed or not""" |
|
721 # Disable delta if either rev requires a content-changing flag |
|
722 # processor (ex. LFS). This is because such flag processor can alter |
|
723 # the rawtext content that the delta will be based on, and two clients |
|
724 # could have a same revlog node with different flags (i.e. different |
|
725 # rawtext contents) and the delta could be incompatible. |
|
726 if ((self.flags(baserev) & REVIDX_RAWTEXT_CHANGING_FLAGS) |
|
727 or (self.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS)): |
|
728 return False |
|
729 return True |
715 |
730 |
716 def clearcaches(self): |
731 def clearcaches(self): |
717 self._cache = None |
732 self._cache = None |
718 self._chainbasecache.clear() |
733 self._chainbasecache.clear() |
719 self._chunkcache = (0, '') |
734 self._chunkcache = (0, '') |