Show More
@@ -33,8 +33,8 b' from itertools import tee, imap' | |||
|
33 | 33 | from pylons.i18n.translation import _ |
|
34 | 34 | |
|
35 | 35 | from rhodecode.lib.vcs.exceptions import VCSError |
|
36 | from rhodecode.lib.vcs.nodes import FileNode | |
|
37 | ||
|
36 | from rhodecode.lib.vcs.nodes import FileNode, SubModuleNode | |
|
37 | from rhodecode.lib.helpers import escape | |
|
38 | 38 | from rhodecode.lib.utils import EmptyChangeset |
|
39 | 39 | |
|
40 | 40 | |
@@ -79,8 +79,12 b' def wrapped_diff(filenode_old, filenode_' | |||
|
79 | 79 | 'diff menu to display this diff')) |
|
80 | 80 | stats = (0, 0) |
|
81 | 81 | size = 0 |
|
82 | ||
|
83 | 82 | if not diff: |
|
83 | submodules = filter(lambda o: isinstance(o, SubModuleNode), | |
|
84 | [filenode_new, filenode_old]) | |
|
85 | if submodules: | |
|
86 | diff = wrap_to_table(escape('Submodule %r' % submodules[0])) | |
|
87 | else: | |
|
84 | 88 | diff = wrap_to_table(_('No changes detected')) |
|
85 | 89 | |
|
86 | 90 | cs1 = filenode_old.changeset.raw_id |
@@ -97,6 +101,10 b' def get_gitdiff(filenode_old, filenode_n' | |||
|
97 | 101 | """ |
|
98 | 102 | # make sure we pass in default context |
|
99 | 103 | context = context or 3 |
|
104 | submodules = filter(lambda o: isinstance(o, SubModuleNode), | |
|
105 | [filenode_new, filenode_old]) | |
|
106 | if submodules: | |
|
107 | return '' | |
|
100 | 108 | |
|
101 | 109 | for filenode in (filenode_old, filenode_new): |
|
102 | 110 | if not isinstance(filenode, FileNode): |
@@ -109,7 +117,6 b' def get_gitdiff(filenode_old, filenode_n' | |||
|
109 | 117 | |
|
110 | 118 | vcs_gitdiff = repo.get_diff(old_raw_id, new_raw_id, filenode_new.path, |
|
111 | 119 | ignore_whitespace, context) |
|
112 | ||
|
113 | 120 | return vcs_gitdiff |
|
114 | 121 | |
|
115 | 122 |
@@ -364,11 +364,18 b' class GitChangeset(BaseChangeset):' | |||
|
364 | 364 | path = self._fix_path(path) |
|
365 | 365 | if not path in self.nodes: |
|
366 | 366 | try: |
|
367 | id = self._get_id_for_path(path) | |
|
367 | id_ = self._get_id_for_path(path) | |
|
368 | 368 | except ChangesetError: |
|
369 | 369 | raise NodeDoesNotExistError("Cannot find one of parents' " |
|
370 | 370 | "directories for a given path: %s" % path) |
|
371 | obj = self.repository._repo.get_object(id) | |
|
371 | ||
|
372 | als = self.repository.alias | |
|
373 | _GL = lambda m: m and objects.S_ISGITLINK(m) | |
|
374 | if _GL(self._stat_modes.get(path)): | |
|
375 | node = SubModuleNode(path, url=None, changeset=id_, alias=als) | |
|
376 | else: | |
|
377 | obj = self.repository._repo.get_object(id_) | |
|
378 | ||
|
372 | 379 | if isinstance(obj, objects.Tree): |
|
373 | 380 | if path == '': |
|
374 | 381 | node = RootNode(changeset=self) |
@@ -423,7 +430,6 b' class GitChangeset(BaseChangeset):' | |||
|
423 | 430 | line)) |
|
424 | 431 | _path = splitted[1].strip() |
|
425 | 432 | paths.add(_path) |
|
426 | ||
|
427 | 433 | return sorted(paths) |
|
428 | 434 | |
|
429 | 435 | @LazyProperty |
@@ -19,6 +19,7 b' from rhodecode.lib.vcs.utils.lazy import' | |||
|
19 | 19 | from rhodecode.lib.vcs.utils import safe_unicode, safe_str |
|
20 | 20 | from rhodecode.lib.vcs.exceptions import NodeError |
|
21 | 21 | from rhodecode.lib.vcs.exceptions import RemovedFileNodeError |
|
22 | from rhodecode.lib.utils import EmptyChangeset | |
|
22 | 23 | |
|
23 | 24 | |
|
24 | 25 | class NodeKind: |
@@ -576,16 +577,26 b' class SubModuleNode(Node):' | |||
|
576 | 577 | """ |
|
577 | 578 | represents a SubModule of Git or SubRepo of Mercurial |
|
578 | 579 | """ |
|
580 | is_binary = False | |
|
581 | size = 0 | |
|
582 | ||
|
579 | 583 | def __init__(self, name, url=None, changeset=None, alias=None): |
|
580 | 584 | self.path = name |
|
581 | 585 | self.kind = NodeKind.SUBMODULE |
|
582 | 586 | self.alias = alias |
|
583 | # changeset MUST be STR !! since it can point to non-valid SCM | |
|
584 | self.changeset = str(changeset) | |
|
587 | # we have to use emptyChangeset here since this can point to svn/git/hg | |
|
588 | # submodules we cannot get from repository | |
|
589 | self.changeset = EmptyChangeset(str(changeset), alias=alias) | |
|
585 | 590 | self.url = url or self._extract_submodule_url() |
|
586 | 591 | |
|
592 | def __repr__(self): | |
|
593 | return '<%s %r @ %s>' % (self.__class__.__name__, self.path, | |
|
594 | self.changeset.short_id) | |
|
595 | ||
|
587 | 596 | def _extract_submodule_url(self): |
|
588 | 597 | if self.alias == 'git': |
|
598 | #TODO: find a way to parse gits submodule file and extract the | |
|
599 | # linking URL | |
|
589 | 600 | return self.path |
|
590 | 601 | if self.alias == 'hg': |
|
591 | 602 | return self.path |
@@ -597,4 +608,4 b' class SubModuleNode(Node):' | |||
|
597 | 608 | then only last part is returned. |
|
598 | 609 | """ |
|
599 | 610 | org = safe_unicode(self.path.rstrip('/').split('/')[-1]) |
|
600 |
return u'%s @ %s' % (org, self.changeset |
|
|
611 | return u'%s @ %s' % (org, self.changeset.short_id) |
General Comments 0
You need to be logged in to leave comments.
Login now