Mercurial > kallithea
annotate rhodecode/controllers/files.py @ 1664:65386911df2a beta
fixes issue with mercurial 2.0 and archival of subrepos.
- Disable hooks when doing archive commandsvovercome mercurial problem of hook propagation to subrepos
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 11 Nov 2011 18:16:14 +0200 |
parents | 6a44904838e9 |
children | 61eda8bf70d0 |
rev | line source |
---|---|
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
1 # -*- coding: utf-8 -*- |
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
2 """ |
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
3 rhodecode.controllers.files |
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
275
diff
changeset
|
5 |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
6 Files controller for RhodeCode |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1200
diff
changeset
|
7 |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
8 :created_on: Apr 21, 2010 |
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
9 :author: marcink |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1200
diff
changeset
|
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
12 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
16 # (at your option) any later version. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1200
diff
changeset
|
17 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
21 # GNU General Public License for more details. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1200
diff
changeset
|
22 # |
252
3782a6d698af
licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
245
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1134
1dc5d169e85a
fixed issue with vcs stream
Marcin Kuzminski <marcin@python-works.com>
parents:
1132
diff
changeset
|
25 |
1200
3ecaa17d9dea
added os.sep for files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1190
diff
changeset
|
26 import os |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
27 import logging |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
28 import traceback |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
29 |
1452
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
30 from os.path import join as jn |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
31 |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
275
diff
changeset
|
32 from pylons import request, response, session, tmpl_context as c, url |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
33 from pylons.i18n.translation import _ |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
275
diff
changeset
|
34 from pylons.controllers.util import redirect |
1452
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
35 from pylons.decorators import jsonify |
812
30ad41c76fae
fixes #79 cut off limit was added into .ini config files
Marcin Kuzminski <marcin@python-works.com>
parents:
774
diff
changeset
|
36 |
1480
daa29da0f783
fixes for vcs settings module
Marcin Kuzminski <marcin@python-works.com>
parents:
1452
diff
changeset
|
37 from vcs.conf import settings |
1134
1dc5d169e85a
fixed issue with vcs stream
Marcin Kuzminski <marcin@python-works.com>
parents:
1132
diff
changeset
|
38 from vcs.exceptions import RepositoryError, ChangesetDoesNotExistError, \ |
1485
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
39 EmptyRepositoryError, ImproperArchiveTypeError, VCSError, NodeAlreadyExistsError |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
40 from vcs.nodes import FileNode, NodeKind |
318
fdf9f6ee5217
Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
275
diff
changeset
|
41 from vcs.utils import diffs as differ |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
42 |
1401
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1313
diff
changeset
|
43 from rhodecode.lib import convert_line_endings, detect_mode, safe_str |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
44 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
45 from rhodecode.lib.base import BaseRepoController, render |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
46 from rhodecode.lib.utils import EmptyChangeset |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
47 import rhodecode.lib.helpers as h |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
48 from rhodecode.model.repo import RepoModel |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
49 |
93
aec4c0071cb3
added empty controllers for branches tags files graph, routing and test for them
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 log = logging.getLogger(__name__) |
aec4c0071cb3
added empty controllers for branches tags files graph, routing and test for them
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 |
1134
1dc5d169e85a
fixed issue with vcs stream
Marcin Kuzminski <marcin@python-works.com>
parents:
1132
diff
changeset
|
52 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
53 class FilesController(BaseRepoController): |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
54 |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
160
diff
changeset
|
55 @LoginRequired() |
99
5b57295601b6
Updated basic files browser with, pygments
Marcin Kuzminski <marcin@python-works.com>
parents:
93
diff
changeset
|
56 def __before__(self): |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
160
diff
changeset
|
57 super(FilesController, self).__before__() |
813
e8b5be26fb78
fixed small issue made on latest patches
Marcin Kuzminski <marcin@python-works.com>
parents:
812
diff
changeset
|
58 c.cut_off_limit = self.cut_off_limit |
93
aec4c0071cb3
added empty controllers for branches tags files graph, routing and test for them
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
60 def __get_cs_or_redirect(self, rev, repo_name, redirect_after=True): |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
61 """ |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
62 Safe way to get changeset if error occur it redirects to tip with |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
63 proper message |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1200
diff
changeset
|
64 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
65 :param rev: revision to fetch |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
66 :param repo_name: repo name to redirect after |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
67 """ |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
68 |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
69 try: |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
70 return c.rhodecode_repo.get_changeset(rev) |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
71 except EmptyRepositoryError, e: |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
72 if not redirect_after: |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
73 return None |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
74 url_ = url('files_add_home', |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
75 repo_name=c.repo_name, |
1485
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
76 revision=0, f_path='') |
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
77 add_new = '<a href="%s">[%s]</a>' % (url_, _('add new')) |
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
78 h.flash(h.literal(_('There are no files yet %s' % add_new)), |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
79 category='warning') |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
80 redirect(h.url('summary_home', repo_name=repo_name)) |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
81 |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
82 except RepositoryError, e: |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
83 h.flash(str(e), category='warning') |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
84 redirect(h.url('files_home', repo_name=repo_name, revision='tip')) |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
85 |
1189
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
86 def __get_filenode_or_redirect(self, repo_name, cs, path): |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
87 """ |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
88 Returns file_node, if error occurs or given path is directory, |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
89 it'll redirect to top level path |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1200
diff
changeset
|
90 |
1189
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
91 :param repo_name: repo_name |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
92 :param cs: given changeset |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
93 :param path: path to lookup |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
94 """ |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
95 |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
96 try: |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
97 file_node = cs.get_node(path) |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
98 if file_node.is_dir(): |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
99 raise RepositoryError('given path is a directory') |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
100 except RepositoryError, e: |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
101 h.flash(str(e), category='warning') |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
102 redirect(h.url('files_home', repo_name=repo_name, |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
103 revision=cs.raw_id)) |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
104 |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
105 return file_node |
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
106 |
1452
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
107 |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
108 def __get_paths(self, changeset, starting_path): |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
109 """recursive walk in root dir and return a set of all path in that dir |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
110 based on repository walk function |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
111 """ |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
112 _files = list() |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
113 _dirs = list() |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
114 |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
115 try: |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
116 tip = changeset |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
117 for topnode, dirs, files in tip.walk(starting_path): |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
118 for f in files: |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
119 _files.append(f.path) |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
120 for d in dirs: |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
121 _dirs.append(d.path) |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
122 except RepositoryError, e: |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
123 log.debug(traceback.format_exc()) |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
124 pass |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
125 return _dirs, _files |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
126 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
127 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
128 'repository.admin') |
99
5b57295601b6
Updated basic files browser with, pygments
Marcin Kuzminski <marcin@python-works.com>
parents:
93
diff
changeset
|
129 def index(self, repo_name, revision, f_path): |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
130 #reditect to given revision from form if given |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
131 post_revision = request.POST.get('at_rev', None) |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
132 if post_revision: |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
133 cs = self.__get_cs_or_redirect(post_revision, repo_name) |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
134 redirect(url('files_home', repo_name=c.repo_name, |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
135 revision=cs.raw_id, f_path=f_path)) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
136 |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
137 c.changeset = self.__get_cs_or_redirect(revision, repo_name) |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
138 c.branch = request.GET.get('branch', None) |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
139 c.f_path = f_path |
884
322b53be49cc
Fixed url bug when using numeric revision in file browser,
Marcin Kuzminski <marcin@python-works.com>
parents:
883
diff
changeset
|
140 |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
141 cur_rev = c.changeset.revision |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
142 |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
143 #prev link |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
144 try: |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
145 prev_rev = c.rhodecode_repo.get_changeset(cur_rev).prev(c.branch) |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
146 c.url_prev = url('files_home', repo_name=c.repo_name, |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
147 revision=prev_rev.raw_id, f_path=f_path) |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
148 if c.branch: |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
149 c.url_prev += '?branch=%s' % c.branch |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
150 except (ChangesetDoesNotExistError, VCSError): |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
151 c.url_prev = '#' |
883
20ed6f6a6329
Changed prev/next in file browser to new vcs methods
Marcin Kuzminski <marcin@python-works.com>
parents:
872
diff
changeset
|
152 |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
153 #next link |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
154 try: |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
155 next_rev = c.rhodecode_repo.get_changeset(cur_rev).next(c.branch) |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
156 c.url_next = url('files_home', repo_name=c.repo_name, |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
157 revision=next_rev.raw_id, f_path=f_path) |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
158 if c.branch: |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
159 c.url_next += '?branch=%s' % c.branch |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
160 except (ChangesetDoesNotExistError, VCSError): |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
161 c.url_next = '#' |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
162 |
1189
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
163 #files or dirs |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
164 try: |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
165 c.files_list = c.changeset.get_node(f_path) |
1190
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
166 |
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
167 if c.files_list.is_file(): |
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
168 c.file_history = self._get_node_history(c.changeset, f_path) |
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
169 else: |
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
170 c.file_history = [] |
644
c8bd0e6cc3da
some changes for #45.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
171 except RepositoryError, e: |
c8bd0e6cc3da
some changes for #45.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
172 h.flash(str(e), category='warning') |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
173 redirect(h.url('files_home', repo_name=repo_name, |
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
174 revision=revision)) |
644
c8bd0e6cc3da
some changes for #45.
Marcin Kuzminski <marcin@python-works.com>
parents:
636
diff
changeset
|
175 |
128
9deb6f1d5b90
Implemented file history.
Marcin Kuzminski <marcin@python-works.com>
parents:
106
diff
changeset
|
176 return render('files/files.html') |
9deb6f1d5b90
Implemented file history.
Marcin Kuzminski <marcin@python-works.com>
parents:
106
diff
changeset
|
177 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
178 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
179 'repository.admin') |
147
873fd2dc62c2
Added rawfile support, and few fixes for file
Marcin Kuzminski <marcin@python-works.com>
parents:
145
diff
changeset
|
180 def rawfile(self, repo_name, revision, f_path): |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
181 cs = self.__get_cs_or_redirect(revision, repo_name) |
1189
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
182 file_node = self.__get_filenode_or_redirect(repo_name, cs, f_path) |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
183 |
1189
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
184 response.content_disposition = 'attachment; filename=%s' % \ |
1401
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1313
diff
changeset
|
185 safe_str(f_path.split(os.sep)[-1]) |
1189
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
186 |
160
0f7f93df5802
implemented rawdiff and diff download into diff view.
Marcin Kuzminski <marcin@python-works.com>
parents:
158
diff
changeset
|
187 response.content_type = file_node.mimetype |
147
873fd2dc62c2
Added rawfile support, and few fixes for file
Marcin Kuzminski <marcin@python-works.com>
parents:
145
diff
changeset
|
188 return file_node.content |
485
9836541b0509
added limit for showing pygemntized source codes larger than 250kb.
Marcin Kuzminski <marcin@python-works.com>
parents:
438
diff
changeset
|
189 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
190 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
191 'repository.admin') |
485
9836541b0509
added limit for showing pygemntized source codes larger than 250kb.
Marcin Kuzminski <marcin@python-works.com>
parents:
438
diff
changeset
|
192 def raw(self, repo_name, revision, f_path): |
1137
82344ce0a892
clean and fixes in files controller
Marcin Kuzminski <marcin@python-works.com>
parents:
1134
diff
changeset
|
193 cs = self.__get_cs_or_redirect(revision, repo_name) |
1189
a4e1b955fe07
fixes for rawfile, annotation, download. It will check now if it's a filenode.
Marcin Kuzminski <marcin@python-works.com>
parents:
1151
diff
changeset
|
194 file_node = self.__get_filenode_or_redirect(repo_name, cs, f_path) |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
195 |
1241
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
196 raw_mimetype_mapping = { |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
197 # map original mimetype to a mimetype used for "show as raw" |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
198 # you can also provide a content-disposition to override the |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
199 # default "attachment" disposition. |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
200 # orig_type: (new_type, new_dispo) |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
201 |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
202 # show images inline: |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
203 'image/x-icon': ('image/x-icon', 'inline'), |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
204 'image/png': ('image/png', 'inline'), |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
205 'image/gif': ('image/gif', 'inline'), |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
206 'image/jpeg': ('image/jpeg', 'inline'), |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
207 'image/svg+xml': ('image/svg+xml', 'inline'), |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
208 } |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
209 |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
210 mimetype = file_node.mimetype |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
211 try: |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
212 mimetype, dispo = raw_mimetype_mapping[mimetype] |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
213 except KeyError: |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
214 # we don't know anything special about this, handle it safely |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
215 if file_node.is_binary: |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
216 # do same as download raw for binary files |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
217 mimetype, dispo = 'application/octet-stream', 'attachment' |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
218 else: |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
219 # do not just use the original mimetype, but force text/plain, |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
220 # otherwise it would serve text/html and that might be unsafe. |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
221 # Note: underlying vcs library fakes text/plain mimetype if the |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1241
diff
changeset
|
222 # mimetype can not be determined and it thinks it is not |
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1241
diff
changeset
|
223 # binary.This might lead to erroneous text display in some |
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1241
diff
changeset
|
224 # cases, but helps in other cases, like with text files |
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1241
diff
changeset
|
225 # without extension. |
1241
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
226 mimetype, dispo = 'text/plain', 'inline' |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
227 |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
228 if dispo == 'attachment': |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
229 dispo = 'attachment; filename=%s' % \ |
1401
b7563ad4e7ee
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents:
1313
diff
changeset
|
230 safe_str(f_path.split(os.sep)[-1]) |
1241
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
231 |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
232 response.content_disposition = dispo |
ed5270522724
changed raw action to show images instead of saying about binary file
Marcin Kuzminski <marcin@python-works.com>
parents:
1224
diff
changeset
|
233 response.content_type = mimetype |
485
9836541b0509
added limit for showing pygemntized source codes larger than 250kb.
Marcin Kuzminski <marcin@python-works.com>
parents:
438
diff
changeset
|
234 return file_node.content |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
235 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
236 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
237 'repository.admin') |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
160
diff
changeset
|
238 def annotate(self, repo_name, revision, f_path): |
1190
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
239 c.cs = self.__get_cs_or_redirect(revision, repo_name) |
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
240 c.file = self.__get_filenode_or_redirect(repo_name, c.cs, f_path) |
774
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
241 |
1190
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
242 c.file_history = self._get_node_history(c.cs, f_path) |
191
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
160
diff
changeset
|
243 c.f_path = f_path |
b68b2246e5a6
Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents:
160
diff
changeset
|
244 return render('files/files_annotate.html') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
245 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
246 @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin') |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
247 def edit(self, repo_name, revision, f_path): |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
248 r_post = request.POST |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
249 |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
250 c.cs = self.__get_cs_or_redirect(revision, repo_name) |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
251 c.file = self.__get_filenode_or_redirect(repo_name, c.cs, f_path) |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
252 |
1313
856be614d9a4
disabled edition of binary files
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
253 if c.file.is_binary: |
856be614d9a4
disabled edition of binary files
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
254 return redirect(url('files_home', repo_name=c.repo_name, |
856be614d9a4
disabled edition of binary files
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
255 revision=c.cs.raw_id, f_path=f_path)) |
856be614d9a4
disabled edition of binary files
Marcin Kuzminski <marcin@python-works.com>
parents:
1312
diff
changeset
|
256 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
257 c.f_path = f_path |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
258 |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
259 if r_post: |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
260 |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
261 old_content = c.file.content |
1306
6e1d24503383
Added support for ascendent characters for inMemoryCommit
Marcin Kuzminski <marcin@python-works.com>
parents:
1305
diff
changeset
|
262 sl = old_content.splitlines(1) |
6e1d24503383
Added support for ascendent characters for inMemoryCommit
Marcin Kuzminski <marcin@python-works.com>
parents:
1305
diff
changeset
|
263 first_line = sl[0] if sl else '' |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
264 # modes: 0 - Unix, 1 - Mac, 2 - DOS |
1306
6e1d24503383
Added support for ascendent characters for inMemoryCommit
Marcin Kuzminski <marcin@python-works.com>
parents:
1305
diff
changeset
|
265 mode = detect_mode(first_line, 0) |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
266 content = convert_line_endings(r_post.get('content'), mode) |
1306
6e1d24503383
Added support for ascendent characters for inMemoryCommit
Marcin Kuzminski <marcin@python-works.com>
parents:
1305
diff
changeset
|
267 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
268 message = r_post.get('message') or (_('Edited %s via RhodeCode') |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
269 % (f_path)) |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1308
diff
changeset
|
270 author = self.rhodecode_user.full_contact |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
271 |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
272 if content == old_content: |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
273 h.flash(_('No changes'), |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
274 category='warning') |
1306
6e1d24503383
Added support for ascendent characters for inMemoryCommit
Marcin Kuzminski <marcin@python-works.com>
parents:
1305
diff
changeset
|
275 return redirect(url('changeset_home', repo_name=c.repo_name, |
6e1d24503383
Added support for ascendent characters for inMemoryCommit
Marcin Kuzminski <marcin@python-works.com>
parents:
1305
diff
changeset
|
276 revision='tip')) |
6e1d24503383
Added support for ascendent characters for inMemoryCommit
Marcin Kuzminski <marcin@python-works.com>
parents:
1305
diff
changeset
|
277 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
278 try: |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1308
diff
changeset
|
279 self.scm_model.commit_change(repo=c.rhodecode_repo, |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1308
diff
changeset
|
280 repo_name=repo_name, cs=c.cs, |
1312
70a5a9a57864
logged local commit with special action via action_logger,
Marcin Kuzminski <marcin@python-works.com>
parents:
1311
diff
changeset
|
281 user=self.rhodecode_user, |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1308
diff
changeset
|
282 author=author, message=message, |
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1308
diff
changeset
|
283 content=content, f_path=f_path) |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
284 h.flash(_('Successfully committed to %s' % f_path), |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
285 category='success') |
1306
6e1d24503383
Added support for ascendent characters for inMemoryCommit
Marcin Kuzminski <marcin@python-works.com>
parents:
1305
diff
changeset
|
286 |
1311
6705eeebc41b
moved out commit into scm model, and added cache invalidation after commit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1308
diff
changeset
|
287 except Exception: |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
288 log.error(traceback.format_exc()) |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
289 h.flash(_('Error occurred during commit'), category='error') |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
290 return redirect(url('changeset_home', |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
291 repo_name=c.repo_name, revision='tip')) |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
292 |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
293 return render('files/files_edit.html') |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
294 |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
295 @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin') |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
296 def add(self, repo_name, revision, f_path): |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
297 r_post = request.POST |
1485
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
298 c.cs = self.__get_cs_or_redirect(revision, repo_name, |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
299 redirect_after=False) |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
300 if c.cs is None: |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
301 c.cs = EmptyChangeset(alias=c.rhodecode_repo.alias) |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
302 |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
303 c.f_path = f_path |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
304 |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
305 if r_post: |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
306 unix_mode = 0 |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
307 content = convert_line_endings(r_post.get('content'), unix_mode) |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
308 |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
309 message = r_post.get('message') or (_('Added %s via RhodeCode') |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
310 % (f_path)) |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
311 location = r_post.get('location') |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
312 filename = r_post.get('filename') |
1485
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
313 file_obj = r_post.get('upload_file', None) |
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
314 |
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
315 if file_obj is not None and hasattr(file_obj, 'filename'): |
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
316 filename = file_obj.filename |
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
317 content = file_obj.file |
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
318 |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
319 node_path = os.path.join(location, filename) |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
320 author = self.rhodecode_user.full_contact |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
321 |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
322 if not content: |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
323 h.flash(_('No content'), category='warning') |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
324 return redirect(url('changeset_home', repo_name=c.repo_name, |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
325 revision='tip')) |
1484
1db451a44504
fixed small issues with adding new filenodes
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
326 if not filename: |
1db451a44504
fixed small issues with adding new filenodes
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
327 h.flash(_('No filename'), category='warning') |
1db451a44504
fixed small issues with adding new filenodes
Marcin Kuzminski <marcin@python-works.com>
parents:
1483
diff
changeset
|
328 return redirect(url('changeset_home', repo_name=c.repo_name, |
1485
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
329 revision='tip')) |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
330 |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
331 try: |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
332 self.scm_model.create_node(repo=c.rhodecode_repo, |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
333 repo_name=repo_name, cs=c.cs, |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
334 user=self.rhodecode_user, |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
335 author=author, message=message, |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
336 content=content, f_path=node_path) |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
337 h.flash(_('Successfully committed to %s' % node_path), |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
338 category='success') |
1485
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
339 except NodeAlreadyExistsError, e: |
269905fac50a
added uploading of files from web interface directly into repo
Marcin Kuzminski <marcin@python-works.com>
parents:
1484
diff
changeset
|
340 h.flash(_(e), category='error') |
1483
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
341 except Exception: |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
342 log.error(traceback.format_exc()) |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
343 h.flash(_('Error occurred during commit'), category='error') |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
344 return redirect(url('changeset_home', |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
345 repo_name=c.repo_name, revision='tip')) |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
346 |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
347 return render('files/files_add.html') |
7b67b0dcad6d
Added initial support for creating new nodes in repos
Marcin Kuzminski <marcin@python-works.com>
parents:
1480
diff
changeset
|
348 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
349 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
350 'repository.admin') |
872
b956e6f415a2
implemented #91,
Marcin Kuzminski <marcin@python-works.com>
parents:
813
diff
changeset
|
351 def archivefile(self, repo_name, fname): |
945
05b59c48556f
fixed error when trying to make download on empty repository
Marcin Kuzminski <marcin@python-works.com>
parents:
942
diff
changeset
|
352 |
942
32318ec7bfc1
added branch/tag options to download links in summary
Marcin Kuzminski <marcin@python-works.com>
parents:
915
diff
changeset
|
353 fileformat = None |
32318ec7bfc1
added branch/tag options to download links in summary
Marcin Kuzminski <marcin@python-works.com>
parents:
915
diff
changeset
|
354 revision = None |
948
85ee0ea183e7
fixed archival in rhodecode to use new functions from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
945
diff
changeset
|
355 ext = None |
1450
2a8bf2a3da98
fixes #214 added support for downloading subrepos in download menu.
Marcin Kuzminski <marcin@python-works.com>
parents:
1401
diff
changeset
|
356 subrepos = request.GET.get('subrepos') == 'true' |
945
05b59c48556f
fixed error when trying to make download on empty repository
Marcin Kuzminski <marcin@python-works.com>
parents:
942
diff
changeset
|
357 |
1480
daa29da0f783
fixes for vcs settings module
Marcin Kuzminski <marcin@python-works.com>
parents:
1452
diff
changeset
|
358 for a_type, ext_data in settings.ARCHIVE_SPECS.items(): |
948
85ee0ea183e7
fixed archival in rhodecode to use new functions from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
945
diff
changeset
|
359 archive_spec = fname.split(ext_data[1]) |
85ee0ea183e7
fixed archival in rhodecode to use new functions from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
945
diff
changeset
|
360 if len(archive_spec) == 2 and archive_spec[1] == '': |
85ee0ea183e7
fixed archival in rhodecode to use new functions from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
945
diff
changeset
|
361 fileformat = a_type or ext_data[1] |
942
32318ec7bfc1
added branch/tag options to download links in summary
Marcin Kuzminski <marcin@python-works.com>
parents:
915
diff
changeset
|
362 revision = archive_spec[0] |
948
85ee0ea183e7
fixed archival in rhodecode to use new functions from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
945
diff
changeset
|
363 ext = ext_data[1] |
872
b956e6f415a2
implemented #91,
Marcin Kuzminski <marcin@python-works.com>
parents:
813
diff
changeset
|
364 |
b956e6f415a2
implemented #91,
Marcin Kuzminski <marcin@python-works.com>
parents:
813
diff
changeset
|
365 try: |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
366 dbrepo = RepoModel().get_by_repo_name(repo_name) |
1038
5554aa9c2480
another major code rafactor, reimplemented (almost from scratch)
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
367 if dbrepo.enable_downloads is False: |
962
72f008ed9b18
implemented #84 downloads can be enabled/disabled per each repository from now.
Marcin Kuzminski <marcin@python-works.com>
parents:
961
diff
changeset
|
368 return _('downloads disabled') |
72f008ed9b18
implemented #84 downloads can be enabled/disabled per each repository from now.
Marcin Kuzminski <marcin@python-works.com>
parents:
961
diff
changeset
|
369 |
1664
65386911df2a
fixes issue with mercurial 2.0 and archival of subrepos.
Marcin Kuzminski <marcin@python-works.com>
parents:
1568
diff
changeset
|
370 # patch and reset hooks section of UI config to not run any |
65386911df2a
fixes issue with mercurial 2.0 and archival of subrepos.
Marcin Kuzminski <marcin@python-works.com>
parents:
1568
diff
changeset
|
371 # hooks on fetching archives with subrepos |
65386911df2a
fixes issue with mercurial 2.0 and archival of subrepos.
Marcin Kuzminski <marcin@python-works.com>
parents:
1568
diff
changeset
|
372 for k, v in c.rhodecode_repo._repo.ui.configitems('hooks'): |
65386911df2a
fixes issue with mercurial 2.0 and archival of subrepos.
Marcin Kuzminski <marcin@python-works.com>
parents:
1568
diff
changeset
|
373 c.rhodecode_repo._repo.ui.setconfig('hooks', k, None) |
65386911df2a
fixes issue with mercurial 2.0 and archival of subrepos.
Marcin Kuzminski <marcin@python-works.com>
parents:
1568
diff
changeset
|
374 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
375 cs = c.rhodecode_repo.get_changeset(revision) |
1480
daa29da0f783
fixes for vcs settings module
Marcin Kuzminski <marcin@python-works.com>
parents:
1452
diff
changeset
|
376 content_type = settings.ARCHIVE_SPECS[fileformat][0] |
872
b956e6f415a2
implemented #91,
Marcin Kuzminski <marcin@python-works.com>
parents:
813
diff
changeset
|
377 except ChangesetDoesNotExistError: |
b956e6f415a2
implemented #91,
Marcin Kuzminski <marcin@python-works.com>
parents:
813
diff
changeset
|
378 return _('Unknown revision %s') % revision |
945
05b59c48556f
fixed error when trying to make download on empty repository
Marcin Kuzminski <marcin@python-works.com>
parents:
942
diff
changeset
|
379 except EmptyRepositoryError: |
05b59c48556f
fixed error when trying to make download on empty repository
Marcin Kuzminski <marcin@python-works.com>
parents:
942
diff
changeset
|
380 return _('Empty repository') |
961
840ca7492dbe
fixed typo in exception
Marcin Kuzminski <marcin@python-works.com>
parents:
953
diff
changeset
|
381 except (ImproperArchiveTypeError, KeyError): |
948
85ee0ea183e7
fixed archival in rhodecode to use new functions from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
945
diff
changeset
|
382 return _('Unknown archive type') |
872
b956e6f415a2
implemented #91,
Marcin Kuzminski <marcin@python-works.com>
parents:
813
diff
changeset
|
383 |
950
343c28c33c19
fixed key error on unknown archival
Marcin Kuzminski <marcin@python-works.com>
parents:
948
diff
changeset
|
384 response.content_type = content_type |
343c28c33c19
fixed key error on unknown archival
Marcin Kuzminski <marcin@python-works.com>
parents:
948
diff
changeset
|
385 response.content_disposition = 'attachment; filename=%s-%s%s' \ |
343c28c33c19
fixed key error on unknown archival
Marcin Kuzminski <marcin@python-works.com>
parents:
948
diff
changeset
|
386 % (repo_name, revision, ext) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
387 |
1308
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
388 import tempfile |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
389 archive = tempfile.mkstemp()[1] |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
390 t = open(archive, 'wb') |
1450
2a8bf2a3da98
fixes #214 added support for downloading subrepos in download menu.
Marcin Kuzminski <marcin@python-works.com>
parents:
1401
diff
changeset
|
391 cs.fill_archive(stream=t, kind=fileformat, subrepos=subrepos) |
1308
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
392 |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
393 def get_chunked_archive(archive): |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
394 stream = open(archive, 'rb') |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
395 while True: |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
396 data = stream.read(4096) |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
397 if not data: |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
398 os.remove(archive) |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
399 break |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
400 yield data |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
401 |
73b2fc324c1e
changes for archivals in rhodecode. Also made it work for git that way
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
402 return get_chunked_archive(archive) |
948
85ee0ea183e7
fixed archival in rhodecode to use new functions from vcs
Marcin Kuzminski <marcin@python-works.com>
parents:
945
diff
changeset
|
403 |
1305
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
404 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
166317d464f3
Added server side file editing with commit
Marcin Kuzminski <marcin@python-works.com>
parents:
1273
diff
changeset
|
405 'repository.admin') |
129
42d46deb124d
implemented simple diffs for history of files.
Marcin Kuzminski <marcin@python-works.com>
parents:
128
diff
changeset
|
406 def diff(self, repo_name, f_path): |
42d46deb124d
implemented simple diffs for history of files.
Marcin Kuzminski <marcin@python-works.com>
parents:
128
diff
changeset
|
407 diff1 = request.GET.get('diff1') |
42d46deb124d
implemented simple diffs for history of files.
Marcin Kuzminski <marcin@python-works.com>
parents:
128
diff
changeset
|
408 diff2 = request.GET.get('diff2') |
337
fa3835d34fc1
fixed bug when diff command was different than available options
Marcin Kuzminski <marcin@python-works.com>
parents:
335
diff
changeset
|
409 c.action = request.GET.get('diff') |
131
49c7e191c2cd
Implemented mercurial style diff-lib
Marcin Kuzminski <marcin@python-works.com>
parents:
130
diff
changeset
|
410 c.no_changes = diff1 == diff2 |
129
42d46deb124d
implemented simple diffs for history of files.
Marcin Kuzminski <marcin@python-works.com>
parents:
128
diff
changeset
|
411 c.f_path = f_path |
1273
64cb9612f9aa
Added show as raw into big diff
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
412 c.big_diff = False |
152
0c00fbaff55a
Fixed differ to properly extract filenames, and dates from diff file. and swaped order of columns with lines nr in diff html
Marcin Kuzminski <marcin@python-works.com>
parents:
149
diff
changeset
|
413 |
275
2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
Marcin Kuzminski <marcin@python-works.com>
parents:
272
diff
changeset
|
414 try: |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
415 if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]: |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
416 c.changeset_1 = c.rhodecode_repo.get_changeset(diff1) |
275
2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
Marcin Kuzminski <marcin@python-works.com>
parents:
272
diff
changeset
|
417 node1 = c.changeset_1.get_node(f_path) |
2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
Marcin Kuzminski <marcin@python-works.com>
parents:
272
diff
changeset
|
418 else: |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
419 c.changeset_1 = EmptyChangeset(repo=c.rhodecode_repo) |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
420 node1 = FileNode('.', '', changeset=c.changeset_1) |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
421 |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
422 if diff2 not in ['', None, 'None', '0' * 12, '0' * 40]: |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
423 c.changeset_2 = c.rhodecode_repo.get_changeset(diff2) |
275
2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
Marcin Kuzminski <marcin@python-works.com>
parents:
272
diff
changeset
|
424 node2 = c.changeset_2.get_node(f_path) |
2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
Marcin Kuzminski <marcin@python-works.com>
parents:
272
diff
changeset
|
425 else: |
1224
e76833cd555a
files: fixes error when passing a diff without parameters and caused server crash
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
426 c.changeset_2 = EmptyChangeset(repo=c.rhodecode_repo) |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
427 node2 = FileNode('.', '', changeset=c.changeset_2) |
275
2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
Marcin Kuzminski <marcin@python-works.com>
parents:
272
diff
changeset
|
428 except RepositoryError: |
2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
Marcin Kuzminski <marcin@python-works.com>
parents:
272
diff
changeset
|
429 return redirect(url('files_home', |
2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
Marcin Kuzminski <marcin@python-works.com>
parents:
272
diff
changeset
|
430 repo_name=c.repo_name, f_path=f_path)) |
2d61aa00e855
fixed bugs when putting empty or unknown changesets into diff
Marcin Kuzminski <marcin@python-works.com>
parents:
272
diff
changeset
|
431 |
337
fa3835d34fc1
fixed bug when diff command was different than available options
Marcin Kuzminski <marcin@python-works.com>
parents:
335
diff
changeset
|
432 if c.action == 'download': |
1132
c4b59dcf063e
fixed files diffs to use gitdiff enabled diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1125
diff
changeset
|
433 diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2), |
c4b59dcf063e
fixed files diffs to use gitdiff enabled diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1125
diff
changeset
|
434 format='gitdiff') |
1044
f3402cb92fdf
changed raw and download diffs to gitdiff
Marcin Kuzminski <marcin@python-works.com>
parents:
1043
diff
changeset
|
435 |
160
0f7f93df5802
implemented rawdiff and diff download into diff view.
Marcin Kuzminski <marcin@python-works.com>
parents:
158
diff
changeset
|
436 diff_name = '%s_vs_%s.diff' % (diff1, diff2) |
0f7f93df5802
implemented rawdiff and diff download into diff view.
Marcin Kuzminski <marcin@python-works.com>
parents:
158
diff
changeset
|
437 response.content_type = 'text/plain' |
0f7f93df5802
implemented rawdiff and diff download into diff view.
Marcin Kuzminski <marcin@python-works.com>
parents:
158
diff
changeset
|
438 response.content_disposition = 'attachment; filename=%s' \ |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
439 % diff_name |
160
0f7f93df5802
implemented rawdiff and diff download into diff view.
Marcin Kuzminski <marcin@python-works.com>
parents:
158
diff
changeset
|
440 return diff.raw_diff() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
441 |
337
fa3835d34fc1
fixed bug when diff command was different than available options
Marcin Kuzminski <marcin@python-works.com>
parents:
335
diff
changeset
|
442 elif c.action == 'raw': |
1132
c4b59dcf063e
fixed files diffs to use gitdiff enabled diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1125
diff
changeset
|
443 diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2), |
c4b59dcf063e
fixed files diffs to use gitdiff enabled diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1125
diff
changeset
|
444 format='gitdiff') |
649
3765f0f479a2
fixed raw diff as purly raw without html
Marcin Kuzminski <marcin@python-works.com>
parents:
644
diff
changeset
|
445 response.content_type = 'text/plain' |
3765f0f479a2
fixed raw diff as purly raw without html
Marcin Kuzminski <marcin@python-works.com>
parents:
644
diff
changeset
|
446 return diff.raw_diff() |
662
373ee7031003
fixed annotation bug, added history to annotation.
Marcin Kuzminski <marcin@python-works.com>
parents:
649
diff
changeset
|
447 |
337
fa3835d34fc1
fixed bug when diff command was different than available options
Marcin Kuzminski <marcin@python-works.com>
parents:
335
diff
changeset
|
448 elif c.action == 'diff': |
1149
d162de13caec
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1137
diff
changeset
|
449 if node1.is_binary or node2.is_binary: |
d162de13caec
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1137
diff
changeset
|
450 c.cur_diff = _('Binary file') |
1212 | 451 elif node1.size > self.cut_off_limit or \ |
452 node2.size > self.cut_off_limit: | |
1273
64cb9612f9aa
Added show as raw into big diff
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
453 c.cur_diff = '' |
64cb9612f9aa
Added show as raw into big diff
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
454 c.big_diff = True |
1149
d162de13caec
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1137
diff
changeset
|
455 else: |
d162de13caec
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1137
diff
changeset
|
456 diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2), |
1132
c4b59dcf063e
fixed files diffs to use gitdiff enabled diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
1125
diff
changeset
|
457 format='gitdiff') |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
458 c.cur_diff = diff.as_html() |
337
fa3835d34fc1
fixed bug when diff command was different than available options
Marcin Kuzminski <marcin@python-works.com>
parents:
335
diff
changeset
|
459 else: |
1149
d162de13caec
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1137
diff
changeset
|
460 |
337
fa3835d34fc1
fixed bug when diff command was different than available options
Marcin Kuzminski <marcin@python-works.com>
parents:
335
diff
changeset
|
461 #default option |
1149
d162de13caec
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1137
diff
changeset
|
462 if node1.is_binary or node2.is_binary: |
1043
6ec53c16c744
fixed binary file issues
Marcin Kuzminski <marcin@python-works.com>
parents:
1038
diff
changeset
|
463 c.cur_diff = _('Binary file') |
1212 | 464 elif node1.size > self.cut_off_limit or \ |
465 node2.size > self.cut_off_limit: | |
1273
64cb9612f9aa
Added show as raw into big diff
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
466 c.cur_diff = '' |
64cb9612f9aa
Added show as raw into big diff
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
467 c.big_diff = True |
64cb9612f9aa
Added show as raw into big diff
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
468 |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
469 else: |
1149
d162de13caec
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1137
diff
changeset
|
470 diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2), |
d162de13caec
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1137
diff
changeset
|
471 format='gitdiff') |
544
d8778cde98f0
added limits to single file diffs
Marcin Kuzminski <marcin@python-works.com>
parents:
512
diff
changeset
|
472 c.cur_diff = diff.as_html() |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
473 |
1273
64cb9612f9aa
Added show as raw into big diff
Marcin Kuzminski <marcin@python-works.com>
parents:
1245
diff
changeset
|
474 if not c.cur_diff and not c.big_diff: |
1149
d162de13caec
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit.
Marcin Kuzminski <marcin@python-works.com>
parents:
1137
diff
changeset
|
475 c.no_changes = True |
129
42d46deb124d
implemented simple diffs for history of files.
Marcin Kuzminski <marcin@python-works.com>
parents:
128
diff
changeset
|
476 return render('files/file_diff.html') |
636
ffd07396d315
Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
477 |
1190
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
478 def _get_node_history(self, cs, f_path): |
0d7a127e6449
use cs get history instead of node.history, node history have to much reference calls
Marcin Kuzminski <marcin@python-works.com>
parents:
1189
diff
changeset
|
479 changesets = cs.get_file_history(f_path) |
128
9deb6f1d5b90
Implemented file history.
Marcin Kuzminski <marcin@python-works.com>
parents:
106
diff
changeset
|
480 hist_l = [] |
774
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
481 |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
482 changesets_group = ([], _("Changesets")) |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
483 branches_group = ([], _("Branches")) |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
484 tags_group = ([], _("Tags")) |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
485 |
128
9deb6f1d5b90
Implemented file history.
Marcin Kuzminski <marcin@python-works.com>
parents:
106
diff
changeset
|
486 for chs in changesets: |
512
d945c95ba4ac
refactoring for new vcs implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
485
diff
changeset
|
487 n_desc = 'r%s:%s' % (chs.revision, chs.short_id) |
774
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
488 changesets_group[0].append((chs.raw_id, n_desc,)) |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
489 |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
490 hist_l.append(changesets_group) |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
491 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
492 for name, chs in c.rhodecode_repo.branches.items(): |
774
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
493 #chs = chs.split(':')[-1] |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
494 branches_group[0].append((chs, name),) |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
495 hist_l.append(branches_group) |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
496 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1044
diff
changeset
|
497 for name, chs in c.rhodecode_repo.tags.items(): |
774
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
498 #chs = chs.split(':')[-1] |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
499 tags_group[0].append((chs, name),) |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
500 hist_l.append(tags_group) |
c47152c5fe01
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
Marcin Kuzminski <marcin@python-works.com>
parents:
691
diff
changeset
|
501 |
128
9deb6f1d5b90
Implemented file history.
Marcin Kuzminski <marcin@python-works.com>
parents:
106
diff
changeset
|
502 return hist_l |
1452
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
503 |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
504 @jsonify |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
505 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
506 'repository.admin') |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
507 def nodelist(self, repo_name, revision, f_path): |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
508 if request.environ.get('HTTP_X_PARTIAL_XHR'): |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
509 cs = self.__get_cs_or_redirect(revision, repo_name) |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
510 _d, _f = self.__get_paths(cs, f_path) |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
511 return _d + _f |
8585fbf3ed06
Implemented #111 copy github node finder solution
Marcin Kuzminski <marcin@python-works.com>
parents:
1450
diff
changeset
|
512 |