##// END OF EJS Templates
commits: allow tag commit translation to be skipped for faster commit fetching in big chunks.
marcink -
r3468:7bc93053 default
parent child Browse files
Show More
@@ -381,7 +381,7 b' def get_repo_changesets(request, apiuser'
381 381
382 382 try:
383 383 commits = vcs_repo.get_commits(
384 start_id=start_rev, pre_load=pre_load)
384 start_id=start_rev, pre_load=pre_load, translate_tags=False)
385 385 except TypeError as e:
386 386 raise JSONRPCError(safe_str(e))
387 387 except Exception:
@@ -203,7 +203,6 b' class RepoChangelogView(RepoAppView):'
203 203 pre_load = self._get_preload_attrs()
204 204
205 205 partial_xhr = self.request.environ.get('HTTP_X_PARTIAL_XHR')
206
207 206 try:
208 207 if f_path:
209 208 log.debug('generating changelog for path %s', f_path)
@@ -231,7 +230,7 b' class RepoChangelogView(RepoAppView):'
231 230 else:
232 231 collection = self.rhodecode_vcs_repo.get_commits(
233 232 branch_name=branch_name, show_hidden=show_hidden,
234 pre_load=pre_load)
233 pre_load=pre_load, translate_tags=False)
235 234
236 235 self._load_changelog_data(
237 236 c, collection, p, chunk_size, c.branch_name,
@@ -320,7 +319,8 b' class RepoChangelogView(RepoAppView):'
320 319 collection = list(reversed(collection))
321 320 else:
322 321 collection = self.rhodecode_vcs_repo.get_commits(
323 branch_name=branch_name, show_hidden=show_hidden, pre_load=pre_load)
322 branch_name=branch_name, show_hidden=show_hidden, pre_load=pre_load,
323 translate_tags=False)
324 324
325 325 p = safe_int(self.request.GET.get('page', 1), 1)
326 326 try:
@@ -97,7 +97,7 b' class RepoCommitsView(RepoAppView):'
97 97 if len(commit_range) == 2:
98 98 commits = self.rhodecode_vcs_repo.get_commits(
99 99 start_id=commit_range[0], end_id=commit_range[1],
100 pre_load=pre_load)
100 pre_load=pre_load, translate_tags=False)
101 101 commits = list(commits)
102 102 else:
103 103 commits = [self.rhodecode_vcs_repo.get_commit(
@@ -141,7 +141,8 b' class RepoSummaryView(RepoAppView):'
141 141
142 142 pre_load = ['author', 'branch', 'date', 'message']
143 143 try:
144 collection = self.rhodecode_vcs_repo.get_commits(pre_load=pre_load)
144 collection = self.rhodecode_vcs_repo.get_commits(
145 pre_load=pre_load, translate_tags=False)
145 146 except EmptyRepositoryError:
146 147 collection = self.rhodecode_vcs_repo
147 148
@@ -401,7 +401,7 b' class BaseRepository(object):'
401 401 # COMMITS
402 402 # ==========================================================================
403 403
404 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None):
404 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None, translate_tag=None):
405 405 """
406 406 Returns instance of `BaseCommit` class. If `commit_id` and `commit_idx`
407 407 are both None, most recent commit is returned.
@@ -418,7 +418,7 b' class BaseRepository(object):'
418 418
419 419 def get_commits(
420 420 self, start_id=None, end_id=None, start_date=None, end_date=None,
421 branch_name=None, show_hidden=False, pre_load=None):
421 branch_name=None, show_hidden=False, pre_load=None, translate_tags=None):
422 422 """
423 423 Returns iterator of `BaseCommit` objects from start to end
424 424 not inclusive. This should behave just like a list, ie. end is not
@@ -431,6 +431,7 b' class BaseRepository(object):'
431 431 :param branch_name:
432 432 :param show_hidden:
433 433 :param pre_load:
434 :param translate_tags:
434 435 """
435 436 raise NotImplementedError
436 437
@@ -1646,12 +1647,13 b' class EmptyRepository(BaseRepository):'
1646 1647
1647 1648 class CollectionGenerator(object):
1648 1649
1649 def __init__(self, repo, commit_ids, collection_size=None, pre_load=None):
1650 def __init__(self, repo, commit_ids, collection_size=None, pre_load=None, translate_tag=None):
1650 1651 self.repo = repo
1651 1652 self.commit_ids = commit_ids
1652 1653 # TODO: (oliver) this isn't currently hooked up
1653 1654 self.collection_size = None
1654 1655 self.pre_load = pre_load
1656 self.translate_tag = translate_tag
1655 1657
1656 1658 def __len__(self):
1657 1659 if self.collection_size is not None:
@@ -1667,8 +1669,9 b' class CollectionGenerator(object):'
1667 1669 """
1668 1670 Allows backends to override the way commits are generated.
1669 1671 """
1670 return self.repo.get_commit(commit_id=commit_id,
1671 pre_load=self.pre_load)
1672 return self.repo.get_commit(
1673 commit_id=commit_id, pre_load=self.pre_load,
1674 translate_tag=self.translate_tag)
1672 1675
1673 1676 def __getslice__(self, i, j):
1674 1677 """
@@ -1676,7 +1679,8 b' class CollectionGenerator(object):'
1676 1679 """
1677 1680 commit_ids = self.commit_ids[i:j]
1678 1681 return self.__class__(
1679 self.repo, commit_ids, pre_load=self.pre_load)
1682 self.repo, commit_ids, pre_load=self.pre_load,
1683 translate_tag=self.translate_tag)
1680 1684
1681 1685 def __repr__(self):
1682 1686 return '<CollectionGenerator[len:%s]>' % (self.__len__())
@@ -269,7 +269,8 b' class GitCommit(base.BaseCommit):'
269 269
270 270 def _make_commits(self, commit_ids, pre_load=None):
271 271 return [
272 self.repository.get_commit(commit_id=commit_id, pre_load=pre_load)
272 self.repository.get_commit(commit_id=commit_id, pre_load=pre_load,
273 translate_tag=False)
273 274 for commit_id in commit_ids]
274 275
275 276 def get_file_mode(self, path):
@@ -426,7 +426,7 b' class GitRepository(BaseRepository):'
426 426 except Exception:
427 427 return
428 428
429 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None):
429 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None, translate_tag=True):
430 430 """
431 431 Returns `GitCommit` object representing commit from git repository
432 432 at the given `commit_id` or head (most recent commit) if None given.
@@ -438,8 +438,9 b' class GitRepository(BaseRepository):'
438 438 commit_id = commit_idx
439 439 commit_id = self._get_commit_id(commit_id)
440 440 try:
441 # Need to call remote to translate id for tagging scenario
442 commit_id = self._remote.get_object(commit_id)["commit_id"]
441 if translate_tag:
442 # Need to call remote to translate id for tagging scenario
443 commit_id = self._remote.get_object(commit_id)["commit_id"]
443 444 idx = self._commit_ids[commit_id]
444 445 except KeyError:
445 446 raise RepositoryError("Cannot get object with id %s" % commit_id)
@@ -448,7 +449,7 b' class GitRepository(BaseRepository):'
448 449
449 450 def get_commits(
450 451 self, start_id=None, end_id=None, start_date=None, end_date=None,
451 branch_name=None, show_hidden=False, pre_load=None):
452 branch_name=None, show_hidden=False, pre_load=None, translate_tags=True):
452 453 """
453 454 Returns generator of `GitCommit` objects from start to end (both
454 455 are inclusive), in ascending date order.
@@ -528,7 +529,8 b' class GitRepository(BaseRepository):'
528 529 if start_pos or end_pos:
529 530 commit_ids = commit_ids[start_pos: end_pos]
530 531
531 return CollectionGenerator(self, commit_ids, pre_load=pre_load)
532 return CollectionGenerator(self, commit_ids, pre_load=pre_load,
533 translate_tag=translate_tags)
532 534
533 535 def get_diff(
534 536 self, commit1, commit2, path='', ignore_whitespace=False,
@@ -414,7 +414,7 b' class MercurialRepository(BaseRepository'
414 414 """
415 415 return os.path.join(self.path, '.hg', '.hgrc')
416 416
417 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None):
417 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None, translate_tag=None):
418 418 """
419 419 Returns ``MercurialCommit`` object representing repository's
420 420 commit at the given `commit_id` or `commit_idx`.
@@ -456,7 +456,7 b' class MercurialRepository(BaseRepository'
456 456
457 457 def get_commits(
458 458 self, start_id=None, end_id=None, start_date=None, end_date=None,
459 branch_name=None, show_hidden=False, pre_load=None):
459 branch_name=None, show_hidden=False, pre_load=None, translate_tags=None):
460 460 """
461 461 Returns generator of ``MercurialCommit`` objects from start to end
462 462 (both are inclusive)
@@ -250,7 +250,7 b' class SubversionRepository(base.BaseRepo'
250 250 """
251 251 return os.path.join(self.path, 'hooks')
252 252
253 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None):
253 def get_commit(self, commit_id=None, commit_idx=None, pre_load=None, translate_tag=None):
254 254 if self.is_empty():
255 255 raise EmptyRepositoryError("There are no commits yet")
256 256 if commit_id is not None:
@@ -268,7 +268,7 b' class SubversionRepository(base.BaseRepo'
268 268
269 269 def get_commits(
270 270 self, start_id=None, end_id=None, start_date=None, end_date=None,
271 branch_name=None, show_hidden=False, pre_load=None):
271 branch_name=None, show_hidden=False, pre_load=None, translate_tags=None):
272 272 if self.is_empty():
273 273 raise EmptyRepositoryError("There are no commit_ids yet")
274 274 self._validate_branch_name(branch_name)
General Comments 0
You need to be logged in to leave comments. Login now