Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHGed4e68efebfe: narrowrevlog: document excludeddir class and friends
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | hgext/narrow/narrowrevlog.py (20 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 |
(readtransform, writetransform, rawtransform)) | (readtransform, writetransform, rawtransform)) | ||||
def setup(): | def setup(): | ||||
# We just wanted to add the flag processor, which is done at module | # We just wanted to add the flag processor, which is done at module | ||||
# load time. | # load time. | ||||
pass | pass | ||||
class excludeddir(manifest.treemanifest): | class excludeddir(manifest.treemanifest): | ||||
"""Stand-in for a directory that is excluded from the repository. | |||||
With narrowing active on a repository that uses treemanifests, | |||||
some of the directory revlogs will be excluded from the resulting | |||||
clone. This is a huge storage win for clients, but means we need | |||||
some sort of pseudo-manifest to surface to internals so we can | |||||
detect a merge conflict outside the narrowspec. That's what this | |||||
class is: it stands in for a directory whose node is known, but | |||||
whose contents are unknown. | |||||
""" | |||||
def __init__(self, dir, node): | def __init__(self, dir, node): | ||||
super(excludeddir, self).__init__(dir) | super(excludeddir, self).__init__(dir) | ||||
self._node = node | self._node = node | ||||
# Add an empty file, which will be included by iterators and such, | # Add an empty file, which will be included by iterators and such, | ||||
# appearing as the directory itself (i.e. something like "dir/") | # appearing as the directory itself (i.e. something like "dir/") | ||||
self._files[''] = node | self._files[''] = node | ||||
self._flags[''] = 't' | self._flags[''] = 't' | ||||
# Manifests outside the narrowspec should never be modified, so avoid | # Manifests outside the narrowspec should never be modified, so avoid | ||||
# copying. This makes a noticeable difference when there are very many | # copying. This makes a noticeable difference when there are very many | ||||
# directories outside the narrowspec. Also, it makes sense for the copy to | # directories outside the narrowspec. Also, it makes sense for the copy to | ||||
# be of the same type as the original, which would not happen with the | # be of the same type as the original, which would not happen with the | ||||
# super type's copy(). | # super type's copy(). | ||||
def copy(self): | def copy(self): | ||||
return self | return self | ||||
class excludeddirmanifestctx(manifest.treemanifestctx): | class excludeddirmanifestctx(manifest.treemanifestctx): | ||||
"""context wrapper for excludeddir - see that docstring for rationale""" | |||||
def __init__(self, dir, node): | def __init__(self, dir, node): | ||||
self._dir = dir | self._dir = dir | ||||
self._node = node | self._node = node | ||||
def read(self): | def read(self): | ||||
return excludeddir(self._dir, self._node) | return excludeddir(self._dir, self._node) | ||||
def write(self, *args): | def write(self, *args): | ||||
raise AssertionError('Attempt to write manifest from excluded dir %s' % | raise AssertionError('Attempt to write manifest from excluded dir %s' % | ||||
self._dir) | self._dir) | ||||
class excludedmanifestrevlog(manifest.manifestrevlog): | class excludedmanifestrevlog(manifest.manifestrevlog): | ||||
"""Stand-in for excluded treemanifest revlogs. | |||||
When narrowing is active on a treemanifest repository, we'll have | |||||
references to directories we can't see due to the revlog being | |||||
skipped. This class exists to conform to the manifestrevlog | |||||
interface for those directories and proactively prevent writes to | |||||
outside the narrowspec. | |||||
""" | |||||
def __init__(self, dir): | def __init__(self, dir): | ||||
self._dir = dir | self._dir = dir | ||||
def __len__(self): | def __len__(self): | ||||
raise AssertionError('Attempt to get length of excluded dir %s' % | raise AssertionError('Attempt to get length of excluded dir %s' % | ||||
self._dir) | self._dir) | ||||
def rev(self, node): | def rev(self, node): |