##// END OF EJS Templates
fix(submodules): fixed an error if reaching out submodule path....
fix(submodules): fixed an error if reaching out submodule path. - small UI fixes - cleanups of submodule code

File last commit:

r5091:9ce86a18 default
r5261:550d6219 default
Show More
inmemory.py
94 lines | 3.6 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/
"""
HG 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
project: added all source files and assets
r1 from rhodecode.lib.vcs.backends.base import BaseInMemoryCommit
from rhodecode.lib.vcs.exceptions import RepositoryError
class MercurialInMemoryCommit(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 `MercurialCommit`. 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: Optional. Branch name as unicode. Will use the backend's
default if not given.
:raises `RepositoryError`: if any error occurs while committing
"""
self.check_integrity(parents)
python3: more unicode fixes
r4961 if not isinstance(message, str) or not isinstance(author, str):
project: added all source files and assets
r1 # TODO: johbo: Should be a TypeError
python3: more unicode fixes
r4961 raise RepositoryError(
f'Given message and author needs to be '
f'an <str> instance got {type(message)} & {type(author)} instead'
)
project: added all source files and assets
r1
if branch is None:
branch = self.repository.DEFAULT_BRANCH_NAME
kwargs['branch'] = safe_str(branch)
message = safe_str(message)
author = safe_str(author)
parent_ids = [p.raw_id if p else None for p in self.parents]
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)
project: added all source files and assets
r1 updated.append({
'path': node.path,
'content': content,
'mode': node.mode,
})
removed = [node.path for node in self.removed]
date, tz = date_to_timestamp_plus_offset(date)
commits: re-implemented fetching a single commit for git case....
r3740 commit_id = self.repository._remote.commitctx(
project: added all source files and assets
r1 message=message, parents=parent_ids,
commit_time=date, commit_timezone=tz, user=author,
files=self.get_paths(), extra=kwargs, removed=removed,
updated=updated)
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
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