##// END OF EJS Templates
new dulwich based implementation of added/modified/removed...
marcink -
r2762:ba4fb9c4 beta
parent child Browse files
Show More
@@ -9,7 +9,7 b' from rhodecode.lib.vcs.exceptions import'
9 from rhodecode.lib.vcs.exceptions import VCSError
9 from rhodecode.lib.vcs.exceptions import VCSError
10 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
10 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
11 from rhodecode.lib.vcs.exceptions import ImproperArchiveTypeError
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 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 RemovedFileNode, SubModuleNode
15 from rhodecode.lib.vcs.utils import safe_unicode
15 from rhodecode.lib.vcs.utils import safe_unicode
@@ -410,20 +410,8 b' class GitChangeset(BaseChangeset):'
410 """
410 """
411 Get's a fast accessible file changes for given changeset
411 Get's a fast accessible file changes for given changeset
412 """
412 """
413 #OLD SOLUTION
413 a, m, d = self._changes_cache
414 #files = set()
414 return list(a.union(m).union(d))
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)
427
415
428 @LazyProperty
416 @LazyProperty
429 def _diff_name_status(self):
417 def _diff_name_status(self):
@@ -435,27 +423,43 b' class GitChangeset(BaseChangeset):'
435 output.append(so.strip())
423 output.append(so.strip())
436 return '\n'.join(output)
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 def _get_paths_for_status(self, status):
451 def _get_paths_for_status(self, status):
439 """
452 """
440 Returns sorted list of paths for given ``status``.
453 Returns sorted list of paths for given ``status``.
441
454
442 :param status: one of: *added*, *modified* or *deleted*
455 :param status: one of: *added*, *modified* or *deleted*
443 """
456 """
444 paths = set()
457 a, m, d = self._changes_cache
445 char = status[0].upper()
458 return sorted({
446 for line in self._diff_name_status.splitlines():
459 'added': list(a),
447 if not line:
460 'modified': list(m),
448 continue
461 'deleted': list(d)}[status]
449
462 )
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)
459
463
460 @LazyProperty
464 @LazyProperty
461 def added(self):
465 def added(self):
General Comments 0
You need to be logged in to leave comments. Login now