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

@ -44,40 +44,44 @@ filter-repo requires:
# How do I install it?
git-filter-repo is a single-file python script, which was done to make
installation for basic use on many systems trivial: just place the
script into your $PATH.
`git-filter-repo` is a single-file python script, which was done to make
installation for basic use on many systems trivial: just place that
file into your $PATH.
See [INSTALL.md](INSTALL.md) for things beyond basic usage or special
cases. The more involved instructions are only needed if you
* are working with a python3 executable named something other than "python3"
* want to install documentation (beyond the builtin docs shown with -h)
* want to run some of the [contrib](contrib/filter-repo-demos/) examples
* want to create your own python filtering scripts using filter-repo as a
module/library
cases. The more involved instructions are only needed if one of the
following apply:
* you do not find the above comment about trivial installation intuitively
obvious
* you are working with a python3 executable named something other than
"python3"
* you want to install documentation (beyond the builtin docs shown with -h)
* you want to run some of the [contrib](contrib/filter-repo-demos/) examples
* you want to create your own python filtering scripts using filter-repo as
a module/library
# How do I use it?
See the [user
manual](https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html).
For comprehensive documentation:
* see the [user manual](https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html)
* alternative formating of the user manual is available on various
external sites
([example](https://www.mankier.com/1/git-filter-repo)), for those
that don't like the htmlpreview.github.io layout, though it may
only be up-to-date as of the latest release
If you prefer learning from examples:
* the [simple example](#simple-example-with-comparisons) below may
be of interest
* the user manual has an extensive [examples
section](https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#EXAMPLES)
* there is a [cheat sheet for converting filter-branch
commands](Documentation/converting-from-filter-branch.md#cheat-sheet-conversion-of-examples-from-the-filter-branch-manpage),
which covers every example from the filter-branch manual
* there is a [cheat sheet for converting BFG Repo Cleaner
commands](Documentation/converting-from-bfg-repo-cleaner.md#cheat-sheet-conversion-of-examples-from-bfg),
which covers every example from the BFG website
External sites also have [alternative formats of the user
manual](https://www.mankier.com/1/git-filter-repo) available, at least
for the most recent release. This also may be beneficial if
htmlpreview.github.io starts hitting load limits.
* the [simple example](#simple-example-with-comparisons) below may
be of interest
* the user manual has an extensive [examples
section](https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#EXAMPLES)
# Why filter-repo instead of other alternatives?
@ -304,9 +308,9 @@ 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
first eight traits below I wanted, and all failed to provide at least
one of the last four traits as well:
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:
1. [Starting report] Provide user an analysis of their repo to help
them get started on what to prune or rename, instead of expecting

@ -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