Show More
@@ -211,7 +211,7 b' class RepoChangelogView(RepoAppView):' | |||||
211 | base_commit = self.rhodecode_vcs_repo.get_commit(commit_id) |
|
211 | base_commit = self.rhodecode_vcs_repo.get_commit(commit_id) | |
212 |
|
212 | |||
213 | try: |
|
213 | try: | |
214 |
collection = base_commit.get_ |
|
214 | collection = base_commit.get_path_history( | |
215 | f_path, limit=hist_limit, pre_load=pre_load) |
|
215 | f_path, limit=hist_limit, pre_load=pre_load) | |
216 | if collection and partial_xhr: |
|
216 | if collection and partial_xhr: | |
217 | # for ajax call we remove first one since we're looking |
|
217 | # for ajax call we remove first one since we're looking | |
@@ -221,7 +221,7 b' class RepoChangelogView(RepoAppView):' | |||||
221 | # this node is not present at tip! |
|
221 | # this node is not present at tip! | |
222 | try: |
|
222 | try: | |
223 | commit = self._get_commit_or_redirect(commit_id) |
|
223 | commit = self._get_commit_or_redirect(commit_id) | |
224 |
collection = commit.get_ |
|
224 | collection = commit.get_path_history(f_path) | |
225 | except RepositoryError as e: |
|
225 | except RepositoryError as e: | |
226 | h.flash(safe_str(e), category='warning') |
|
226 | h.flash(safe_str(e), category='warning') | |
227 | redirect_url = h.route_path( |
|
227 | redirect_url = h.route_path( | |
@@ -315,7 +315,7 b' class RepoChangelogView(RepoAppView):' | |||||
315 | raise HTTPFound( |
|
315 | raise HTTPFound( | |
316 | h.route_path('repo_changelog', repo_name=self.db_repo_name)) |
|
316 | h.route_path('repo_changelog', repo_name=self.db_repo_name)) | |
317 |
|
317 | |||
318 |
collection = base_commit.get_ |
|
318 | collection = base_commit.get_path_history( | |
319 | f_path, limit=hist_limit, pre_load=pre_load) |
|
319 | f_path, limit=hist_limit, pre_load=pre_load) | |
320 | collection = list(reversed(collection)) |
|
320 | collection = list(reversed(collection)) | |
321 | else: |
|
321 | else: |
@@ -663,7 +663,7 b' class RepoFilesView(RepoAppView):' | |||||
663 | pass |
|
663 | pass | |
664 |
|
664 | |||
665 | if is_file: |
|
665 | if is_file: | |
666 |
history = commit.get_ |
|
666 | history = commit.get_path_history(f_path) | |
667 | prev_commit_id = history[1].raw_id \ |
|
667 | prev_commit_id = history[1].raw_id \ | |
668 | if len(history) > 1 else prev_commit_id |
|
668 | if len(history) > 1 else prev_commit_id | |
669 | prev_url = h.route_path( |
|
669 | prev_url = h.route_path( | |
@@ -897,10 +897,10 b' class RepoFilesView(RepoAppView):' | |||||
897 | if commits is None: |
|
897 | if commits is None: | |
898 | pre_load = ["author", "branch"] |
|
898 | pre_load = ["author", "branch"] | |
899 | try: |
|
899 | try: | |
900 |
commits = tip.get_ |
|
900 | commits = tip.get_path_history(f_path, pre_load=pre_load) | |
901 | except (NodeDoesNotExistError, CommitError): |
|
901 | except (NodeDoesNotExistError, CommitError): | |
902 | # this node is not present at tip! |
|
902 | # this node is not present at tip! | |
903 |
commits = commit_obj.get_ |
|
903 | commits = commit_obj.get_path_history(f_path, pre_load=pre_load) | |
904 |
|
904 | |||
905 | history = [] |
|
905 | history = [] | |
906 | commits_group = ([], _("Changesets")) |
|
906 | commits_group = ([], _("Changesets")) |
@@ -942,13 +942,13 b' class BaseCommit(object):' | |||||
942 | """ |
|
942 | """ | |
943 | raise NotImplementedError |
|
943 | raise NotImplementedError | |
944 |
|
944 | |||
945 |
def get_ |
|
945 | def get_path_commit(self, path, pre_load=None): | |
946 | """ |
|
946 | """ | |
947 | Returns last commit of the file at the given `path`. |
|
947 | Returns last commit of the file at the given `path`. | |
948 |
|
948 | |||
949 | :param pre_load: Optional. List of commit attributes to load. |
|
949 | :param pre_load: Optional. List of commit attributes to load. | |
950 | """ |
|
950 | """ | |
951 |
commits = self.get_ |
|
951 | commits = self.get_path_history(path, limit=1, pre_load=pre_load) | |
952 | if not commits: |
|
952 | if not commits: | |
953 | raise RepositoryError( |
|
953 | raise RepositoryError( | |
954 | 'Failed to fetch history for path {}. ' |
|
954 | 'Failed to fetch history for path {}. ' | |
@@ -956,7 +956,7 b' class BaseCommit(object):' | |||||
956 | path)) |
|
956 | path)) | |
957 | return commits[0] |
|
957 | return commits[0] | |
958 |
|
958 | |||
959 |
def get_ |
|
959 | def get_path_history(self, path, limit=None, pre_load=None): | |
960 | """ |
|
960 | """ | |
961 | Returns history of file as reversed list of :class:`BaseCommit` |
|
961 | Returns history of file as reversed list of :class:`BaseCommit` | |
962 | objects for which file at given `path` has been modified. |
|
962 | objects for which file at given `path` has been modified. | |
@@ -1194,8 +1194,8 b' class BaseCommit(object):' | |||||
1194 | self.idx = value |
|
1194 | self.idx = value | |
1195 |
|
1195 | |||
1196 | def get_file_changeset(self, path): |
|
1196 | def get_file_changeset(self, path): | |
1197 |
warnings.warn("Use get_ |
|
1197 | warnings.warn("Use get_path_commit instead", DeprecationWarning) | |
1198 |
return self.get_ |
|
1198 | return self.get_path_commit(path) | |
1199 |
|
1199 | |||
1200 |
|
1200 | |||
1201 | class BaseChangesetClass(type): |
|
1201 | class BaseChangesetClass(type): | |
@@ -1502,7 +1502,7 b' class EmptyCommit(BaseCommit):' | |||||
1502 | def id(self): |
|
1502 | def id(self): | |
1503 | return self.raw_id |
|
1503 | return self.raw_id | |
1504 |
|
1504 | |||
1505 |
def get_ |
|
1505 | def get_path_commit(self, path): | |
1506 | return self |
|
1506 | return self | |
1507 |
|
1507 | |||
1508 | def get_file_content(self, path): |
|
1508 | def get_file_content(self, path): |
@@ -298,7 +298,7 b' class GitCommit(base.BaseCommit):' | |||||
298 | id_, _ = self._get_id_for_path(path) |
|
298 | id_, _ = self._get_id_for_path(path) | |
299 | return self._remote.blob_raw_length(id_) |
|
299 | return self._remote.blob_raw_length(id_) | |
300 |
|
300 | |||
301 |
def get_ |
|
301 | def get_path_history(self, path, limit=None, pre_load=None): | |
302 | """ |
|
302 | """ | |
303 | Returns history of file as reversed list of `GitCommit` objects for |
|
303 | Returns history of file as reversed list of `GitCommit` objects for | |
304 | which file at given `path` has been modified. |
|
304 | which file at given `path` has been modified. | |
@@ -321,21 +321,6 b' class GitCommit(base.BaseCommit):' | |||||
321 | self.repository.get_commit(commit_id=commit_id, pre_load=pre_load) |
|
321 | self.repository.get_commit(commit_id=commit_id, pre_load=pre_load) | |
322 | for commit_id in commit_ids] |
|
322 | for commit_id in commit_ids] | |
323 |
|
323 | |||
324 | # TODO: unused for now potential replacement for subprocess |
|
|||
325 | def get_file_history_2(self, path, limit=None, pre_load=None): |
|
|||
326 | """ |
|
|||
327 | Returns history of file as reversed list of `Commit` objects for |
|
|||
328 | which file at given `path` has been modified. |
|
|||
329 | """ |
|
|||
330 | self._get_filectx(path) |
|
|||
331 | f_path = safe_str(path) |
|
|||
332 |
|
||||
333 | commit_ids = self._remote.get_file_history(f_path, self.id, limit) |
|
|||
334 |
|
||||
335 | return [ |
|
|||
336 | self.repository.get_commit(commit_id=commit_id, pre_load=pre_load) |
|
|||
337 | for commit_id in commit_ids] |
|
|||
338 |
|
||||
339 | def get_file_annotate(self, path, pre_load=None): |
|
324 | def get_file_annotate(self, path, pre_load=None): | |
340 | """ |
|
325 | """ | |
341 | Returns a generator of four element tuples with |
|
326 | Returns a generator of four element tuples with |
@@ -252,13 +252,13 b' class MercurialCommit(base.BaseCommit):' | |||||
252 | path = self._get_filectx(path) |
|
252 | path = self._get_filectx(path) | |
253 | return self._remote.fctx_size(self.idx, path) |
|
253 | return self._remote.fctx_size(self.idx, path) | |
254 |
|
254 | |||
255 |
def get_ |
|
255 | def get_path_history(self, path, limit=None, pre_load=None): | |
256 | """ |
|
256 | """ | |
257 | Returns history of file as reversed list of `MercurialCommit` objects |
|
257 | Returns history of file as reversed list of `MercurialCommit` objects | |
258 | for which file at given ``path`` has been modified. |
|
258 | for which file at given ``path`` has been modified. | |
259 | """ |
|
259 | """ | |
260 | path = self._get_filectx(path) |
|
260 | path = self._get_filectx(path) | |
261 |
hist = self._remote. |
|
261 | hist = self._remote.node_history(self.idx, path, limit) | |
262 | return [ |
|
262 | return [ | |
263 | self.repository.get_commit(commit_id=commit_id, pre_load=pre_load) |
|
263 | self.repository.get_commit(commit_id=commit_id, pre_load=pre_load) | |
264 | for commit_id in hist] |
|
264 | for commit_id in hist] |
@@ -121,7 +121,7 b' class SubversionCommit(base.BaseCommit):' | |||||
121 | path = self._fix_path(path) |
|
121 | path = self._fix_path(path) | |
122 | return self._remote.get_file_size(safe_str(path), self._svn_rev) |
|
122 | return self._remote.get_file_size(safe_str(path), self._svn_rev) | |
123 |
|
123 | |||
124 |
def get_ |
|
124 | def get_path_history(self, path, limit=None, pre_load=None): | |
125 | path = safe_str(self._fix_path(path)) |
|
125 | path = safe_str(self._fix_path(path)) | |
126 | history = self._remote.node_history(path, self._svn_rev, limit) |
|
126 | history = self._remote.node_history(path, self._svn_rev, limit) | |
127 | return [ |
|
127 | return [ |
@@ -404,7 +404,7 b' class FileNode(Node):' | |||||
404 | def last_commit(self): |
|
404 | def last_commit(self): | |
405 | if self.commit: |
|
405 | if self.commit: | |
406 | pre_load = ["author", "date", "message"] |
|
406 | pre_load = ["author", "date", "message"] | |
407 |
return self.commit.get_ |
|
407 | return self.commit.get_path_commit(self.path, pre_load=pre_load) | |
408 | raise NodeError( |
|
408 | raise NodeError( | |
409 | "Cannot retrieve last commit of the file without " |
|
409 | "Cannot retrieve last commit of the file without " | |
410 | "related commit attribute") |
|
410 | "related commit attribute") | |
@@ -510,7 +510,7 b' class FileNode(Node):' | |||||
510 | """ |
|
510 | """ | |
511 | if self.commit is None: |
|
511 | if self.commit is None: | |
512 | raise NodeError('Unable to get commit for this FileNode') |
|
512 | raise NodeError('Unable to get commit for this FileNode') | |
513 |
return self.commit.get_ |
|
513 | return self.commit.get_path_history(self.path) | |
514 |
|
514 | |||
515 | @LazyProperty |
|
515 | @LazyProperty | |
516 | def annotate(self): |
|
516 | def annotate(self): | |
@@ -724,6 +724,15 b' class DirNode(Node):' | |||||
724 |
|
724 | |||
725 | return size |
|
725 | return size | |
726 |
|
726 | |||
|
727 | @LazyProperty | |||
|
728 | def last_commit(self): | |||
|
729 | if self.commit: | |||
|
730 | pre_load = ["author", "date", "message"] | |||
|
731 | return self.commit.get_path_commit(self.path, pre_load=pre_load) | |||
|
732 | raise NodeError( | |||
|
733 | "Cannot retrieve last commit of the file without " | |||
|
734 | "related commit attribute") | |||
|
735 | ||||
727 | def __repr__(self): |
|
736 | def __repr__(self): | |
728 | return '<%s %r @ %s>' % (self.__class__.__name__, self.path, |
|
737 | return '<%s %r @ %s>' % (self.__class__.__name__, self.path, | |
729 | getattr(self.commit, 'short_id', '')) |
|
738 | getattr(self.commit, 'short_id', '')) |
@@ -310,9 +310,9 b' class TestCommits(BackendTestMixin):' | |||||
310 | with pytest.raises(CommitDoesNotExistError): |
|
310 | with pytest.raises(CommitDoesNotExistError): | |
311 | commit.next() |
|
311 | commit.next() | |
312 |
|
312 | |||
313 |
def test_get_ |
|
313 | def test_get_path_commit(self): | |
314 | commit = self.repo.get_commit() |
|
314 | commit = self.repo.get_commit() | |
315 |
commit.get_ |
|
315 | commit.get_path_commit('file_4.txt') | |
316 | assert commit.message == 'Commit 4' |
|
316 | assert commit.message == 'Commit 4' | |
317 |
|
317 | |||
318 | def test_get_filenodes_generator(self): |
|
318 | def test_get_filenodes_generator(self): | |
@@ -571,19 +571,19 b' class TestCommitsChanges(BackendTestMixi' | |||||
571 | assert FILEMODE_DEFAULT == commit.get_file_mode('foo/bał') |
|
571 | assert FILEMODE_DEFAULT == commit.get_file_mode('foo/bał') | |
572 | assert FILEMODE_DEFAULT == commit.get_file_mode(u'foo/bał') |
|
572 | assert FILEMODE_DEFAULT == commit.get_file_mode(u'foo/bał') | |
573 |
|
573 | |||
574 |
def test_get_ |
|
574 | def test_get_path_history(self): | |
575 | commit = self.repo.get_commit() |
|
575 | commit = self.repo.get_commit() | |
576 |
history = commit.get_ |
|
576 | history = commit.get_path_history('foo/bar') | |
577 | assert len(history) == 2 |
|
577 | assert len(history) == 2 | |
578 |
|
578 | |||
579 |
def test_get_ |
|
579 | def test_get_path_history_with_limit(self): | |
580 | commit = self.repo.get_commit() |
|
580 | commit = self.repo.get_commit() | |
581 |
history = commit.get_ |
|
581 | history = commit.get_path_history('foo/bar', limit=1) | |
582 | assert len(history) == 1 |
|
582 | assert len(history) == 1 | |
583 |
|
583 | |||
584 |
def test_get_ |
|
584 | def test_get_path_history_first_commit(self): | |
585 | commit = self.repo[0] |
|
585 | commit = self.repo[0] | |
586 |
history = commit.get_ |
|
586 | history = commit.get_path_history('foo/bar') | |
587 | assert len(history) == 1 |
|
587 | assert len(history) == 1 | |
588 |
|
588 | |||
589 |
|
589 |
General Comments 0
You need to be logged in to leave comments.
Login now