Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/svn.py
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | ): | |||||||||||||||||||||||||
local_name = os.path.basename(self.remote_url) | local_name = os.path.basename(self.remote_url) | |||||||||||||||||||||||||
self.local_url = os.path.join(self.local_dirname, local_name).encode("utf-8") | self.local_url = os.path.join(self.local_dirname, local_name).encode("utf-8") | |||||||||||||||||||||||||
self.uuid = self.conn.get_uuid().encode("utf-8") | self.uuid = self.conn.get_uuid().encode("utf-8") | |||||||||||||||||||||||||
self.swhreplay = ra.Replay( | self.swhreplay = ra.Replay( | |||||||||||||||||||||||||
conn=self.conn, rootpath=self.local_url, svnrepo=self | conn=self.conn, rootpath=self.local_url, svnrepo=self | |||||||||||||||||||||||||
) | ) | |||||||||||||||||||||||||
self.max_content_length = max_content_length | self.max_content_length = max_content_length | |||||||||||||||||||||||||
self.has_externals = False | ||||||||||||||||||||||||||
self.replay_started = False | ||||||||||||||||||||||||||
def __str__(self): | def __str__(self): | |||||||||||||||||||||||||
return str( | return str( | |||||||||||||||||||||||||
{ | { | |||||||||||||||||||||||||
"swh-origin": self.origin_url, | "swh-origin": self.origin_url, | |||||||||||||||||||||||||
"remote_url": self.remote_url, | "remote_url": self.remote_url, | |||||||||||||||||||||||||
"local_url": self.local_url, | "local_url": self.local_url, | |||||||||||||||||||||||||
"uuid": self.uuid, | "uuid": self.uuid, | |||||||||||||||||||||||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | def export_temporary(self, revision: int) -> Tuple[str, bytes]: | |||||||||||||||||||||||||
Returns: | Returns: | |||||||||||||||||||||||||
The tuple local_dirname the temporary location root | The tuple local_dirname the temporary location root | |||||||||||||||||||||||||
folder, local_url where the repository was exported. | folder, local_url where the repository was exported. | |||||||||||||||||||||||||
""" | """ | |||||||||||||||||||||||||
local_dirname = tempfile.mkdtemp( | local_dirname = tempfile.mkdtemp( | |||||||||||||||||||||||||
dir=self.local_dirname, prefix=f"check-revision-{revision}." | dir=self.local_dirname, prefix=f"check-revision-{revision}." | |||||||||||||||||||||||||
) | ) | |||||||||||||||||||||||||
local_name = os.path.basename(self.remote_url) | local_name = os.path.basename(self.remote_url) | |||||||||||||||||||||||||
local_url = os.path.join(local_dirname, local_name) | local_url = os.path.join(local_dirname, local_name) | |||||||||||||||||||||||||
url = self.remote_url | ||||||||||||||||||||||||||
# if some paths have svn:externals property set, we need to export from | ||||||||||||||||||||||||||
# the origin URL as external URLs can be relative to it and the remote | ||||||||||||||||||||||||||
# URL can target a dump mounted on the local filesystem | ||||||||||||||||||||||||||
if self.has_externals: | ||||||||||||||||||||||||||
# externals detected while replaying revisions | ||||||||||||||||||||||||||
url = self.origin_url | ||||||||||||||||||||||||||
elif not self.replay_started and self.remote_url.startswith("file://"): | ||||||||||||||||||||||||||
# revisions replay has not started, we need to check if svn:externals | ||||||||||||||||||||||||||
# properties are set from a checkout of the revision | ||||||||||||||||||||||||||
co_dirname = tempfile.mkdtemp( | ||||||||||||||||||||||||||
dir=self.local_dirname, prefix=f"checkout-revision-{revision}." | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
self.client.checkout( | ||||||||||||||||||||||||||
self.remote_url, co_dirname, revision, ignore_externals=True | ||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||
# get all svn:externals properties recursively | ||||||||||||||||||||||||||
if self.client.propget("svn:externals", co_dirname, None, revision, True): | ||||||||||||||||||||||||||
url = self.origin_url | ||||||||||||||||||||||||||
shutil.rmtree(co_dirname) | ||||||||||||||||||||||||||
vlorentzUnsubmitted Not Done Inline Actions
vlorentz: | ||||||||||||||||||||||||||
self.client.export( | self.client.export( | |||||||||||||||||||||||||
self.remote_url, to=local_url, rev=revision, ignore_keywords=True | url.rstrip("/"), to=local_url, rev=revision, ignore_keywords=True, | |||||||||||||||||||||||||
) | ) | |||||||||||||||||||||||||
return local_dirname, os.fsencode(local_url) | return local_dirname, os.fsencode(local_url) | |||||||||||||||||||||||||
def swh_hash_data_per_revision( | def swh_hash_data_per_revision( | |||||||||||||||||||||||||
self, start_revision: int, end_revision: int | self, start_revision: int, end_revision: int | |||||||||||||||||||||||||
) -> Iterator[ | ) -> Iterator[ | |||||||||||||||||||||||||
Tuple[ | Tuple[ | |||||||||||||||||||||||||
int, | int, | |||||||||||||||||||||||||
Show All 20 Lines | ]: | |||||||||||||||||||||||||
- objects_per_path: Tuple of list of objects between start_revision and | - objects_per_path: Tuple of list of objects between start_revision and | |||||||||||||||||||||||||
end_revision | end_revision | |||||||||||||||||||||||||
- complete Directory representation | - complete Directory representation | |||||||||||||||||||||||||
""" | """ | |||||||||||||||||||||||||
# 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 | ||||||||||||||||||||||||||
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) | objects = self.swhreplay.compute_objects(rev) | |||||||||||||||||||||||||
if rev == end_revision: | if rev == end_revision: | |||||||||||||||||||||||||
nextrev = None | nextrev = None | |||||||||||||||||||||||||
else: | else: | |||||||||||||||||||||||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |