Show More
@@ -10,7 +10,8 b' from rhodecode.lib.vcs.exceptions import' | |||
|
10 | 10 | from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError |
|
11 | 11 | from rhodecode.lib.vcs.exceptions import ImproperArchiveTypeError |
|
12 | 12 | from rhodecode.lib.vcs.backends.base import BaseChangeset |
|
13 |
from rhodecode.lib.vcs.nodes import FileNode, DirNode, NodeKind, RootNode, |
|
|
13 | from rhodecode.lib.vcs.nodes import FileNode, DirNode, NodeKind, RootNode, \ | |
|
14 | RemovedFileNode, SubModuleNode | |
|
14 | 15 | from rhodecode.lib.vcs.utils import safe_unicode |
|
15 | 16 | from rhodecode.lib.vcs.utils import date_fromtimestamp |
|
16 | 17 | from rhodecode.lib.vcs.utils.lazy import LazyProperty |
@@ -329,7 +330,13 b' class GitChangeset(BaseChangeset):' | |||
|
329 | 330 | tree = self.repository._repo[id] |
|
330 | 331 | dirnodes = [] |
|
331 | 332 | filenodes = [] |
|
333 | als = self.repository.alias | |
|
332 | 334 | for name, stat, id in tree.iteritems(): |
|
335 | if objects.S_ISGITLINK(stat): | |
|
336 | dirnodes.append(SubModuleNode(name, url=None, changeset=id, | |
|
337 | alias=als)) | |
|
338 | continue | |
|
339 | ||
|
333 | 340 | obj = self.repository._repo.get_object(id) |
|
334 | 341 | if path != '': |
|
335 | 342 | obj_path = '/'.join((path, name)) |
@@ -5,8 +5,9 b' from rhodecode.lib.vcs.backends.base imp' | |||
|
5 | 5 | from rhodecode.lib.vcs.conf import settings |
|
6 | 6 | from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError, \ |
|
7 | 7 | ChangesetError, ImproperArchiveTypeError, NodeDoesNotExistError, VCSError |
|
8 |
from rhodecode.lib.vcs.nodes import AddedFileNodesGenerator, |
|
|
9 | DirNode, FileNode, NodeKind, RemovedFileNodesGenerator, RootNode | |
|
8 | from rhodecode.lib.vcs.nodes import AddedFileNodesGenerator, \ | |
|
9 | ChangedFileNodesGenerator, DirNode, FileNode, NodeKind, \ | |
|
10 | RemovedFileNodesGenerator, RootNode, SubModuleNode | |
|
10 | 11 | |
|
11 | 12 | from rhodecode.lib.vcs.utils import safe_str, safe_unicode, date_fromtimestamp |
|
12 | 13 | from rhodecode.lib.vcs.utils.lazy import LazyProperty |
@@ -159,6 +160,13 b' class MercurialChangeset(BaseChangeset):' | |||
|
159 | 160 | " %r" % (self.revision, path)) |
|
160 | 161 | return self._ctx.filectx(path) |
|
161 | 162 | |
|
163 | def _extract_submodules(self): | |
|
164 | """ | |
|
165 | returns a dictionary with submodule information from substate file | |
|
166 | of hg repository | |
|
167 | """ | |
|
168 | return self._ctx.substate | |
|
169 | ||
|
162 | 170 | def get_file_mode(self, path): |
|
163 | 171 | """ |
|
164 | 172 | Returns stat mode of the file at the given ``path``. |
@@ -271,17 +279,27 b' class MercurialChangeset(BaseChangeset):' | |||
|
271 | 279 | raise ChangesetError("Directory does not exist for revision %r at " |
|
272 | 280 | " %r" % (self.revision, path)) |
|
273 | 281 | path = self._fix_path(path) |
|
282 | ||
|
274 | 283 | filenodes = [FileNode(f, changeset=self) for f in self._file_paths |
|
275 | 284 | if os.path.dirname(f) == path] |
|
276 | 285 | dirs = path == '' and '' or [d for d in self._dir_paths |
|
277 | 286 | if d and posixpath.dirname(d) == path] |
|
278 | 287 | dirnodes = [DirNode(d, changeset=self) for d in dirs |
|
279 | 288 | if os.path.dirname(d) == path] |
|
289 | ||
|
290 | als = self.repository.alias | |
|
291 | for k, vals in self._extract_submodules().iteritems(): | |
|
292 | #vals = url,rev,type | |
|
293 | loc = vals[0] | |
|
294 | cs = vals[1] | |
|
295 | dirnodes.append(SubModuleNode(k, url=loc, changeset=cs, | |
|
296 | alias=als)) | |
|
280 | 297 | nodes = dirnodes + filenodes |
|
281 | 298 | # cache nodes |
|
282 | 299 | for node in nodes: |
|
283 | 300 | self.nodes[node.path] = node |
|
284 | 301 | nodes.sort() |
|
302 | ||
|
285 | 303 | return nodes |
|
286 | 304 | |
|
287 | 305 | def get_node(self, path): |
@@ -8,19 +8,21 b'' | |||
|
8 | 8 | :created_on: Apr 8, 2010 |
|
9 | 9 | :copyright: (c) 2010-2011 by Marcin Kuzminski, Lukasz Balcerzak. |
|
10 | 10 | """ |
|
11 | import os | |
|
11 | 12 | import stat |
|
12 | 13 | import posixpath |
|
13 | 14 | import mimetypes |
|
14 | 15 | |
|
16 | from pygments import lexers | |
|
17 | ||
|
15 | 18 | from rhodecode.lib.vcs.utils.lazy import LazyProperty |
|
16 | from rhodecode.lib.vcs.utils import safe_unicode | |
|
19 | from rhodecode.lib.vcs.utils import safe_unicode, safe_str | |
|
17 | 20 | from rhodecode.lib.vcs.exceptions import NodeError |
|
18 | 21 | from rhodecode.lib.vcs.exceptions import RemovedFileNodeError |
|
19 | 22 | |
|
20 | from pygments import lexers | |
|
21 | ||
|
22 | 23 | |
|
23 | 24 | class NodeKind: |
|
25 | SUBMODULE = -1 | |
|
24 | 26 | DIR = 1 |
|
25 | 27 | FILE = 2 |
|
26 | 28 | |
@@ -209,6 +211,13 b' class Node(object):' | |||
|
209 | 211 | """ |
|
210 | 212 | return self.kind == NodeKind.DIR and self.path == '' |
|
211 | 213 | |
|
214 | def is_submodule(self): | |
|
215 | """ | |
|
216 | Returns ``True`` if node's kind is ``NodeKind.SUBMODULE``, ``False`` | |
|
217 | otherwise. | |
|
218 | """ | |
|
219 | return self.kind == NodeKind.SUBMODULE | |
|
220 | ||
|
212 | 221 | @LazyProperty |
|
213 | 222 | def added(self): |
|
214 | 223 | return self.state is NodeState.ADDED |
@@ -561,3 +570,31 b' class RootNode(DirNode):' | |||
|
561 | 570 | |
|
562 | 571 | def __repr__(self): |
|
563 | 572 | return '<%s>' % self.__class__.__name__ |
|
573 | ||
|
574 | ||
|
575 | class SubModuleNode(Node): | |
|
576 | """ | |
|
577 | represents a SubModule of Git or SubRepo of Mercurial | |
|
578 | """ | |
|
579 | def __init__(self, name, url=None, changeset=None, alias=None): | |
|
580 | self.path = name | |
|
581 | self.kind = NodeKind.SUBMODULE | |
|
582 | self.alias = alias | |
|
583 | # changeset MUST be STR !! since it can point to non-valid SCM | |
|
584 | self.changeset = str(changeset) | |
|
585 | self.url = url or self._extract_submodule_url() | |
|
586 | ||
|
587 | def _extract_submodule_url(self): | |
|
588 | if self.alias == 'git': | |
|
589 | return self.path | |
|
590 | if self.alias == 'hg': | |
|
591 | return self.path | |
|
592 | ||
|
593 | @LazyProperty | |
|
594 | def name(self): | |
|
595 | """ | |
|
596 | Returns name of the node so if its path | |
|
597 | then only last part is returned. | |
|
598 | """ | |
|
599 | org = safe_unicode(self.path.rstrip('/').split('/')[-1]) | |
|
600 | return u'%s @ %s' % (org, self.changeset[:12]) |
@@ -2718,6 +2718,14 b' table.code-browser .browser-dir {' | |||
|
2718 | 2718 | text-align: left; |
|
2719 | 2719 | } |
|
2720 | 2720 | |
|
2721 | table.code-browser .submodule-dir { | |
|
2722 | background: url("../images/icons/disconnect.png") no-repeat scroll 3px; | |
|
2723 | height: 16px; | |
|
2724 | padding-left: 20px; | |
|
2725 | text-align: left; | |
|
2726 | } | |
|
2727 | ||
|
2728 | ||
|
2721 | 2729 | .box .search { |
|
2722 | 2730 | clear: both; |
|
2723 | 2731 | overflow: hidden; |
@@ -70,7 +70,11 b'' | |||
|
70 | 70 | %for cnt,node in enumerate(c.file): |
|
71 | 71 | <tr class="parity${cnt%2}"> |
|
72 | 72 | <td> |
|
73 | ${h.link_to(node.name,h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=h.safe_unicode(node.path)),class_=file_class(node)+" ypjax-link")} | |
|
73 | %if node.is_submodule(): | |
|
74 | ${h.link_to(node.name,node.url or '#',class_="submodule-dir ypjax-link")} | |
|
75 | %else: | |
|
76 | ${h.link_to(node.name, h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=h.safe_unicode(node.path)),class_=file_class(node)+" ypjax-link")} | |
|
77 | %endif: | |
|
74 | 78 | </td> |
|
75 | 79 | <td> |
|
76 | 80 | %if node.is_file(): |
General Comments 0
You need to be logged in to leave comments.
Login now