Show More
@@ -416,10 +416,12 b' def make_map(config):' | |||
|
416 | 416 | controller='changeset', action='raw_changeset', |
|
417 | 417 | revision='tip', conditions=dict(function=check_repo)) |
|
418 | 418 | |
|
419 |
rmap.connect('compare_ |
|
|
420 |
'/{repo_name:.*}/compare/{ |
|
|
419 | rmap.connect('compare_url', | |
|
420 | '/{repo_name:.*}/compare/{org_ref_type}@{org_ref}...{other_ref_type}@{other_ref}', | |
|
421 | 421 | controller='compare', action='index', |
|
422 |
conditions=dict(function=check_repo) |
|
|
422 | conditions=dict(function=check_repo), | |
|
423 | requirements=dict(org_ref_type='(branch|book|tag)', | |
|
424 | other_ref_type='(branch|book|tag)')) | |
|
423 | 425 | |
|
424 | 426 | rmap.connect('pullrequest_home', |
|
425 | 427 | '/{repo_name:.*}/pull-request/new', |
@@ -49,41 +49,6 b' class CompareController(BaseRepoControll' | |||
|
49 | 49 | def __before__(self): |
|
50 | 50 | super(CompareController, self).__before__() |
|
51 | 51 | |
|
52 | def _handle_ref(self, ref): | |
|
53 | """ | |
|
54 | Parse the org...other string | |
|
55 | Possible formats are | |
|
56 | `(branch|book|tag):<name>...(branch|book|tag):<othername>` | |
|
57 | ||
|
58 | :param ref: <orginal_reference>...<other_reference> | |
|
59 | :type ref: str | |
|
60 | """ | |
|
61 | org_repo = c.rhodecode_db_repo.repo_name | |
|
62 | ||
|
63 | def org_parser(org): | |
|
64 | _repo = org_repo | |
|
65 | name, val = org.split(':') | |
|
66 | return _repo, (name, val) | |
|
67 | ||
|
68 | def other_parser(other): | |
|
69 | _other_repo = request.GET.get('repo') | |
|
70 | _repo = org_repo | |
|
71 | name, val = other.split(':') | |
|
72 | if _other_repo: | |
|
73 | _repo = _other_repo | |
|
74 | ||
|
75 | return _repo, (name, val) | |
|
76 | ||
|
77 | if '...' in ref: | |
|
78 | try: | |
|
79 | org, other = ref.split('...') | |
|
80 | org_repo, org_ref = org_parser(org) | |
|
81 | other_repo, other_ref = other_parser(other) | |
|
82 | return org_repo, org_ref, other_repo, other_ref | |
|
83 | except: | |
|
84 | log.error(traceback.format_exc()) | |
|
85 | ||
|
86 | raise HTTPNotFound | |
|
87 | 52 | |
|
88 | 53 | def _get_discovery(self, org_repo, org_ref, other_repo, other_ref): |
|
89 | 54 | from mercurial import discovery |
@@ -125,13 +90,18 b' class CompareController(BaseRepoControll' | |||
|
125 | 90 | |
|
126 | 91 | return changesets |
|
127 | 92 | |
|
128 | def index(self, ref): | |
|
129 | org_repo, org_ref, other_repo, other_ref = self._handle_ref(ref) | |
|
93 | def index(self, org_ref_type, org_ref, other_ref_type, other_ref): | |
|
130 | 94 | |
|
131 | c.swap_url = h.url('compare_home', repo_name=other_repo, | |
|
132 | ref='%s...%s' % (':'.join(other_ref), | |
|
133 | ':'.join(org_ref)), | |
|
95 | org_repo = c.rhodecode_db_repo.repo_name | |
|
96 | org_ref = (org_ref_type, org_ref) | |
|
97 | other_ref = (other_ref_type, other_ref) | |
|
98 | other_repo = request.GET.get('repo', org_repo) | |
|
99 | ||
|
100 | c.swap_url = h.url('compare_url', repo_name=other_repo, | |
|
101 | org_ref_type=other_ref[0], org_ref=other_ref[1], | |
|
102 | other_ref_type=org_ref[0], other_ref=org_ref[1], | |
|
134 | 103 |
|
|
104 | ||
|
135 | 105 | c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) |
|
136 | 106 | c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) |
|
137 | 107 |
@@ -37,10 +37,11 b" YUE.on('compare_branches','click',functi" | |||
|
37 | 37 | YUE.preventDefault(e); |
|
38 | 38 | var org = YUQ('input[name=compare_org]:checked')[0]; |
|
39 | 39 | var other = YUQ('input[name=compare_other]:checked')[0]; |
|
40 | var compare_url = "${h.url('compare_home',repo_name=c.repo_name,ref='__ORG__...__OTHER__')}"; | |
|
40 | ||
|
41 | 41 | if(org && other){ |
|
42 | var u = compare_url.replace('__ORG__','branch:'+org.value) | |
|
43 | .replace('__OTHER__','branch:'+other.value); | |
|
42 | var compare_url = "${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref='__ORG__',other_ref_type='branch',other_ref='__OTHER__')}"; | |
|
43 | var u = compare_url.replace('__ORG__',org.value) | |
|
44 | .replace('__OTHER__',other.value); | |
|
44 | 45 | window.location=u; |
|
45 | 46 | } |
|
46 | 47 |
@@ -32,7 +32,12 b'' | |||
|
32 | 32 | <canvas id="graph_canvas"></canvas> |
|
33 | 33 | </div> |
|
34 | 34 | <div id="graph_content"> |
|
35 |
<div class="info_box" style="clear: both;padding: 10px 6px;vertical-align: right;text-align: right;"> |
|
|
35 | <div class="info_box" style="clear: both;padding: 10px 6px;vertical-align: right;text-align: right;"> | |
|
36 | %if c.rhodecode_db_repo.fork: | |
|
37 | <a title="${_('compare fork with %s' % c.rhodecode_db_repo.fork.repo_name)}" href="${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref='default',other_ref_type='branch',other_ref='default',repo=c.rhodecode_db_repo.fork.repo_name)}" class="ui-btn small">${_('Compare fork')}</a> | |
|
38 | %endif | |
|
39 | <a href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="ui-btn small">${_('Open new pull request')}</a> | |
|
40 | </div> | |
|
36 | 41 | <div class="container_header"> |
|
37 | 42 | ${h.form(h.url.current(),method='get')} |
|
38 | 43 | <div class="info_box" style="float:left"> |
General Comments 0
You need to be logged in to leave comments.
Login now