mercurial/bundlerepo.py
changeset 42822 0f5652f17325
parent 42821 c070ca6ed86d
child 42823 5ba8c328a895
equal deleted inserted replaced
42821:c070ca6ed86d 42822:0f5652f17325
   140         return rev, rawtext, validated
   140         return rev, rawtext, validated
   141 
   141 
   142     def rawdata(self, nodeorrev, _df=None):
   142     def rawdata(self, nodeorrev, _df=None):
   143         return self.revision(nodeorrev, _df=_df, raw=True)
   143         return self.revision(nodeorrev, _df=_df, raw=True)
   144 
   144 
   145     def baserevision(self, nodeorrev):
       
   146         # Revlog subclasses may override 'revision' method to modify format of
       
   147         # content retrieved from revlog. To use bundlerevlog with such class one
       
   148         # needs to override 'baserevision' and make more specific call here.
       
   149         return revlog.revlog.rawdata(self, nodeorrev)
       
   150 
       
   151     def addrevision(self, *args, **kwargs):
   145     def addrevision(self, *args, **kwargs):
   152         raise NotImplementedError
   146         raise NotImplementedError
   153 
   147 
   154     def addgroup(self, *args, **kwargs):
   148     def addgroup(self, *args, **kwargs):
   155         raise NotImplementedError
   149         raise NotImplementedError
   164     def __init__(self, opener, cgunpacker):
   158     def __init__(self, opener, cgunpacker):
   165         changelog.changelog.__init__(self, opener)
   159         changelog.changelog.__init__(self, opener)
   166         linkmapper = lambda x: x
   160         linkmapper = lambda x: x
   167         bundlerevlog.__init__(self, opener, self.indexfile, cgunpacker,
   161         bundlerevlog.__init__(self, opener, self.indexfile, cgunpacker,
   168                               linkmapper)
   162                               linkmapper)
   169 
       
   170     def baserevision(self, nodeorrev):
       
   171         # Although changelog doesn't override 'revision' method, some extensions
       
   172         # may replace this class with another that does. Same story with
       
   173         # manifest and filelog classes.
       
   174 
       
   175         # This bypasses filtering on changelog.node() and rev() because we need
       
   176         # revision text of the bundle base even if it is hidden.
       
   177         oldfilter = self.filteredrevs
       
   178         try:
       
   179             self.filteredrevs = ()
       
   180             return changelog.changelog.rawdata(self, nodeorrev)
       
   181         finally:
       
   182             self.filteredrevs = oldfilter
       
   183 
   163 
   184 class bundlemanifest(bundlerevlog, manifest.manifestrevlog):
   164 class bundlemanifest(bundlerevlog, manifest.manifestrevlog):
   185     def __init__(self, opener, cgunpacker, linkmapper, dirlogstarts=None,
   165     def __init__(self, opener, cgunpacker, linkmapper, dirlogstarts=None,
   186                  dir=''):
   166                  dir=''):
   187         manifest.manifestrevlog.__init__(self, opener, tree=dir)
   167         manifest.manifestrevlog.__init__(self, opener, tree=dir)
   192             if self.bundle.version == "03":
   172             if self.bundle.version == "03":
   193                 dirlogstarts = _getfilestarts(self.bundle)
   173                 dirlogstarts = _getfilestarts(self.bundle)
   194         self._dirlogstarts = dirlogstarts
   174         self._dirlogstarts = dirlogstarts
   195         self._linkmapper = linkmapper
   175         self._linkmapper = linkmapper
   196 
   176 
   197     def baserevision(self, nodeorrev):
       
   198         node = nodeorrev
       
   199         if isinstance(node, int):
       
   200             node = self.node(node)
       
   201 
       
   202         if node in self.fulltextcache:
       
   203             result = '%s' % self.fulltextcache[node]
       
   204         else:
       
   205             result = manifest.manifestrevlog.rawdata(self, nodeorrev)
       
   206         return result
       
   207 
       
   208     def dirlog(self, d):
   177     def dirlog(self, d):
   209         if d in self._dirlogstarts:
   178         if d in self._dirlogstarts:
   210             self.bundle.seek(self._dirlogstarts[d])
   179             self.bundle.seek(self._dirlogstarts[d])
   211             return bundlemanifest(
   180             return bundlemanifest(
   212                 self.opener, self.bundle, self._linkmapper,
   181                 self.opener, self.bundle, self._linkmapper,
   216 class bundlefilelog(filelog.filelog):
   185 class bundlefilelog(filelog.filelog):
   217     def __init__(self, opener, path, cgunpacker, linkmapper):
   186     def __init__(self, opener, path, cgunpacker, linkmapper):
   218         filelog.filelog.__init__(self, opener, path)
   187         filelog.filelog.__init__(self, opener, path)
   219         self._revlog = bundlerevlog(opener, self.indexfile,
   188         self._revlog = bundlerevlog(opener, self.indexfile,
   220                                     cgunpacker, linkmapper)
   189                                     cgunpacker, linkmapper)
   221 
       
   222     def baserevision(self, nodeorrev):
       
   223         return filelog.filelog.rawdata(self, nodeorrev)
       
   224 
   190 
   225 class bundlepeer(localrepo.localpeer):
   191 class bundlepeer(localrepo.localpeer):
   226     def canpush(self):
   192     def canpush(self):
   227         return False
   193         return False
   228 
   194