Show More
@@ -9,7 +9,7 b' from rhodecode.lib.vcs.exceptions import' | |||
|
9 | 9 | from rhodecode.lib.vcs.exceptions import VCSError |
|
10 | 10 | from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError |
|
11 | 11 | from rhodecode.lib.vcs.exceptions import ImproperArchiveTypeError |
|
12 | from rhodecode.lib.vcs.backends.base import BaseChangeset | |
|
12 | from rhodecode.lib.vcs.backends.base import BaseChangeset, EmptyChangeset | |
|
13 | 13 | from rhodecode.lib.vcs.nodes import FileNode, DirNode, NodeKind, RootNode, \ |
|
14 | 14 | RemovedFileNode, SubModuleNode |
|
15 | 15 | from rhodecode.lib.vcs.utils import safe_unicode |
@@ -410,20 +410,8 b' class GitChangeset(BaseChangeset):' | |||
|
410 | 410 | """ |
|
411 | 411 | Get's a fast accessible file changes for given changeset |
|
412 | 412 | """ |
|
413 | #OLD SOLUTION | |
|
414 | #files = set() | |
|
415 | #for f in (self.added + self.changed + self.removed): | |
|
416 | # files.add(f.path) | |
|
417 | #files = list(files) | |
|
418 | ||
|
419 | _r = self.repository._repo | |
|
420 | files = set() | |
|
421 | for parent in self.parents: | |
|
422 | changes = _r.object_store.tree_changes(_r[parent.raw_id].tree, | |
|
423 | _r[self.raw_id].tree) | |
|
424 | for (oldpath, newpath), (_, _), (_, _) in changes: | |
|
425 | files.add(newpath or oldpath) | |
|
426 | return list(files) | |
|
413 | a, m, d = self._changes_cache | |
|
414 | return list(a.union(m).union(d)) | |
|
427 | 415 | |
|
428 | 416 | @LazyProperty |
|
429 | 417 | def _diff_name_status(self): |
@@ -435,27 +423,43 b' class GitChangeset(BaseChangeset):' | |||
|
435 | 423 | output.append(so.strip()) |
|
436 | 424 | return '\n'.join(output) |
|
437 | 425 | |
|
426 | @LazyProperty | |
|
427 | def _changes_cache(self): | |
|
428 | added = set() | |
|
429 | modified = set() | |
|
430 | deleted = set() | |
|
431 | _r = self.repository._repo | |
|
432 | ||
|
433 | parents = self.parents | |
|
434 | if not self.parents: | |
|
435 | parents = [EmptyChangeset()] | |
|
436 | for parent in parents: | |
|
437 | if isinstance(parent, EmptyChangeset): | |
|
438 | oid = None | |
|
439 | else: | |
|
440 | oid = _r[parent.raw_id].tree | |
|
441 | changes = _r.object_store.tree_changes(oid, _r[self.raw_id].tree) | |
|
442 | for (oldpath, newpath), (_, _), (_, _) in changes: | |
|
443 | if newpath and oldpath: | |
|
444 | modified.add(newpath) | |
|
445 | elif newpath and not oldpath: | |
|
446 | added.add(newpath) | |
|
447 | elif not newpath and oldpath: | |
|
448 | deleted.add(oldpath) | |
|
449 | return added, modified, deleted | |
|
450 | ||
|
438 | 451 | def _get_paths_for_status(self, status): |
|
439 | 452 | """ |
|
440 | 453 | Returns sorted list of paths for given ``status``. |
|
441 | 454 | |
|
442 | 455 | :param status: one of: *added*, *modified* or *deleted* |
|
443 | 456 | """ |
|
444 | paths = set() | |
|
445 | char = status[0].upper() | |
|
446 | for line in self._diff_name_status.splitlines(): | |
|
447 |
if |
|
|
448 | continue | |
|
449 | ||
|
450 | if line.startswith(char): | |
|
451 | splitted = line.split(char, 1) | |
|
452 | if not len(splitted) == 2: | |
|
453 | raise VCSError("Couldn't parse diff result:\n%s\n\n and " | |
|
454 | "particularly that line: %s" % (self._diff_name_status, | |
|
455 | line)) | |
|
456 | _path = splitted[1].strip() | |
|
457 | paths.add(_path) | |
|
458 | return sorted(paths) | |
|
457 | a, m, d = self._changes_cache | |
|
458 | return sorted({ | |
|
459 | 'added': list(a), | |
|
460 | 'modified': list(m), | |
|
461 | 'deleted': list(d)}[status] | |
|
462 | ) | |
|
459 | 463 | |
|
460 | 464 | @LazyProperty |
|
461 | 465 | def added(self): |
General Comments 0
You need to be logged in to leave comments.
Login now