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