##// END OF EJS Templates
unionrevlog: extract 'baserevision' and 'baserevdiff' methods...
Wojciech Lopata -
r19630:bb67f630 default
parent child Browse files
Show More
@@ -70,7 +70,7 b' class unionrevlog(revlog.revlog):'
70 70 self.revlog2.rev(self.node(rev1)),
71 71 self.revlog2.rev(self.node(rev2)))
72 72 elif rev1 <= self.repotiprev and rev2 <= self.repotiprev:
73 return revlog.revlog.revdiff(self, rev1, rev2)
73 return self.baserevdiff(rev1, rev2)
74 74
75 75 return mdiff.textdiff(self.revision(self.node(rev1)),
76 76 self.revision(self.node(rev2)))
@@ -93,10 +93,20 b' class unionrevlog(revlog.revlog):'
93 93 text = self.revlog2.revision(node)
94 94 self._cache = (node, rev, text)
95 95 else:
96 text = revlog.revlog.revision(self, rev)
96 text = self.baserevision(rev)
97 97 # already cached
98 98 return text
99 99
100 def baserevision(self, nodeorrev):
101 # Revlog subclasses may override 'revision' method to modify format of
102 # content retrieved from revlog. To use unionrevlog with such class one
103 # needs to override 'baserevision' and make more specific call here.
104 return revlog.revlog.revision(self, nodeorrev)
105
106 def baserevdiff(self, rev1, rev2):
107 # Exists for the same purpose as baserevision.
108 return revlog.revlog.revdiff(self, rev1, rev2)
109
100 110 def addrevision(self, text, transaction, link, p1=None, p2=None, d=None):
101 111 raise NotImplementedError
102 112 def addgroup(self, revs, linkmapper, transaction):
@@ -114,6 +124,15 b' class unionchangelog(unionrevlog, change'
114 124 unionrevlog.__init__(self, opener, self.indexfile, changelog2,
115 125 linkmapper)
116 126
127 def baserevision(self, nodeorrev):
128 # Although changelog doesn't override 'revision' method, some extensions
129 # may replace this class with another that does. Same story with
130 # manifest and filelog classes.
131 return changelog.changelog.revision(self, nodeorrev)
132
133 def baserevdiff(self, rev1, rev2):
134 return changelog.changelog.revdiff(self, rev1, rev2)
135
117 136 class unionmanifest(unionrevlog, manifest.manifest):
118 137 def __init__(self, opener, opener2, linkmapper):
119 138 manifest.manifest.__init__(self, opener)
@@ -121,6 +140,12 b' class unionmanifest(unionrevlog, manifes'
121 140 unionrevlog.__init__(self, opener, self.indexfile, manifest2,
122 141 linkmapper)
123 142
143 def baserevision(self, nodeorrev):
144 return manifest.manifest.revision(self, nodeorrev)
145
146 def baserevdiff(self, rev1, rev2):
147 return manifest.manifest.revdiff(self, rev1, rev2)
148
124 149 class unionfilelog(unionrevlog, filelog.filelog):
125 150 def __init__(self, opener, path, opener2, linkmapper, repo):
126 151 filelog.filelog.__init__(self, opener, path)
@@ -129,6 +154,12 b' class unionfilelog(unionrevlog, filelog.'
129 154 linkmapper)
130 155 self._repo = repo
131 156
157 def baserevision(self, nodeorrev):
158 return filelog.filelog.revision(self, nodeorrev)
159
160 def baserevdiff(self, rev1, rev2):
161 return filelog.filelog.revdiff(self, rev1, rev2)
162
132 163 def _file(self, f):
133 164 self._repo.file(f)
134 165
General Comments 0
You need to be logged in to leave comments. Login now