mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-09-24 00:01:05 +02:00
convert-svnexternals: fix parsing of wrongly transformed SVN revisions
SVN revision numbers from svn:externals property, which are a multiple of 1024 (2^10), are transformed by SubGit to contain a binary suffix ("k", "m" and "g" have been checked) in .gitsvnextmodules file. These aren't valid revision numbers in SVN either. Examples: 1024 -> 1k 2048 -> 2k 1048576 -> 1m 1049600 -> 1025k 1073741824 -> 1g This led to the following error: svn_rev = int(parsed_config[section]['revision']) ValueError: invalid literal for int() with base 10: '1k' Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de> Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
c8767ea56c
commit
4bc9022afc
|
@ -254,6 +254,21 @@ def get_absolute_svn_url(svnext_url, svn_root_url):
|
||||||
|
|
||||||
return True, svnext_url
|
return True, svnext_url
|
||||||
|
|
||||||
|
def parse_revision_value(value):
|
||||||
|
"""
|
||||||
|
Parse the value of key 'revision' from a .gitsvnextmodules file and return it
|
||||||
|
as integer.
|
||||||
|
|
||||||
|
Used to handle non-numeric values like 1k, 2k, 3k etc. added by SubGit
|
||||||
|
instead of 1024, 2048, 3072 etc., likewise 1m, 2m, ..., 1g, ...
|
||||||
|
"""
|
||||||
|
suffix = value[-1]
|
||||||
|
if suffix in "kmg":
|
||||||
|
mult = {"k": 1024, "m": 1024**2, "g": 1024**3}
|
||||||
|
return int(value[0:-1]) * mult[suffix]
|
||||||
|
else:
|
||||||
|
return int(value)
|
||||||
|
|
||||||
def add_submodule_tree_entry(commit, parsed_config, section):
|
def add_submodule_tree_entry(commit, parsed_config, section):
|
||||||
"""
|
"""
|
||||||
Add a submodule entry to the tree of a Git commit.
|
Add a submodule entry to the tree of a Git commit.
|
||||||
|
@ -271,7 +286,7 @@ def add_submodule_tree_entry(commit, parsed_config, section):
|
||||||
|
|
||||||
# Get SVN revision
|
# Get SVN revision
|
||||||
if parsed_config.has_option(section, 'revision'):
|
if parsed_config.has_option(section, 'revision'):
|
||||||
svn_rev = int(parsed_config[section]['revision'])
|
svn_rev = parse_revision_value(parsed_config[section]['revision'])
|
||||||
else:
|
else:
|
||||||
# TODO: revision has to be guessed according to commit timestamp, skip for now
|
# TODO: revision has to be guessed according to commit timestamp, skip for now
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user