Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHG142ce66a4118: narrowrevlog: replace AssertionError with ProgrammingError
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 (21 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 |
# narrowrevlog.py - revlog storing irrelevant nodes as "ellipsis" nodes | # narrowrevlog.py - revlog storing irrelevant nodes as "ellipsis" nodes | ||||
# | # | ||||
# Copyright 2017 Google, Inc. | # Copyright 2017 Google, Inc. | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
from mercurial import ( | from mercurial import ( | ||||
error, | |||||
manifest, | manifest, | ||||
revlog, | revlog, | ||||
util, | util, | ||||
) | ) | ||||
def readtransform(self, text): | def readtransform(self, text): | ||||
return text, False | return text, False | ||||
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 error.ProgrammingError( | ||||
self._dir) | 'attempt to write manifest from excluded dir %s' % self._dir) | ||||
class excludedmanifestrevlog(manifest.manifestrevlog): | class excludedmanifestrevlog(manifest.manifestrevlog): | ||||
"""Stand-in for excluded treemanifest revlogs. | """Stand-in for excluded treemanifest revlogs. | ||||
When narrowing is active on a treemanifest repository, we'll have | When narrowing is active on a treemanifest repository, we'll have | ||||
references to directories we can't see due to the revlog being | references to directories we can't see due to the revlog being | ||||
skipped. This class exists to conform to the manifestrevlog | skipped. This class exists to conform to the manifestrevlog | ||||
interface for those directories and proactively prevent writes to | interface for those directories and proactively prevent writes to | ||||
outside the narrowspec. | 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 error.ProgrammingError( | ||||
self._dir) | 'attempt to get length of excluded dir %s' % self._dir) | ||||
def rev(self, node): | def rev(self, node): | ||||
raise AssertionError('Attempt to get rev from excluded dir %s' % | raise error.ProgrammingError( | ||||
self._dir) | 'attempt to get rev from excluded dir %s' % self._dir) | ||||
def linkrev(self, node): | def linkrev(self, node): | ||||
raise AssertionError('Attempt to get linkrev from excluded dir %s' % | raise error.ProgrammingError( | ||||
self._dir) | 'attempt to get linkrev from excluded dir %s' % self._dir) | ||||
def node(self, rev): | def node(self, rev): | ||||
raise AssertionError('Attempt to get node from excluded dir %s' % | raise error.ProgrammingError( | ||||
self._dir) | 'attempt to get node from excluded dir %s' % self._dir) | ||||
def add(self, *args, **kwargs): | def add(self, *args, **kwargs): | ||||
# We should never write entries in dirlogs outside the narrow clone. | # We should never write entries in dirlogs outside the narrow clone. | ||||
# However, the method still gets called from writesubtree() in | # However, the method still gets called from writesubtree() in | ||||
# _addtree(), so we need to handle it. We should possibly make that | # _addtree(), so we need to handle it. We should possibly make that | ||||
# avoid calling add() with a clean manifest (_dirty is always False | # avoid calling add() with a clean manifest (_dirty is always False | ||||
# in excludeddir instances). | # in excludeddir instances). | ||||
pass | pass |