Git::SVN: use accessors internally for path

Then later it can be canonicalized automatically rather than everywhere
its used.

Later patch will make other things use it.

[ew: commit title, reformatted accessor to match existing style]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Git::SVN: use accessor for URLs internally

So later it can do automatic canonicalization.

A later patch will make other things use the accessor.

No functional change here.

[ew: commit title]
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Git::SVN::Ra: use accessor for URLs

Later it can canonicalize automatically.

A later change will make other things use the accessor.

No functional change.

[ew: commit title, reformatted accessor to match existing style]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
use Git::SVN->path accessor globally

No functional change.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
use Git::SVN{,::RA}->url accessor globally

Note: The structure returned from Git::SVN->read_all_remotes() does not
appear to contain objects, so I'm leaving them alone.

That's everything converted over to the url and path accessors.

No functional change.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: move canonicalization to Git::SVN::Utils

So they can be used by others.

I'd like to test them, but they're going to become SVN API wrappers shortly
and those aren't predictable.

No functional change.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: use SVN 1.7 to canonicalize when possible

No change on SVN 1.6.  The tests all pass with SVN 1.6 if
canonicalize_url() does nothing, so tests passing doesn't have
much meaning.

The tests are so messed up right now with SVN 1.7 it isn't really
useful to check.  They will be useful later.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: factor out _collapse_dotdot function

The SVN API functions will not accept ../foo but their canonicalization
functions will not collapse it.  So we'll have to do it ourselves.

_collapse_dotdot() works better than the existing regex did.

This will be used shortly when canonicalize_path() starts using the
SVN API.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: add join_paths() to safely concatenate paths

Otherwise you might wind up with things like...

    my $path1 = undef;
    my $path2 = 'foo';
    my $path = $path1 . '/' . $path2;

creating '/foo'.  Or this...

    my $path1 = 'foo/';
    my $path2 = 'bar';
    my $path = $path1 . '/' . $path2;

creating 'foo//bar'.

Could have used File::Spec, but I'm shying away from it due to SVN
1.7's pickiness about paths.  Felt it would be better to have our own
we can control completely.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Git::SVN::Utils: remove irrelevant comment

The code doesn't use File::Spec.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: path canonicalization uses SVN API

All tests pass with SVN 1.6.  SVN 1.7 remains broken, not worrying
about it yet.

SVN changed its path canonicalization API between 1.6 and 1.7.
http://svnbook.red-bean.com/en/1.6/svn.developer.usingapi.html#svn.developer.usingapi.urlpath
http://svnbook.red-bean.com/en/1.7/svn.developer.usingapi.html#svn.developer.usingapi.urlpath

The SVN API does not accept foo/.. but it also doesn't canonicalize
it.  We have to do it ourselves.

[ew: commit title, fall back if SVN <= 1.6 fails to canonicalize]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Git::SVN{,::Ra}: canonicalize earlier

This canonicalizes paths and urls as early as possible so we don't
have to remember to do it at the point of use.  It will fix a swath
of SVN 1.7 problems in one go.

Its ok to double canonicalize things.

SVN 1.7 still fails, still not worrying about that.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
t9118: workaround inconsistency between SVN versions

SVN 1.7 will truncate "not-a%40{0}" to just "not-a".

Rather than guess what SVN is going to do for each version, make the test use
the branch name that was actually created.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
t9107: fix typo

Test to check that the migration got rid of the old style git-svn directory.
It wasn't failing, just throwing a message to STDERR.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: attempt to mimic SVN 1.7 URL canonicalization

Previously, our URL canonicalization didn't do much of anything.
Now it actually escapes and collapses slashes.  This is mostly a cut & paste
of escape_url from git-svn.

This is closer to how SVN 1.7's canonicalization behaves.  Doing it with
1.6 lets us chase down some problems caused by more effective canonicalization
without having to deal with all the other 1.7 issues on top of that.

* Remote URLs have to be canonicalized otherwise Git::SVN->find_existing_remote
  will think they're different.

* The SVN remote is now written to the git config canonicalized.  That
  should be ok.  Adjust a test to account for that.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: replace URL escapes with canonicalization

The old hand-rolled URL escape functions were inferior to
canonicalization functions.

Continuing to move towards getting everything canonicalizing the same way.

* Git::SVN->init_remote_config and Git::SVN::Ra->minimize_url both
  have to canonicalize the same way else init_remote_config
  will incorrectly think they're different URLs causing
  t9107-git-svn-migrate.sh to fail.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: canonicalize earlier

Just a few things I noticed.  Its good to canonicalize as early as
possible.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: introduce add_path_to_url function

Remove the ad-hoc versions.

This is mostly to normalize the process and ensure the URLs produced
don't have double slashes or anything.

Also provides a place to fix the corner case where a file path
contains a percent sign.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: canonicalize newly-minted URLs

Go through all the spots that use the new add_path_to_url() to
make a new URL and canonicalize them.

* copyfrom_path has to be canonicalized else find_parent_branch
  will get confused

* due to the `canonicalize_url($full_url) ne $full_url)` line of
  logic in gs_do_switch(), $full_url is left alone until after.

At this point SVN 1.7 passes except for 3 tests in
t9100-git-svn-basic.sh that look like an SVN bug to do with
symlinks.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn: remove ad-hoc canonicalizations

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>