@@ -308,49 +308,49 @@ class MercurialChangeset(BaseChangeset):
def get_nodes(self, path):
"""
Returns combined ``DirNode`` and ``FileNode`` objects list representing
state of changeset at the given ``path``. If node at the given ``path``
is not instance of ``DirNode``, ChangesetError would be raised.
if self._get_kind(path) != NodeKind.DIR:
raise ChangesetError("Directory does not exist for revision %s at "
" '%s'" % (self.revision, path))
path = path.rstrip('/')
filenodes = [FileNode(f, changeset=self) for f in self._file_paths
if os.path.dirname(f) == path]
dirs = path == '' and '' or [d for d in self._dir_paths
if d and posixpath.dirname(d) == path]
dirnodes = [DirNode(d, changeset=self) for d in dirs
if os.path.dirname(d) == path]
als = self.repository.alias
for k, vals in self._extract_submodules().items():
#vals = url,rev,type
loc = vals[0]
cs = vals[1]
dirnodes.append(SubModuleNode(k, url=loc, changeset=cs,
dirnodes.append(SubModuleNode(safe_str(k), url=safe_str(loc), changeset=cs,
alias=als))
nodes = dirnodes + filenodes
for node in nodes:
self.nodes[node.path] = node
nodes.sort()
return nodes
def get_node(self, path):
Returns ``Node`` object from the given ``path``. If there is no node at
the given ``path``, ``ChangesetError`` would be raised.
if path not in self.nodes:
if path in self._file_paths:
node = FileNode(path, changeset=self)
elif path in self._dir_paths or path in self._dir_paths:
if path == '':
node = RootNode(changeset=self)
else:
node = DirNode(path, changeset=self)
raise NodeDoesNotExistError("There is no file nor directory "
"at the given path: '%s' at revision %s"
@@ -582,25 +582,25 @@ class SubModuleNode(Node):
is_binary = False
size = 0
def __init__(self, name, url, changeset=None, alias=None):
# Note: Doesn't call Node.__init__!
self.path = name.rstrip('/')
self.kind = NodeKind.SUBMODULE
self.alias = alias
# we have to use emptyChangeset here since this can point to svn/git/hg
# submodules we cannot get from repository
self.changeset = EmptyChangeset(changeset, alias=alias)
self.url = url
def __repr__(self):
return '<%s %r @ %s>' % (self.__class__.__name__, self.path,
getattr(self.changeset, 'short_id', ''))
@LazyProperty
def name(self):
Returns name of the node so if its path
then only last part is returned.
org = self.path.rstrip('/').rsplit('/', 1)[-1]
return '%s @ %s' % (org, self.changeset.short_id)
return '%s @ %s' % (org, safe_str(self.changeset.short_id))
Status change: