##// END OF EJS Templates
old style: fix text areas in fork dialog...
old style: fix text areas in fork dialog There's no textarea-repo style, so the entry box isn't properly aligned.

File last commit:

r4116:ffd45b18 rhodecode-2.2.5-gpl
r4155:cee56368 rhodecode-2.2.5-gpl
Show More
files.py
803 lines | 33.6 KiB | text/x-python | PythonLexer
fixes #79 cut off limit was added into .ini config files
r812 # -*- coding: utf-8 -*-
fixed license issue #149
r1206 # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
source code cleanup: remove trailing white space, normalize file endings
r1203 #
renamed project to rhodecode
r547 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
source code cleanup: remove trailing white space, normalize file endings
r1203 #
renamed project to rhodecode
r547 # You should have received a copy of the GNU General Public License
fixed license issue #149
r1206 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 """
rhodecode.controllers.files
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Files controller for RhodeCode
:created_on: Apr 21, 2010
:author: marcink
:copyright: (c) 2013 RhodeCode GmbH.
:license: GPLv3, see LICENSE for more details.
"""
archive file fixes for python 2.5
r2291 from __future__ import with_statement
added os.sep for files controller...
r1200 import os
fixes #79 cut off limit was added into .ini config files
r812 import logging
Added server side file editing with commit
r1305 import traceback
cleanup code of get archive for repositories
r2267 import tempfile
initial version of #788 tarball cache
r3490 import shutil
fixes #79 cut off limit was added into .ini config files
r812
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 from pylons import request, response, tmpl_context as c, url
renamed project to rhodecode
r547 from pylons.i18n.translation import _
from pylons.controllers.util import redirect
store download archive actions in journal
r3868 from rhodecode.lib.utils import jsonify, action_logger
fixes #79 cut off limit was added into .ini config files
r812
utils/conf...
r2109 from rhodecode.lib import diffs
from rhodecode.lib import helpers as h
moved soon-to-be-deleted code from vcs to rhodecode...
r1753
fixes issue #860....
r4070 from rhodecode.lib.compat import OrderedDict
fixed issue with show at revision button. Some JS were not properly loaded due to ajaxified files view....
r2931 from rhodecode.lib.utils2 import convert_line_endings, detect_mode, safe_str,\
str2bool
Added server side file editing with commit
r1305 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
from rhodecode.lib.base import BaseRepoController, render
Bumped mercurial version to 2.3...
r2684 from rhodecode.lib.vcs.backends.base import EmptyChangeset
utils/conf...
r2109 from rhodecode.lib.vcs.conf import settings
from rhodecode.lib.vcs.exceptions import RepositoryError, \
ChangesetDoesNotExistError, EmptyRepositoryError, \
Fixed issue when node didn't exists at 'tip' and we tried calculate history based on that assumption....
r2977 ImproperArchiveTypeError, VCSError, NodeAlreadyExistsError,\
fix error when diff path is a directory, edge case generated by google bots
r3037 NodeDoesNotExistError, ChangesetError, NodeError
utils/conf...
r2109 from rhodecode.lib.vcs.nodes import FileNode
Added server side file editing with commit
r1305 from rhodecode.model.repo import RepoModel
utils/conf...
r2109 from rhodecode.model.scm import ScmModel
fixes for tests on Windows
r2255 from rhodecode.model.db import Repository
utils/conf...
r2109
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 from rhodecode.controllers.changeset import anchor_url, _ignorews_url,\
_context_url, get_line_ctx, get_ignore_ws
missing files or bad files revisions should return 404s not redirects - ref #808
r3621 from webob.exc import HTTPNotFound
fixes issue #860....
r4070 from rhodecode.lib.exceptions import NonRelativePathError, IMCCommitError
utils/conf...
r2109
Added server side file editing with commit
r1305
renamed project to rhodecode
r547 log = logging.getLogger(__name__)
fixed issue with vcs stream
r1134
another major codes rewrite:...
r1045 class FilesController(BaseRepoController):
Fixes for raw_id, needed for git...
r636
renamed project to rhodecode
r547 def __before__(self):
super(FilesController, self).__before__()
fixed small issue made on latest patches
r813 c.cut_off_limit = self.cut_off_limit
renamed project to rhodecode
r547
Added initial support for creating new nodes in repos
r1483 def __get_cs_or_redirect(self, rev, repo_name, redirect_after=True):
another major codes rewrite:...
r1045 """
clean and fixes in files controller
r1137 Safe way to get changeset if error occur it redirects to tip with
proper message
source code cleanup: remove trailing white space, normalize file endings
r1203
another major codes rewrite:...
r1045 :param rev: revision to fetch
:param repo_name: repo name to redirect after
"""
try:
return c.rhodecode_repo.get_changeset(rev)
except EmptyRepositoryError, e:
Added initial support for creating new nodes in repos
r1483 if not redirect_after:
return None
url_ = url('files_add_home',
repo_name=c.repo_name,
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 revision=0, f_path='', anchor='edit')
add_new = h.link_to(_('Click here to add new file'), url_, class_="alert-link")
h.flash(h.literal(_('There are no files yet. %s') % add_new),
Added initial support for creating new nodes in repos
r1483 category='warning')
another major codes rewrite:...
r1045 redirect(h.url('summary_home', repo_name=repo_name))
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 except(ChangesetDoesNotExistError, LookupError), e:
log.error(traceback.format_exc())
msg = _('Such revision does not exist for this repository')
h.flash(msg, category='error')
raise HTTPNotFound()
except RepositoryError, e:
Use safe_str on flash messages.
r4077 h.flash(safe_str(e), category='error')
missing files or bad files revisions should return 404s not redirects - ref #808
r3621 raise HTTPNotFound()
another major codes rewrite:...
r1045
fixes for rawfile, annotation, download. It will check now if it's a filenode....
r1189 def __get_filenode_or_redirect(self, repo_name, cs, path):
"""
Returns file_node, if error occurs or given path is directory,
it'll redirect to top level path
source code cleanup: remove trailing white space, normalize file endings
r1203
fixes for rawfile, annotation, download. It will check now if it's a filenode....
r1189 :param repo_name: repo_name
:param cs: given changeset
:param path: path to lookup
"""
try:
file_node = cs.get_node(path)
if file_node.is_dir():
raise RepositoryError('given path is a directory')
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 except(ChangesetDoesNotExistError,), e:
log.error(traceback.format_exc())
msg = _('Such revision does not exist for this repository')
h.flash(msg, category='error')
raise HTTPNotFound()
fixes for rawfile, annotation, download. It will check now if it's a filenode....
r1189 except RepositoryError, e:
Use safe_str on flash messages.
r4077 h.flash(safe_str(e), category='error')
missing files or bad files revisions should return 404s not redirects - ref #808
r3621 raise HTTPNotFound()
fixes for rawfile, annotation, download. It will check now if it's a filenode....
r1189
return file_node
moved login required into seperate calls for files due to optional API access option...
r2457 @LoginRequired()
Added server side file editing with commit
r1305 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
unified annotation view with file source view
r2177 def index(self, repo_name, revision, f_path, annotate=False):
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 # redirect to given revision from form if given
clean and fixes in files controller
r1137 post_revision = request.POST.get('at_rev', None)
if post_revision:
files: fixes error when passing a diff without parameters and caused server crash...
r1224 cs = self.__get_cs_or_redirect(post_revision, repo_name)
Fixes for raw_id, needed for git...
r636
clean and fixes in files controller
r1137 c.changeset = self.__get_cs_or_redirect(revision, repo_name)
c.branch = request.GET.get('branch', None)
c.f_path = f_path
unified annotation view with file source view
r2177 c.annotate = annotate
disable file editing when not on branch head fixes issue #462
r3237 c.changeset = self.__get_cs_or_redirect(revision, repo_name)
clean and fixes in files controller
r1137 cur_rev = c.changeset.revision
Fixes for raw_id, needed for git...
r636
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 # prev link
clean and fixes in files controller
r1137 try:
prev_rev = c.rhodecode_repo.get_changeset(cur_rev).prev(c.branch)
c.url_prev = url('files_home', repo_name=c.repo_name,
revision=prev_rev.raw_id, f_path=f_path)
if c.branch:
c.url_prev += '?branch=%s' % c.branch
except (ChangesetDoesNotExistError, VCSError):
c.url_prev = '#'
Changed prev/next in file browser to new vcs methods
r883
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 # next link
clean and fixes in files controller
r1137 try:
next_rev = c.rhodecode_repo.get_changeset(cur_rev).next(c.branch)
c.url_next = url('files_home', repo_name=c.repo_name,
revision=next_rev.raw_id, f_path=f_path)
if c.branch:
c.url_next += '?branch=%s' % c.branch
except (ChangesetDoesNotExistError, VCSError):
c.url_next = '#'
Fixes for raw_id, needed for git...
r636
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 # files or dirs
clean and fixes in files controller
r1137 try:
new files views...
r1737 c.file = c.changeset.get_node(f_path)
use cs get history instead of node.history, node history have to much reference calls
r1190
new files views...
r1737 if c.file.is_file():
implements #636, lazy loading of history and authors to speed up page responsiveness....
r3001 c.load_full_history = False
file_last_cs = c.file.last_changeset
c.file_changeset = (c.changeset
if c.changeset.revision < file_last_cs.revision
else file_last_cs)
disable file editing when not on branch head fixes issue #462
r3237 #determine if we're on branch head
_branches = c.rhodecode_repo.branches
Mads Kiilerich
coding style: fix trailing and leading spaces and tabs
r3267 c.on_branch_head = revision in _branches.keys() + _branches.values()
implements #636, lazy loading of history and authors to speed up page responsiveness....
r3001 _hist = []
c.file_history = []
if c.load_full_history:
c.file_history, _hist = self._get_node_history(c.changeset, f_path)
Add authors into file view
r2456 c.authors = []
for a in set([x.author for x in _hist]):
c.authors.append((h.email(a), h.person(a)))
use cs get history instead of node.history, node history have to much reference calls
r1190 else:
Add authors into file view
r2456 c.authors = c.file_history = []
some changes for #45....
r644 except RepositoryError, e:
Use safe_str on flash messages.
r4077 h.flash(safe_str(e), category='error')
missing files or bad files revisions should return 404s not redirects - ref #808
r3621 raise HTTPNotFound()
some changes for #45....
r644
Reimplemented file-browser using partial-ajax...
r2686 if request.environ.get('HTTP_X_PARTIAL_XHR'):
return render('files/files_ypjax.html')
renamed project to rhodecode
r547 return render('files/files.html')
auth decorators are not used anymore on __before__...
r3749 @LoginRequired()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 @jsonify
def history(self, repo_name, revision, f_path):
changeset = self.__get_cs_or_redirect(revision, repo_name)
f_path = f_path
_file = changeset.get_node(f_path)
if _file.is_file():
file_history, _hist = self._get_node_history(changeset, f_path)
res = []
for obj in file_history:
res.append({
'text': obj[1],
'children': [{'id': o[0], 'text': o[1]} for o in obj[0]]
})
data = {
'more': False,
'results': res
}
return data
@LoginRequired()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
def authors(self, repo_name, revision, f_path):
changeset = self.__get_cs_or_redirect(revision, repo_name)
f_path = f_path
_file = changeset.get_node(f_path)
if _file.is_file():
file_history, _hist = self._get_node_history(changeset, f_path)
c.authors = []
for a in set([x.author for x in _hist]):
c.authors.append((h.email(a), h.person(a)))
return render('files/files_history_box.html')
implements #636, lazy loading of history and authors to speed up page responsiveness....
r3001
moved login required into seperate calls for files due to optional API access option...
r2457 @LoginRequired()
Added server side file editing with commit
r1305 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
renamed project to rhodecode
r547 def rawfile(self, repo_name, revision, f_path):
clean and fixes in files controller
r1137 cs = self.__get_cs_or_redirect(revision, repo_name)
fixes for rawfile, annotation, download. It will check now if it's a filenode....
r1189 file_node = self.__get_filenode_or_redirect(repo_name, cs, f_path)
another major codes rewrite:...
r1045
fixes for rawfile, annotation, download. It will check now if it's a filenode....
r1189 response.content_disposition = 'attachment; filename=%s' % \
fixes for tests on Windows
r2255 safe_str(f_path.split(Repository.url_sep())[-1])
fixes for rawfile, annotation, download. It will check now if it's a filenode....
r1189
renamed project to rhodecode
r547 response.content_type = file_node.mimetype
return file_node.content
whitespace cleanup
r2461
moved login required into seperate calls for files due to optional API access option...
r2457 @LoginRequired()
Added server side file editing with commit
r1305 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
renamed project to rhodecode
r547 def raw(self, repo_name, revision, f_path):
clean and fixes in files controller
r1137 cs = self.__get_cs_or_redirect(revision, repo_name)
fixes for rawfile, annotation, download. It will check now if it's a filenode....
r1189 file_node = self.__get_filenode_or_redirect(repo_name, cs, f_path)
another major codes rewrite:...
r1045
changed raw action to show images instead of saying about binary file...
r1241 raw_mimetype_mapping = {
# map original mimetype to a mimetype used for "show as raw"
# you can also provide a content-disposition to override the
# default "attachment" disposition.
# orig_type: (new_type, new_dispo)
# show images inline:
'image/x-icon': ('image/x-icon', 'inline'),
'image/png': ('image/png', 'inline'),
'image/gif': ('image/gif', 'inline'),
'image/jpeg': ('image/jpeg', 'inline'),
'image/svg+xml': ('image/svg+xml', 'inline'),
}
mimetype = file_node.mimetype
try:
mimetype, dispo = raw_mimetype_mapping[mimetype]
except KeyError:
# we don't know anything special about this, handle it safely
if file_node.is_binary:
# do same as download raw for binary files
mimetype, dispo = 'application/octet-stream', 'attachment'
else:
# do not just use the original mimetype, but force text/plain,
# otherwise it would serve text/html and that might be unsafe.
# Note: underlying vcs library fakes text/plain mimetype if the
PEP8ify - controllers
r1245 # mimetype can not be determined and it thinks it is not
# binary.This might lead to erroneous text display in some
# cases, but helps in other cases, like with text files
# without extension.
changed raw action to show images instead of saying about binary file...
r1241 mimetype, dispo = 'text/plain', 'inline'
if dispo == 'attachment':
dispo = 'attachment; filename=%s' % \
Unicode fixes, added safe_str method for global str() operations +better test sandboxing
r1401 safe_str(f_path.split(os.sep)[-1])
changed raw action to show images instead of saying about binary file...
r1241
response.content_disposition = dispo
response.content_type = mimetype
renamed project to rhodecode
r547 return file_node.content
Fixes for raw_id, needed for git...
r636
moved login required into seperate calls for files due to optional API access option...
r2457 @LoginRequired()
Added server side file editing with commit
r1305 @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin')
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 def delete(self, repo_name, revision, f_path):
repo = c.rhodecode_db_repo
if repo.enable_locking and repo.locked[0]:
h.flash(_('This repository is has been locked by %s on %s')
% (h.person_by_id(repo.locked[0]),
h.fmt_date(h.time_to_datetime(repo.locked[1]))),
'warning')
return redirect(h.url('files_home',
repo_name=repo_name, revision='tip'))
# check if revision is a branch identifier- basically we cannot
# create multiple heads via file editing
_branches = repo.scm_instance.branches
# check if revision is a branch name or branch hash
if revision not in _branches.keys() + _branches.values():
h.flash(_('You can only delete files with revision '
'being a valid branch '), category='warning')
return redirect(h.url('files_home',
repo_name=repo_name, revision='tip',
f_path=f_path))
r_post = request.POST
c.cs = self.__get_cs_or_redirect(revision, repo_name)
c.file = self.__get_filenode_or_redirect(repo_name, c.cs, f_path)
c.default_message = _('Deleted file %s via RhodeCode') % (f_path)
c.f_path = f_path
node_path = f_path
author = self.rhodecode_user.full_contact
if r_post:
message = r_post.get('message') or c.default_message
try:
nodes = {
node_path: {
'content': ''
}
}
self.scm_model.delete_nodes(
user=c.rhodecode_user.user_id, repo=c.rhodecode_db_repo,
message=message,
nodes=nodes,
parent_cs=c.cs,
author=author,
)
h.flash(_('Successfully deleted file %s') % f_path,
category='success')
except Exception:
log.error(traceback.format_exc())
h.flash(_('Error occurred during commit'), category='error')
return redirect(url('changeset_home',
repo_name=c.repo_name, revision='tip'))
return render('files/files_delete.html')
@LoginRequired()
@HasRepoPermissionAnyDecorator('repository.write', 'repository.admin')
Added server side file editing with commit
r1305 def edit(self, repo_name, revision, f_path):
disable file editing when not on branch head fixes issue #462
r3237 repo = c.rhodecode_db_repo
Forbid adding files and editing from web interface while repo is locked
r2727 if repo.enable_locking and repo.locked[0]:
h.flash(_('This repository is has been locked by %s on %s')
% (h.person_by_id(repo.locked[0]),
h.fmt_date(h.time_to_datetime(repo.locked[1]))),
fixes issue #860....
r4070 'warning')
Forbid adding files and editing from web interface while repo is locked
r2727 return redirect(h.url('files_home',
repo_name=repo_name, revision='tip'))
disable file editing when not on branch head fixes issue #462
r3237 # check if revision is a branch identifier- basically we cannot
# create multiple heads via file editing
_branches = repo.scm_instance.branches
# check if revision is a branch name or branch hash
if revision not in _branches.keys() + _branches.values():
h.flash(_('You can only edit files with revision '
'being a valid branch '), category='warning')
return redirect(h.url('files_home',
repo_name=repo_name, revision='tip',
f_path=f_path))
Added server side file editing with commit
r1305 r_post = request.POST
c.cs = self.__get_cs_or_redirect(revision, repo_name)
c.file = self.__get_filenode_or_redirect(repo_name, c.cs, f_path)
disabled edition of binary files
r1313 if c.file.is_binary:
return redirect(url('files_home', repo_name=c.repo_name,
fixes issue #860....
r4070 revision=c.cs.raw_id, f_path=f_path))
disable file editing when not on branch head fixes issue #462
r3237 c.default_message = _('Edited file %s via RhodeCode') % (f_path)
Added server side file editing with commit
r1305 c.f_path = f_path
if r_post:
old_content = c.file.content
Added support for ascendent characters for inMemoryCommit
r1306 sl = old_content.splitlines(1)
first_line = sl[0] if sl else ''
Added server side file editing with commit
r1305 # modes: 0 - Unix, 1 - Mac, 2 - DOS
Added support for ascendent characters for inMemoryCommit
r1306 mode = detect_mode(first_line, 0)
Added more tests for web based file edit and add
r3839 content = convert_line_endings(r_post.get('content', ''), mode)
Added support for ascendent characters for inMemoryCommit
r1306
disable file editing when not on branch head fixes issue #462
r3237 message = r_post.get('message') or c.default_message
moved out commit into scm model, and added cache invalidation after commit.
r1311 author = self.rhodecode_user.full_contact
Added server side file editing with commit
r1305
if content == old_content:
missing files or bad files revisions should return 404s not redirects - ref #808
r3621 h.flash(_('No changes'), category='warning')
Added support for ascendent characters for inMemoryCommit
r1306 return redirect(url('changeset_home', repo_name=c.repo_name,
revision='tip'))
Added server side file editing with commit
r1305 try:
moved out commit into scm model, and added cache invalidation after commit.
r1311 self.scm_model.commit_change(repo=c.rhodecode_repo,
repo_name=repo_name, cs=c.cs,
it's safer to user user_id for IMC
r3487 user=self.rhodecode_user.user_id,
moved out commit into scm model, and added cache invalidation after commit.
r1311 author=author, message=message,
content=content, f_path=f_path)
Takumi IINO
i18n improve
r2570 h.flash(_('Successfully committed to %s') % f_path,
Added server side file editing with commit
r1305 category='success')
moved out commit into scm model, and added cache invalidation after commit.
r1311 except Exception:
Added server side file editing with commit
r1305 log.error(traceback.format_exc())
h.flash(_('Error occurred during commit'), category='error')
return redirect(url('changeset_home',
repo_name=c.repo_name, revision='tip'))
return render('files/files_edit.html')
moved login required into seperate calls for files due to optional API access option...
r2457 @LoginRequired()
Added initial support for creating new nodes in repos
r1483 @HasRepoPermissionAnyDecorator('repository.write', 'repository.admin')
def add(self, repo_name, revision, f_path):
Forbid adding files and editing from web interface while repo is locked
r2727
repo = Repository.get_by_repo_name(repo_name)
if repo.enable_locking and repo.locked[0]:
h.flash(_('This repository is has been locked by %s on %s')
% (h.person_by_id(repo.locked[0]),
h.fmt_date(h.time_to_datetime(repo.locked[1]))),
'warning')
return redirect(h.url('files_home',
repo_name=repo_name, revision='tip'))
Added initial support for creating new nodes in repos
r1483 r_post = request.POST
added uploading of files from web interface directly into repo
r1485 c.cs = self.__get_cs_or_redirect(revision, repo_name,
Added initial support for creating new nodes in repos
r1483 redirect_after=False)
if c.cs is None:
c.cs = EmptyChangeset(alias=c.rhodecode_repo.alias)
disable file editing when not on branch head fixes issue #462
r3237 c.default_message = (_('Added file via RhodeCode'))
Added initial support for creating new nodes in repos
r1483 c.f_path = f_path
if r_post:
unix_mode = 0
Added more tests for web based file edit and add
r3839 content = convert_line_endings(r_post.get('content', ''), unix_mode)
Added initial support for creating new nodes in repos
r1483
disable file editing when not on branch head fixes issue #462
r3237 message = r_post.get('message') or c.default_message
added more strict checks for file path in add file controller
r3559 filename = r_post.get('filename')
Added more tests for web based file edit and add
r3839 location = r_post.get('location', '')
added uploading of files from web interface directly into repo
r1485 file_obj = r_post.get('upload_file', None)
if file_obj is not None and hasattr(file_obj, 'filename'):
filename = file_obj.filename
content = file_obj.file
fixes issue #856 file upload >1000 bytes on windows throws exception....
r4072 if hasattr(content, 'file'):
# non posix systems store real file under file attr
content = content.file
Added initial support for creating new nodes in repos
r1483 if not content:
h.flash(_('No content'), category='warning')
return redirect(url('changeset_home', repo_name=c.repo_name,
revision='tip'))
fixed small issues with adding new filenodes
r1484 if not filename:
h.flash(_('No filename'), category='warning')
return redirect(url('changeset_home', repo_name=c.repo_name,
added uploading of files from web interface directly into repo
r1485 revision='tip'))
Implemented simple gist functionality ref #530....
r3840 #strip all crap out of file, just leave the basename
added more strict checks for file path in add file controller
r3559 filename = os.path.basename(filename)
node_path = os.path.join(location, filename)
author = self.rhodecode_user.full_contact
Added initial support for creating new nodes in repos
r1483
try:
Implemented simple gist functionality ref #530....
r3840 nodes = {
node_path: {
'content': content
}
}
self.scm_model.create_nodes(
user=c.rhodecode_user.user_id, repo=c.rhodecode_db_repo,
message=message,
nodes=nodes,
parent_cs=c.cs,
author=author,
)
Takumi IINO
i18n improve
r2570 h.flash(_('Successfully committed to %s') % node_path,
Added initial support for creating new nodes in repos
r1483 category='success')
Implemented simple gist functionality ref #530....
r3840 except NonRelativePathError, e:
h.flash(_('Location must be relative path and must not '
'contain .. in path'), category='warning')
return redirect(url('changeset_home', repo_name=c.repo_name,
revision='tip'))
added more strict checks for file path in add file controller
r3559 except (NodeError, NodeAlreadyExistsError), e:
added uploading of files from web interface directly into repo
r1485 h.flash(_(e), category='error')
Added initial support for creating new nodes in repos
r1483 except Exception:
log.error(traceback.format_exc())
h.flash(_('Error occurred during commit'), category='error')
return redirect(url('changeset_home',
repo_name=c.repo_name, revision='tip'))
return render('files/files_add.html')
moved login required into seperate calls for files due to optional API access option...
r2457 @LoginRequired()
Added server side file editing with commit
r1305 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
implemented #91,...
r872 def archivefile(self, repo_name, fname):
fixed error when trying to make download on empty repository
r945
added branch/tag options to download links in summary
r942 fileformat = None
revision = None
fixed archival in rhodecode to use new functions from vcs
r948 ext = None
fixes #214 added support for downloading subrepos in download menu.
r1450 subrepos = request.GET.get('subrepos') == 'true'
fixed error when trying to make download on empty repository
r945
fixes for vcs settings module
r1480 for a_type, ext_data in settings.ARCHIVE_SPECS.items():
fixed archival in rhodecode to use new functions from vcs
r948 archive_spec = fname.split(ext_data[1])
if len(archive_spec) == 2 and archive_spec[1] == '':
fileformat = a_type or ext_data[1]
added branch/tag options to download links in summary
r942 revision = archive_spec[0]
fixed archival in rhodecode to use new functions from vcs
r948 ext = ext_data[1]
implemented #91,...
r872
try:
another major codes rewrite:...
r1045 dbrepo = RepoModel().get_by_repo_name(repo_name)
Mads Kiilerich
follow Python conventions for boolean values...
r3625 if not dbrepo.enable_downloads:
Mads Kiilerich
Fix a lot of casings - use standard casing in most places
r3654 return _('Downloads disabled')
implemented #84 downloads can be enabled/disabled per each repository from now.
r962
fix archive download for git
r1809 if c.rhodecode_repo.alias == 'hg':
# patch and reset hooks section of UI config to not run any
# hooks on fetching archives with subrepos
for k, v in c.rhodecode_repo._repo.ui.configitems('hooks'):
c.rhodecode_repo._repo.ui.setconfig('hooks', k, None)
fixes issue with mercurial 2.0 and archival of subrepos....
r1664
another major codes rewrite:...
r1045 cs = c.rhodecode_repo.get_changeset(revision)
fixes for vcs settings module
r1480 content_type = settings.ARCHIVE_SPECS[fileformat][0]
implemented #91,...
r872 except ChangesetDoesNotExistError:
return _('Unknown revision %s') % revision
fixed error when trying to make download on empty repository
r945 except EmptyRepositoryError:
return _('Empty repository')
fixed typo in exception
r961 except (ImproperArchiveTypeError, KeyError):
fixed archival in rhodecode to use new functions from vcs
r948 return _('Unknown archive type')
initial version of #788 tarball cache
r3490 # archive cache
from rhodecode import CONFIG
rev_name = cs.raw_id[:12]
archive_name = '%s-%s%s' % (safe_str(repo_name.replace('/', '_')),
safe_str(rev_name), ext)
implemented #91,...
r872
initial version of #788 tarball cache
r3490 use_cached_archive = False # defines if we use cached version of archive
archive_cache_enabled = CONFIG.get('archive_cache_dir')
if not subrepos and archive_cache_enabled:
#check if we it's ok to write
if not os.path.isdir(CONFIG['archive_cache_dir']):
os.makedirs(CONFIG['archive_cache_dir'])
cached_archive_path = os.path.join(CONFIG['archive_cache_dir'], archive_name)
if os.path.isfile(cached_archive_path):
log.debug('Found cached archive in %s' % cached_archive_path)
fd, archive = None, cached_archive_path
use_cached_archive = True
else:
log.debug('Archive %s is not yet cached' % (archive_name))
if not use_cached_archive:
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 # generate new archive
temp_stream = None
initial version of #788 tarball cache
r3490 try:
fd, archive = tempfile.mkstemp()
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 temp_stream = open(archive, 'wb')
initial version of #788 tarball cache
r3490 log.debug('Creating new temp archive in %s' % archive)
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 cs.fill_archive(stream=temp_stream, kind=fileformat, subrepos=subrepos)
if not subrepos and archive_cache_enabled:
initial version of #788 tarball cache
r3490 #if we generated the archive and use cache rename that
log.debug('Storing new archive in %s' % cached_archive_path)
shutil.move(archive, cached_archive_path)
archive = cached_archive_path
finally:
Bradley M. Kuhn
Imported some of the GPLv3'd changes from RhodeCode v2.2.5....
r4116 if temp_stream:
temp_stream.close()
Use paste fileapp to properly send the archive size
r2294
fixes issue #455 Creating an archive generates an exception on Windows...
r2318 def get_chunked_archive(archive):
stream = open(archive, 'rb')
while True:
data = stream.read(16 * 1024)
if not data:
stream.close()
initial version of #788 tarball cache
r3490 if fd: # fd means we used temporary file
os.close(fd)
if not archive_cache_enabled:
log.debug('Destroing temp archive %s' % archive)
os.remove(archive)
fixes issue #455 Creating an archive generates an exception on Windows...
r2318 break
yield data
store download archive actions in journal
r3868 # store download action
action_logger(user=c.rhodecode_user,
action='user_downloaded_archive:%s' % (archive_name),
repo=repo_name, ipaddr=self.ip_addr, commit=True)
initial version of #788 tarball cache
r3490 response.content_disposition = str('attachment; filename=%s' % (archive_name))
fixes issue #455 Creating an archive generates an exception on Windows...
r2318 response.content_type = str(content_type)
return get_chunked_archive(archive)
fixed archival in rhodecode to use new functions from vcs
r948
moved login required into seperate calls for files due to optional API access option...
r2457 @LoginRequired()
Added server side file editing with commit
r1305 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
renamed project to rhodecode
r547 def diff(self, repo_name, f_path):
Added handling of ignore whitespace flag in changesets...
r1752 ignore_whitespace = request.GET.get('ignorews') == '1'
added line context control to diffs
r1768 line_context = request.GET.get('context', 3)
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 diff1 = request.GET.get('diff1', '')
diff2 = request.GET.get('diff2', '')
renamed project to rhodecode
r547 c.action = request.GET.get('diff')
c.no_changes = diff1 == diff2
c.f_path = f_path
Added show as raw into big diff
r1273 c.big_diff = False
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 c.anchor_url = anchor_url
c.ignorews_url = _ignorews_url
c.context_url = _context_url
c.changes = OrderedDict()
c.changes[diff2] = []
fixed issue with show at revision button. Some JS were not properly loaded due to ajaxified files view....
r2931
#special case if we want a show rev only, it's impl here
#to reduce JS and callbacks
Implemented generation of changesets based...
r2995
fixed issue with show at revision button. Some JS were not properly loaded due to ajaxified files view....
r2931 if request.GET.get('show_rev'):
if str2bool(request.GET.get('annotate', 'False')):
_url = url('files_annotate_home', repo_name=c.repo_name,
revision=diff1, f_path=c.f_path)
else:
_url = url('files_home', repo_name=c.repo_name,
revision=diff1, f_path=c.f_path)
return redirect(_url)
renamed project to rhodecode
r547 try:
if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
another major codes rewrite:...
r1045 c.changeset_1 = c.rhodecode_repo.get_changeset(diff1)
Implemented generation of changesets based...
r2995 try:
node1 = c.changeset_1.get_node(f_path)
check if given f_path in diff is not a dir by any chance
r3440 if node1.is_dir():
fixed bad raise statement
r3563 raise NodeError('%s path is a %s not a file'
% (node1, type(node1)))
Implemented generation of changesets based...
r2995 except NodeDoesNotExistError:
c.changeset_1 = EmptyChangeset(cs=diff1,
revision=c.changeset_1.revision,
repo=c.rhodecode_repo)
node1 = FileNode(f_path, '', changeset=c.changeset_1)
renamed project to rhodecode
r547 else:
files: fixes error when passing a diff without parameters and caused server crash...
r1224 c.changeset_1 = EmptyChangeset(repo=c.rhodecode_repo)
Implemented generation of changesets based...
r2995 node1 = FileNode(f_path, '', changeset=c.changeset_1)
Fixes for raw_id, needed for git...
r636
renamed project to rhodecode
r547 if diff2 not in ['', None, 'None', '0' * 12, '0' * 40]:
another major codes rewrite:...
r1045 c.changeset_2 = c.rhodecode_repo.get_changeset(diff2)
Implemented generation of changesets based...
r2995 try:
node2 = c.changeset_2.get_node(f_path)
fixed bad raise statement
r3563 if node2.is_dir():
raise NodeError('%s path is a %s not a file'
% (node2, type(node2)))
Implemented generation of changesets based...
r2995 except NodeDoesNotExistError:
c.changeset_2 = EmptyChangeset(cs=diff2,
revision=c.changeset_2.revision,
repo=c.rhodecode_repo)
node2 = FileNode(f_path, '', changeset=c.changeset_2)
renamed project to rhodecode
r547 else:
files: fixes error when passing a diff without parameters and caused server crash...
r1224 c.changeset_2 = EmptyChangeset(repo=c.rhodecode_repo)
Implemented generation of changesets based...
r2995 node2 = FileNode(f_path, '', changeset=c.changeset_2)
fix error when diff path is a directory, edge case generated by google bots
r3037 except (RepositoryError, NodeError):
Implemented generation of changesets based...
r2995 log.error(traceback.format_exc())
auto white-space removal
r1818 return redirect(url('files_home', repo_name=c.repo_name,
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 f_path=f_path))
renamed project to rhodecode
r547
if c.action == 'download':
moved soon-to-be-deleted code from vcs to rhodecode...
r1753 _diff = diffs.get_gitdiff(node1, node2,
added line context control to diffs
r1768 ignore_whitespace=ignore_whitespace,
context=line_context)
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 diff = diffs.DiffProcessor(_diff, format='gitdiff')
changed raw and download diffs to gitdiff
r1044
renamed project to rhodecode
r547 diff_name = '%s_vs_%s.diff' % (diff1, diff2)
response.content_type = 'text/plain'
fixed raw_changeset for git, accidentally it was generated with hg patch headers...
r2083 response.content_disposition = (
'attachment; filename=%s' % diff_name
)
Implemented generation of changesets based...
r2995 return diff.as_raw()
Fixes for raw_id, needed for git...
r636
renamed project to rhodecode
r547 elif c.action == 'raw':
moved soon-to-be-deleted code from vcs to rhodecode...
r1753 _diff = diffs.get_gitdiff(node1, node2,
added line context control to diffs
r1768 ignore_whitespace=ignore_whitespace,
context=line_context)
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 diff = diffs.DiffProcessor(_diff, format='gitdiff')
fixed raw diff as purly raw without html
r649 response.content_type = 'text/plain'
Implemented generation of changesets based...
r2995 return diff.as_raw()
fixed annotation bug, added history to annotation....
r662
renamed project to rhodecode
r547 else:
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 fid = h.FID(diff2, node2.path)
line_context_lcl = get_line_ctx(fid, request.GET)
ign_whitespace_lcl = get_ignore_ws(fid, request.GET)
memory optimizations, call diffs only when needed ie. after checking for binary, and cutoff limit....
r1149
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 lim = request.GET.get('fulldiff') or self.cut_off_limit
utils/conf...
r2109 _, cs1, cs2, diff, st = diffs.wrapped_diff(filenode_old=node1,
implements #308 rewrote diffs to enable displaying full diff on each file...
r1789 filenode_new=node2,
cut_off_limit=lim,
ignore_whitespace=ign_whitespace_lcl,
line_context=line_context_lcl,
enable_comments=False)
Implemented generation of changesets based...
r2995 op = ''
filename = node1.path
cs_changes = {
'fid': [cs1, cs2, op, filename, diff, st]
}
c.changes = cs_changes
Fixes for raw_id, needed for git...
r636
renamed project to rhodecode
r547 return render('files/file_diff.html')
Fixes for raw_id, needed for git...
r636
Implemented issue #387 side-by-side diffs view
r4043 @LoginRequired()
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
def diff_2way(self, repo_name, f_path):
diff1 = request.GET.get('diff1', '')
diff2 = request.GET.get('diff2', '')
try:
if diff1 not in ['', None, 'None', '0' * 12, '0' * 40]:
c.changeset_1 = c.rhodecode_repo.get_changeset(diff1)
try:
node1 = c.changeset_1.get_node(f_path)
if node1.is_dir():
raise NodeError('%s path is a %s not a file'
% (node1, type(node1)))
except NodeDoesNotExistError:
c.changeset_1 = EmptyChangeset(cs=diff1,
revision=c.changeset_1.revision,
repo=c.rhodecode_repo)
node1 = FileNode(f_path, '', changeset=c.changeset_1)
else:
c.changeset_1 = EmptyChangeset(repo=c.rhodecode_repo)
node1 = FileNode(f_path, '', changeset=c.changeset_1)
if diff2 not in ['', None, 'None', '0' * 12, '0' * 40]:
c.changeset_2 = c.rhodecode_repo.get_changeset(diff2)
try:
node2 = c.changeset_2.get_node(f_path)
if node2.is_dir():
raise NodeError('%s path is a %s not a file'
% (node2, type(node2)))
except NodeDoesNotExistError:
c.changeset_2 = EmptyChangeset(cs=diff2,
revision=c.changeset_2.revision,
repo=c.rhodecode_repo)
node2 = FileNode(f_path, '', changeset=c.changeset_2)
else:
c.changeset_2 = EmptyChangeset(repo=c.rhodecode_repo)
node2 = FileNode(f_path, '', changeset=c.changeset_2)
except (RepositoryError, NodeError):
log.error(traceback.format_exc())
return redirect(url('files_home', repo_name=c.repo_name,
f_path=f_path))
c.node1 = node1
c.node2 = node2
c.cs1 = c.changeset_1
c.cs2 = c.changeset_2
return render('files/diff_2way.html')
Add authors into file view
r2456 def _get_node_history(self, cs, f_path, changesets=None):
Fixed issue when node didn't exists at 'tip' and we tried calculate history based on that assumption....
r2977 """
get changesets history for given node
:param cs: changeset to calculate history
:param f_path: path for node to calculate history for
:param changesets: if passed don't calculate history and take
changesets defined in this list
"""
# calculate history based on tip
tip_cs = c.rhodecode_repo.get_changeset()
Add authors into file view
r2456 if changesets is None:
Fixed issue when node didn't exists at 'tip' and we tried calculate history based on that assumption....
r2977 try:
changesets = tip_cs.get_file_history(f_path)
Let the function calculating changeset history do all the work...
r2981 except (NodeDoesNotExistError, ChangesetError):
Fixed issue when node didn't exists at 'tip' and we tried calculate history based on that assumption....
r2977 #this node is not present at tip !
changesets = cs.get_file_history(f_path)
renamed project to rhodecode
r547 hist_l = []
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
r774
changesets_group = ([], _("Changesets"))
branches_group = ([], _("Branches"))
tags_group = ([], _("Tags"))
remove branch from git filenode history drop-down
r2046 _hg = cs.repository.alias == 'hg'
renamed project to rhodecode
r547 for chs in changesets:
implements #636, lazy loading of history and authors to speed up page responsiveness....
r3001 #_branch = '(%s)' % chs.branch if _hg else ''
_branch = chs.branch
fixed file history tests
r3009 n_desc = 'r%s:%s (%s)' % (chs.revision, chs.short_id, _branch)
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
r774 changesets_group[0].append((chs.raw_id, n_desc,))
hist_l.append(changesets_group)
another major codes rewrite:...
r1045 for name, chs in c.rhodecode_repo.branches.items():
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
r774 branches_group[0].append((chs, name),)
hist_l.append(branches_group)
another major codes rewrite:...
r1045 for name, chs in c.rhodecode_repo.tags.items():
added tags, and branches to file history select box, fixed annotation changeset errors crash on wrongly given revions
r774 tags_group[0].append((chs, name),)
hist_l.append(tags_group)
fixed file history tests
r3009
Let the function calculating changeset history do all the work...
r2981 return hist_l, changesets
Implemented #111 copy github node finder solution
r1452
moved login required into seperate calls for files due to optional API access option...
r2457 @LoginRequired()
Implemented #111 copy github node finder solution
r1452 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
'repository.admin')
moved login required into seperate calls for files due to optional API access option...
r2457 @jsonify
Implemented #111 copy github node finder solution
r1452 def nodelist(self, repo_name, revision, f_path):
if request.environ.get('HTTP_X_PARTIAL_XHR'):
cs = self.__get_cs_or_redirect(revision, repo_name)
implements #330 api method for listing nodes at particular revision...
r1810 _d, _f = ScmModel().get_nodes(repo_name, cs.raw_id, f_path,
flat=False)
removed JSON array envelope from filter files function...
r2428 return {'nodes': _d + _f}