Show More
@@ -0,0 +1,153 b'' | |||||
|
1 | from rhodecode.tests import * | |||
|
2 | from rhodecode.model.repo import RepoModel | |||
|
3 | from rhodecode.model.meta import Session | |||
|
4 | from rhodecode.model.db import Repository | |||
|
5 | from rhodecode.model.scm import ScmModel | |||
|
6 | from rhodecode.lib.vcs.backends.base import EmptyChangeset | |||
|
7 | ||||
|
8 | ||||
|
9 | class TestCompareController(TestController): | |||
|
10 | ||||
|
11 | def test_compare_tag_hg(self): | |||
|
12 | self.log_user() | |||
|
13 | tag1 = '0.1.2' | |||
|
14 | tag2 = '0.1.3' | |||
|
15 | response = self.app.get(url(controller='compare', action='index', | |||
|
16 | repo_name=HG_REPO, | |||
|
17 | org_ref_type="tag", | |||
|
18 | org_ref=tag1, | |||
|
19 | other_ref_type="tag", | |||
|
20 | other_ref=tag2, | |||
|
21 | )) | |||
|
22 | response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, tag1, HG_REPO, tag2)) | |||
|
23 | ## outgoing changesets between tags | |||
|
24 | response.mustcontain('''<a href="/%s/changeset/c5ddebc06eaaba3010c2d66ea6ec9d074eb0f678">r112:c5ddebc06eaa</a>''' % HG_REPO) | |||
|
25 | response.mustcontain('''<a href="/%s/changeset/70d4cef8a37657ee4cf5aabb3bd9f68879769816">r115:70d4cef8a376</a>''' % HG_REPO) | |||
|
26 | response.mustcontain('''<a href="/%s/changeset/9749bfbfc0d2eba208d7947de266303b67c87cda">r116:9749bfbfc0d2</a>''' % HG_REPO) | |||
|
27 | response.mustcontain('''<a href="/%s/changeset/41fda979f02fda216374bf8edac4e83f69e7581c">r117:41fda979f02f</a>''' % HG_REPO) | |||
|
28 | response.mustcontain('''<a href="/%s/changeset/bb1a3ab98cc45cb934a77dcabf87a5a598b59e97">r118:bb1a3ab98cc4</a>''' % HG_REPO) | |||
|
29 | response.mustcontain('''<a href="/%s/changeset/36e0fc9d2808c5022a24f49d6658330383ed8666">r119:36e0fc9d2808</a>''' % HG_REPO) | |||
|
30 | response.mustcontain('''<a href="/%s/changeset/17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">r120:17544fbfcd33</a>''' % HG_REPO) | |||
|
31 | ||||
|
32 | response.mustcontain('11 files changed with 94 insertions and 64 deletions') | |||
|
33 | ||||
|
34 | ## files diff | |||
|
35 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--1c5cf9e91c12">docs/api/utils/index.rst</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
36 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--e3305437df55">test_and_report.sh</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
37 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--c8e92ef85cd1">.hgignore</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
38 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--6e08b694d687">.hgtags</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
39 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--2c14b00f3393">docs/api/index.rst</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
40 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--430ccbc82bdf">vcs/__init__.py</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
41 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--9c390eb52cd6">vcs/backends/hg.py</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
42 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--ebb592c595c0">vcs/utils/__init__.py</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
43 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--7abc741b5052">vcs/utils/annotate.py</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
44 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--2ef0ef106c56">vcs/utils/diffs.py</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
45 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--3150cb87d4b7">vcs/utils/lazy.py</a></div>''' % (HG_REPO, tag1, tag2)) | |||
|
46 | ||||
|
47 | def test_compare_tag_git(self): | |||
|
48 | self.log_user() | |||
|
49 | tag1 = 'v0.1.2' | |||
|
50 | tag2 = 'v0.1.3' | |||
|
51 | response = self.app.get(url(controller='compare', action='index', | |||
|
52 | repo_name=GIT_REPO, | |||
|
53 | org_ref_type="tag", | |||
|
54 | org_ref=tag1, | |||
|
55 | other_ref_type="tag", | |||
|
56 | other_ref=tag2, | |||
|
57 | bundle=False | |||
|
58 | )) | |||
|
59 | response.mustcontain('%s@%s -> %s@%s' % (GIT_REPO, tag1, GIT_REPO, tag2)) | |||
|
60 | ||||
|
61 | ## outgoing changesets between tags | |||
|
62 | response.mustcontain('''<a href="/%s/changeset/794bbdd31545c199f74912709ea350dedcd189a2">r113:794bbdd31545</a>''' % GIT_REPO) | |||
|
63 | response.mustcontain('''<a href="/%s/changeset/e36d8c5025329bdd4212bd53d4ed8a70ff44985f">r115:e36d8c502532</a>''' % GIT_REPO) | |||
|
64 | response.mustcontain('''<a href="/%s/changeset/5c9ff4f6d7508db0e72b1d2991c357d0d8e07af2">r116:5c9ff4f6d750</a>''' % GIT_REPO) | |||
|
65 | response.mustcontain('''<a href="/%s/changeset/b7187fa2b8c1d773ec35e9dee12f01f74808c879">r117:b7187fa2b8c1</a>''' % GIT_REPO) | |||
|
66 | response.mustcontain('''<a href="/%s/changeset/5f3b74262014a8de2dc7dade1152de9fd0c8efef">r118:5f3b74262014</a>''' % GIT_REPO) | |||
|
67 | response.mustcontain('''<a href="/%s/changeset/17438a11f72b93f56d0e08e7d1fa79a378578a82">r119:17438a11f72b</a>''' % GIT_REPO) | |||
|
68 | response.mustcontain('''<a href="/%s/changeset/5a3a8fb005554692b16e21dee62bf02667d8dc3e">r120:5a3a8fb00555</a>''' % GIT_REPO) | |||
|
69 | ||||
|
70 | response.mustcontain('11 files changed with 94 insertions and 64 deletions') | |||
|
71 | ||||
|
72 | #files | |||
|
73 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--1c5cf9e91c12">docs/api/utils/index.rst</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
74 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--e3305437df55">test_and_report.sh</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
75 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--c8e92ef85cd1">.hgignore</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
76 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--6e08b694d687">.hgtags</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
77 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--2c14b00f3393">docs/api/index.rst</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
78 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--430ccbc82bdf">vcs/__init__.py</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
79 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
80 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--ebb592c595c0">vcs/utils/__init__.py</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
81 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--7abc741b5052">vcs/utils/annotate.py</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
82 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--2ef0ef106c56">vcs/utils/diffs.py</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
83 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--3150cb87d4b7">vcs/utils/lazy.py</a>''' % (GIT_REPO, tag1, tag2)) | |||
|
84 | ||||
|
85 | def test_index_branch_hg(self): | |||
|
86 | self.log_user() | |||
|
87 | response = self.app.get(url(controller='compare', action='index', | |||
|
88 | repo_name=HG_REPO, | |||
|
89 | org_ref_type="branch", | |||
|
90 | org_ref='default', | |||
|
91 | other_ref_type="branch", | |||
|
92 | other_ref='default', | |||
|
93 | )) | |||
|
94 | ||||
|
95 | response.mustcontain('%s@default -> %s@default' % (HG_REPO, HG_REPO)) | |||
|
96 | # branch are equal | |||
|
97 | response.mustcontain('<span class="empty_data">No files</span>') | |||
|
98 | response.mustcontain('<span class="empty_data">No changesets</span>') | |||
|
99 | ||||
|
100 | def test_index_branch_git(self): | |||
|
101 | self.log_user() | |||
|
102 | response = self.app.get(url(controller='compare', action='index', | |||
|
103 | repo_name=GIT_REPO, | |||
|
104 | org_ref_type="branch", | |||
|
105 | org_ref='master', | |||
|
106 | other_ref_type="branch", | |||
|
107 | other_ref='master', | |||
|
108 | )) | |||
|
109 | ||||
|
110 | response.mustcontain('%s@master -> %s@master' % (GIT_REPO, GIT_REPO)) | |||
|
111 | # branch are equal | |||
|
112 | response.mustcontain('<span class="empty_data">No files</span>') | |||
|
113 | response.mustcontain('<span class="empty_data">No changesets</span>') | |||
|
114 | ||||
|
115 | def test_compare_revisions_hg(self): | |||
|
116 | self.log_user() | |||
|
117 | rev1 = 'b986218ba1c9' | |||
|
118 | rev2 = '3d8f361e72ab' | |||
|
119 | ||||
|
120 | response = self.app.get(url(controller='compare', action='index', | |||
|
121 | repo_name=HG_REPO, | |||
|
122 | org_ref_type="rev", | |||
|
123 | org_ref=rev1, | |||
|
124 | other_ref_type="rev", | |||
|
125 | other_ref=rev2, | |||
|
126 | )) | |||
|
127 | response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_REPO, rev2)) | |||
|
128 | ## outgoing changesets between those revisions | |||
|
129 | response.mustcontain("""<a href="/%s/changeset/3d8f361e72ab303da48d799ff1ac40d5ac37c67e">r1:%s</a>""" % (HG_REPO, rev2)) | |||
|
130 | ||||
|
131 | response.mustcontain('1 file changed with 7 insertions and 0 deletions') | |||
|
132 | ## files | |||
|
133 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--c8e92ef85cd1">.hgignore</a>""" % (HG_REPO, rev1, rev2)) | |||
|
134 | ||||
|
135 | def test_compare_revisions_git(self): | |||
|
136 | self.log_user() | |||
|
137 | rev1 = 'c1214f7e79e02fc37156ff215cd71275450cffc3' | |||
|
138 | rev2 = '38b5fe81f109cb111f549bfe9bb6b267e10bc557' | |||
|
139 | ||||
|
140 | response = self.app.get(url(controller='compare', action='index', | |||
|
141 | repo_name=GIT_REPO, | |||
|
142 | org_ref_type="rev", | |||
|
143 | org_ref=rev1, | |||
|
144 | other_ref_type="rev", | |||
|
145 | other_ref=rev2, | |||
|
146 | )) | |||
|
147 | response.mustcontain('%s@%s -> %s@%s' % (GIT_REPO, rev1, GIT_REPO, rev2)) | |||
|
148 | ## outgoing changesets between those revisions | |||
|
149 | response.mustcontain("""<a href="/%s/changeset/38b5fe81f109cb111f549bfe9bb6b267e10bc557">r1:%s</a>""" % (GIT_REPO, rev2[:12])) | |||
|
150 | response.mustcontain('1 file changed with 7 insertions and 0 deletions') | |||
|
151 | ||||
|
152 | ## files | |||
|
153 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--c8e92ef85cd1">.hgignore</a>""" % (GIT_REPO, rev1, rev2)) |
@@ -194,7 +194,7 b' class ChangesetController(BaseRepoContro' | |||||
194 | rev_start = rev_range[0] |
|
194 | rev_start = rev_range[0] | |
195 | rev_end = rev_range[1] |
|
195 | rev_end = rev_range[1] | |
196 | rev_ranges = c.rhodecode_repo.get_changesets(start=rev_start, |
|
196 | rev_ranges = c.rhodecode_repo.get_changesets(start=rev_start, | |
197 | end=rev_end) |
|
197 | end=rev_end) | |
198 | else: |
|
198 | else: | |
199 | rev_ranges = [c.rhodecode_repo.get_changeset(revision)] |
|
199 | rev_ranges = [c.rhodecode_repo.get_changeset(revision)] | |
200 |
|
200 |
@@ -42,6 +42,7 b' from rhodecode.model.pull_request import' | |||||
42 | from webob.exc import HTTPBadRequest |
|
42 | from webob.exc import HTTPBadRequest | |
43 | from rhodecode.lib.utils2 import str2bool |
|
43 | from rhodecode.lib.utils2 import str2bool | |
44 | from rhodecode.lib.diffs import LimitedDiffContainer |
|
44 | from rhodecode.lib.diffs import LimitedDiffContainer | |
|
45 | from rhodecode.lib.vcs.backends.base import EmptyChangeset | |||
45 |
|
46 | |||
46 | log = logging.getLogger(__name__) |
|
47 | log = logging.getLogger(__name__) | |
47 |
|
48 | |||
@@ -88,14 +89,16 b' class CompareController(BaseRepoControll' | |||||
88 | org_ref = (org_ref_type, org_ref) |
|
89 | org_ref = (org_ref_type, org_ref) | |
89 | other_ref = (other_ref_type, other_ref) |
|
90 | other_ref = (other_ref_type, other_ref) | |
90 | other_repo = request.GET.get('repo', org_repo) |
|
91 | other_repo = request.GET.get('repo', org_repo) | |
91 |
|
|
92 | incoming_changesets = str2bool(request.GET.get('bundle', False)) | |
92 | c.fulldiff = fulldiff = request.GET.get('fulldiff') |
|
93 | c.fulldiff = fulldiff = request.GET.get('fulldiff') | |
|
94 | rev_start = request.GET.get('rev_start') | |||
|
95 | rev_end = request.GET.get('rev_end') | |||
93 |
|
96 | |||
94 | c.swap_url = h.url('compare_url', repo_name=other_repo, |
|
97 | c.swap_url = h.url('compare_url', repo_name=other_repo, | |
95 | org_ref_type=other_ref[0], org_ref=other_ref[1], |
|
98 | org_ref_type=other_ref[0], org_ref=other_ref[1], | |
96 | other_ref_type=org_ref[0], other_ref=org_ref[1], |
|
99 | other_ref_type=org_ref[0], other_ref=org_ref[1], | |
97 | repo=org_repo, as_form=request.GET.get('as_form'), |
|
100 | repo=org_repo, as_form=request.GET.get('as_form'), | |
98 |
bundle= |
|
101 | bundle=incoming_changesets) | |
99 |
|
102 | |||
100 | c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) |
|
103 | c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) | |
101 | c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) |
|
104 | c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) | |
@@ -116,8 +119,13 b' class CompareController(BaseRepoControll' | |||||
116 | self.__get_cs_or_redirect(rev=org_ref, repo=org_repo, partial=partial) |
|
119 | self.__get_cs_or_redirect(rev=org_ref, repo=org_repo, partial=partial) | |
117 | self.__get_cs_or_redirect(rev=other_ref, repo=other_repo, partial=partial) |
|
120 | self.__get_cs_or_redirect(rev=other_ref, repo=other_repo, partial=partial) | |
118 |
|
121 | |||
|
122 | if rev_start and rev_end: | |||
|
123 | #replace our org_ref with given CS | |||
|
124 | org_ref = ('rev', rev_start) | |||
|
125 | other_ref = ('rev', rev_end) | |||
|
126 | ||||
119 | c.cs_ranges, discovery_data = PullRequestModel().get_compare_data( |
|
127 | c.cs_ranges, discovery_data = PullRequestModel().get_compare_data( | |
120 | org_repo, org_ref, other_repo, other_ref |
|
128 | org_repo, org_ref, other_repo, other_ref, | |
121 | ) |
|
129 | ) | |
122 |
|
130 | |||
123 | c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in |
|
131 | c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in | |
@@ -131,16 +139,22 b' class CompareController(BaseRepoControll' | |||||
131 | c.org_ref = org_ref[1] |
|
139 | c.org_ref = org_ref[1] | |
132 | c.other_ref = other_ref[1] |
|
140 | c.other_ref = other_ref[1] | |
133 |
|
141 | |||
134 | if not remote_compare and c.cs_ranges: |
|
142 | if not incoming_changesets and c.cs_ranges and c.org_repo != c.other_repo: | |
135 | # case we want a simple diff without incoming changesets, just |
|
143 | # case we want a simple diff without incoming changesets, just | |
136 | # for review purposes. Make the diff on the forked repo, with |
|
144 | # for review purposes. Make the diff on the forked repo, with | |
137 | # revision that is common ancestor |
|
145 | # revision that is common ancestor | |
138 | other_ref = ('rev', c.cs_ranges[-1].parents[0].raw_id) |
|
146 | _org_ref = org_ref | |
|
147 | org_ref = ('rev', getattr(c.cs_ranges[0].parents[0] | |||
|
148 | if c.cs_ranges[0].parents | |||
|
149 | else EmptyChangeset(), 'raw_id')) | |||
|
150 | log.debug('Changed org_ref from %s to %s' % (_org_ref, org_ref)) | |||
139 | other_repo = org_repo |
|
151 | other_repo = org_repo | |
140 |
|
152 | |||
141 | diff_limit = self.cut_off_limit if not fulldiff else None |
|
153 | diff_limit = self.cut_off_limit if not fulldiff else None | |
|
154 | ||||
142 | _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref, |
|
155 | _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref, | |
143 |
discovery_data, |
|
156 | discovery_data, | |
|
157 | remote_compare=incoming_changesets) | |||
144 |
|
158 | |||
145 | diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff', |
|
159 | diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff', | |
146 | diff_limit=diff_limit) |
|
160 | diff_limit=diff_limit) |
@@ -52,6 +52,8 b' from rhodecode.model.changeset_status im' | |||||
52 | from rhodecode.model.forms import PullRequestForm |
|
52 | from rhodecode.model.forms import PullRequestForm | |
53 | from rhodecode.lib.vcs.exceptions import EmptyRepositoryError |
|
53 | from rhodecode.lib.vcs.exceptions import EmptyRepositoryError | |
54 | from rhodecode.lib.vcs.backends.base import EmptyChangeset |
|
54 | from rhodecode.lib.vcs.backends.base import EmptyChangeset | |
|
55 | from rhodecode.lib.diffs import LimitedDiffContainer | |||
|
56 | from rhodecode.lib.utils2 import str2bool | |||
55 |
|
57 | |||
56 | log = logging.getLogger(__name__) |
|
58 | log = logging.getLogger(__name__) | |
57 |
|
59 | |||
@@ -195,6 +197,17 b' class PullrequestsController(BaseRepoCon' | |||||
195 | revisions = _form['revisions'] |
|
197 | revisions = _form['revisions'] | |
196 | reviewers = _form['review_members'] |
|
198 | reviewers = _form['review_members'] | |
197 |
|
199 | |||
|
200 | # if we have cherry picked pull request we don't care what is in | |||
|
201 | # org_ref/other_ref | |||
|
202 | rev_start = request.POST.get('rev_start') | |||
|
203 | rev_end = request.POST.get('rev_end') | |||
|
204 | ||||
|
205 | if rev_start and rev_end: | |||
|
206 | # this is swapped to simulate that rev_end is a revision from | |||
|
207 | # parent of the fork | |||
|
208 | org_ref = 'rev:%s:%s' % (rev_end, rev_end) | |||
|
209 | other_ref = 'rev:%s:%s' % (rev_start, rev_start) | |||
|
210 | ||||
198 | title = _form['pullrequest_title'] |
|
211 | title = _form['pullrequest_title'] | |
199 | description = _form['pullrequest_desc'] |
|
212 | description = _form['pullrequest_desc'] | |
200 |
|
213 | |||
@@ -228,7 +241,7 b' class PullrequestsController(BaseRepoCon' | |||||
228 | request.POST.get('reviewers_ids', '').split(','))) |
|
241 | request.POST.get('reviewers_ids', '').split(','))) | |
229 |
|
242 | |||
230 | PullRequestModel().update_reviewers(pull_request_id, reviewers_ids) |
|
243 | PullRequestModel().update_reviewers(pull_request_id, reviewers_ids) | |
231 | Session.commit() |
|
244 | Session().commit() | |
232 | return True |
|
245 | return True | |
233 | raise HTTPForbidden() |
|
246 | raise HTTPForbidden() | |
234 |
|
247 | |||
@@ -242,7 +255,7 b' class PullrequestsController(BaseRepoCon' | |||||
242 | Session().commit() |
|
255 | Session().commit() | |
243 | h.flash(_('Successfully deleted pull request'), |
|
256 | h.flash(_('Successfully deleted pull request'), | |
244 | category='success') |
|
257 | category='success') | |
245 | return redirect(url('admin_settings_my_account')) |
|
258 | return redirect(url('admin_settings_my_account', anchor='pullrequests')) | |
246 | raise HTTPForbidden() |
|
259 | raise HTTPForbidden() | |
247 |
|
260 | |||
248 | def _load_compare_data(self, pull_request, enable_comments=True): |
|
261 | def _load_compare_data(self, pull_request, enable_comments=True): | |
@@ -252,13 +265,15 b' class PullrequestsController(BaseRepoCon' | |||||
252 | :param pull_request: |
|
265 | :param pull_request: | |
253 | :type pull_request: |
|
266 | :type pull_request: | |
254 | """ |
|
267 | """ | |
|
268 | rev_start = request.GET.get('rev_start') | |||
|
269 | rev_end = request.GET.get('rev_end') | |||
255 |
|
270 | |||
256 | org_repo = pull_request.org_repo |
|
271 | org_repo = pull_request.org_repo | |
257 | (org_ref_type, |
|
272 | (org_ref_type, | |
258 | org_ref_name, |
|
273 | org_ref_name, | |
259 | org_ref_rev) = pull_request.org_ref.split(':') |
|
274 | org_ref_rev) = pull_request.org_ref.split(':') | |
260 |
|
275 | |||
261 |
other_repo = |
|
276 | other_repo = org_repo | |
262 | (other_ref_type, |
|
277 | (other_ref_type, | |
263 | other_ref_name, |
|
278 | other_ref_name, | |
264 | other_ref_rev) = pull_request.other_ref.split(':') |
|
279 | other_ref_rev) = pull_request.other_ref.split(':') | |
@@ -271,34 +286,44 b' class PullrequestsController(BaseRepoCon' | |||||
271 | c.org_repo = org_repo |
|
286 | c.org_repo = org_repo | |
272 | c.other_repo = other_repo |
|
287 | c.other_repo = other_repo | |
273 |
|
288 | |||
274 | c.cs_ranges, discovery_data = PullRequestModel().get_compare_data( |
|
289 | c.fulldiff = fulldiff = request.GET.get('fulldiff') | |
275 | org_repo, org_ref, other_repo, other_ref |
|
290 | ||
276 | ) |
|
291 | c.cs_ranges = [org_repo.get_changeset(x) for x in pull_request.revisions] | |
277 | if c.cs_ranges: |
|
292 | ||
278 | # case we want a simple diff without incoming changesets, just |
|
293 | other_ref = ('rev', getattr(c.cs_ranges[0].parents[0] | |
279 | # for review purposes. Make the diff on the forked repo, with |
|
294 | if c.cs_ranges[0].parents | |
280 | # revision that is common ancestor |
|
295 | else EmptyChangeset(), 'raw_id')) | |
281 | other_ref = ('rev', getattr(c.cs_ranges[-1].parents[0] |
|
|||
282 | if c.cs_ranges[-1].parents |
|
|||
283 | else EmptyChangeset(), 'raw_id')) |
|
|||
284 | other_repo = org_repo |
|
|||
285 |
|
296 | |||
286 | c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges]) |
|
297 | c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges]) | |
|
298 | c.target_repo = c.repo_name | |||
287 | # defines that we need hidden inputs with changesets |
|
299 | # defines that we need hidden inputs with changesets | |
288 | c.as_form = request.GET.get('as_form', False) |
|
300 | c.as_form = request.GET.get('as_form', False) | |
289 |
|
301 | |||
290 | c.org_ref = org_ref[1] |
|
302 | c.org_ref = org_ref[1] | |
291 | c.other_ref = other_ref[1] |
|
303 | c.other_ref = other_ref[1] | |
292 | _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref, |
|
304 | ||
293 | discovery_data) |
|
305 | diff_limit = self.cut_off_limit if not fulldiff else None | |
|
306 | ||||
|
307 | #we swap org/other ref since we run a simple diff on one repo | |||
|
308 | _diff = diffs.differ(org_repo, other_ref, other_repo, org_ref) | |||
294 |
|
309 | |||
295 |
diff_processor = diffs.DiffProcessor(_diff, format='gitdiff' |
|
310 | diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff', | |
|
311 | diff_limit=diff_limit) | |||
296 | _parsed = diff_processor.prepare() |
|
312 | _parsed = diff_processor.prepare() | |
297 |
|
313 | |||
|
314 | c.limited_diff = False | |||
|
315 | if isinstance(_parsed, LimitedDiffContainer): | |||
|
316 | c.limited_diff = True | |||
|
317 | ||||
298 | c.files = [] |
|
318 | c.files = [] | |
299 | c.changes = {} |
|
319 | c.changes = {} | |
300 |
|
320 | c.lines_added = 0 | ||
|
321 | c.lines_deleted = 0 | |||
301 | for f in _parsed: |
|
322 | for f in _parsed: | |
|
323 | st = f['stats'] | |||
|
324 | if st[0] != 'b': | |||
|
325 | c.lines_added += st[0] | |||
|
326 | c.lines_deleted += st[1] | |||
302 | fid = h.FID('', f['filename']) |
|
327 | fid = h.FID('', f['filename']) | |
303 | c.files.append([fid, f['operation'], f['filename'], f['stats']]) |
|
328 | c.files.append([fid, f['operation'], f['filename'], f['stats']]) | |
304 | diff = diff_processor.as_html(enable_comments=enable_comments, |
|
329 | diff = diff_processor.as_html(enable_comments=enable_comments, |
@@ -726,7 +726,7 b' def differ(org_repo, org_ref, other_repo' | |||||
726 |
|
726 | |||
727 | if org_repo == other_repo: |
|
727 | if org_repo == other_repo: | |
728 | log.debug('running diff between %s@%s and %s@%s' |
|
728 | log.debug('running diff between %s@%s and %s@%s' | |
729 | % (org_repo, org_ref, other_repo, other_ref)) |
|
729 | % (org_repo.path, org_ref, other_repo.path, other_ref)) | |
730 | _diff = org_repo_scm.get_diff(rev1=org_ref, rev2=other_ref, |
|
730 | _diff = org_repo_scm.get_diff(rev1=org_ref, rev2=other_ref, | |
731 | ignore_whitespace=ignore_whitespace, context=context) |
|
731 | ignore_whitespace=ignore_whitespace, context=context) | |
732 | return _diff |
|
732 | return _diff | |
@@ -742,8 +742,7 b' def differ(org_repo, org_ref, other_repo' | |||||
742 | # hooks on fetching archives with subrepos |
|
742 | # hooks on fetching archives with subrepos | |
743 | for k, _ in org_repo.ui.configitems('hooks'): |
|
743 | for k, _ in org_repo.ui.configitems('hooks'): | |
744 | org_repo.ui.setconfig('hooks', k, None) |
|
744 | org_repo.ui.setconfig('hooks', k, None) | |
745 |
|
745 | unbundle = org_repo.getbundle('incoming', common=None, | ||
746 | unbundle = org_repo.getbundle('incoming', common=common, |
|
|||
747 | heads=None) |
|
746 | heads=None) | |
748 |
|
747 | |||
749 | buf = BytesIO() |
|
748 | buf = BytesIO() |
@@ -152,27 +152,30 b' class PullRequestModel(BaseModel):' | |||||
152 | to other_repo@other_ref |
|
152 | to other_repo@other_ref | |
153 |
|
153 | |||
154 | :param org_repo: |
|
154 | :param org_repo: | |
155 | :type org_repo: |
|
|||
156 | :param org_ref: |
|
155 | :param org_ref: | |
157 | :type org_ref: |
|
|||
158 | :param other_repo: |
|
156 | :param other_repo: | |
159 | :type other_repo: |
|
|||
160 | :param other_ref: |
|
157 | :param other_ref: | |
161 | :type other_ref: |
|
|||
162 | :param tmp: |
|
158 | :param tmp: | |
163 | :type tmp: |
|
|||
164 | """ |
|
159 | """ | |
|
160 | ||||
165 | changesets = [] |
|
161 | changesets = [] | |
166 | #case two independent repos |
|
162 | #case two independent repos | |
167 | common, incoming, rheads = discovery_data |
|
163 | common, incoming, rheads = discovery_data | |
168 |
if org_repo != other_repo |
|
164 | if org_repo != other_repo: | |
|
165 | revs = [ | |||
|
166 | org_repo._repo.lookup(org_ref[1]), | |||
|
167 | org_repo._repo.lookup(other_ref[1]), | |||
|
168 | ] | |||
|
169 | ||||
169 | obj = findcommonoutgoing(org_repo._repo, |
|
170 | obj = findcommonoutgoing(org_repo._repo, | |
170 | localrepo.locallegacypeer(other_repo._repo.local()), |
|
171 | localrepo.locallegacypeer(other_repo._repo.local()), | |
|
172 | revs, | |||
171 | force=True) |
|
173 | force=True) | |
172 | revs = obj.missing |
|
174 | revs = obj.missing | |
173 |
|
175 | |||
174 |
for cs in |
|
176 | for cs in map(binascii.hexlify, revs): | |
175 |
|
|
177 | _cs = org_repo.get_changeset(cs) | |
|
178 | changesets.append(_cs) | |||
176 | else: |
|
179 | else: | |
177 | #no remote compare do it on the same repository |
|
180 | #no remote compare do it on the same repository | |
178 | if alias == 'hg': |
|
181 | if alias == 'hg': | |
@@ -234,8 +237,8 b' class PullRequestModel(BaseModel):' | |||||
234 | tmp = discovery.findcommonincoming( |
|
237 | tmp = discovery.findcommonincoming( | |
235 | repo=_other_repo, # other_repo we check for incoming |
|
238 | repo=_other_repo, # other_repo we check for incoming | |
236 | remote=org_peer, # org_repo source for incoming |
|
239 | remote=org_peer, # org_repo source for incoming | |
237 | heads=[_other_repo[other_rev].node(), |
|
240 | # heads=[_other_repo[other_rev].node(), | |
238 | _org_repo[org_rev].node()], |
|
241 | # _org_repo[org_rev].node()], | |
239 | force=True |
|
242 | force=True | |
240 | ) |
|
243 | ) | |
241 | return tmp |
|
244 | return tmp |
@@ -203,6 +203,8 b'' | |||||
203 | YUD.setStyle('rev_range_container','display',''); |
|
203 | YUD.setStyle('rev_range_container','display',''); | |
204 | YUD.setStyle('rev_range_clear','display',''); |
|
204 | YUD.setStyle('rev_range_clear','display',''); | |
205 |
|
205 | |||
|
206 | YUD.get('open_new_pr').href += '?rev_start={0}&rev_end={1}'.format(rev_start,rev_end); | |||
|
207 | ||||
206 | } |
|
208 | } | |
207 | else{ |
|
209 | else{ | |
208 | YUD.setStyle('rev_range_container','display','none'); |
|
210 | YUD.setStyle('rev_range_container','display','none'); |
@@ -21,7 +21,9 b'' | |||||
21 | </div> |
|
21 | </div> | |
22 | ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')} |
|
22 | ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')} | |
23 | <div style="float:left;padding:0px 30px 30px 30px"> |
|
23 | <div style="float:left;padding:0px 30px 30px 30px"> | |
24 |
|
24 | <input type="hidden" name="rev_start" value="${request.GET.get('rev_start')}" /> | ||
|
25 | <input type="hidden" name="rev_end" value="${request.GET.get('rev_end')}" /> | |||
|
26 | ||||
25 | ##ORG |
|
27 | ##ORG | |
26 | <div style="float:left"> |
|
28 | <div style="float:left"> | |
27 | <div class="fork_user"> |
|
29 | <div class="fork_user"> | |
@@ -141,7 +143,9 b'' | |||||
141 | org_ref_type='org_ref_type', org_ref='org_ref', |
|
143 | org_ref_type='org_ref_type', org_ref='org_ref', | |
142 | other_ref_type='other_ref_type', other_ref='other_ref', |
|
144 | other_ref_type='other_ref_type', other_ref='other_ref', | |
143 | repo='other_repo', |
|
145 | repo='other_repo', | |
144 |
as_form=True, bundle=False |
|
146 | as_form=True, bundle=False, | |
|
147 | rev_start=request.GET.get('rev_start',''), | |||
|
148 | rev_end=request.GET.get('rev_end',''))}"; | |||
145 |
|
149 | |||
146 | var select_refs = YUQ('#pull_request_form select.refs') |
|
150 | var select_refs = YUQ('#pull_request_form select.refs') | |
147 | var rev_data = {}; // gather the org/other ref and repo here |
|
151 | var rev_data = {}; // gather the org/other ref and repo here |
@@ -58,7 +58,7 b'' | |||||
58 | <div>${_('Created on')}: ${h.fmt_date(c.pull_request.created_on)}</div> |
|
58 | <div>${_('Created on')}: ${h.fmt_date(c.pull_request.created_on)}</div> | |
59 | </div> |
|
59 | </div> | |
60 |
|
60 | |||
61 | <div style="min-height:160px"> |
|
61 | <div style="overflow: auto;"> | |
62 | ##DIFF |
|
62 | ##DIFF | |
63 | <div class="table" style="float:left;clear:none"> |
|
63 | <div class="table" style="float:left;clear:none"> | |
64 | <div id="body" class="diffblock"> |
|
64 | <div id="body" class="diffblock"> | |
@@ -66,33 +66,41 b'' | |||||
66 | </div> |
|
66 | </div> | |
67 | <div id="changeset_compare_view_content"> |
|
67 | <div id="changeset_compare_view_content"> | |
68 | ##CS |
|
68 | ##CS | |
69 |
<div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${ |
|
69 | <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${ungettext('Showing %s commit','Showing %s commits', len(c.cs_ranges)) % len(c.cs_ranges)}</div> | |
70 | <%include file="/compare/compare_cs.html" /> |
|
70 | <%include file="/compare/compare_cs.html" /> | |
71 |
|
71 | |||
72 | ## FILES |
|
72 | ## FILES | |
73 | <div id="affected_files"> |
|
73 | <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px"> | |
74 |
|
|
74 | ||
75 | <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${_('Files affected')}</div> |
|
75 | % if c.limited_diff: | |
76 | <div class="cs_files"> |
|
76 | ${ungettext('%s file changed', '%s files changed', len(c.files)) % len(c.files)} | |
|
77 | % else: | |||
|
78 | ${ungettext('%s file changed with %s insertions and %s deletions','%s files changed with %s insertions and %s deletions', len(c.files)) % (len(c.files),c.lines_added,c.lines_deleted)}: | |||
|
79 | %endif | |||
|
80 | ||||
|
81 | </div> | |||
|
82 | <div class="cs_files"> | |||
|
83 | %if not c.files: | |||
|
84 | <span class="empty_data">${_('No files')}</span> | |||
|
85 | %endif | |||
77 | %for fid, change, f, stat in c.files: |
|
86 | %for fid, change, f, stat in c.files: | |
78 | <div class="cs_${change}"> |
|
87 | <div class="cs_${change}"> | |
79 | <div class="node">${h.link_to(h.safe_unicode(f),h.url.current(anchor=fid))}</div> |
|
88 | <div class="node">${h.link_to(h.safe_unicode(f),h.url.current(anchor=fid))}</div> | |
80 | <div class="changes">${h.fancy_file_stats(stat)}</div> |
|
89 | <div class="changes">${h.fancy_file_stats(stat)}</div> | |
81 | </div> |
|
90 | </div> | |
82 | %endfor |
|
91 | %endfor | |
83 | </div> |
|
|||
84 | %else: |
|
|||
85 | <div class="ui-btn" style="text-align: center;margin-top:5px">${_('Click to load diff details')}</div> |
|
|||
86 | %endif |
|
|||
87 | </div> |
|
92 | </div> | |
|
93 | % if c.limited_diff: | |||
|
94 | <h5>${_('Changeset was too big and was cut off...')}</h5> | |||
|
95 | % endif | |||
88 | </div> |
|
96 | </div> | |
89 | </div> |
|
97 | </div> | |
90 | ## REVIEWERS |
|
98 | ## REVIEWERS | |
91 | <div style="float:left; border-left:1px dashed #eee"> |
|
99 | <div style="float:left; border-left:1px dashed #eee"> | |
92 | <h4>${_('Pull request reviewers')}</h4> |
|
100 | <h4>${_('Pull request reviewers')}</h4> | |
93 |
<div id="reviewers" style="padding:0px 0px |
|
101 | <div id="reviewers" style="padding:0px 0px 5px 10px"> | |
94 | ## members goes here ! |
|
102 | ## members goes here ! | |
95 | <div class="group_members_wrap"> |
|
103 | <div class="group_members_wrap" style="min-height:45px"> | |
96 | <ul id="review_members" class="group_members"> |
|
104 | <ul id="review_members" class="group_members"> | |
97 | %for member,status in c.pull_request_reviewers: |
|
105 | %for member,status in c.pull_request_reviewers: | |
98 | <li id="reviewer_${member.user_id}"> |
|
106 | <li id="reviewer_${member.user_id}"> | |
@@ -137,12 +145,14 b'' | |||||
137 | </script> |
|
145 | </script> | |
138 |
|
146 | |||
139 | ## diff block |
|
147 | ## diff block | |
140 | <div id="diff_block_container" style="clear:both;"> |
|
|||
141 | <%namespace name="diff_block" file="/changeset/diff_block.html"/> |
|
148 | <%namespace name="diff_block" file="/changeset/diff_block.html"/> | |
142 | %for fid, change, f, stat in c.files: |
|
149 | %for fid, change, f, stat in c.files: | |
143 | ${diff_block.diff_block_simple([c.changes[fid]])} |
|
150 | ${diff_block.diff_block_simple([c.changes[fid]])} | |
144 | %endfor |
|
151 | %endfor | |
145 | </div> |
|
152 | % if c.limited_diff: | |
|
153 | <h4>${_('Changeset was too big and was cut off...')}</h4> | |||
|
154 | % endif | |||
|
155 | ||||
146 |
|
156 | |||
147 | ## template for inline comment form |
|
157 | ## template for inline comment form | |
148 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
|
158 | <%namespace name="comment" file="/changeset/changeset_file_comment.html"/> |
This diff has been collapsed as it changes many lines, (761 lines changed) Show them Hide them | |||||
@@ -6,251 +6,175 b' from rhodecode.model.scm import ScmModel' | |||||
6 | from rhodecode.lib.vcs.backends.base import EmptyChangeset |
|
6 | from rhodecode.lib.vcs.backends.base import EmptyChangeset | |
7 |
|
7 | |||
8 |
|
8 | |||
|
9 | def _fork_repo(fork_name, vcs_type, parent=None): | |||
|
10 | if vcs_type =='hg': | |||
|
11 | _REPO = HG_REPO | |||
|
12 | elif vcs_type == 'git': | |||
|
13 | _REPO = GIT_REPO | |||
|
14 | ||||
|
15 | if parent: | |||
|
16 | _REPO = parent | |||
|
17 | ||||
|
18 | form_data = dict( | |||
|
19 | repo_name=fork_name, | |||
|
20 | repo_name_full=fork_name, | |||
|
21 | repo_group=None, | |||
|
22 | repo_type=vcs_type, | |||
|
23 | description='', | |||
|
24 | private=False, | |||
|
25 | copy_permissions=False, | |||
|
26 | landing_rev='tip', | |||
|
27 | update_after_clone=False, | |||
|
28 | fork_parent_id=Repository.get_by_repo_name(_REPO), | |||
|
29 | ) | |||
|
30 | repo = RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN) | |||
|
31 | ||||
|
32 | Session().commit() | |||
|
33 | return Repository.get_by_repo_name(fork_name) | |||
|
34 | ||||
|
35 | ||||
|
36 | def _commit_change(repo, filename, content, message, vcs_type, parent=None, newfile=False): | |||
|
37 | repo = Repository.get_by_repo_name(repo) | |||
|
38 | _cs = parent | |||
|
39 | if not parent: | |||
|
40 | _cs = EmptyChangeset(alias=vcs_type) | |||
|
41 | ||||
|
42 | if newfile: | |||
|
43 | cs = ScmModel().create_node( | |||
|
44 | repo=repo.scm_instance, repo_name=repo.repo_name, | |||
|
45 | cs=_cs, user=TEST_USER_ADMIN_LOGIN, | |||
|
46 | author=TEST_USER_ADMIN_LOGIN, | |||
|
47 | message=message, | |||
|
48 | content=content, | |||
|
49 | f_path=filename | |||
|
50 | ) | |||
|
51 | else: | |||
|
52 | cs = ScmModel().commit_change( | |||
|
53 | repo=repo.scm_instance, repo_name=repo.repo_name, | |||
|
54 | cs=parent, user=TEST_USER_ADMIN_LOGIN, | |||
|
55 | author=TEST_USER_ADMIN_LOGIN, | |||
|
56 | message=message, | |||
|
57 | content=content, | |||
|
58 | f_path=filename | |||
|
59 | ) | |||
|
60 | return cs | |||
|
61 | ||||
|
62 | ||||
9 | class TestCompareController(TestController): |
|
63 | class TestCompareController(TestController): | |
10 |
|
64 | |||
11 |
def test_compare_ |
|
65 | def test_compare_forks_on_branch_extra_commits_hg(self): | |
12 | self.log_user() |
|
|||
13 | tag1 = '0.1.2' |
|
|||
14 | tag2 = '0.1.3' |
|
|||
15 | response = self.app.get(url(controller='compare', action='index', |
|
|||
16 | repo_name=HG_REPO, |
|
|||
17 | org_ref_type="tag", |
|
|||
18 | org_ref=tag1, |
|
|||
19 | other_ref_type="tag", |
|
|||
20 | other_ref=tag2, |
|
|||
21 | )) |
|
|||
22 | response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, tag1, HG_REPO, tag2)) |
|
|||
23 | ## outgoing changesets between tags |
|
|||
24 | response.mustcontain('''<a href="/%s/changeset/c5ddebc06eaaba3010c2d66ea6ec9d074eb0f678">r112:c5ddebc06eaa</a>''' % HG_REPO) |
|
|||
25 | response.mustcontain('''<a href="/%s/changeset/70d4cef8a37657ee4cf5aabb3bd9f68879769816">r115:70d4cef8a376</a>''' % HG_REPO) |
|
|||
26 | response.mustcontain('''<a href="/%s/changeset/9749bfbfc0d2eba208d7947de266303b67c87cda">r116:9749bfbfc0d2</a>''' % HG_REPO) |
|
|||
27 | response.mustcontain('''<a href="/%s/changeset/41fda979f02fda216374bf8edac4e83f69e7581c">r117:41fda979f02f</a>''' % HG_REPO) |
|
|||
28 | response.mustcontain('''<a href="/%s/changeset/bb1a3ab98cc45cb934a77dcabf87a5a598b59e97">r118:bb1a3ab98cc4</a>''' % HG_REPO) |
|
|||
29 | response.mustcontain('''<a href="/%s/changeset/36e0fc9d2808c5022a24f49d6658330383ed8666">r119:36e0fc9d2808</a>''' % HG_REPO) |
|
|||
30 | response.mustcontain('''<a href="/%s/changeset/17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">r120:17544fbfcd33</a>''' % HG_REPO) |
|
|||
31 |
|
||||
32 | ## files diff |
|
|||
33 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--1c5cf9e91c12">docs/api/utils/index.rst</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
34 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--e3305437df55">test_and_report.sh</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
35 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--c8e92ef85cd1">.hgignore</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
36 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--6e08b694d687">.hgtags</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
37 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--2c14b00f3393">docs/api/index.rst</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
38 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--430ccbc82bdf">vcs/__init__.py</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
39 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--9c390eb52cd6">vcs/backends/hg.py</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
40 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--ebb592c595c0">vcs/utils/__init__.py</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
41 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--7abc741b5052">vcs/utils/annotate.py</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
42 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--2ef0ef106c56">vcs/utils/diffs.py</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
43 | response.mustcontain('''<div class="node"><a href="/%s/compare/tag@%s...tag@%s#C--3150cb87d4b7">vcs/utils/lazy.py</a></div>''' % (HG_REPO, tag1, tag2)) |
|
|||
44 |
|
||||
45 | def test_compare_tag_git(self): |
|
|||
46 | self.log_user() |
|
|||
47 | tag1 = 'v0.1.2' |
|
|||
48 | tag2 = 'v0.1.3' |
|
|||
49 | response = self.app.get(url(controller='compare', action='index', |
|
|||
50 | repo_name=GIT_REPO, |
|
|||
51 | org_ref_type="tag", |
|
|||
52 | org_ref=tag1, |
|
|||
53 | other_ref_type="tag", |
|
|||
54 | other_ref=tag2, |
|
|||
55 | bundle=False |
|
|||
56 | )) |
|
|||
57 | response.mustcontain('%s@%s -> %s@%s' % (GIT_REPO, tag1, GIT_REPO, tag2)) |
|
|||
58 |
|
||||
59 | ## outgoing changesets between tags |
|
|||
60 | response.mustcontain('''<a href="/%s/changeset/794bbdd31545c199f74912709ea350dedcd189a2">r113:794bbdd31545</a>''' % GIT_REPO) |
|
|||
61 | response.mustcontain('''<a href="/%s/changeset/e36d8c5025329bdd4212bd53d4ed8a70ff44985f">r115:e36d8c502532</a>''' % GIT_REPO) |
|
|||
62 | response.mustcontain('''<a href="/%s/changeset/5c9ff4f6d7508db0e72b1d2991c357d0d8e07af2">r116:5c9ff4f6d750</a>''' % GIT_REPO) |
|
|||
63 | response.mustcontain('''<a href="/%s/changeset/b7187fa2b8c1d773ec35e9dee12f01f74808c879">r117:b7187fa2b8c1</a>''' % GIT_REPO) |
|
|||
64 | response.mustcontain('''<a href="/%s/changeset/5f3b74262014a8de2dc7dade1152de9fd0c8efef">r118:5f3b74262014</a>''' % GIT_REPO) |
|
|||
65 | response.mustcontain('''<a href="/%s/changeset/17438a11f72b93f56d0e08e7d1fa79a378578a82">r119:17438a11f72b</a>''' % GIT_REPO) |
|
|||
66 | response.mustcontain('''<a href="/%s/changeset/5a3a8fb005554692b16e21dee62bf02667d8dc3e">r120:5a3a8fb00555</a>''' % GIT_REPO) |
|
|||
67 |
|
||||
68 | #files |
|
|||
69 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--1c5cf9e91c12">docs/api/utils/index.rst</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
70 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--e3305437df55">test_and_report.sh</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
71 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--c8e92ef85cd1">.hgignore</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
72 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--6e08b694d687">.hgtags</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
73 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--2c14b00f3393">docs/api/index.rst</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
74 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--430ccbc82bdf">vcs/__init__.py</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
75 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
76 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--ebb592c595c0">vcs/utils/__init__.py</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
77 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--7abc741b5052">vcs/utils/annotate.py</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
78 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--2ef0ef106c56">vcs/utils/diffs.py</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
79 | response.mustcontain('''<a href="/%s/compare/tag@%s...tag@%s#C--3150cb87d4b7">vcs/utils/lazy.py</a>''' % (GIT_REPO, tag1, tag2)) |
|
|||
80 |
|
||||
81 | def test_index_branch_hg(self): |
|
|||
82 | self.log_user() |
|
|||
83 | response = self.app.get(url(controller='compare', action='index', |
|
|||
84 | repo_name=HG_REPO, |
|
|||
85 | org_ref_type="branch", |
|
|||
86 | org_ref='default', |
|
|||
87 | other_ref_type="branch", |
|
|||
88 | other_ref='default', |
|
|||
89 | )) |
|
|||
90 |
|
||||
91 | response.mustcontain('%s@default -> %s@default' % (HG_REPO, HG_REPO)) |
|
|||
92 | # branch are equal |
|
|||
93 | response.mustcontain('<span class="empty_data">No files</span>') |
|
|||
94 | response.mustcontain('<span class="empty_data">No changesets</span>') |
|
|||
95 |
|
||||
96 | def test_index_branch_git(self): |
|
|||
97 | self.log_user() |
|
|||
98 | response = self.app.get(url(controller='compare', action='index', |
|
|||
99 | repo_name=GIT_REPO, |
|
|||
100 | org_ref_type="branch", |
|
|||
101 | org_ref='master', |
|
|||
102 | other_ref_type="branch", |
|
|||
103 | other_ref='master', |
|
|||
104 | )) |
|
|||
105 |
|
||||
106 | response.mustcontain('%s@master -> %s@master' % (GIT_REPO, GIT_REPO)) |
|
|||
107 | # branch are equal |
|
|||
108 | response.mustcontain('<span class="empty_data">No files</span>') |
|
|||
109 | response.mustcontain('<span class="empty_data">No changesets</span>') |
|
|||
110 |
|
||||
111 | def test_compare_revisions(self): |
|
|||
112 | self.log_user() |
|
|||
113 | rev1 = 'b986218ba1c9' |
|
|||
114 | rev2 = '3d8f361e72ab' |
|
|||
115 |
|
||||
116 | response = self.app.get(url(controller='compare', action='index', |
|
|||
117 | repo_name=HG_REPO, |
|
|||
118 | org_ref_type="rev", |
|
|||
119 | org_ref=rev1, |
|
|||
120 | other_ref_type="rev", |
|
|||
121 | other_ref=rev2, |
|
|||
122 | )) |
|
|||
123 | response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_REPO, rev2)) |
|
|||
124 | ## outgoing changesets between those revisions |
|
|||
125 | response.mustcontain("""<a href="/%s/changeset/3d8f361e72ab303da48d799ff1ac40d5ac37c67e">r1:%s</a>""" % (HG_REPO, rev2)) |
|
|||
126 | ## files |
|
|||
127 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--c8e92ef85cd1">.hgignore</a>""" % (HG_REPO, rev1, rev2)) |
|
|||
128 |
|
||||
129 | def test_compare_remote_repos(self): |
|
|||
130 | self.log_user() |
|
66 | self.log_user() | |
131 |
|
67 | |||
132 | form_data = dict( |
|
68 | repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg', | |
133 | repo_name=HG_FORK, |
|
69 | description='diff-test', | |
134 | repo_name_full=HG_FORK, |
|
70 | owner=TEST_USER_ADMIN_LOGIN) | |
135 | repo_group=None, |
|
71 | r1_id = repo1.repo_id | |
136 | repo_type='hg', |
|
72 | Session().commit() | |
137 | description='', |
|
73 | #commit something ! | |
138 | private=False, |
|
74 | cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | |
139 | copy_permissions=False, |
|
75 | message='commit1', vcs_type='hg', parent=None, newfile=True) | |
140 | landing_rev='tip', |
|
76 | ||
141 | update_after_clone=False, |
|
77 | #fork this repo | |
142 | fork_parent_id=Repository.get_by_repo_name(HG_REPO), |
|
78 | repo2 = _fork_repo('one-fork', 'hg', parent='one') | |
143 | ) |
|
79 | Session().commit() | |
144 | RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN) |
|
80 | r2_id = repo2.repo_id | |
145 |
|
81 | |||
146 | Session().commit() |
|
82 | #add two extra commit into fork | |
|
83 | cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n', | |||
|
84 | message='commit2', vcs_type='hg', parent=cs0) | |||
147 |
|
85 | |||
148 | rev1 = '56349e29c2af' |
|
86 | cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n', | |
149 | rev2 = '7d4bc8ec6be5' |
|
87 | message='commit3', vcs_type='hg', parent=cs1) | |
150 |
|
88 | |||
|
89 | rev1 = 'default' | |||
|
90 | rev2 = 'default' | |||
151 | response = self.app.get(url(controller='compare', action='index', |
|
91 | response = self.app.get(url(controller='compare', action='index', | |
152 |
repo_name= |
|
92 | repo_name=repo2.repo_name, | |
153 |
org_ref_type=" |
|
93 | org_ref_type="branch", | |
154 | org_ref=rev1, |
|
94 | org_ref=rev1, | |
155 |
other_ref_type=" |
|
95 | other_ref_type="branch", | |
156 | other_ref=rev2, |
|
96 | other_ref=rev2, | |
157 |
repo= |
|
97 | repo=repo1.repo_name | |
158 | )) |
|
98 | )) | |
159 |
|
99 | |||
160 | try: |
|
100 | try: | |
161 |
response.mustcontain('%s@%s -> %s@%s' % ( |
|
101 | response.mustcontain('%s@%s -> %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2)) | |
162 | ## outgoing changesets between those revisions |
|
102 | response.mustcontain("""Showing 2 commits""") | |
|
103 | response.mustcontain("""1 file changed with 2 insertions and 0 deletions""") | |||
163 |
|
104 | |||
164 | response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO)) |
|
105 | response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""") | |
165 | response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO)) |
|
106 | response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""") | |
166 | response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2)) |
|
|||
167 |
|
107 | |||
|
108 | response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) | |||
|
109 | response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) | |||
168 | ## files |
|
110 | ## files | |
169 |
response.mustcontain("""<a href="/%s/compare/ |
|
111 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2)) | |
170 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2)) |
|
112 | ||
171 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2)) |
|
|||
172 | finally: |
|
113 | finally: | |
173 |
RepoModel().delete( |
|
114 | RepoModel().delete(r1_id) | |
|
115 | RepoModel().delete(r2_id) | |||
174 |
|
116 | |||
175 | def test_compare_remote_repos_remote_flag_off(self): |
|
117 | def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self): | |
176 | self.log_user() |
|
118 | self.log_user() | |
177 |
|
119 | |||
178 | form_data = dict( |
|
120 | repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg', | |
179 | repo_name=HG_FORK, |
|
121 | description='diff-test', | |
180 | repo_name_full=HG_FORK, |
|
122 | owner=TEST_USER_ADMIN_LOGIN) | |
181 | repo_group=None, |
|
123 | r1_id = repo1.repo_id | |
182 | repo_type='hg', |
|
124 | Session().commit() | |
183 | description='', |
|
125 | #commit something ! | |
184 | private=False, |
|
126 | cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | |
185 | copy_permissions=False, |
|
127 | message='commit1', vcs_type='hg', parent=None, newfile=True) | |
186 | landing_rev='tip', |
|
|||
187 | update_after_clone=False, |
|
|||
188 | fork_parent_id=Repository.get_by_repo_name(HG_REPO), |
|
|||
189 | ) |
|
|||
190 | RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN) |
|
|||
191 |
|
128 | |||
|
129 | #fork this repo | |||
|
130 | repo2 = _fork_repo('one-fork', 'hg', parent='one') | |||
192 | Session().commit() |
|
131 | Session().commit() | |
193 |
|
132 | |||
194 | rev1 = '56349e29c2af' |
|
133 | #now commit something to origin repo | |
195 | rev2 = '7d4bc8ec6be5' |
|
134 | cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n', | |
|
135 | message='commit2', vcs_type='hg', parent=cs0, newfile=True) | |||
|
136 | ||||
|
137 | r2_id = repo2.repo_id | |||
196 |
|
138 | |||
|
139 | #add two extra commit into fork | |||
|
140 | cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n', | |||
|
141 | message='commit2', vcs_type='hg', parent=cs0) | |||
|
142 | ||||
|
143 | cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n', | |||
|
144 | message='commit3', vcs_type='hg', parent=cs1) | |||
|
145 | ||||
|
146 | rev1 = 'default' | |||
|
147 | rev2 = 'default' | |||
197 | response = self.app.get(url(controller='compare', action='index', |
|
148 | response = self.app.get(url(controller='compare', action='index', | |
198 |
repo_name= |
|
149 | repo_name=repo2.repo_name, | |
199 |
org_ref_type=" |
|
150 | org_ref_type="branch", | |
200 | org_ref=rev1, |
|
151 | org_ref=rev1, | |
201 |
other_ref_type=" |
|
152 | other_ref_type="branch", | |
202 | other_ref=rev2, |
|
153 | other_ref=rev2, | |
203 |
repo= |
|
154 | repo=repo1.repo_name | |
204 | bundle=False, |
|
|||
205 | )) |
|
155 | )) | |
206 |
|
156 | |||
207 | try: |
|
157 | try: | |
208 |
response.mustcontain('%s@%s -> %s@%s' % ( |
|
158 | response.mustcontain('%s@%s -> %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2)) | |
209 | ## outgoing changesets between those revisions |
|
159 | response.mustcontain("""Showing 2 commits""") | |
|
160 | response.mustcontain("""1 file changed with 2 insertions and 0 deletions""") | |||
210 |
|
161 | |||
211 | response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO)) |
|
162 | response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""") | |
212 | response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO)) |
|
163 | response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""") | |
213 | response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2)) |
|
|||
214 |
|
164 | |||
|
165 | response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) | |||
|
166 | response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) | |||
215 | ## files |
|
167 | ## files | |
216 |
response.mustcontain("""<a href="/%s/compare/ |
|
168 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2)) | |
217 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2)) |
|
169 | ||
218 | response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2)) |
|
|||
219 | finally: |
|
170 | finally: | |
220 |
RepoModel().delete( |
|
171 | RepoModel().delete(r1_id) | |
|
172 | RepoModel().delete(r2_id) | |||
221 |
|
173 | |||
222 | # def test_compare_origin_ahead_of_fork(self): |
|
174 | ||
|
175 | # def test_compare_remote_repos_remote_flag_off(self): | |||
223 | # self.log_user() |
|
176 | # self.log_user() | |
224 | # |
|
177 | # _fork_repo(HG_FORK, 'hg') | |
225 | # form_data = dict( |
|
|||
226 | # repo_name=HG_FORK, |
|
|||
227 | # repo_name_full=HG_FORK, |
|
|||
228 | # repo_group=None, |
|
|||
229 | # repo_type='hg', |
|
|||
230 | # description='', |
|
|||
231 | # private=False, |
|
|||
232 | # copy_permissions=False, |
|
|||
233 | # landing_rev='tip', |
|
|||
234 | # update_after_clone=False, |
|
|||
235 | # fork_parent_id=Repository.get_by_repo_name(HG_REPO), |
|
|||
236 | # ) |
|
|||
237 | # RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN) |
|
|||
238 | # |
|
|||
239 | # Session().commit() |
|
|||
240 | # |
|
|||
241 | # repo1 = Repository.get_by_repo_name(HG_REPO) |
|
|||
242 | # r1_name = HG_REPO |
|
|||
243 | # |
|
|||
244 | # #commit something ! |
|
|||
245 | # cs0 = ScmModel().create_node( |
|
|||
246 | # repo=repo1.scm_instance, repo_name=r1_name, |
|
|||
247 | # cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, |
|
|||
248 | # author=TEST_USER_ADMIN_LOGIN, |
|
|||
249 | # message='extra commit1', |
|
|||
250 | # content='line1', |
|
|||
251 | # f_path='file1' |
|
|||
252 | # ) |
|
|||
253 | # |
|
|||
254 | # |
|
178 | # | |
255 | # rev1 = '56349e29c2af' |
|
179 | # rev1 = '56349e29c2af' | |
256 | # rev2 = '7d4bc8ec6be5' |
|
180 | # rev2 = '7d4bc8ec6be5' | |
@@ -266,7 +190,7 b' class TestCompareController(TestControll' | |||||
266 | # )) |
|
190 | # )) | |
267 | # |
|
191 | # | |
268 | # try: |
|
192 | # try: | |
269 |
# response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_ |
|
193 | # response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2)) | |
270 | # ## outgoing changesets between those revisions |
|
194 | # ## outgoing changesets between those revisions | |
271 | # |
|
195 | # | |
272 | # response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO)) |
|
196 | # response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO)) | |
@@ -280,284 +204,143 b' class TestCompareController(TestControll' | |||||
280 | # finally: |
|
204 | # finally: | |
281 | # RepoModel().delete(HG_FORK) |
|
205 | # RepoModel().delete(HG_FORK) | |
282 |
|
206 | |||
283 | def test_compare_extra_commits(self): |
|
|||
284 | self.log_user() |
|
|||
285 |
|
207 | |||
286 | repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg', |
|
|||
287 | description='diff-test', |
|
|||
288 | owner=TEST_USER_ADMIN_LOGIN) |
|
|||
289 |
|
||||
290 | repo2 = RepoModel().create_repo(repo_name='one-fork', repo_type='hg', |
|
|||
291 | description='diff-test', |
|
|||
292 | owner=TEST_USER_ADMIN_LOGIN) |
|
|||
293 |
|
||||
294 | Session().commit() |
|
|||
295 | r1_id = repo1.repo_id |
|
|||
296 | r1_name = repo1.repo_name |
|
|||
297 | r2_id = repo2.repo_id |
|
|||
298 | r2_name = repo2.repo_name |
|
|||
299 |
|
||||
300 | #commit something ! |
|
|||
301 | cs0 = ScmModel().create_node( |
|
|||
302 | repo=repo1.scm_instance, repo_name=r1_name, |
|
|||
303 | cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, |
|
|||
304 | author=TEST_USER_ADMIN_LOGIN, |
|
|||
305 | message='commit1', |
|
|||
306 | content='line1', |
|
|||
307 | f_path='file1' |
|
|||
308 | ) |
|
|||
309 |
|
||||
310 | cs0_prim = ScmModel().create_node( |
|
|||
311 | repo=repo2.scm_instance, repo_name=r2_name, |
|
|||
312 | cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, |
|
|||
313 | author=TEST_USER_ADMIN_LOGIN, |
|
|||
314 | message='commit1', |
|
|||
315 | content='line1', |
|
|||
316 | f_path='file1' |
|
|||
317 | ) |
|
|||
318 |
|
||||
319 | cs1 = ScmModel().commit_change( |
|
|||
320 | repo=repo2.scm_instance, repo_name=r2_name, |
|
|||
321 | cs=cs0_prim, user=TEST_USER_ADMIN_LOGIN, author=TEST_USER_ADMIN_LOGIN, |
|
|||
322 | message='commit2', |
|
|||
323 | content='line1\nline2', |
|
|||
324 | f_path='file1' |
|
|||
325 | ) |
|
|||
326 |
|
||||
327 | rev1 = 'default' |
|
|||
328 | rev2 = 'default' |
|
|||
329 | response = self.app.get(url(controller='compare', action='index', |
|
|||
330 | repo_name=r2_name, |
|
|||
331 | org_ref_type="branch", |
|
|||
332 | org_ref=rev1, |
|
|||
333 | other_ref_type="branch", |
|
|||
334 | other_ref=rev2, |
|
|||
335 | repo=r1_name |
|
|||
336 | )) |
|
|||
337 |
|
||||
338 | try: |
|
|||
339 | response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) |
|
|||
340 |
|
||||
341 | response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""") |
|
|||
342 | response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (r2_name, cs1.raw_id, cs1.short_id)) |
|
|||
343 | ## files |
|
|||
344 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (r2_name, rev1, rev2)) |
|
|||
345 |
|
||||
346 | finally: |
|
|||
347 | RepoModel().delete(r1_id) |
|
|||
348 | RepoModel().delete(r2_id) |
|
|||
349 |
|
||||
350 | def test_org_repo_new_commits_after_forking(self): |
|
|||
351 | self.log_user() |
|
|||
352 |
|
||||
353 | repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg', |
|
|||
354 | description='diff-test', |
|
|||
355 | owner=TEST_USER_ADMIN_LOGIN) |
|
|||
356 |
|
||||
357 | Session().commit() |
|
|||
358 | r1_id = repo1.repo_id |
|
|||
359 | r1_name = repo1.repo_name |
|
|||
360 |
|
||||
361 | #commit something initially ! |
|
|||
362 | cs0 = ScmModel().create_node( |
|
|||
363 | repo=repo1.scm_instance, repo_name=r1_name, |
|
|||
364 | cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, |
|
|||
365 | author=TEST_USER_ADMIN_LOGIN, |
|
|||
366 | message='commit1', |
|
|||
367 | content='line1', |
|
|||
368 | f_path='file1' |
|
|||
369 | ) |
|
|||
370 | Session().commit() |
|
|||
371 | self.assertEqual(repo1.scm_instance.revisions, [cs0.raw_id]) |
|
|||
372 | #fork the repo1 |
|
|||
373 | repo2 = RepoModel().create_repo(repo_name='one-fork', repo_type='hg', |
|
|||
374 | description='compare-test', |
|
|||
375 | clone_uri=repo1.repo_full_path, |
|
|||
376 | owner=TEST_USER_ADMIN_LOGIN, fork_of='one') |
|
|||
377 | Session().commit() |
|
|||
378 | self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id]) |
|
|||
379 | r2_id = repo2.repo_id |
|
|||
380 | r2_name = repo2.repo_name |
|
|||
381 |
|
||||
382 | #make 3 new commits in fork |
|
|||
383 | cs1 = ScmModel().create_node( |
|
|||
384 | repo=repo2.scm_instance, repo_name=r2_name, |
|
|||
385 | cs=repo2.scm_instance[-1], user=TEST_USER_ADMIN_LOGIN, |
|
|||
386 | author=TEST_USER_ADMIN_LOGIN, |
|
|||
387 | message='commit1-fork', |
|
|||
388 | content='file1-line1-from-fork', |
|
|||
389 | f_path='file1-fork' |
|
|||
390 | ) |
|
|||
391 | cs2 = ScmModel().create_node( |
|
|||
392 | repo=repo2.scm_instance, repo_name=r2_name, |
|
|||
393 | cs=cs1, user=TEST_USER_ADMIN_LOGIN, |
|
|||
394 | author=TEST_USER_ADMIN_LOGIN, |
|
|||
395 | message='commit2-fork', |
|
|||
396 | content='file2-line1-from-fork', |
|
|||
397 | f_path='file2-fork' |
|
|||
398 | ) |
|
|||
399 | cs3 = ScmModel().create_node( |
|
|||
400 | repo=repo2.scm_instance, repo_name=r2_name, |
|
|||
401 | cs=cs2, user=TEST_USER_ADMIN_LOGIN, |
|
|||
402 | author=TEST_USER_ADMIN_LOGIN, |
|
|||
403 | message='commit3-fork', |
|
|||
404 | content='file3-line1-from-fork', |
|
|||
405 | f_path='file3-fork' |
|
|||
406 | ) |
|
|||
407 |
|
||||
408 | #compare ! |
|
|||
409 | rev1 = 'default' |
|
|||
410 | rev2 = 'default' |
|
|||
411 | response = self.app.get(url(controller='compare', action='index', |
|
|||
412 | repo_name=r2_name, |
|
|||
413 | org_ref_type="branch", |
|
|||
414 | org_ref=rev1, |
|
|||
415 | other_ref_type="branch", |
|
|||
416 | other_ref=rev2, |
|
|||
417 | repo=r1_name, |
|
|||
418 | bundle=True, |
|
|||
419 | )) |
|
|||
420 |
|
208 | |||
421 | try: |
|
209 | # | |
422 | response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) |
|
210 | # def test_compare_remote_branches_hg(self): | |
423 | response.mustcontain("""file1-line1-from-fork""") |
|
211 | # self.log_user() | |
424 | response.mustcontain("""file2-line1-from-fork""") |
|
212 | # | |
425 | response.mustcontain("""file3-line1-from-fork""") |
|
213 | # _fork_repo(HG_FORK, 'hg') | |
426 |
|
214 | # | ||
427 | #add new commit into parent ! |
|
215 | # rev1 = '56349e29c2af' | |
428 | cs0 = ScmModel().create_node( |
|
216 | # rev2 = '7d4bc8ec6be5' | |
429 | repo=repo1.scm_instance, repo_name=r1_name, |
|
217 | # | |
430 | cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, |
|
218 | # response = self.app.get(url(controller='compare', action='index', | |
431 | author=TEST_USER_ADMIN_LOGIN, |
|
219 | # repo_name=HG_REPO, | |
432 | message='commit2', |
|
220 | # org_ref_type="rev", | |
433 | content='line1-from-new-parent', |
|
221 | # org_ref=rev1, | |
434 | f_path='file2' |
|
222 | # other_ref_type="rev", | |
435 | ) |
|
223 | # other_ref=rev2, | |
436 | #compare ! |
|
224 | # repo=HG_FORK, | |
437 | rev1 = 'default' |
|
225 | # )) | |
438 | rev2 = 'default' |
|
226 | # | |
439 | response = self.app.get(url(controller='compare', action='index', |
|
227 | # try: | |
440 | repo_name=r2_name, |
|
228 | # response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2)) | |
441 | org_ref_type="branch", |
|
229 | # ## outgoing changesets between those revisions | |
442 | org_ref=rev1, |
|
230 | # | |
443 | other_ref_type="branch", |
|
231 | # response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO)) | |
444 | other_ref=rev2, |
|
232 | # response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO)) | |
445 | repo=r1_name, |
|
233 | # response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2)) | |
446 | bundle=True, |
|
234 | # | |
447 | )) |
|
235 | # ## files | |
448 |
|
236 | # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2)) | ||
449 | response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) |
|
237 | # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2)) | |
450 | response.mustcontain("""<a href="#">file2</a>""") # new commit from parent |
|
238 | # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2)) | |
451 | response.mustcontain("""line1-from-new-parent""") |
|
239 | # finally: | |
452 | response.mustcontain("""file1-line1-from-fork""") |
|
240 | # RepoModel().delete(HG_FORK) | |
453 | response.mustcontain("""file2-line1-from-fork""") |
|
241 | # | |
454 | response.mustcontain("""file3-line1-from-fork""") |
|
242 | # def test_org_repo_new_commits_after_forking_simple_diff(self): | |
455 | finally: |
|
243 | # self.log_user() | |
456 | RepoModel().delete(r2_id) |
|
244 | # | |
457 | RepoModel().delete(r1_id) |
|
245 | # repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg', | |
458 |
|
246 | # description='diff-test', | ||
459 | def test_org_repo_new_commits_after_forking_simple_diff(self): |
|
247 | # owner=TEST_USER_ADMIN_LOGIN) | |
460 | self.log_user() |
|
248 | # | |
461 |
|
249 | # Session().commit() | ||
462 | repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg', |
|
250 | # r1_id = repo1.repo_id | |
463 | description='diff-test', |
|
251 | # r1_name = repo1.repo_name | |
464 | owner=TEST_USER_ADMIN_LOGIN) |
|
252 | # | |
465 |
|
253 | # #commit something initially ! | ||
466 | Session().commit() |
|
254 | # cs0 = ScmModel().create_node( | |
467 | r1_id = repo1.repo_id |
|
255 | # repo=repo1.scm_instance, repo_name=r1_name, | |
468 | r1_name = repo1.repo_name |
|
256 | # cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, | |
469 |
|
257 | # author=TEST_USER_ADMIN_LOGIN, | ||
470 | #commit something initially ! |
|
258 | # message='commit1', | |
471 | cs0 = ScmModel().create_node( |
|
259 | # content='line1', | |
472 | repo=repo1.scm_instance, repo_name=r1_name, |
|
260 | # f_path='file1' | |
473 | cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, |
|
261 | # ) | |
474 | author=TEST_USER_ADMIN_LOGIN, |
|
262 | # Session().commit() | |
475 | message='commit1', |
|
263 | # self.assertEqual(repo1.scm_instance.revisions, [cs0.raw_id]) | |
476 | content='line1', |
|
264 | # #fork the repo1 | |
477 | f_path='file1' |
|
265 | # repo2 = RepoModel().create_repo(repo_name='one-fork', repo_type='hg', | |
478 | ) |
|
266 | # description='compare-test', | |
479 | Session().commit() |
|
267 | # clone_uri=repo1.repo_full_path, | |
480 | self.assertEqual(repo1.scm_instance.revisions, [cs0.raw_id]) |
|
268 | # owner=TEST_USER_ADMIN_LOGIN, fork_of='one') | |
481 | #fork the repo1 |
|
269 | # Session().commit() | |
482 | repo2 = RepoModel().create_repo(repo_name='one-fork', repo_type='hg', |
|
270 | # self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id]) | |
483 | description='compare-test', |
|
271 | # r2_id = repo2.repo_id | |
484 | clone_uri=repo1.repo_full_path, |
|
272 | # r2_name = repo2.repo_name | |
485 | owner=TEST_USER_ADMIN_LOGIN, fork_of='one') |
|
273 | # | |
486 | Session().commit() |
|
274 | # #make 3 new commits in fork | |
487 | self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id]) |
|
275 | # cs1 = ScmModel().create_node( | |
488 | r2_id = repo2.repo_id |
|
276 | # repo=repo2.scm_instance, repo_name=r2_name, | |
489 | r2_name = repo2.repo_name |
|
277 | # cs=repo2.scm_instance[-1], user=TEST_USER_ADMIN_LOGIN, | |
490 |
|
278 | # author=TEST_USER_ADMIN_LOGIN, | ||
491 | #make 3 new commits in fork |
|
279 | # message='commit1-fork', | |
492 | cs1 = ScmModel().create_node( |
|
280 | # content='file1-line1-from-fork', | |
493 | repo=repo2.scm_instance, repo_name=r2_name, |
|
281 | # f_path='file1-fork' | |
494 | cs=repo2.scm_instance[-1], user=TEST_USER_ADMIN_LOGIN, |
|
282 | # ) | |
495 | author=TEST_USER_ADMIN_LOGIN, |
|
283 | # cs2 = ScmModel().create_node( | |
496 | message='commit1-fork', |
|
284 | # repo=repo2.scm_instance, repo_name=r2_name, | |
497 | content='file1-line1-from-fork', |
|
285 | # cs=cs1, user=TEST_USER_ADMIN_LOGIN, | |
498 | f_path='file1-fork' |
|
286 | # author=TEST_USER_ADMIN_LOGIN, | |
499 | ) |
|
287 | # message='commit2-fork', | |
500 | cs2 = ScmModel().create_node( |
|
288 | # content='file2-line1-from-fork', | |
501 | repo=repo2.scm_instance, repo_name=r2_name, |
|
289 | # f_path='file2-fork' | |
502 | cs=cs1, user=TEST_USER_ADMIN_LOGIN, |
|
290 | # ) | |
503 | author=TEST_USER_ADMIN_LOGIN, |
|
291 | # cs3 = ScmModel().create_node( | |
504 | message='commit2-fork', |
|
292 | # repo=repo2.scm_instance, repo_name=r2_name, | |
505 | content='file2-line1-from-fork', |
|
293 | # cs=cs2, user=TEST_USER_ADMIN_LOGIN, | |
506 | f_path='file2-fork' |
|
294 | # author=TEST_USER_ADMIN_LOGIN, | |
507 | ) |
|
295 | # message='commit3-fork', | |
508 | cs3 = ScmModel().create_node( |
|
296 | # content='file3-line1-from-fork', | |
509 | repo=repo2.scm_instance, repo_name=r2_name, |
|
297 | # f_path='file3-fork' | |
510 | cs=cs2, user=TEST_USER_ADMIN_LOGIN, |
|
298 | # ) | |
511 | author=TEST_USER_ADMIN_LOGIN, |
|
299 | # | |
512 | message='commit3-fork', |
|
300 | # #compare ! | |
513 | content='file3-line1-from-fork', |
|
301 | # rev1 = 'default' | |
514 | f_path='file3-fork' |
|
302 | # rev2 = 'default' | |
515 | ) |
|
303 | # response = self.app.get(url(controller='compare', action='index', | |
516 |
|
304 | # repo_name=r2_name, | ||
517 | #compare ! |
|
305 | # org_ref_type="branch", | |
518 | rev1 = 'default' |
|
306 | # org_ref=rev1, | |
519 | rev2 = 'default' |
|
307 | # other_ref_type="branch", | |
520 | response = self.app.get(url(controller='compare', action='index', |
|
308 | # other_ref=rev2, | |
521 |
repo |
|
309 | # repo=r1_name, | |
522 |
|
|
310 | # bundle=False, | |
523 |
|
|
311 | # )) | |
524 | other_ref_type="branch", |
|
312 | # | |
525 | other_ref=rev2, |
|
313 | # try: | |
526 | repo=r1_name, |
|
314 | # #response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) | |
527 | bundle=False, |
|
315 | # | |
528 | )) |
|
316 | # #add new commit into parent ! | |
529 |
|
317 | # cs0 = ScmModel().create_node( | ||
530 | try: |
|
318 | # repo=repo1.scm_instance, repo_name=r1_name, | |
531 | #response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) |
|
319 | # cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, | |
532 |
|
320 | # author=TEST_USER_ADMIN_LOGIN, | ||
533 | #add new commit into parent ! |
|
321 | # message='commit2', | |
534 | cs0 = ScmModel().create_node( |
|
322 | # content='line1', | |
535 | repo=repo1.scm_instance, repo_name=r1_name, |
|
323 | # f_path='file2' | |
536 | cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, |
|
324 | # ) | |
537 | author=TEST_USER_ADMIN_LOGIN, |
|
325 | # #compare ! | |
538 | message='commit2', |
|
326 | # rev1 = 'default' | |
539 | content='line1', |
|
327 | # rev2 = 'default' | |
540 | f_path='file2' |
|
328 | # response = self.app.get(url(controller='compare', action='index', | |
541 | ) |
|
329 | # repo_name=r2_name, | |
542 | #compare ! |
|
330 | # org_ref_type="branch", | |
543 | rev1 = 'default' |
|
331 | # org_ref=rev1, | |
544 | rev2 = 'default' |
|
332 | # other_ref_type="branch", | |
545 | response = self.app.get(url(controller='compare', action='index', |
|
333 | # other_ref=rev2, | |
546 |
repo |
|
334 | # repo=r1_name, | |
547 |
|
|
335 | # bundle=False | |
548 |
|
|
336 | # )) | |
549 | other_ref_type="branch", |
|
337 | # | |
550 | other_ref=rev2, |
|
338 | # response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) | |
551 | repo=r1_name, |
|
339 | # response.mustcontain("""file1-line1-from-fork""") | |
552 | bundle=False |
|
340 | # response.mustcontain("""file2-line1-from-fork""") | |
553 | )) |
|
341 | # response.mustcontain("""file3-line1-from-fork""") | |
554 |
|
342 | # self.assertFalse("""<a href="#">file2</a>""" in response.body) # new commit from parent | ||
555 | response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) |
|
343 | # self.assertFalse("""line1-from-new-parent""" in response.body) | |
556 | response.mustcontain("""file1-line1-from-fork""") |
|
344 | # finally: | |
557 | response.mustcontain("""file2-line1-from-fork""") |
|
345 | # RepoModel().delete(r2_id) | |
558 | response.mustcontain("""file3-line1-from-fork""") |
|
346 | # RepoModel().delete(r1_id) | |
559 | self.assertFalse("""<a href="#">file2</a>""" in response.body) # new commit from parent |
|
|||
560 | self.assertFalse("""line1-from-new-parent""" in response.body) |
|
|||
561 | finally: |
|
|||
562 | RepoModel().delete(r2_id) |
|
|||
563 | RepoModel().delete(r1_id) |
|
General Comments 0
You need to be logged in to leave comments.
Login now