##// END OF EJS Templates
compare: make __get_cs_or_redirect more exact
Mads Kiilerich -
r4038:ed50319a default
parent child Browse files
Show More
@@ -54,7 +54,7 b' class CompareController(BaseRepoControll'
54 def __before__(self):
54 def __before__(self):
55 super(CompareController, self).__before__()
55 super(CompareController, self).__before__()
56
56
57 def __get_cs_or_redirect(self, rev, repo, redirect_after=True,
57 def __get_cs_or_redirect(self, ref, repo, redirect_after=True,
58 partial=False):
58 partial=False):
59 """
59 """
60 Safe way to get changeset if error occur it redirects to changeset with
60 Safe way to get changeset if error occur it redirects to changeset with
@@ -65,8 +65,22 b' class CompareController(BaseRepoControll'
65 :param repo: repo instance
65 :param repo: repo instance
66 """
66 """
67
67
68 rev = ref[1] # default and used for git
69 if repo.scm_instance.alias == 'hg':
70 # lookup up the exact node id
71 _revset_predicates = {
72 'branch': 'branch',
73 'book': 'bookmark',
74 'tag': 'tag',
75 'rev': 'id',
76 }
77 rev_spec = "max(%s(%%s))" % _revset_predicates[ref[0]]
78 revs = repo.scm_instance._repo.revs(rev_spec, safe_str(ref[1]))
79 if revs:
80 rev = revs[-1]
81 # else: TODO: just report 'not found'
82
68 try:
83 try:
69 type_, rev = rev
70 return repo.scm_instance.get_changeset(rev)
84 return repo.scm_instance.get_changeset(rev)
71 except EmptyRepositoryError, e:
85 except EmptyRepositoryError, e:
72 if not redirect_after:
86 if not redirect_after:
@@ -205,8 +219,8 b' class CompareController(BaseRepoControll'
205 log.error('compare of two different kind of remote repos not available')
219 log.error('compare of two different kind of remote repos not available')
206 raise HTTPNotFound
220 raise HTTPNotFound
207
221
208 self.__get_cs_or_redirect(rev=org_ref, repo=org_repo, partial=partial)
222 self.__get_cs_or_redirect(ref=org_ref, repo=org_repo, partial=partial)
209 self.__get_cs_or_redirect(rev=other_ref, repo=other_repo, partial=partial)
223 self.__get_cs_or_redirect(ref=other_ref, repo=other_repo, partial=partial)
210
224
211 c.org_repo = org_repo
225 c.org_repo = org_repo
212 c.other_repo = other_repo
226 c.other_repo = other_repo
General Comments 0
You need to be logged in to leave comments. Login now