Show More
@@ -845,6 +845,32 b' class revlog(object):' | |||||
845 | c.append(self.node(r)) |
|
845 | c.append(self.node(r)) | |
846 | return c |
|
846 | return c | |
847 |
|
847 | |||
|
848 | def descendant(self, start, end): | |||
|
849 | for i in self.descendants(start): | |||
|
850 | if i == end: | |||
|
851 | return True | |||
|
852 | elif i > end: | |||
|
853 | break | |||
|
854 | return False | |||
|
855 | ||||
|
856 | def ancestor(self, a, b): | |||
|
857 | """calculate the least common ancestor of nodes a and b""" | |||
|
858 | ||||
|
859 | # fast path, check if it is a descendant | |||
|
860 | a, b = self.rev(a), self.rev(b) | |||
|
861 | start, end = sorted((a, b)) | |||
|
862 | if self.descendant(start, end): | |||
|
863 | return self.node(start) | |||
|
864 | ||||
|
865 | def parents(rev): | |||
|
866 | return [p for p in self.parentrevs(rev) if p != nullrev] | |||
|
867 | ||||
|
868 | c = ancestor.ancestor(a, b, parents) | |||
|
869 | if c is None: | |||
|
870 | return nullid | |||
|
871 | ||||
|
872 | return self.node(c) | |||
|
873 | ||||
848 | def _match(self, id): |
|
874 | def _match(self, id): | |
849 | if isinstance(id, (long, int)): |
|
875 | if isinstance(id, (long, int)): | |
850 | # rev |
|
876 | # rev | |
@@ -1119,32 +1145,6 b' class revlog(object):' | |||||
1119 | self._cache = (node, curr, text) |
|
1145 | self._cache = (node, curr, text) | |
1120 | return node |
|
1146 | return node | |
1121 |
|
1147 | |||
1122 | def descendant(self, start, end): |
|
|||
1123 | for i in self.descendants(start): |
|
|||
1124 | if i == end: |
|
|||
1125 | return True |
|
|||
1126 | elif i > end: |
|
|||
1127 | break |
|
|||
1128 | return False |
|
|||
1129 |
|
||||
1130 | def ancestor(self, a, b): |
|
|||
1131 | """calculate the least common ancestor of nodes a and b""" |
|
|||
1132 |
|
||||
1133 | # fast path, check if it is a descendant |
|
|||
1134 | a, b = self.rev(a), self.rev(b) |
|
|||
1135 | start, end = sorted((a, b)) |
|
|||
1136 | if self.descendant(start, end): |
|
|||
1137 | return self.node(start) |
|
|||
1138 |
|
||||
1139 | def parents(rev): |
|
|||
1140 | return [p for p in self.parentrevs(rev) if p != nullrev] |
|
|||
1141 |
|
||||
1142 | c = ancestor.ancestor(a, b, parents) |
|
|||
1143 | if c is None: |
|
|||
1144 | return nullid |
|
|||
1145 |
|
||||
1146 | return self.node(c) |
|
|||
1147 |
|
||||
1148 | def group(self, nodelist, lookup, infocollect=None): |
|
1148 | def group(self, nodelist, lookup, infocollect=None): | |
1149 | """Calculate a delta group, yielding a sequence of changegroup chunks |
|
1149 | """Calculate a delta group, yielding a sequence of changegroup chunks | |
1150 | (strings). |
|
1150 | (strings). |
General Comments 0
You need to be logged in to leave comments.
Login now