##// END OF EJS Templates
narrow: move manifestrevlog overrides to core...
narrow: move manifestrevlog overrides to core Differential Revision: https://phab.mercurial-scm.org/D3045

File last commit:

r37391:c50078fc default
r37391:c50078fc default
Show More
narrowrevlog.py
89 lines | 3.4 KiB | text/x-python | PythonLexer
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 # narrowrevlog.py - revlog storing irrelevant nodes as "ellipsis" nodes
#
# Copyright 2017 Google, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from mercurial import (
manifest,
revlog,
util,
)
def readtransform(self, text):
return text, False
def writetransform(self, text):
return text, False
def rawtransform(self, text):
return False
Augie Fackler
narrow: move from ELLIPSIS_NODE_FLAG to revlog.REVIDX_ELLIPSIS...
r36107 revlog.addflagprocessor(revlog.REVIDX_ELLIPSIS,
Augie Fackler
narrow: assume addflagprocessor will always exist on revlog module...
r36100 (readtransform, writetransform, rawtransform))
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
def setup():
# We just wanted to add the flag processor, which is done at module
# load time.
pass
def makenarrowmanifestlog(mfl, repo):
class narrowmanifestlog(mfl.__class__):
def get(self, dir, node, verify=True):
if not repo.narrowmatch().visitdir(dir[:-1] or '.'):
Martin von Zweigbergk
narrow: move excludeddir and related classes to core...
r37390 return manifest.excludeddirmanifestctx(dir, node)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 return super(narrowmanifestlog, self).get(dir, node, verify=verify)
mfl.__class__ = narrowmanifestlog
def makenarrowfilelog(fl, narrowmatch):
class narrowfilelog(fl.__class__):
def renamed(self, node):
Augie Fackler
narrowrevlog: add what little I can remember about rename filtering...
r36113 # Renames that come from outside the narrowspec are
# problematic at least for git-diffs, because we lack the
# base text for the rename. This logic was introduced in
# 3cd72b1 of narrowhg (authored by martinvonz, reviewed by
# adgar), but that revision doesn't have any additional
# commentary on what problems we can encounter.
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 m = super(narrowfilelog, self).renamed(node)
if m and not narrowmatch(m[0]):
return None
return m
def size(self, rev):
# We take advantage of the fact that remotefilelog
# lacks a node() method to just skip the
# rename-checking logic when on remotefilelog. This
# might be incorrect on other non-revlog-based storage
# engines, but for now this seems to be fine.
Augie Fackler
narrowrevlog: add a TODO around remotefilelog moving to core...
r36114 #
# TODO: when remotefilelog is in core, improve this to
# explicitly look for remotefilelog instead of cheating
# with a hasattr check.
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 if util.safehasattr(self, 'node'):
node = self.node(rev)
# Because renamed() is overridden above to
# sometimes return None even if there is metadata
# in the revlog, size can be incorrect for
# copies/renames, so we need to make sure we call
# the super class's implementation of renamed()
# for the purpose of size calculation.
if super(narrowfilelog, self).renamed(node):
return len(self.read(node))
return super(narrowfilelog, self).size(rev)
def cmp(self, node, text):
different = super(narrowfilelog, self).cmp(node, text)
if different:
# Similar to size() above, if the file was copied from
# a file outside the narrowspec, the super class's
# would have returned True because we tricked it into
# thinking that the file was not renamed.
if super(narrowfilelog, self).renamed(node):
t2 = self.read(node)
return t2 != text
return different
fl.__class__ = narrowfilelog