Mercurial > kallithea
annotate rhodecode/lib/diffs.py @ 3195:a50901f2108d beta
Added repository followers to the get_repo api function result.
author | aparkar <aparkar@icloud.com> |
---|---|
date | Tue, 22 Jan 2013 11:56:47 +1100 |
parents | b9105d31e582 |
children | 70309536c143 |
rev | line source |
---|---|
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.lib.diffs |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 Set of diffing helpers, previously part of vcs |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
7 |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
8 |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :created_on: Dec 4, 2011 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1789
diff
changeset
|
11 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
12 :original copyright: 2007-2008 by Armin Ronacher |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 :license: GPLv3, see COPYING for more details. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 # This program is free software: you can redistribute it and/or modify |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 # it under the terms of the GNU General Public License as published by |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # the Free Software Foundation, either version 3 of the License, or |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # (at your option) any later version. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # This program is distributed in the hope that it will be useful, |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # GNU General Public License for more details. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 # You should have received a copy of the GNU General Public License |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 import re |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 import difflib |
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:
2843
diff
changeset
|
30 import logging |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
31 import traceback |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
32 |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
33 from itertools import tee, imap |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
35 from mercurial import patch |
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
36 from mercurial.mdiff import diffopts |
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
37 from mercurial.bundlerepo import bundlerepository |
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
38 |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
39 from pylons.i18n.translation import _ |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 |
2552
e8650fbc4d4e
Moved BytesIO into compat because of py25 compatibility issue
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
41 from rhodecode.lib.compat import BytesIO |
2684
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2567
diff
changeset
|
42 from rhodecode.lib.vcs.utils.hgcompat import localrepo |
2007
324ac367a4da
Added VCS into rhodecode core for faster and easier deployments of new versions
Marcin Kuzminski <marcin@python-works.com>
parents:
1894
diff
changeset
|
43 from rhodecode.lib.vcs.exceptions import VCSError |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
44 from rhodecode.lib.vcs.nodes import FileNode, SubModuleNode |
2684
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2567
diff
changeset
|
45 from rhodecode.lib.vcs.backends.base import EmptyChangeset |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
46 from rhodecode.lib.helpers import escape |
2684
2b6939a77052
Bumped mercurial version to 2.3
Marcin Kuzminski <marcin@python-works.com>
parents:
2567
diff
changeset
|
47 from rhodecode.lib.utils import make_ui |
2843
ab75def5c15d
fixes #567 diff non-unicode encoding missmatch
Marcin Kuzminski <marcin@python-works.com>
parents:
2801
diff
changeset
|
48 from rhodecode.lib.utils2 import safe_unicode |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
49 |
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:
2843
diff
changeset
|
50 log = logging.getLogger(__name__) |
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:
2843
diff
changeset
|
51 |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
52 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
53 def wrap_to_table(str_): |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
54 return '''<table class="code-difftable"> |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
55 <tr class="line no-comment"> |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
56 <td class="lineno new"></td> |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
57 <td class="code no-comment"><pre>%s</pre></td> |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
58 </tr> |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
59 </table>''' % str_ |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
60 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
61 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
62 def wrapped_diff(filenode_old, filenode_new, cut_off_limit=None, |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
63 ignore_whitespace=True, line_context=3, |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
64 enable_comments=False): |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
65 """ |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
66 returns a wrapped diff into a table, checks for cut_off_limit and presents |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
67 proper message |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
68 """ |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
69 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
70 if filenode_old is None: |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
71 filenode_old = FileNode(filenode_new.path, '', EmptyChangeset()) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
72 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
73 if filenode_old.is_binary or filenode_new.is_binary: |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
74 diff = wrap_to_table(_('binary file')) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
75 stats = (0, 0) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
76 size = 0 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
77 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
78 elif cut_off_limit != -1 and (cut_off_limit is None or |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
79 (filenode_old.size < cut_off_limit and filenode_new.size < cut_off_limit)): |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
80 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
81 f_gitdiff = get_gitdiff(filenode_old, filenode_new, |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
82 ignore_whitespace=ignore_whitespace, |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
83 context=line_context) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
84 diff_processor = DiffProcessor(f_gitdiff, format='gitdiff') |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
85 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
86 diff = diff_processor.as_html(enable_comments=enable_comments) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
87 stats = diff_processor.stat() |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
88 size = len(diff or '') |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
89 else: |
2340
93243e162068
typo fix ref #461
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
90 diff = wrap_to_table(_('Changeset was too big and was cut off, use ' |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
91 'diff menu to display this diff')) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
92 stats = (0, 0) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
93 size = 0 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
94 if not diff: |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
95 submodules = filter(lambda o: isinstance(o, SubModuleNode), |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
96 [filenode_new, filenode_old]) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
97 if submodules: |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
98 diff = wrap_to_table(escape('Submodule %r' % submodules[0])) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
99 else: |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
100 diff = wrap_to_table(_('No changes detected')) |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
101 |
2084
feb0fccdcf83
fixed vcs issue with last_changeset for filenodes
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
102 cs1 = filenode_old.changeset.raw_id |
feb0fccdcf83
fixed vcs issue with last_changeset for filenodes
Marcin Kuzminski <marcin@python-works.com>
parents:
2007
diff
changeset
|
103 cs2 = filenode_new.changeset.raw_id |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
104 |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
105 return size, cs1, cs2, diff, stats |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
106 |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
107 |
1768
5610fd9b6803
added line context control to diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1753
diff
changeset
|
108 def get_gitdiff(filenode_old, filenode_new, ignore_whitespace=True, context=3): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
109 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
110 Returns git style diff between given ``filenode_old`` and ``filenode_new``. |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
111 |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
112 :param ignore_whitespace: ignore whitespaces in diff |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
113 """ |
1894
0cbc3fb540b0
adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
1883
diff
changeset
|
114 # make sure we pass in default context |
0cbc3fb540b0
adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
1883
diff
changeset
|
115 context = context or 3 |
2233
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
116 submodules = filter(lambda o: isinstance(o, SubModuleNode), |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
117 [filenode_new, filenode_old]) |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
118 if submodules: |
07fce1930417
fixed issues with gitsubmodule diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2084
diff
changeset
|
119 return '' |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
120 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
121 for filenode in (filenode_old, filenode_new): |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
122 if not isinstance(filenode, FileNode): |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
123 raise VCSError("Given object should be FileNode object, not %s" |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 % filenode.__class__) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
125 |
1894
0cbc3fb540b0
adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
1883
diff
changeset
|
126 repo = filenode_new.changeset.repository |
0cbc3fb540b0
adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
1883
diff
changeset
|
127 old_raw_id = getattr(filenode_old.changeset, 'raw_id', repo.EMPTY_CHANGESET) |
0cbc3fb540b0
adapt codes to latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
1883
diff
changeset
|
128 new_raw_id = getattr(filenode_new.changeset, 'raw_id', repo.EMPTY_CHANGESET) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
129 |
1883
69d3c4450944
fix for latest vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
130 vcs_gitdiff = repo.get_diff(old_raw_id, new_raw_id, filenode_new.path, |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
131 ignore_whitespace, context) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
132 return vcs_gitdiff |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
134 NEW_FILENODE = 1 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
135 DEL_FILENODE = 2 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
136 MOD_FILENODE = 3 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
137 RENAMED_FILENODE = 4 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
138 CHMOD_FILENODE = 5 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
139 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
140 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
141 class DiffLimitExceeded(Exception): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
142 pass |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
143 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
144 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
145 class LimitedDiffContainer(object): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
146 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
147 def __init__(self, diff_limit, cur_diff_size, diff): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
148 self.diff = diff |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
149 self.diff_limit = diff_limit |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
150 self.cur_diff_size = cur_diff_size |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
151 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
152 def __iter__(self): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
153 for l in self.diff: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
154 yield l |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
155 |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
156 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
157 class DiffProcessor(object): |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
158 """ |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
159 Give it a unified or git diff and it returns a list of the files that were |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
160 mentioned in the diff together with a dict of meta information that |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
161 can be used to render it in a HTML template. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
162 """ |
3022
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
163 _chunk_re = re.compile(r'^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)') |
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
164 _newline_marker = re.compile(r'^\\ No newline at end of file') |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
165 _git_header_re = re.compile(r""" |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
166 #^diff[ ]--git |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
167 [ ]a/(?P<a_path>.+?)[ ]b/(?P<b_path>.+?)\n |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
168 (?:^similarity[ ]index[ ](?P<similarity_index>\d+)%\n |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
169 ^rename[ ]from[ ](?P<rename_from>\S+)\n |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
170 ^rename[ ]to[ ](?P<rename_to>\S+)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
171 (?:^old[ ]mode[ ](?P<old_mode>\d+)\n |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
172 ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
173 (?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
174 (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
175 (?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
176 \.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
177 (?:^---[ ](a/(?P<a_file>.+)|/dev/null)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
178 (?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
179 """, re.VERBOSE | re.MULTILINE) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
180 _hg_header_re = re.compile(r""" |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
181 #^diff[ ]--git |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
182 [ ]a/(?P<a_path>.+?)[ ]b/(?P<b_path>.+?)\n |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
183 (?:^similarity[ ]index[ ](?P<similarity_index>\d+)%(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
184 (?:^rename[ ]from[ ](?P<rename_from>\S+)\n |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
185 ^rename[ ]to[ ](?P<rename_to>\S+)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
186 (?:^old[ ]mode[ ](?P<old_mode>\d+)\n |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
187 ^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
188 (?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
189 (?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
190 (?:^index[ ](?P<a_blob_id>[0-9A-Fa-f]+) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
191 \.\.(?P<b_blob_id>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
192 (?:^---[ ](a/(?P<a_file>.+)|/dev/null)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
193 (?:^\+\+\+[ ](b/(?P<b_file>.+)|/dev/null)(?:\n|$))? |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
194 """, re.VERBOSE | re.MULTILINE) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
195 |
3085
7d0476e1f1dc
fixes issue #678 Incorrect diff markup when diff contains >, <, or & symbols
Marcin Kuzminski <marcin@python-works.com>
parents:
3047
diff
changeset
|
196 #used for inline highlighter word split |
7d0476e1f1dc
fixes issue #678 Incorrect diff markup when diff contains >, <, or & symbols
Marcin Kuzminski <marcin@python-works.com>
parents:
3047
diff
changeset
|
197 _token_re = re.compile(r'()(>|<|&|\W+?)') |
7d0476e1f1dc
fixes issue #678 Incorrect diff markup when diff contains >, <, or & symbols
Marcin Kuzminski <marcin@python-works.com>
parents:
3047
diff
changeset
|
198 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
199 def __init__(self, diff, vcs='hg', format='gitdiff', diff_limit=None): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
200 """ |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
201 :param diff: a text in diff format |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
202 :param vcs: type of version controll hg or git |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
203 :param format: format of diff passed, `udiff` or `gitdiff` |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
204 :param diff_limit: define the size of diff that is considered "big" |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
205 based on that parameter cut off will be triggered, set to None |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
206 to show full diff |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
207 """ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
208 if not isinstance(diff, basestring): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
209 raise Exception('Diff must be a basestring got %s instead' % type(diff)) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
210 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
211 self._diff = diff |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
212 self._format = format |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
213 self.adds = 0 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
214 self.removes = 0 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
215 # calculate diff size |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
216 self.diff_size = len(diff) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
217 self.diff_limit = diff_limit |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
218 self.cur_diff_size = 0 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
219 self.parsed = False |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
220 self.parsed_diff = [] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
221 self.vcs = vcs |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
222 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
223 if format == 'gitdiff': |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
224 self.differ = self._highlight_line_difflib |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
225 self._parser = self._parse_gitdiff |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
226 else: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
227 self.differ = self._highlight_line_udiff |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
228 self._parser = self._parse_udiff |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
229 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
230 def _copy_iterator(self): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
231 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
232 make a fresh copy of generator, we should not iterate thru |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
233 an original as it's needed for repeating operations on |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
234 this instance of DiffProcessor |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
235 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
236 self.__udiff, iterator_copy = tee(self.__udiff) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
237 return iterator_copy |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
238 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
239 def _escaper(self, string): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
240 """ |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
241 Escaper for diff escapes special chars and checks the diff limit |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
242 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
243 :param string: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
244 :type string: |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
245 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
246 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
247 self.cur_diff_size += len(string) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
248 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
249 # escaper get's iterated on each .next() call and it checks if each |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
250 # parsed line doesn't exceed the diff limit |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
251 if self.diff_limit is not None and self.cur_diff_size > self.diff_limit: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
252 raise DiffLimitExceeded('Diff Limit Exceeded') |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
253 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
254 return safe_unicode(string).replace('&', '&')\ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
255 .replace('<', '<')\ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
256 .replace('>', '>') |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
257 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
258 def _line_counter(self, l): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
259 """ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
260 Checks each line and bumps total adds/removes for this diff |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
261 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
262 :param l: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
263 """ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
264 if l.startswith('+') and not l.startswith('+++'): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
265 self.adds += 1 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
266 elif l.startswith('-') and not l.startswith('---'): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
267 self.removes += 1 |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
268 return safe_unicode(l) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
269 |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
270 def _highlight_line_difflib(self, line, next_): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
271 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
272 Highlight inline changes in both lines. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
273 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
274 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
275 if line['action'] == 'del': |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
276 old, new = line, next_ |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
277 else: |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
278 old, new = next_, line |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
279 |
3085
7d0476e1f1dc
fixes issue #678 Incorrect diff markup when diff contains >, <, or & symbols
Marcin Kuzminski <marcin@python-works.com>
parents:
3047
diff
changeset
|
280 oldwords = self._token_re.split(old['line']) |
7d0476e1f1dc
fixes issue #678 Incorrect diff markup when diff contains >, <, or & symbols
Marcin Kuzminski <marcin@python-works.com>
parents:
3047
diff
changeset
|
281 newwords = self._token_re.split(new['line']) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
282 sequence = difflib.SequenceMatcher(None, oldwords, newwords) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
283 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
284 oldfragments, newfragments = [], [] |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
285 for tag, i1, i2, j1, j2 in sequence.get_opcodes(): |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
286 oldfrag = ''.join(oldwords[i1:i2]) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
287 newfrag = ''.join(newwords[j1:j2]) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
288 if tag != 'equal': |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
289 if oldfrag: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
290 oldfrag = '<del>%s</del>' % oldfrag |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
291 if newfrag: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
292 newfrag = '<ins>%s</ins>' % newfrag |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
293 oldfragments.append(oldfrag) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
294 newfragments.append(newfrag) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
295 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
296 old['line'] = "".join(oldfragments) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
297 new['line'] = "".join(newfragments) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
298 |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
299 def _highlight_line_udiff(self, line, next_): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
300 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
301 Highlight inline changes in both lines. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
302 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
303 start = 0 |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
304 limit = min(len(line['line']), len(next_['line'])) |
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
305 while start < limit and line['line'][start] == next_['line'][start]: |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
306 start += 1 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
307 end = -1 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
308 limit -= start |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
309 while -end <= limit and line['line'][end] == next_['line'][end]: |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
310 end -= 1 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
311 end += 1 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
312 if start or end: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
313 def do(l): |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
314 last = end + len(l['line']) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
315 if l['action'] == 'add': |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
316 tag = 'ins' |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
317 else: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
318 tag = 'del' |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
319 l['line'] = '%s<%s>%s</%s>%s' % ( |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
320 l['line'][:start], |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
321 tag, |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
322 l['line'][start:last], |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
323 tag, |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
324 l['line'][last:] |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
325 ) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
326 do(line) |
1781
089c81cf04d9
fixes #326 some html special chars where not escaped in diffs + code garden in helpers
Marcin Kuzminski <marcin@python-works.com>
parents:
1772
diff
changeset
|
327 do(next_) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
328 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
329 def _get_header(self, diff_chunk): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
330 """ |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
331 parses the diff header, and returns parts, and leftover diff |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
332 parts consists of 14 elements:: |
2967
e46d0a90556e
fixes #612 Double quotes to Single quotes result in 4; to 9; in a visual Diff. Markupsafe.escape method usage
Marcin Kuzminski <marcin@python-works.com>
parents:
2892
diff
changeset
|
333 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
334 a_path, b_path, similarity_index, rename_from, rename_to, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
335 old_mode, new_mode, new_file_mode, deleted_file_mode, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
336 a_blob_id, b_blob_id, b_mode, a_file, b_file |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
337 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
338 :param diff_chunk: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
339 :type diff_chunk: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
340 """ |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
341 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
342 if self.vcs == 'git': |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
343 match = self._git_header_re.match(diff_chunk) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
344 diff = diff_chunk[match.end():] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
345 return match.groupdict(), imap(self._escaper, diff.splitlines(1)) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
346 elif self.vcs == 'hg': |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
347 match = self._hg_header_re.match(diff_chunk) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
348 diff = diff_chunk[match.end():] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
349 return match.groupdict(), imap(self._escaper, diff.splitlines(1)) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
350 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
351 raise Exception('VCS type %s is not supported' % self.vcs) |
2967
e46d0a90556e
fixes #612 Double quotes to Single quotes result in 4; to 9; in a visual Diff. Markupsafe.escape method usage
Marcin Kuzminski <marcin@python-works.com>
parents:
2892
diff
changeset
|
352 |
3022
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
353 def _clean_line(self, line, command): |
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
354 if command in ['+', '-', ' ']: |
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
355 #only modify the line if it's actually a diff thing |
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
356 line = line[1:] |
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
357 return line |
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
358 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
359 def _parse_gitdiff(self, inline_diff=True): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
360 _files = [] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
361 diff_container = lambda arg: arg |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
362 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
363 ##split the diff in chunks of separate --git a/file b/file chunks |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
364 for raw_diff in ('\n' + self._diff).split('\ndiff --git')[1:]: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
365 binary = False |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
366 binary_msg = 'unknown binary' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
367 head, diff = self._get_header(raw_diff) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
368 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
369 if not head['a_file'] and head['b_file']: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
370 op = 'A' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
371 elif head['a_file'] and head['b_file']: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
372 op = 'M' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
373 elif head['a_file'] and not head['b_file']: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
374 op = 'D' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
375 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
376 #probably we're dealing with a binary file 1 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
377 binary = True |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
378 if head['deleted_file_mode']: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
379 op = 'D' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
380 stats = ['b', DEL_FILENODE] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
381 binary_msg = 'deleted binary file' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
382 elif head['new_file_mode']: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
383 op = 'A' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
384 stats = ['b', NEW_FILENODE] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
385 binary_msg = 'new binary file %s' % head['new_file_mode'] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
386 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
387 if head['new_mode'] and head['old_mode']: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
388 stats = ['b', CHMOD_FILENODE] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
389 op = 'M' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
390 binary_msg = ('modified binary file chmod %s => %s' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
391 % (head['old_mode'], head['new_mode'])) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
392 elif (head['rename_from'] and head['rename_to'] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
393 and head['rename_from'] != head['rename_to']): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
394 stats = ['b', RENAMED_FILENODE] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
395 op = 'M' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
396 binary_msg = ('file renamed from %s to %s' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
397 % (head['rename_from'], head['rename_to'])) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
398 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
399 stats = ['b', MOD_FILENODE] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
400 op = 'M' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
401 binary_msg = 'modified binary file' |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
402 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
403 if not binary: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
404 try: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
405 chunks, stats = self._parse_lines(diff) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
406 except DiffLimitExceeded: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
407 diff_container = lambda _diff: LimitedDiffContainer( |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
408 self.diff_limit, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
409 self.cur_diff_size, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
410 _diff) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
411 break |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
412 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
413 chunks = [] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
414 chunks.append([{ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
415 'old_lineno': '', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
416 'new_lineno': '', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
417 'action': 'binary', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
418 'line': binary_msg, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
419 }]) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
420 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
421 _files.append({ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
422 'filename': head['b_path'], |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
423 'old_revision': head['a_blob_id'], |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
424 'new_revision': head['b_blob_id'], |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
425 'chunks': chunks, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
426 'operation': op, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
427 'stats': stats, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
428 }) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
429 |
2385
a455b2c79c85
Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents:
2360
diff
changeset
|
430 sorter = lambda info: {'A': 0, 'M': 1, 'D': 2}.get(info['operation']) |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
431 |
2385
a455b2c79c85
Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents:
2360
diff
changeset
|
432 if inline_diff is False: |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
433 return diff_container(sorted(_files, key=sorter)) |
2385
a455b2c79c85
Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents:
2360
diff
changeset
|
434 |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
435 # highlight inline changes |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
436 for diff_data in _files: |
2385
a455b2c79c85
Improved RSS/ATOM feeds
Marcin Kuzminski <marcin@python-works.com>
parents:
2360
diff
changeset
|
437 for chunk in diff_data['chunks']: |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
438 lineiter = iter(chunk) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
439 try: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
440 while 1: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
441 line = lineiter.next() |
2566
d097d4bb0437
fix strikethrough issues on `No new line at end of file`
Marcin Kuzminski <marcin@python-works.com>
parents:
2552
diff
changeset
|
442 if line['action'] not in ['unmod', 'context']: |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
443 nextline = lineiter.next() |
2360
c15c3430df74
fixed issue with git's `no new line..` messages inside diff block. It might sometimes happen that showed html diff was short one line because of this
Marcin Kuzminski <marcin@python-works.com>
parents:
2359
diff
changeset
|
444 if nextline['action'] in ['unmod', 'context'] or \ |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
445 nextline['action'] == line['action']: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
446 continue |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
447 self.differ(line, nextline) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
448 except StopIteration: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
449 pass |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
450 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
451 return diff_container(sorted(_files, key=sorter)) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
452 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
453 def _parse_udiff(self, inline_diff=True): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
454 raise NotImplementedError() |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
455 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
456 def _parse_lines(self, diff): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
457 """ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
458 Parse the diff an return data for the template. |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
459 """ |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
460 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
461 lineiter = iter(diff) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
462 stats = [0, 0] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
463 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
464 try: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
465 chunks = [] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
466 line = lineiter.next() |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
467 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
468 while line: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
469 lines = [] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
470 chunks.append(lines) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
471 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
472 match = self._chunk_re.match(line) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
473 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
474 if not match: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
475 break |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
476 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
477 gr = match.groups() |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
478 (old_line, old_end, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
479 new_line, new_end) = [int(x or 1) for x in gr[:-1]] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
480 old_line -= 1 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
481 new_line -= 1 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
482 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
483 context = len(gr) == 5 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
484 old_end += old_line |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
485 new_end += new_line |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
486 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
487 if context: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
488 # skip context only if it's first line |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
489 if int(gr[0]) > 1: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
490 lines.append({ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
491 'old_lineno': '...', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
492 'new_lineno': '...', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
493 'action': 'context', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
494 'line': line, |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
495 }) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
496 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
497 line = lineiter.next() |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
498 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
499 while old_line < old_end or new_line < new_end: |
3022
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
500 command = ' ' |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
501 if line: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
502 command = line[0] |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
503 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
504 affects_old = affects_new = False |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
505 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
506 # ignore those if we don't expect them |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
507 if command in '#@': |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
508 continue |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
509 elif command == '+': |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
510 affects_new = True |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
511 action = 'add' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
512 stats[0] += 1 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
513 elif command == '-': |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
514 affects_old = True |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
515 action = 'del' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
516 stats[1] += 1 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
517 else: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
518 affects_old = affects_new = True |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
519 action = 'unmod' |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
520 |
3022
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
521 if not self._newline_marker.match(line): |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
522 old_line += affects_old |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
523 new_line += affects_new |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
524 lines.append({ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
525 'old_lineno': affects_old and old_line or '', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
526 'new_lineno': affects_new and new_line or '', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
527 'action': action, |
3022
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
528 'line': self._clean_line(line, command) |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
529 }) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
530 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
531 line = lineiter.next() |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
532 |
3022
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
533 if self._newline_marker.match(line): |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
534 # we need to append to lines, since this is not |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
535 # counted in the line specs of diff |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
536 lines.append({ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
537 'old_lineno': '...', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
538 'new_lineno': '...', |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
539 'action': 'context', |
3022
0ed42ca7ff9e
Fixed issue with inproper handling of diff parsing that could lead to infinit loops.
Marcin Kuzminski <marcin@python-works.com>
parents:
3015
diff
changeset
|
540 'line': self._clean_line(line, command) |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
541 }) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
542 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
543 except StopIteration: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
544 pass |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
545 return chunks, stats |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
546 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
547 def _safe_id(self, idstring): |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
548 """Make a string safe for including in an id attribute. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
549 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
550 The HTML spec says that id attributes 'must begin with |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
551 a letter ([A-Za-z]) and may be followed by any number |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
552 of letters, digits ([0-9]), hyphens ("-"), underscores |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
553 ("_"), colons (":"), and periods (".")'. These regexps |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
554 are slightly over-zealous, in that they remove colons |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
555 and periods unnecessarily. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
556 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
557 Whitespace is transformed into underscores, and then |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
558 anything which is not a hyphen or a character that |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
559 matches \w (alphanumerics and underscore) is removed. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
560 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
561 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
562 # Transform all whitespace to underscore |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
563 idstring = re.sub(r'\s', "_", '%s' % idstring) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
564 # Remove everything that is not a hyphen or a member of \w |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
565 idstring = re.sub(r'(?!-)\W', "", idstring).lower() |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
566 return idstring |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
567 |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
568 def prepare(self, inline_diff=True): |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
569 """ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
570 Prepare the passed udiff for HTML rendering. It'l return a list |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
571 of dicts with diff information |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
572 """ |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
573 parsed = self._parser(inline_diff=inline_diff) |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
574 self.parsed = True |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
575 self.parsed_diff = parsed |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
576 return parsed |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
577 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
578 def as_raw(self, diff_lines=None): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
579 """ |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
580 Returns raw string diff |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
581 """ |
2996
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
582 return self._diff |
ebe3e388bbb3
new patch function, and urls schema.
Marcin Kuzminski <marcin@python-works.com>
parents:
2995
diff
changeset
|
583 #return u''.join(imap(self._line_counter, self._diff.splitlines(1))) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
584 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
585 def as_html(self, table_class='code-difftable', line_class='line', |
3144
a64fb6d9ce03
diff view: don't mix css classes for new and old line numbers
Mads Kiilerich <madski@unity3d.com>
parents:
3085
diff
changeset
|
586 old_lineno_class='lineno old', new_lineno_class='lineno new', |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
587 code_class='code', enable_comments=False, parsed_lines=None): |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
588 """ |
2349
0edbffa9e2e2
fixed bug with inline changes highlighter.
Marcin Kuzminski <marcin@python-works.com>
parents:
2347
diff
changeset
|
589 Return given diff as html table with customized css classes |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
590 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
591 def _link_to_if(condition, label, url): |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
592 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
593 Generates a link if condition is meet or just the label if not. |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
594 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
595 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
596 if condition: |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
597 return '''<a href="%(url)s">%(label)s</a>''' % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
598 'url': url, |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
599 'label': label |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
600 } |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
601 else: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
602 return label |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
603 if not self.parsed: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
604 self.prepare() |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
605 |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
606 diff_lines = self.parsed_diff |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
607 if parsed_lines: |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
608 diff_lines = parsed_lines |
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
609 |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
610 _html_empty = True |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
611 _html = [] |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
612 _html.append('''<table class="%(table_class)s">\n''' % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
613 'table_class': table_class |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
614 }) |
2995
32471bd1f4ee
Implemented generation of changesets based
Marcin Kuzminski <marcin@python-works.com>
parents:
2967
diff
changeset
|
615 |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
616 for diff in diff_lines: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
617 for line in diff['chunks']: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
618 _html_empty = False |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
619 for change in line: |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
620 _html.append('''<tr class="%(lc)s %(action)s">\n''' % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
621 'lc': line_class, |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
622 'action': change['action'] |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
623 }) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
624 anchor_old_id = '' |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
625 anchor_new_id = '' |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
626 anchor_old = "%(filename)s_o%(oldline_no)s" % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
627 'filename': self._safe_id(diff['filename']), |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
628 'oldline_no': change['old_lineno'] |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
629 } |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
630 anchor_new = "%(filename)s_n%(oldline_no)s" % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
631 'filename': self._safe_id(diff['filename']), |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
632 'oldline_no': change['new_lineno'] |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
633 } |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
634 cond_old = (change['old_lineno'] != '...' and |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
635 change['old_lineno']) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
636 cond_new = (change['new_lineno'] != '...' and |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
637 change['new_lineno']) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
638 if cond_old: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
639 anchor_old_id = 'id="%s"' % anchor_old |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
640 if cond_new: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
641 anchor_new_id = 'id="%s"' % anchor_new |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
642 ########################################################### |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
643 # OLD LINE NUMBER |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
644 ########################################################### |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
645 _html.append('''\t<td %(a_id)s class="%(olc)s">''' % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
646 'a_id': anchor_old_id, |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
647 'olc': old_lineno_class |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
648 }) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
649 |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
650 _html.append('''%(link)s''' % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
651 'link': _link_to_if(True, change['old_lineno'], |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
652 '#%s' % anchor_old) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
653 }) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
654 _html.append('''</td>\n''') |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
655 ########################################################### |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
656 # NEW LINE NUMBER |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
657 ########################################################### |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
658 |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
659 _html.append('''\t<td %(a_id)s class="%(nlc)s">''' % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
660 'a_id': anchor_new_id, |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
661 'nlc': new_lineno_class |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
662 }) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
663 |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
664 _html.append('''%(link)s''' % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
665 'link': _link_to_if(True, change['new_lineno'], |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
666 '#%s' % anchor_new) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
667 }) |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
668 _html.append('''</td>\n''') |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
669 ########################################################### |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
670 # CODE |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
671 ########################################################### |
1787
d4a7b6c82efe
code garden for changeset ranges and comments
Marcin Kuzminski <marcin@python-works.com>
parents:
1781
diff
changeset
|
672 comments = '' if enable_comments else 'no-comment' |
1789
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
673 _html.append('''\t<td class="%(cc)s %(inc)s">''' % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
674 'cc': code_class, |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
675 'inc': comments |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
676 }) |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
677 _html.append('''\n\t\t<pre>%(code)s</pre>\n''' % { |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
678 'code': change['line'] |
17caf4efe15c
implements #308 rewrote diffs to enable displaying full diff on each file
Marcin Kuzminski <marcin@python-works.com>
parents:
1787
diff
changeset
|
679 }) |
2967
e46d0a90556e
fixes #612 Double quotes to Single quotes result in 4; to 9; in a visual Diff. Markupsafe.escape method usage
Marcin Kuzminski <marcin@python-works.com>
parents:
2892
diff
changeset
|
680 |
1753
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
681 _html.append('''\t</td>''') |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
682 _html.append('''\n</tr>\n''') |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
683 _html.append('''</table>''') |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
684 if _html_empty: |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
685 return None |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
686 return ''.join(_html) |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
687 |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
688 def stat(self): |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
689 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
690 Returns tuple of added, and removed lines for this instance |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
691 """ |
1d1ccb873d00
moved soon-to-be-deleted code from vcs to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
692 return self.adds, self.removes |
2337
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
693 |
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
694 |
2362
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
695 class InMemoryBundleRepo(bundlerepository): |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
696 def __init__(self, ui, path, bundlestream): |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
697 self._tempparent = None |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
698 localrepo.localrepository.__init__(self, ui, path) |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
699 self.ui.setconfig('phases', 'publish', False) |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
700 |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
701 self.bundle = bundlestream |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
702 |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
703 # dict with the mapping 'filename' -> position in the bundle |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
704 self.bundlefilespos = {} |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
705 |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
706 |
3192
b9105d31e582
refactoring: drop unused 'discovery data' in pull request and compare diffs
Mads Kiilerich <madski@unity3d.com>
parents:
3144
diff
changeset
|
707 def differ(org_repo, org_ref, other_repo, other_ref, |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
708 remote_compare=False, context=3, ignore_whitespace=False): |
2337
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
709 """ |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
710 General differ between branches, bookmarks, revisions of two remote or |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
711 local but related repositories |
2337
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
712 |
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
713 :param org_repo: |
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
714 :param org_ref: |
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
715 :param other_repo: |
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
716 :type other_repo: |
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
717 :type other_ref: |
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
718 """ |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
719 |
3010
bf96fd1920c1
Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents:
2996
diff
changeset
|
720 org_repo_scm = org_repo.scm_instance |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
721 other_repo_scm = other_repo.scm_instance |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
722 |
3010
bf96fd1920c1
Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents:
2996
diff
changeset
|
723 org_repo = org_repo_scm._repo |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
724 other_repo = other_repo_scm._repo |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
725 |
2337
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
726 org_ref = org_ref[1] |
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
727 other_ref = other_ref[1] |
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
728 |
3047
3b3de7c68ae1
fixed issue with no-cached dulwich repos
Marcin Kuzminski <marcin@python-works.com>
parents:
3029
diff
changeset
|
729 if org_repo_scm == other_repo_scm: |
3010
bf96fd1920c1
Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents:
2996
diff
changeset
|
730 log.debug('running diff between %s@%s and %s@%s' |
3023
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3022
diff
changeset
|
731 % (org_repo.path, org_ref, other_repo.path, other_ref)) |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
732 _diff = org_repo_scm.get_diff(rev1=org_ref, rev2=other_ref, |
3010
bf96fd1920c1
Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents:
2996
diff
changeset
|
733 ignore_whitespace=ignore_whitespace, context=context) |
bf96fd1920c1
Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents:
2996
diff
changeset
|
734 return _diff |
bf96fd1920c1
Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents:
2996
diff
changeset
|
735 |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
736 elif remote_compare: |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
737 opts = diffopts(git=True, ignorews=ignore_whitespace, context=context) |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
738 org_repo_peer = localrepo.locallegacypeer(org_repo.local()) |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
739 # create a bundle (uncompressed if other repo is not local) |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
740 if org_repo_peer.capable('getbundle'): |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
741 # disable repo hooks here since it's just bundle ! |
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
742 # patch and reset hooks section of UI config to not run any |
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
743 # hooks on fetching archives with subrepos |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
744 for k, _ in org_repo.ui.configitems('hooks'): |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
745 org_repo.ui.setconfig('hooks', k, None) |
3023
c2a206162062
Basic implementation of cherry picking changesets
Marcin Kuzminski <marcin@python-works.com>
parents:
3022
diff
changeset
|
746 unbundle = org_repo.getbundle('incoming', common=None, |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
747 heads=None) |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
748 |
2552
e8650fbc4d4e
Moved BytesIO into compat because of py25 compatibility issue
Marcin Kuzminski <marcin@python-works.com>
parents:
2478
diff
changeset
|
749 buf = BytesIO() |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
750 while True: |
2364 | 751 chunk = unbundle._stream.read(1024 * 4) |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
752 if not chunk: |
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
753 break |
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
754 buf.write(chunk) |
2337
f8c953c6b040
Created base for diffing two repositories inside rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
2233
diff
changeset
|
755 |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
756 buf.seek(0) |
2364 | 757 # replace chunked _stream with data that can do tell() and seek() |
2355
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
758 unbundle._stream = buf |
29a8096820dc
added basic comparision of two repositories using bundles
Marcin Kuzminski <marcin@python-works.com>
parents:
2349
diff
changeset
|
759 |
2362
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
760 ui = make_ui('db') |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
761 bundlerepo = InMemoryBundleRepo(ui, path=org_repo.root, |
3c4afb8894bd
Improved cross repos diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
2361
diff
changeset
|
762 bundlestream=unbundle) |
2431
60dfc369df1d
Improved cross-repo diff using bundlerepo
Marcin Kuzminski <marcin@python-works.com>
parents:
2391
diff
changeset
|
763 |
3015
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
764 return ''.join(patch.diff(bundlerepo, |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
765 node1=other_repo[other_ref].node(), |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
766 node2=org_repo[org_ref].node(), |
16af24982e30
Multiple changes for compare system
Marcin Kuzminski <marcin@python-works.com>
parents:
3010
diff
changeset
|
767 opts=opts)) |
3010
bf96fd1920c1
Enabled compare engine for tags
Marcin Kuzminski <marcin@python-works.com>
parents:
2996
diff
changeset
|
768 |
3029
685ebc84c2e9
White space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
3023
diff
changeset
|
769 return '' |