##// END OF EJS Templates
Multiple changes for compare system...
marcink -
r3015:16af2498 beta
parent child Browse files
Show More
@@ -88,14 +88,14 b' class CompareController(BaseRepoControll'
88 org_ref = (org_ref_type, org_ref)
88 org_ref = (org_ref_type, org_ref)
89 other_ref = (other_ref_type, other_ref)
89 other_ref = (other_ref_type, other_ref)
90 other_repo = request.GET.get('repo', org_repo)
90 other_repo = request.GET.get('repo', org_repo)
91 bundle_compare = str2bool(request.GET.get('bundle', True))
91 remote_compare = str2bool(request.GET.get('bundle', True))
92 c.fulldiff = fulldiff = request.GET.get('fulldiff')
92 c.fulldiff = fulldiff = request.GET.get('fulldiff')
93
93
94 c.swap_url = h.url('compare_url', repo_name=other_repo,
94 c.swap_url = h.url('compare_url', repo_name=other_repo,
95 org_ref_type=other_ref[0], org_ref=other_ref[1],
95 org_ref_type=other_ref[0], org_ref=other_ref[1],
96 other_ref_type=org_ref[0], other_ref=org_ref[1],
96 other_ref_type=org_ref[0], other_ref=org_ref[1],
97 repo=org_repo, as_form=request.GET.get('as_form'),
97 repo=org_repo, as_form=request.GET.get('as_form'),
98 bundle=bundle_compare)
98 bundle=remote_compare)
99
99
100 c.org_repo = org_repo = Repository.get_by_repo_name(org_repo)
100 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)
101 c.other_repo = other_repo = Repository.get_by_repo_name(other_repo)
@@ -128,20 +128,21 b' class CompareController(BaseRepoControll'
128 if partial:
128 if partial:
129 return render('compare/compare_cs.html')
129 return render('compare/compare_cs.html')
130
130
131 if not bundle_compare and c.cs_ranges:
131 c.org_ref = org_ref[1]
132 c.other_ref = other_ref[1]
133
134 if not remote_compare and c.cs_ranges:
132 # case we want a simple diff without incoming changesets, just
135 # case we want a simple diff without incoming changesets, just
133 # for review purposes. Make the diff on the forked repo, with
136 # for review purposes. Make the diff on the forked repo, with
134 # revision that is common ancestor
137 # revision that is common ancestor
135 other_ref = ('rev', c.cs_ranges[-1].parents[0].raw_id)
138 other_ref = ('rev', c.cs_ranges[-1].parents[0].raw_id)
136 other_repo = org_repo
139 other_repo = org_repo
137
140
138 c.org_ref = org_ref[1]
141 diff_limit = self.cut_off_limit if not fulldiff else None
139 c.other_ref = other_ref[1]
142 _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref,
143 discovery_data, remote_compare=remote_compare)
140
144
141 _diff = diffs.differ(other_repo, other_ref, org_repo, org_ref,
145 diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff',
142 discovery_data, bundle_compare=bundle_compare)
143 diff_limit = self.cut_off_limit if not fulldiff else None
144 diff_processor = diffs.DiffProcessor(_diff, format='gitdiff',
145 diff_limit=diff_limit)
146 diff_limit=diff_limit)
146 _parsed = diff_processor.prepare()
147 _parsed = diff_processor.prepare()
147
148
@@ -151,8 +152,13 b' class CompareController(BaseRepoControll'
151
152
152 c.files = []
153 c.files = []
153 c.changes = {}
154 c.changes = {}
154
155 c.lines_added = 0
156 c.lines_deleted = 0
155 for f in _parsed:
157 for f in _parsed:
158 st = f['stats']
159 if st[0] != 'b':
160 c.lines_added += st[0]
161 c.lines_deleted += st[1]
156 fid = h.FID('', f['filename'])
162 fid = h.FID('', f['filename'])
157 c.files.append([fid, f['operation'], f['filename'], f['stats']])
163 c.files.append([fid, f['operation'], f['filename'], f['stats']])
158 diff = diff_processor.as_html(enable_comments=False, parsed_lines=[f])
164 diff = diff_processor.as_html(enable_comments=False, parsed_lines=[f])
@@ -51,6 +51,7 b' from rhodecode.model.comment import Chan'
51 from rhodecode.model.changeset_status import ChangesetStatusModel
51 from rhodecode.model.changeset_status import ChangesetStatusModel
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
55
55 log = logging.getLogger(__name__)
56 log = logging.getLogger(__name__)
56
57
@@ -277,7 +278,9 b' class PullrequestsController(BaseRepoCon'
277 # case we want a simple diff without incoming changesets, just
278 # case we want a simple diff without incoming changesets, just
278 # for review purposes. Make the diff on the forked repo, with
279 # for review purposes. Make the diff on the forked repo, with
279 # revision that is common ancestor
280 # revision that is common ancestor
280 other_ref = ('rev', c.cs_ranges[-1].parents[0].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'))
281 other_repo = org_repo
284 other_repo = org_repo
282
285
283 c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges])
286 c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges])
@@ -286,9 +289,9 b' class PullrequestsController(BaseRepoCon'
286
289
287 c.org_ref = org_ref[1]
290 c.org_ref = org_ref[1]
288 c.other_ref = other_ref[1]
291 c.other_ref = other_ref[1]
289 # diff needs to have swapped org with other to generate proper diff
292 _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref,
290 _diff = diffs.differ(other_repo, other_ref, org_repo, org_ref,
291 discovery_data)
293 discovery_data)
294
292 diff_processor = diffs.DiffProcessor(_diff, format='gitdiff')
295 diff_processor = diffs.DiffProcessor(_diff, format='gitdiff')
293 _parsed = diff_processor.prepare()
296 _parsed = diff_processor.prepare()
294
297
@@ -702,52 +702,48 b' class InMemoryBundleRepo(bundlerepositor'
702
702
703
703
704 def differ(org_repo, org_ref, other_repo, other_ref, discovery_data=None,
704 def differ(org_repo, org_ref, other_repo, other_ref, discovery_data=None,
705 bundle_compare=False, context=3, ignore_whitespace=False):
705 remote_compare=False, context=3, ignore_whitespace=False):
706 """
706 """
707 General differ between branches, bookmarks, revisions of two remote related
707 General differ between branches, bookmarks, revisions of two remote or
708 repositories
708 local but related repositories
709
709
710 :param org_repo:
710 :param org_repo:
711 :type org_repo:
712 :param org_ref:
711 :param org_ref:
713 :type org_ref:
714 :param other_repo:
712 :param other_repo:
715 :type other_repo:
713 :type other_repo:
716 :param other_ref:
717 :type other_ref:
714 :type other_ref:
718 """
715 """
719
716
720 bundlerepo = None
721 ignore_whitespace = ignore_whitespace
722 context = context
723 org_repo_scm = org_repo.scm_instance
717 org_repo_scm = org_repo.scm_instance
718 other_repo_scm = other_repo.scm_instance
719
724 org_repo = org_repo_scm._repo
720 org_repo = org_repo_scm._repo
725 other_repo = other_repo.scm_instance._repo
721 other_repo = other_repo_scm._repo
726 opts = diffopts(git=True, ignorews=ignore_whitespace, context=context)
722
727 org_ref = org_ref[1]
723 org_ref = org_ref[1]
728 other_ref = other_ref[1]
724 other_ref = other_ref[1]
729
725
730 if org_repo == other_repo:
726 if org_repo == other_repo:
731 log.debug('running diff between %s@%s and %s@%s'
727 log.debug('running diff between %s@%s and %s@%s'
732 % (org_repo, org_ref, other_repo, other_ref))
728 % (org_repo, org_ref, other_repo, other_ref))
733 _diff = org_repo_scm.get_diff(rev1=other_ref, rev2=org_ref,
729 _diff = org_repo_scm.get_diff(rev1=org_ref, rev2=other_ref,
734 ignore_whitespace=ignore_whitespace, context=context)
730 ignore_whitespace=ignore_whitespace, context=context)
735 return _diff
731 return _diff
736
732
737 elif bundle_compare:
733 elif remote_compare:
738
734 opts = diffopts(git=True, ignorews=ignore_whitespace, context=context)
739 common, incoming, rheads = discovery_data
735 common, incoming, rheads = discovery_data
740 other_repo_peer = localrepo.locallegacypeer(other_repo.local())
736 org_repo_peer = localrepo.locallegacypeer(org_repo.local())
741 # create a bundle (uncompressed if other repo is not local)
737 # create a bundle (uncompressed if other repo is not local)
742 if other_repo_peer.capable('getbundle') and incoming:
738 if org_repo_peer.capable('getbundle'):
743 # disable repo hooks here since it's just bundle !
739 # disable repo hooks here since it's just bundle !
744 # patch and reset hooks section of UI config to not run any
740 # patch and reset hooks section of UI config to not run any
745 # hooks on fetching archives with subrepos
741 # hooks on fetching archives with subrepos
746 for k, _ in other_repo.ui.configitems('hooks'):
742 for k, _ in org_repo.ui.configitems('hooks'):
747 other_repo.ui.setconfig('hooks', k, None)
743 org_repo.ui.setconfig('hooks', k, None)
748
744
749 unbundle = other_repo.getbundle('incoming', common=common,
745 unbundle = org_repo.getbundle('incoming', common=common,
750 heads=None)
746 heads=None)
751
747
752 buf = BytesIO()
748 buf = BytesIO()
753 while True:
749 while True:
@@ -764,8 +760,9 b' def differ(org_repo, org_ref, other_repo'
764 bundlerepo = InMemoryBundleRepo(ui, path=org_repo.root,
760 bundlerepo = InMemoryBundleRepo(ui, path=org_repo.root,
765 bundlestream=unbundle)
761 bundlestream=unbundle)
766
762
767 return ''.join(patch.diff(bundlerepo or org_repo,
763 return ''.join(patch.diff(bundlerepo,
768 node1=org_repo[org_ref].node(),
764 node1=other_repo[other_ref].node(),
769 node2=other_repo[other_ref].node(),
765 node2=org_repo[org_ref].node(),
770 opts=opts))
766 opts=opts))
771
767
768 return '' No newline at end of file
@@ -185,21 +185,21 b' class PullRequestModel(BaseModel):'
185
185
186 revs = [
186 revs = [
187 "ancestors(%s('%s')) and not ancestors(%s('%s'))" % (
187 "ancestors(%s('%s')) and not ancestors(%s('%s'))" % (
188 _revset_predicates[other_ref[0]], other_ref[1],
188 _revset_predicates[org_ref[0]], org_ref[1],
189 _revset_predicates[org_ref[0]], org_ref[1],
189 _revset_predicates[other_ref[0]], other_ref[1]
190 )
190 )
191 ]
191 ]
192
192
193 out = scmutil.revrange(org_repo._repo, revs)
193 out = scmutil.revrange(org_repo._repo, revs)
194 for cs in reversed(out):
194 for cs in (out):
195 changesets.append(org_repo.get_changeset(cs))
195 changesets.append(org_repo.get_changeset(cs))
196 elif alias == 'git':
196 elif alias == 'git':
197 so, se = org_repo.run_git_command(
197 so, se = org_repo.run_git_command(
198 'log --pretty="format: %%H" -s -p %s..%s' % (org_ref[1],
198 'log --reverse --pretty="format: %%H" -s -p %s..%s' % (org_ref[1],
199 other_ref[1])
199 other_ref[1])
200 )
200 )
201 ids = re.findall(r'[0-9a-fA-F]{40}', so)
201 ids = re.findall(r'[0-9a-fA-F]{40}', so)
202 for cs in reversed(ids):
202 for cs in (ids):
203 changesets.append(org_repo.get_changeset(cs))
203 changesets.append(org_repo.get_changeset(cs))
204
204
205 return changesets
205 return changesets
@@ -26,7 +26,7 b''
26 <div class="table">
26 <div class="table">
27 <div id="body" class="diffblock">
27 <div id="body" class="diffblock">
28 <div class="code-header cv">
28 <div class="code-header cv">
29 <h3 class="code-header-title">${_('Compare View')}</h3>
29 <h3 class="code-header-title">${_('Compare View')} / ${h.link_to(_('Show combined compare'),h.url('compare_url',repo_name=c.repo_name,org_ref_type='rev',org_ref=getattr(c.cs_ranges[0].parents[0] if c.cs_ranges[0].parents else h.EmptyChangeset(),'raw_id'),other_ref_type='rev',other_ref=c.cs_ranges[-1].raw_id))}</h3>
30 <div>
30 <div>
31 ${_('Changesets')} - r${c.cs_ranges[0].revision}:${h.short_id(c.cs_ranges[0].raw_id)} -> r${c.cs_ranges[-1].revision}:${h.short_id(c.cs_ranges[-1].raw_id)}
31 ${_('Changesets')} - r${c.cs_ranges[0].revision}:${h.short_id(c.cs_ranges[0].raw_id)} -> r${c.cs_ranges[-1].revision}:${h.short_id(c.cs_ranges[-1].raw_id)}
32 </div>
32 </div>
@@ -2,7 +2,7 b''
2 <div class="container">
2 <div class="container">
3 <table class="compare_view_commits noborder">
3 <table class="compare_view_commits noborder">
4 %if not c.cs_ranges:
4 %if not c.cs_ranges:
5 <tr><td>${_('No changesets')}</td></tr>
5 <span class="empty_data">${_('No changesets')}</span>
6 %else:
6 %else:
7 %for cnt, cs in enumerate(c.cs_ranges):
7 %for cnt, cs in enumerate(c.cs_ranges):
8 <tr>
8 <tr>
@@ -34,12 +34,23 b''
34 </div>
34 </div>
35 <div id="changeset_compare_view_content">
35 <div id="changeset_compare_view_content">
36 ##CS
36 ##CS
37 <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${_('Outgoing changesets')}</div>
37 <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>
38 <%include file="compare_cs.html" />
38 <%include file="compare_cs.html" />
39
39
40 ## FILES
40 ## FILES
41 <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${_('Files affected')}</div>
41 <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
42
43 % if c.limited_diff:
44 ${ungettext('%s file changed', '%s files changed', len(c.files)) % len(c.files)}
45 % else:
46 ${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)}:
47 %endif
48
49 </div>
42 <div class="cs_files">
50 <div class="cs_files">
51 %if not c.files:
52 <span class="empty_data">${_('No files')}</span>
53 %endif
43 %for fid, change, f, stat in c.files:
54 %for fid, change, f, stat in c.files:
44 <div class="cs_${change}">
55 <div class="cs_${change}">
45 <div class="node">${h.link_to(h.safe_unicode(f),h.url.current(anchor=fid))}</div>
56 <div class="node">${h.link_to(h.safe_unicode(f),h.url.current(anchor=fid))}</div>
@@ -8,10 +8,10 b' from rhodecode.lib.vcs.backends.base imp'
8
8
9 class TestCompareController(TestController):
9 class TestCompareController(TestController):
10
10
11 def test_index_tag(self):
11 def test_compare_tag_hg(self):
12 self.log_user()
12 self.log_user()
13 tag1 = '0.1.3'
13 tag1 = '0.1.2'
14 tag2 = '0.1.2'
14 tag2 = '0.1.3'
15 response = self.app.get(url(controller='compare', action='index',
15 response = self.app.get(url(controller='compare', action='index',
16 repo_name=HG_REPO,
16 repo_name=HG_REPO,
17 org_ref_type="tag",
17 org_ref_type="tag",
@@ -21,13 +21,13 b' class TestCompareController(TestControll'
21 ))
21 ))
22 response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, tag1, HG_REPO, tag2))
22 response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, tag1, HG_REPO, tag2))
23 ## outgoing changesets between tags
23 ## outgoing changesets between tags
24 response.mustcontain('''<a href="/%s/changeset/17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">r120:17544fbfcd33</a>''' % HG_REPO)
24 response.mustcontain('''<a href="/%s/changeset/c5ddebc06eaaba3010c2d66ea6ec9d074eb0f678">r112:c5ddebc06eaa</a>''' % HG_REPO)
25 response.mustcontain('''<a href="/%s/changeset/36e0fc9d2808c5022a24f49d6658330383ed8666">r119:36e0fc9d2808</a>''' % HG_REPO)
25 response.mustcontain('''<a href="/%s/changeset/70d4cef8a37657ee4cf5aabb3bd9f68879769816">r115:70d4cef8a376</a>''' % HG_REPO)
26 response.mustcontain('''<a href="/%s/changeset/bb1a3ab98cc45cb934a77dcabf87a5a598b59e97">r118:bb1a3ab98cc4</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)
27 response.mustcontain('''<a href="/%s/changeset/41fda979f02fda216374bf8edac4e83f69e7581c">r117:41fda979f02f</a>''' % HG_REPO)
28 response.mustcontain('''<a href="/%s/changeset/9749bfbfc0d2eba208d7947de266303b67c87cda">r116:9749bfbfc0d2</a>''' % HG_REPO)
28 response.mustcontain('''<a href="/%s/changeset/bb1a3ab98cc45cb934a77dcabf87a5a598b59e97">r118:bb1a3ab98cc4</a>''' % HG_REPO)
29 response.mustcontain('''<a href="/%s/changeset/70d4cef8a37657ee4cf5aabb3bd9f68879769816">r115:70d4cef8a376</a>''' % HG_REPO)
29 response.mustcontain('''<a href="/%s/changeset/36e0fc9d2808c5022a24f49d6658330383ed8666">r119:36e0fc9d2808</a>''' % HG_REPO)
30 response.mustcontain('''<a href="/%s/changeset/c5ddebc06eaaba3010c2d66ea6ec9d074eb0f678">r112:c5ddebc06eaa</a>''' % HG_REPO)
30 response.mustcontain('''<a href="/%s/changeset/17544fbfcd33ffb439e2b728b5d526b1ef30bfcf">r120:17544fbfcd33</a>''' % HG_REPO)
31
31
32 ## files diff
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))
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))
@@ -42,7 +42,43 b' class TestCompareController(TestControll'
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))
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))
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
44
45 def test_index_branch(self):
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):
46 self.log_user()
82 self.log_user()
47 response = self.app.get(url(controller='compare', action='index',
83 response = self.app.get(url(controller='compare', action='index',
48 repo_name=HG_REPO,
84 repo_name=HG_REPO,
@@ -54,12 +90,29 b' class TestCompareController(TestControll'
54
90
55 response.mustcontain('%s@default -> %s@default' % (HG_REPO, HG_REPO))
91 response.mustcontain('%s@default -> %s@default' % (HG_REPO, HG_REPO))
56 # branch are equal
92 # branch are equal
57 response.mustcontain('<tr><td>No changesets</td></tr>')
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>')
58
110
59 def test_compare_revisions(self):
111 def test_compare_revisions(self):
60 self.log_user()
112 self.log_user()
61 rev1 = '3d8f361e72ab'
113 rev1 = 'b986218ba1c9'
62 rev2 = 'b986218ba1c9'
114 rev2 = '3d8f361e72ab'
115
63 response = self.app.get(url(controller='compare', action='index',
116 response = self.app.get(url(controller='compare', action='index',
64 repo_name=HG_REPO,
117 repo_name=HG_REPO,
65 org_ref_type="rev",
118 org_ref_type="rev",
@@ -69,8 +122,7 b' class TestCompareController(TestControll'
69 ))
122 ))
70 response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_REPO, rev2))
123 response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_REPO, rev2))
71 ## outgoing changesets between those revisions
124 ## outgoing changesets between those revisions
72 response.mustcontain("""<a href="/%s/changeset/3d8f361e72ab303da48d799ff1ac40d5ac37c67e">r1:%s</a>""" % (HG_REPO, rev1))
125 response.mustcontain("""<a href="/%s/changeset/3d8f361e72ab303da48d799ff1ac40d5ac37c67e">r1:%s</a>""" % (HG_REPO, rev2))
73
74 ## files
126 ## files
75 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--c8e92ef85cd1">.hgignore</a>""" % (HG_REPO, rev1, rev2))
127 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--c8e92ef85cd1">.hgignore</a>""" % (HG_REPO, rev1, rev2))
76
128
@@ -93,8 +145,54 b' class TestCompareController(TestControll'
93
145
94 Session().commit()
146 Session().commit()
95
147
96 rev1 = '7d4bc8ec6be5'
148 rev1 = '56349e29c2af'
97 rev2 = '56349e29c2af'
149 rev2 = '7d4bc8ec6be5'
150
151 response = self.app.get(url(controller='compare', action='index',
152 repo_name=HG_REPO,
153 org_ref_type="rev",
154 org_ref=rev1,
155 other_ref_type="rev",
156 other_ref=rev2,
157 repo=HG_FORK,
158 ))
159
160 try:
161 response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2))
162 ## outgoing changesets between those revisions
163
164 response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO))
165 response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO))
166 response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2))
167
168 ## files
169 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2))
170 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2))
171 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2))
172 finally:
173 RepoModel().delete(HG_FORK)
174
175 def test_compare_remote_repos_remote_flag_off(self):
176 self.log_user()
177
178 form_data = dict(
179 repo_name=HG_FORK,
180 repo_name_full=HG_FORK,
181 repo_group=None,
182 repo_type='hg',
183 description='',
184 private=False,
185 copy_permissions=False,
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
192 Session().commit()
193
194 rev1 = '56349e29c2af'
195 rev2 = '7d4bc8ec6be5'
98
196
99 response = self.app.get(url(controller='compare', action='index',
197 response = self.app.get(url(controller='compare', action='index',
100 repo_name=HG_REPO,
198 repo_name=HG_REPO,
@@ -102,16 +200,17 b' class TestCompareController(TestControll'
102 org_ref=rev1,
200 org_ref=rev1,
103 other_ref_type="rev",
201 other_ref_type="rev",
104 other_ref=rev2,
202 other_ref=rev2,
105 repo=HG_FORK
203 repo=HG_FORK,
204 bundle=False,
106 ))
205 ))
107
206
108 try:
207 try:
109 response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2))
208 response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2))
110 ## outgoing changesets between those revisions
209 ## outgoing changesets between those revisions
111
210
112 response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev1))
211 response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO))
113 response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO))
212 response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO))
114 response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO))
213 response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2))
115
214
116 ## files
215 ## files
117 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2))
216 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2))
@@ -120,6 +219,67 b' class TestCompareController(TestControll'
120 finally:
219 finally:
121 RepoModel().delete(HG_FORK)
220 RepoModel().delete(HG_FORK)
122
221
222 # def test_compare_origin_ahead_of_fork(self):
223 # self.log_user()
224 #
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 #
255 # rev1 = '56349e29c2af'
256 # rev2 = '7d4bc8ec6be5'
257 #
258 # response = self.app.get(url(controller='compare', action='index',
259 # repo_name=HG_REPO,
260 # org_ref_type="rev",
261 # org_ref=rev1,
262 # other_ref_type="rev",
263 # other_ref=rev2,
264 # repo=HG_FORK,
265 # bundle=False,
266 # ))
267 #
268 # try:
269 # response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_REPO, rev2))
270 # ## outgoing changesets between those revisions
271 #
272 # response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO))
273 # response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO))
274 # response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2))
275 #
276 # ## files
277 # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2))
278 # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2))
279 # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2))
280 # finally:
281 # RepoModel().delete(HG_FORK)
282
123 def test_compare_extra_commits(self):
283 def test_compare_extra_commits(self):
124 self.log_user()
284 self.log_user()
125
285
@@ -178,7 +338,7 b' class TestCompareController(TestControll'
178 try:
338 try:
179 response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2))
339 response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2))
180
340
181 response.mustcontain("""<div class="message">commit2</div>""")
341 response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""")
182 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (r2_name, cs1.raw_id, cs1.short_id))
342 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (r2_name, cs1.raw_id, cs1.short_id))
183 ## files
343 ## files
184 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (r2_name, rev1, rev2))
344 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (r2_name, rev1, rev2))
@@ -391,7 +551,7 b' class TestCompareController(TestControll'
391 repo=r1_name,
551 repo=r1_name,
392 bundle=False
552 bundle=False
393 ))
553 ))
394 rev2 = cs0.parents[0].raw_id
554
395 response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2))
555 response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2))
396 response.mustcontain("""file1-line1-from-fork""")
556 response.mustcontain("""file1-line1-from-fork""")
397 response.mustcontain("""file2-line1-from-fork""")
557 response.mustcontain("""file2-line1-from-fork""")
General Comments 0
You need to be logged in to leave comments. Login now