Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/loader.py
Show First 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | def _init_from(self, partial_swh_revision, previous_swh_revision): | ||||
""" | """ | ||||
if partial_swh_revision and not previous_swh_revision: | if partial_swh_revision and not previous_swh_revision: | ||||
return partial_swh_revision | return partial_swh_revision | ||||
if not partial_swh_revision and previous_swh_revision: | if not partial_swh_revision and previous_swh_revision: | ||||
return previous_swh_revision | return previous_swh_revision | ||||
if partial_swh_revision and previous_swh_revision: | if partial_swh_revision and previous_swh_revision: | ||||
# will determine from which to start from | # will determine from which to start from | ||||
extra_headers1 = dict(partial_swh_revision["metadata"]["extra_headers"]) | extra_headers1 = dict(partial_swh_revision["extra_headers"]) | ||||
extra_headers2 = dict(previous_swh_revision["metadata"]["extra_headers"]) | extra_headers2 = dict(previous_swh_revision["extra_headers"]) | ||||
rev_start1 = int(extra_headers1["svn_revision"]) | rev_start1 = int(extra_headers1[b"svn_revision"]) | ||||
rev_start2 = int(extra_headers2["svn_revision"]) | rev_start2 = int(extra_headers2[b"svn_revision"]) | ||||
if rev_start1 <= rev_start2: | if rev_start1 <= rev_start2: | ||||
return previous_swh_revision | return previous_swh_revision | ||||
return partial_swh_revision | return partial_swh_revision | ||||
return None | return None | ||||
def start_from(self, last_known_swh_revision=None, start_from_scratch=False): | def start_from(self, last_known_swh_revision=None, start_from_scratch=False): | ||||
"""Determine from where to start the loading. | """Determine from where to start the loading. | ||||
Show All 30 Lines | def start_from(self, last_known_swh_revision=None, start_from_scratch=False): | ||||
swh_rev = None | swh_rev = None | ||||
# Determine from which known revision to start | # Determine from which known revision to start | ||||
swh_rev = self._init_from( | swh_rev = self._init_from( | ||||
last_known_swh_revision, previous_swh_revision=swh_rev | last_known_swh_revision, previous_swh_revision=swh_rev | ||||
) | ) | ||||
if swh_rev: # Yes, we know a previous revision. Try and update it. | if swh_rev: # Yes, we know a previous revision. Try and update it. | ||||
extra_headers = dict(swh_rev["metadata"]["extra_headers"]) | extra_headers = dict(swh_rev["extra_headers"]) | ||||
revision_start = int(extra_headers["svn_revision"]) | revision_start = int(extra_headers[b"svn_revision"]) | ||||
revision_parents = { | revision_parents = { | ||||
revision_start: swh_rev["parents"], | revision_start: swh_rev["parents"], | ||||
} | } | ||||
self.log.debug( | self.log.debug( | ||||
"svn export --ignore-keywords %s@%s" | "svn export --ignore-keywords %s@%s" | ||||
% (self.svnrepo.remote_url, revision_start) | % (self.svnrepo.remote_url, revision_start) | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 338 Lines • ▼ Show 20 Lines | def get_last_loaded_svn_rev(self, svn_url): | ||||
Check if the svn repository has already been visited | Check if the svn repository has already been visited | ||||
and return the last loaded svn revision number or -1 | and return the last loaded svn revision number or -1 | ||||
otherwise. | otherwise. | ||||
""" | """ | ||||
last_loaded_svn_rev = -1 | last_loaded_svn_rev = -1 | ||||
try: | try: | ||||
origin = self.storage.origin_get({"url": svn_url}) | origin = self.storage.origin_get({"url": svn_url}) | ||||
last_swh_rev = self.swh_latest_snapshot_revision(origin["url"])["revision"] | last_swh_rev = self.swh_latest_snapshot_revision(origin["url"])["revision"] | ||||
last_swh_rev_headers = dict(last_swh_rev["metadata"]["extra_headers"]) | last_swh_rev_headers = dict(last_swh_rev["extra_headers"]) | ||||
last_loaded_svn_rev = int(last_swh_rev_headers["svn_revision"]) | last_loaded_svn_rev = int(last_swh_rev_headers[b"svn_revision"]) | ||||
except Exception: | except Exception: | ||||
pass | pass | ||||
return last_loaded_svn_rev | return last_loaded_svn_rev | ||||
def dump_svn_revisions(self, svn_url, last_loaded_svn_rev=-1): | def dump_svn_revisions(self, svn_url, last_loaded_svn_rev=-1): | ||||
""" | """ | ||||
Generate a subversion dump file using the svnrdump tool. | Generate a subversion dump file using the svnrdump tool. | ||||
If the svnrdump command failed somehow, | If the svnrdump command failed somehow, | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |