annotate rhodecode/controllers/compare.py @ 3029:685ebc84c2e9 beta

White space cleanup
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 26 Nov 2012 20:14:40 +0100
parents c2a206162062
children db4ca2212ec0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2241
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 """
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 rhodecode.controllers.compare
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 compare controller for pylons showoing differences between two
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 repos, branches, bookmarks or tips
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 :created_on: May 6, 2012
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 :author: marcink
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 :license: GPLv3, see COPYING for more details.
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 """
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 # This program is free software: you can redistribute it and/or modify
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 # it under the terms of the GNU General Public License as published by
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 # the Free Software Foundation, either version 3 of the License, or
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 # (at your option) any later version.
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 #
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 # This program is distributed in the hope that it will be useful,
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 # GNU General Public License for more details.
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 #
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 # You should have received a copy of the GNU General Public License
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 # along with this program. If not, see <http://www.gnu.org/licenses/>.
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 import logging
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 import traceback
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
29 from webob.exc import HTTPNotFound
2241
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 from pylons import request, response, session, tmpl_context as c, url
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 from pylons.controllers.util import abort, redirect
2593
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
32 from pylons.i18n.translation import _
2241
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33
2593
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
34 from rhodecode.lib.vcs.exceptions import EmptyRepositoryError, RepositoryError
2348
a07e04ef7bb4 Implemented basic compare view(for pull requests) for mercurial.
Marcin Kuzminski <marcin@python-works.com>
parents: 2337
diff changeset
35 from rhodecode.lib import helpers as h
2241
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 from rhodecode.lib.base import BaseRepoController, render
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
38 from rhodecode.lib import diffs
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
39
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
40 from rhodecode.model.db import Repository
2442
3bf057a7f7e8 small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents: 2434
diff changeset
41 from rhodecode.model.pull_request import PullRequestModel
2847
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
42 from webob.exc import HTTPBadRequest
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2847
diff changeset
43 from rhodecode.lib.utils2 import str2bool
3011
25d77aef2729 Optimized look of compare view of changesets.
Marcin Kuzminski <marcin@python-works.com>
parents: 3010
diff changeset
44 from rhodecode.lib.diffs import LimitedDiffContainer
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
45 from rhodecode.lib.vcs.backends.base import EmptyChangeset
2241
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 log = logging.getLogger(__name__)
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 class CompareController(BaseRepoController):
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 @LoginRequired()
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 'repository.admin')
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 def __before__(self):
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 super(CompareController, self).__before__()
b2a2868d7bec Basic compare-view controller with ref parsing
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57
2847
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
58 def __get_cs_or_redirect(self, rev, repo, redirect_after=True,
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
59 partial=False):
2593
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
60 """
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
61 Safe way to get changeset if error occur it redirects to changeset with
2847
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
62 proper message. If partial is set then don't do redirect raise Exception
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
63 instead
2593
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
64
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
65 :param rev: revision to fetch
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
66 :param repo: repo instance
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
67 """
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
68
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
69 try:
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
70 type_, rev = rev
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
71 return repo.scm_instance.get_changeset(rev)
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
72 except EmptyRepositoryError, e:
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
73 if not redirect_after:
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
74 return None
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
75 h.flash(h.literal(_('There are no changesets yet')),
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
76 category='warning')
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
77 redirect(url('summary_home', repo_name=repo.repo_name))
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
78
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
79 except RepositoryError, e:
2684
2b6939a77052 Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents: 2593
diff changeset
80 log.error(traceback.format_exc())
2593
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
81 h.flash(str(e), category='warning')
2847
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
82 if not partial:
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
83 redirect(h.url('summary_home', repo_name=repo.repo_name))
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
84 raise HTTPBadRequest()
2593
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
85
2363
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
86 def index(self, org_ref_type, org_ref, other_ref_type, other_ref):
2362
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2355
diff changeset
87
2363
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
88 org_repo = c.rhodecode_db_repo.repo_name
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
89 org_ref = (org_ref_type, org_ref)
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
90 other_ref = (other_ref_type, other_ref)
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
91 other_repo = request.GET.get('repo', org_repo)
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
92 incoming_changesets = str2bool(request.GET.get('bundle', False))
3011
25d77aef2729 Optimized look of compare view of changesets.
Marcin Kuzminski <marcin@python-works.com>
parents: 3010
diff changeset
93 c.fulldiff = fulldiff = request.GET.get('fulldiff')
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
94 rev_start = request.GET.get('rev_start')
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
95 rev_end = request.GET.get('rev_end')
2363
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
96
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
97 c.swap_url = h.url('compare_url', repo_name=other_repo,
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
98 org_ref_type=other_ref[0], org_ref=other_ref[1],
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
99 other_ref_type=org_ref[0], other_ref=org_ref[1],
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2847
diff changeset
100 repo=org_repo, as_form=request.GET.get('as_form'),
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
101 bundle=incoming_changesets)
2363
745dda7817ed Rewrote url routes to make all validations and parsing for compare view + added compare fork button into forked repos
Marcin Kuzminski <marcin@python-works.com>
parents: 2362
diff changeset
102
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
103 c.org_repo = org_repo = Repository.get_by_repo_name(org_repo)
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
104 c.other_repo = other_repo = Repository.get_by_repo_name(other_repo)
2362
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2355
diff changeset
105
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2355
diff changeset
106 if c.org_repo is None or c.other_repo is None:
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2355
diff changeset
107 log.error('Could not found repo %s or %s' % (org_repo, other_repo))
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2355
diff changeset
108 raise HTTPNotFound
3c4afb8894bd Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents: 2355
diff changeset
109
3010
bf96fd1920c1 Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
110 if c.org_repo != c.other_repo and h.is_git(c.rhodecode_repo):
bf96fd1920c1 Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
111 log.error('compare of two remote repos not available for GIT REPOS')
2444
b45e9fd75ac0 data checks
Marcin Kuzminski <marcin@python-works.com>
parents: 2442
diff changeset
112 raise HTTPNotFound
3010
bf96fd1920c1 Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
113
bf96fd1920c1 Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
114 if c.org_repo.scm_instance.alias != c.other_repo.scm_instance.alias:
bf96fd1920c1 Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
115 log.error('compare of two different kind of remote repos not available')
bf96fd1920c1 Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
116 raise HTTPNotFound
bf96fd1920c1 Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents: 2995
diff changeset
117
2847
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
118 partial = request.environ.get('HTTP_X_PARTIAL_XHR')
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
119 self.__get_cs_or_redirect(rev=org_ref, repo=org_repo, partial=partial)
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
120 self.__get_cs_or_redirect(rev=other_ref, repo=other_repo, partial=partial)
2593
16a6a2f5d422 Add check for existing revisions in compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2487
diff changeset
121
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
122 if rev_start and rev_end:
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
123 #replace our org_ref with given CS
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
124 org_ref = ('rev', rev_start)
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
125 other_ref = ('rev', rev_end)
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
126
2442
3bf057a7f7e8 small refactoring, moved shared for diff generation of code into pull-request model
Marcin Kuzminski <marcin@python-works.com>
parents: 2434
diff changeset
127 c.cs_ranges, discovery_data = PullRequestModel().get_compare_data(
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
128 org_repo, org_ref, other_repo, other_ref,
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2847
diff changeset
129 )
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
130
2393
b94eac50ec4d added changeset review status into repo/branch compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2363
diff changeset
131 c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in
b94eac50ec4d added changeset review status into repo/branch compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2363
diff changeset
132 c.cs_ranges])
2487
995d938ce14b Fixed origin repo in pull-request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2444
diff changeset
133 c.target_repo = c.repo_name
2434
f29469677319 Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2395
diff changeset
134 # defines that we need hidden inputs with changesets
f29469677319 Added basic models for saving open pull requests
Marcin Kuzminski <marcin@python-works.com>
parents: 2395
diff changeset
135 c.as_form = request.GET.get('as_form', False)
2847
1cd0a0c05f42 swap the select values with revisions dynamically when switching the repos on pull request view
Marcin Kuzminski <marcin@python-works.com>
parents: 2684
diff changeset
136 if partial:
2395
b262e349a7a5 created pull-request overview
Marcin Kuzminski <marcin@python-works.com>
parents: 2393
diff changeset
137 return render('compare/compare_cs.html')
2393
b94eac50ec4d added changeset review status into repo/branch compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2363
diff changeset
138
3015
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
139 c.org_ref = org_ref[1]
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
140 c.other_ref = other_ref[1]
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
141
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
142 if not incoming_changesets and c.cs_ranges and c.org_repo != c.other_repo:
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2847
diff changeset
143 # case we want a simple diff without incoming changesets, just
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2847
diff changeset
144 # for review purposes. Make the diff on the forked repo, with
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2847
diff changeset
145 # revision that is common ancestor
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
146 _org_ref = org_ref
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
147 org_ref = ('rev', getattr(c.cs_ranges[0].parents[0]
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
148 if c.cs_ranges[0].parents
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
149 else EmptyChangeset(), 'raw_id'))
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
150 log.debug('Changed org_ref from %s to %s' % (_org_ref, org_ref))
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2847
diff changeset
151 other_repo = org_repo
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2847
diff changeset
152
3015
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
153 diff_limit = self.cut_off_limit if not fulldiff else None
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
154
3015
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
155 _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref,
3023
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
156 discovery_data,
c2a206162062 Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 3015
diff changeset
157 remote_compare=incoming_changesets)
2892
5fba3778431c #590 Add GET flag that controls the way the diff are generated, for pull requests we want to use non-bundle based diffs,
Marcin Kuzminski <marcin@python-works.com>
parents: 2847
diff changeset
158
3015
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
159 diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff',
3011
25d77aef2729 Optimized look of compare view of changesets.
Marcin Kuzminski <marcin@python-works.com>
parents: 3010
diff changeset
160 diff_limit=diff_limit)
2348
a07e04ef7bb4 Implemented basic compare view(for pull requests) for mercurial.
Marcin Kuzminski <marcin@python-works.com>
parents: 2337
diff changeset
161 _parsed = diff_processor.prepare()
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
162
3011
25d77aef2729 Optimized look of compare view of changesets.
Marcin Kuzminski <marcin@python-works.com>
parents: 3010
diff changeset
163 c.limited_diff = False
25d77aef2729 Optimized look of compare view of changesets.
Marcin Kuzminski <marcin@python-works.com>
parents: 3010
diff changeset
164 if isinstance(_parsed, LimitedDiffContainer):
25d77aef2729 Optimized look of compare view of changesets.
Marcin Kuzminski <marcin@python-works.com>
parents: 3010
diff changeset
165 c.limited_diff = True
25d77aef2729 Optimized look of compare view of changesets.
Marcin Kuzminski <marcin@python-works.com>
parents: 3010
diff changeset
166
2348
a07e04ef7bb4 Implemented basic compare view(for pull requests) for mercurial.
Marcin Kuzminski <marcin@python-works.com>
parents: 2337
diff changeset
167 c.files = []
a07e04ef7bb4 Implemented basic compare view(for pull requests) for mercurial.
Marcin Kuzminski <marcin@python-works.com>
parents: 2337
diff changeset
168 c.changes = {}
3015
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
169 c.lines_added = 0
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
170 c.lines_deleted = 0
2393
b94eac50ec4d added changeset review status into repo/branch compare view
Marcin Kuzminski <marcin@python-works.com>
parents: 2363
diff changeset
171 for f in _parsed:
3015
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
172 st = f['stats']
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
173 if st[0] != 'b':
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
174 c.lines_added += st[0]
16af24982e30 Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents: 3011
diff changeset
175 c.lines_deleted += st[1]
2348
a07e04ef7bb4 Implemented basic compare view(for pull requests) for mercurial.
Marcin Kuzminski <marcin@python-works.com>
parents: 2337
diff changeset
176 fid = h.FID('', f['filename'])
a07e04ef7bb4 Implemented basic compare view(for pull requests) for mercurial.
Marcin Kuzminski <marcin@python-works.com>
parents: 2337
diff changeset
177 c.files.append([fid, f['operation'], f['filename'], f['stats']])
2995
32471bd1f4ee Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents: 2892
diff changeset
178 diff = diff_processor.as_html(enable_comments=False, parsed_lines=[f])
2348
a07e04ef7bb4 Implemented basic compare view(for pull requests) for mercurial.
Marcin Kuzminski <marcin@python-works.com>
parents: 2337
diff changeset
179 c.changes[fid] = [f['operation'], f['filename'], diff]
2337
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
180
f8c953c6b040 Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 2245
diff changeset
181 return render('compare/compare_diff.html')