Compare commits

..

5 Commits

Author SHA1 Message Date
Markus Heidelberg 4bc9022afc 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>
1 year ago
Elijah Newren c8767ea56c Merge branch 'nz/clarify-design-rationale'
Signed-off-by: Elijah Newren <newren@gmail.com>
1 year ago
Nicolas Josef Zunker 1fabaa3cf8 README: clarify design rationale
Signed-off-by: Nicolas Josef Zunker <n.zunker@campus.tu-berlin.de>
1 year ago
Elijah Newren 52a9d7ed19 README.md: guide example-oriented learners to the examples
Signed-off-by: Elijah Newren <newren@gmail.com>
1 year ago
Elijah Newren 6d992c2272 README.md: tell windows user to read docs instead of taking random guesses
Windows users do not understand "just place the script into your $PATH",
but surprisingly decide that means they should take random guesses as to
what that means instead of reading the linked page that explains it in
more detail...and then complain that it was hard to figure out.

Make it clear that if they don't understand that statement, they also
should read the more detailed explanation page.

Signed-off-by: Elijah Newren <newren@gmail.com>
1 year ago

@ -308,7 +308,7 @@ But this comes with some nasty caveats and limitations:
# Design rationale behind filter-repo
None of the existing repository filtering tools did what I wanted;
they all came up short for my needs. No tool provided any of the
they all came up short for my needs. No tool provided any of the
first eight traits below I wanted, and no tool provided more than
two of the last four traits either:

@ -254,6 +254,21 @@ def get_absolute_svn_url(svnext_url, svn_root_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):
"""
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
if parsed_config.has_option(section, 'revision'):
svn_rev = int(parsed_config[section]['revision'])
svn_rev = parse_revision_value(parsed_config[section]['revision'])
else:
# TODO: revision has to be guessed according to commit timestamp, skip for now
return False

Loading…
Cancel
Save