##// END OF EJS Templates
Added tag v4.14.1 for changeset a47eeac5dfa4
Added tag v4.14.1 for changeset a47eeac5dfa4

File last commit:

r2487:fcee5614 default
r3205:fd4b2bf5 stable
Show More
105 lines | 3.8 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2018 RhodeCode GmbH
# 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
# 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
from rhodecode.lib.utils import safe_str
from rhodecode.lib.vcs.backends import base
class GitInMemoryCommit(base.BaseInMemoryCommit):
def commit(self, message, author, parents=None, branch=None, date=None,
Performs in-memory commit (doesn't check workdir in any way) and
returns newly created `GitCommit`. Updates repository's
: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
:param branch: branch name, as string. If none given, default backend's
branch would be used.
:raises `CommitError`: if any error occurs while committing
if branch is None:
branch = self.repository.DEFAULT_BRANCH_NAME
commit_tree = None
if self.parents[0]:
commit_tree = self.parents[0]._commit['tree']
updated = []
for node in self.added + self.changed:
if not node.is_binary:
content = node.content.encode(ENCODING)
content = node.content
'path': node.path,
'node_path': node.name.encode(ENCODING),
'content': content,
'mode': node.mode,
removed = [node.path for node in self.removed]
date, tz = date_to_timestamp_plus_offset(date)
# TODO: johbo: Make kwargs explicit and check if this is needed.
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),
'encoding': ENCODING,
'message': safe_str(message),
'commit_time': int(date),
'author_time': int(author_time),
'commit_timezone': tz,
'author_timezone': author_tz,
commit_id = self.repository._remote.commit(
commit_data, branch, commit_tree, updated, removed)
# Update vcs repository object
# invalidate parsed refs after commit
self.repository._refs = self.repository._get_refs()
self.repository.branches = self.repository._get_branches()
tip = self.repository.get_commit()
return tip