Mercurial > kallithea
comparison rhodecode/controllers/changeset.py @ 2165:dc2584ba5fbc
merged beta into default branch
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 28 Mar 2012 19:54:16 +0200 |
parents | ecd59c28f432 e8c016815ab9 |
children | a437a986d399 |
comparison
equal
deleted
inserted
replaced
2097:8fd6650bb436 | 2165:dc2584ba5fbc |
---|---|
49 from rhodecode.lib.diffs import wrapped_diff | 49 from rhodecode.lib.diffs import wrapped_diff |
50 | 50 |
51 log = logging.getLogger(__name__) | 51 log = logging.getLogger(__name__) |
52 | 52 |
53 | 53 |
54 def anchor_url(revision, path): | 54 def _update_with_GET(params, GET): |
55 for k in ['diff1', 'diff2', 'diff']: | |
56 params[k] += GET.getall(k) | |
57 | |
58 | |
59 def anchor_url(revision, path, GET): | |
55 fid = h.FID(revision, path) | 60 fid = h.FID(revision, path) |
56 return h.url.current(anchor=fid, **dict(request.GET)) | 61 return h.url.current(anchor=fid, **dict(GET)) |
57 | 62 |
58 | 63 |
59 def get_ignore_ws(fid, GET): | 64 def get_ignore_ws(fid, GET): |
60 ig_ws_global = request.GET.get('ignorews') | 65 ig_ws_global = GET.get('ignorews') |
61 ig_ws = filter(lambda k: k.startswith('WS'), GET.getall(fid)) | 66 ig_ws = filter(lambda k: k.startswith('WS'), GET.getall(fid)) |
62 if ig_ws: | 67 if ig_ws: |
63 try: | 68 try: |
64 return int(ig_ws[0].split(':')[-1]) | 69 return int(ig_ws[0].split(':')[-1]) |
65 except: | 70 except: |
66 pass | 71 pass |
67 return ig_ws_global | 72 return ig_ws_global |
68 | 73 |
69 | 74 |
70 def _ignorews_url(fileid=None): | 75 def _ignorews_url(GET, fileid=None): |
71 | 76 fileid = str(fileid) if fileid else None |
72 params = defaultdict(list) | 77 params = defaultdict(list) |
78 _update_with_GET(params, GET) | |
73 lbl = _('show white space') | 79 lbl = _('show white space') |
74 ig_ws = get_ignore_ws(fileid, request.GET) | 80 ig_ws = get_ignore_ws(fileid, GET) |
75 ln_ctx = get_line_ctx(fileid, request.GET) | 81 ln_ctx = get_line_ctx(fileid, GET) |
76 # global option | 82 # global option |
77 if fileid is None: | 83 if fileid is None: |
78 if ig_ws is None: | 84 if ig_ws is None: |
79 params['ignorews'] += [1] | 85 params['ignorews'] += [1] |
80 lbl = _('ignore white space') | 86 lbl = _('ignore white space') |
96 img = h.image(h.url('/images/icons/text_strikethrough.png'), lbl, class_='icon') | 102 img = h.image(h.url('/images/icons/text_strikethrough.png'), lbl, class_='icon') |
97 return h.link_to(img, h.url.current(**params), title=lbl, class_='tooltip') | 103 return h.link_to(img, h.url.current(**params), title=lbl, class_='tooltip') |
98 | 104 |
99 | 105 |
100 def get_line_ctx(fid, GET): | 106 def get_line_ctx(fid, GET): |
101 ln_ctx_global = request.GET.get('context') | 107 ln_ctx_global = GET.get('context') |
102 ln_ctx = filter(lambda k: k.startswith('C'), GET.getall(fid)) | 108 ln_ctx = filter(lambda k: k.startswith('C'), GET.getall(fid)) |
103 | 109 |
104 if ln_ctx: | 110 if ln_ctx: |
105 retval = ln_ctx[0].split(':')[-1] | 111 retval = ln_ctx[0].split(':')[-1] |
106 else: | 112 else: |
110 return int(retval) | 116 return int(retval) |
111 except: | 117 except: |
112 return | 118 return |
113 | 119 |
114 | 120 |
115 def _context_url(fileid=None): | 121 def _context_url(GET, fileid=None): |
116 """ | 122 """ |
117 Generates url for context lines | 123 Generates url for context lines |
118 | 124 |
119 :param fileid: | 125 :param fileid: |
120 """ | 126 """ |
121 ig_ws = get_ignore_ws(fileid, request.GET) | 127 |
122 ln_ctx = (get_line_ctx(fileid, request.GET) or 3) * 2 | 128 fileid = str(fileid) if fileid else None |
129 ig_ws = get_ignore_ws(fileid, GET) | |
130 ln_ctx = (get_line_ctx(fileid, GET) or 3) * 2 | |
123 | 131 |
124 params = defaultdict(list) | 132 params = defaultdict(list) |
133 _update_with_GET(params, GET) | |
125 | 134 |
126 # global option | 135 # global option |
127 if fileid is None: | 136 if fileid is None: |
128 if ln_ctx > 0: | 137 if ln_ctx > 0: |
129 params['context'] += [ln_ctx] | 138 params['context'] += [ln_ctx] |
160 def index(self, revision): | 169 def index(self, revision): |
161 | 170 |
162 c.anchor_url = anchor_url | 171 c.anchor_url = anchor_url |
163 c.ignorews_url = _ignorews_url | 172 c.ignorews_url = _ignorews_url |
164 c.context_url = _context_url | 173 c.context_url = _context_url |
165 | 174 limit_off = request.GET.get('fulldiff') |
166 #get ranges of revisions if preset | 175 #get ranges of revisions if preset |
167 rev_range = revision.split('...')[:2] | 176 rev_range = revision.split('...')[:2] |
168 enable_comments = True | 177 enable_comments = True |
169 try: | 178 try: |
170 if len(rev_range) == 2: | 179 if len(rev_range) == 2: |
218 fid = h.FID(revision, node.path) | 227 fid = h.FID(revision, node.path) |
219 line_context_lcl = get_line_ctx(fid, request.GET) | 228 line_context_lcl = get_line_ctx(fid, request.GET) |
220 ign_whitespace_lcl = get_ignore_ws(fid, request.GET) | 229 ign_whitespace_lcl = get_ignore_ws(fid, request.GET) |
221 lim = self.cut_off_limit | 230 lim = self.cut_off_limit |
222 if cumulative_diff > self.cut_off_limit: | 231 if cumulative_diff > self.cut_off_limit: |
223 lim = -1 | 232 lim = -1 if limit_off is None else None |
224 size, cs1, cs2, diff, st = wrapped_diff( | 233 size, cs1, cs2, diff, st = wrapped_diff( |
225 filenode_old=None, | 234 filenode_old=None, |
226 filenode_new=node, | 235 filenode_new=node, |
227 cut_off_limit=lim, | 236 cut_off_limit=lim, |
228 ignore_whitespace=ign_whitespace_lcl, | 237 ignore_whitespace=ign_whitespace_lcl, |
249 fid = h.FID(revision, node.path) | 258 fid = h.FID(revision, node.path) |
250 line_context_lcl = get_line_ctx(fid, request.GET) | 259 line_context_lcl = get_line_ctx(fid, request.GET) |
251 ign_whitespace_lcl = get_ignore_ws(fid, request.GET) | 260 ign_whitespace_lcl = get_ignore_ws(fid, request.GET) |
252 lim = self.cut_off_limit | 261 lim = self.cut_off_limit |
253 if cumulative_diff > self.cut_off_limit: | 262 if cumulative_diff > self.cut_off_limit: |
254 lim = -1 | 263 lim = -1 if limit_off is None else None |
255 size, cs1, cs2, diff, st = wrapped_diff( | 264 size, cs1, cs2, diff, st = wrapped_diff( |
256 filenode_old=filenode_old, | 265 filenode_old=filenode_old, |
257 filenode_new=node, | 266 filenode_new=node, |
258 cut_off_limit=lim, | 267 cut_off_limit=lim, |
259 ignore_whitespace=ign_whitespace_lcl, | 268 ignore_whitespace=ign_whitespace_lcl, |