Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/svn.py
Show First 20 Lines • Show All 214 Lines • ▼ Show 20 Lines | def __to_entry(self, log_entry: Tuple) -> Dict: | ||||
) | ) | ||||
return { | return { | ||||
"rev": rev, | "rev": rev, | ||||
"author_date": author_date, | "author_date": author_date, | ||||
"author_name": author, | "author_name": author, | ||||
"message": message, | "message": message, | ||||
"has_changes": has_changes, | "has_changes": has_changes, | ||||
"changed_paths": changed_paths, | |||||
} | } | ||||
def logs(self, revision_start: int, revision_end: int) -> Iterator[Dict]: | def logs(self, revision_start: int, revision_end: int) -> Iterator[Dict]: | ||||
"""Stream svn logs between revision_start and revision_end by chunks of | """Stream svn logs between revision_start and revision_end by chunks of | ||||
block_size logs. | block_size logs. | ||||
Yields revision and associated revision information between the | Yields revision and associated revision information between the | ||||
revision start and revision_end. | revision start and revision_end. | ||||
Show All 13 Lines | def logs(self, revision_start: int, revision_end: int) -> Iterator[Dict]: | ||||
- author_name: name of the author | - author_name: name of the author | ||||
- message: commit message | - message: commit message | ||||
""" | """ | ||||
for log_entry in self.conn_log.iter_log( | for log_entry in self.conn_log.iter_log( | ||||
paths=None, | paths=None, | ||||
start=revision_start, | start=revision_start, | ||||
end=revision_end, | end=revision_end, | ||||
discover_changed_paths=self.from_dump, | discover_changed_paths=True, | ||||
): | ): | ||||
yield self.__to_entry(log_entry) | yield self.__to_entry(log_entry) | ||||
@svn_retry() | @svn_retry() | ||||
def commit_info(self, revision: int) -> Optional[Dict]: | def commit_info(self, revision: int) -> Optional[Dict]: | ||||
"""Return commit information. | """Return commit information. | ||||
Args: | Args: | ||||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | ]: | ||||
""" | """ | ||||
# even in incremental loading mode, we need to replay the whole set of | # even in incremental loading mode, we need to replay the whole set of | ||||
# path modifications from first revision to restore possible file states induced | # path modifications from first revision to restore possible file states induced | ||||
# by setting svn properties on those files (end of line style for instance) | # by setting svn properties on those files (end of line style for instance) | ||||
self.replay_started = True | self.replay_started = True | ||||
first_revision = 1 if start_revision else 0 # handle empty repository edge case | first_revision = 1 if start_revision else 0 # handle empty repository edge case | ||||
for commit in self.logs(first_revision, end_revision): | for commit in self.logs(first_revision, end_revision): | ||||
rev = commit["rev"] | rev = commit["rev"] | ||||
objects = self.swhreplay.compute_objects(rev) | copyfrom_revs = ( | ||||
[ | |||||
copyfrom_rev | |||||
for (_, _, copyfrom_rev, _) in commit["changed_paths"].values() | |||||
if copyfrom_rev != -1 | |||||
] | |||||
if commit["changed_paths"] | |||||
else None | |||||
) | |||||
low_water_mark = rev + 1 | |||||
if copyfrom_revs: | |||||
# when files or directories in the revision to replay have been copied from | |||||
# ancestor revisions, we need to adjust the low water mark revision used by | |||||
# svn replay API to handle the copies in our commit editor and to ensure | |||||
# replace operations after copy will be replayed | |||||
low_water_mark = min(copyfrom_revs) | |||||
objects = self.swhreplay.compute_objects(rev, low_water_mark) | |||||
if rev >= start_revision: | if rev >= start_revision: | ||||
# start yielding new data to archive once we reached the revision to | # start yielding new data to archive once we reached the revision to | ||||
# resume the loading from | # resume the loading from | ||||
if commit["has_changes"] or start_revision == 0: | if commit["has_changes"] or start_revision == 0: | ||||
# yield data only if commit has changes or if repository is empty | # yield data only if commit has changes or if repository is empty | ||||
root_dir_path = self.root_directory.encode()[1:] | root_dir_path = self.root_directory.encode()[1:] | ||||
if not root_dir_path or root_dir_path in self.swhreplay.directory: | if not root_dir_path or root_dir_path in self.swhreplay.directory: | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |