##// END OF EJS Templates
fix(jupyter): adopted to support more formats. Fixes: RCCE-38
fix(jupyter): adopted to support more formats. Fixes: RCCE-38

File last commit:

r5091:9ce86a18 default
r5273:5af2b517 default
Show More
inmemory.py
105 lines | 3.8 KiB | text/x-python | PythonLexer
copyrights: updated for 2023
r5088 # Copyright (C) 2014-2023 RhodeCode GmbH
project: added all source files and assets
r1 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# 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.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
"""
GIT inmemory module
"""
from rhodecode.lib.datelib import date_to_timestamp_plus_offset
vcs-lib: bulk of changes for python3 support
r5074 from rhodecode.lib.str_utils import safe_str, get_default_encodings
project: added all source files and assets
r1 from rhodecode.lib.vcs.backends import base
class GitInMemoryCommit(base.BaseInMemoryCommit):
commits: updated logic of in-memory-commits, fixed tests and re-architectured a bit how commit_ids are calculated and updated....
r3743 def commit(self, message, author, parents=None, branch=None, date=None, **kwargs):
project: added all source files and assets
r1 """
Performs in-memory commit (doesn't check workdir in any way) and
returns newly created `GitCommit`. Updates repository's
`commit_ids`.
:param message: message of the commit
:param author: full username, i.e. "Joe Doe <joe.doe@example.com>"
:param parents: single parent or sequence of parents from which commit
would be derived
:param date: `datetime.datetime` instance. Defaults to
``datetime.datetime.now()``.
:param branch: branch name, as string. If none given, default backend's
branch would be used.
:raises `CommitError`: if any error occurs while committing
"""
self.check_integrity(parents)
if branch is None:
branch = self.repository.DEFAULT_BRANCH_NAME
commit_tree = None
if self.parents[0]:
commit_tree = self.parents[0]._commit['tree']
vcs-lib: bulk of changes for python3 support
r5074 encoding = get_default_encodings()[0]
project: added all source files and assets
r1 updated = []
for node in self.added + self.changed:
vcs-lib: bulk of changes for python3 support
r5074 content = node.content
# TODO: left for reference pre py3 migration, probably need to be removed
# if node.is_binary:
# content = node.content
# else:
# content = node.content.encode(ENCODING)
dan
vcsserver: made binary content check be calculated on vcsserver...
r3896
project: added all source files and assets
r1 updated.append({
'path': node.path,
vcs-lib: bulk of changes for python3 support
r5074 'node_path': node.name,
project: added all source files and assets
r1 'content': content,
'mode': node.mode,
})
removed = [node.path for node in self.removed]
date, tz = date_to_timestamp_plus_offset(date)
author_time = kwargs.pop('author_time', date)
author_tz = kwargs.pop('author_timezone', tz)
commit_data = {
'parents': [p._commit['id'] for p in self.parents if p],
'author': safe_str(author),
'committer': safe_str(author),
vcs-lib: bulk of changes for python3 support
r5074 'encoding': encoding,
project: added all source files and assets
r1 'message': safe_str(message),
vcs-lib: bulk of changes for python3 support
r5074
project: added all source files and assets
r1 'commit_time': int(date),
vcs-lib: bulk of changes for python3 support
r5074 'commit_timezone': tz,
project: added all source files and assets
r1 'author_time': int(author_time),
'author_timezone': author_tz,
}
commit_id = self.repository._remote.commit(
commit_data, branch, commit_tree, updated, removed)
# Update vcs repository object
commits: updated logic of in-memory-commits, fixed tests and re-architectured a bit how commit_ids are calculated and updated....
r3743 self.repository.append_commit_id(commit_id)
project: added all source files and assets
r1
# invalidate parsed refs after commit
dan
vcs: change way refs are retrieved for git so same name branch/tags...
r784 self.repository._refs = self.repository._get_refs()
project: added all source files and assets
r1 self.repository.branches = self.repository._get_branches()
commits: updated logic of in-memory-commits, fixed tests and re-architectured a bit how commit_ids are calculated and updated....
r3743 tip = self.repository.get_commit(commit_id)
project: added all source files and assets
r1 self.reset()
return tip