Commit Graph

8693 Commits

Author SHA1 Message Date
Eric Wong
befc9adc0c git-svn: fix useSvmProps, hopefully for the last time
svm:mirror is not useful at all for us.  Parts of the old unit
test were broken and based on my misunderstanding of the
svm:mirror property.

When we read svm:source; make sure we correctly handle the '!'
in it: it is used to separate the path of the repository root
from the virtual path within the repository.  We don't need
to make that distinction, honestly!

We also ensure that subdirectories are also mirrored with the
correct URL if we're using useSvmProps.

We have a new test that uses dumped repo that was really
created using SVN::Mirror to avoid ambiguities and
mis-understandings about the svm: properties.

Note: trailing whitespace in the svm.dump file is unfortunately
a reality and required by SVN; so please ignore it when applying
this patch.

Also, ensure that the -R/--remote/--svn-remote flag is always
in effect if explicitly passed via the command-line.  This
allows us to track logically different mirrors sharing the
same URL (probably common with SVN::Mirror/SVK users).

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
62e349d235 git-svn: add support for using svnsync properties
This is similar to useSvmProps, but far simpler in
implementation because svnsync retains a 1:1
between revision numbers and relative paths within
the repository

Config keys: svn.useSvnsyncProps
             svn-remote.<repo>.useSvnsyncProps

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
aea736cc6d git-svn: allow overriding of the SVN repo root in metadata
This feature allows users to create repositories from alternate
URLs.  For example, an administrator could run git-svn on the
server locally (accessing via file://) but wish to distribute
the repository with a public http:// or svn:// URL in the
metadata so users of it will see the public URL.

Config key: svn-remote.<remote>.rewriteRoot

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
0425ea9088 git-svn: add 'clone' command, an alias for init + fetch
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
b7e5348c7f git-svn: hide the private git-svn 'config' file as '.metadata'
Having it named as 'config' prevents us from tracking a
ref named 'config', which is a huge mistake.

On the non-technical side, the word 'config' implies that
a user can freely modify it; but that's not the case
here.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
d6d3346bab git-svn: fix some issues for people migrating from older versions
* Fixed logic for renaming old .rev_db -> .rev_db.$uuid

 * correctly handle manual migrations for those who decide to
   start use globbing to handle branches/tags over individual
   'fetch' keys

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
905f8b7dfc git-svn: add a 'rebase' command
This works similarly to 'svn update' or 'git pull' except that
it preserves linear history with 'git rebase' instead of 'git
merge' for ease of dcommit-ing with git-svn.

While we're at it, put the working_head_info() logic
into its own function and allow --fetch-all/--all for
dcommit and rebase (which will fetch all refs in the
current [svn-remote] instead of just the working one).

Note that the '-a' switch (short for --fetch-all/--all) has been
removed as it conflicts with the non-svn 'git fetch'

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
1e889ef36c git-svn: checkout files on new fetches
On newly-created repositories, 'refs/heads/master' does not
point to anything.  This can be confusing to new users; so we
update 'master' to point to the last imported ref after fetching
is done.

Once 'master' is valid; we assume HEAD points to it; and if
the repository is not bare, then checkout the files if the
working tree is clean and unused.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
488a63ec23 git-svn: add support for --stat in the log command
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
a836a0e172 git-svn: documentation updates for new functionality
Force the showing of the --minimize flag as an option in the
'migrate' help.

Also, fix the usage function to correctly filter out
the deprecated aliases.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
60d9c97adf git-svn: allow dcommit for those who only fetch from SVM with useSvmProps
This allows users to use SVM (SVN::Mirror) to mirror a remote
repository to use dcommit to commit to the repository that SVM
was mirroring.  When dcommit is used in this manner, the automatic
fetch + rebase/reset does not happen; in which case the user will
have to manually invoke svm/svk, run 'git svn fetch', and finally
'git rebase'.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
7447b4bc83 git-svn: error checking for invalid [svn-remote "..."] sections
We don't end up trying to pass an undef URL over to SVN::Ra->new
because it'll segfault.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong
e8d120bd5a git-svn: remember to check for clean indices on globbed refs, too
Also, warn about dirty indices and avoid an unncessary
write-tree call if the index is clean.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
6af1db447b git-svn: allow --log-window-size to be specified, default to 100
The newer default value should should lower memory usage for
large fetches and also help with fetching from less reliable
servers.  Previously the value was 1000 and memory usage
got a bit high on some repositories and fetching became
less reliable in some cases.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
b4d57e5ea3 git-svn: simplify the (multi-)init methods of fetching
Also, some changes to avoid creating dead dirs under
.git/svn/.  We now create all directories as late as
possible.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
28710f74ea git-svn: brown paper bag fixes
* avoid skipping modification-only changes in fetch
  * correctly fetch when we only have branches and tags
    to glob from (no fetch keys defined)

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
dadc6d2a09 git-svn: allow 'init' to act as multi-init
multi-init is now just an alias that requires -T/-t/-b;
all options that 'init' can now accept.

This will hopefully simplify usage and reduce typing.

Also, allow the --shared option in 'init' to take an optional
argument now that 'git-init --shared' supports an optional
argument.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
e98671e5c2 git-svn: hopefully make 'fetch' more user-friendly
multi-fetch is deprecated, "fetch -a" is easier to type
By default, fetch will fetch everything from its default
[svn-remote]; if fetch [--all|-a] is specified, then it will
fetch from all svn remotes.  Refspecs on the command-line
(like git-fetch) are not supported.

Also, enable -r/--revision arguments for fetch so
users can shoot themselves in the foot^W^W^W^W^W
skip some history and do the equivalent of a shallow
clone/fetch they're not interested in.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
ccb6b6f5b5 t910*: s/repo-config/config/g; poke around possible race conditions
Some of the repo-config => config renaming missed the git-svn
tests; so I'm just renaming them to be consisten with the
rest of the modern git.

Also, some of the newer tests didn't have 'poke' in them
to workaround race conditions on fast machines.  This adds
places where they can _possibly_ occur; but I don't have
fast enough hardware to trigger them.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
3bc718ba66 git-svn: usability fixes for the 'git svn log' command
Similar in spirit to the recent dcommit change, we now
look at 'HEAD' by default to look for a GIT_SVN_ID
so the user won't have to pass -i <GIT_SVN_ID> argument.

We are also more tolerant of of people passing bare remote names
as a result (just $GIT_SVN_ID without the -i)

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
ce207c7ad1 git-svn: include merges when calling rev-list for decommit
Merge commits can be created when following certain parents,
(most notably 'R' cases) and we definitely don't want to exclude
them.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
a8ae26235c git-svn: make dcommit usable for glob users
* dcommit no longer requires the correct -i/GIT_SVN_ID option
   passed to it.  Since you're committing from HEAD (or another
   commit that is a parent of HEAD), you'll be able to find
   a commit with metadata information containing the SVN URL
   that your HEAD was descended from anyways.

 * I don't think dcommit ever worked for people using the
   noMetadata option; so I don't think relying on metadata
   is an issue.

 * useSvmProps users shouldn't commit to SVN::Mirror created
   repositories anyways, right?

 * Users of globbing should automatically be able to commit
   to paths that are not explicitly set in .git/config

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
sam@vilain.net
2edb9c5cf9 git-svn: make test for SVK mirror path import
A manual test that sets up a repository that looks like an SVK depot,
and then imports it to check that it looks like we mirrored the
'original' source.

There is also a minor modification to the git-svn test library shell
file which sets a variable for the subversion repository's filesystem
path.

[ew: made some of the tests stricter and more thorough]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
db03cd24a1 git-svn: handle multi-init without --trunk, UseSvmProps fixes
multi-init did not write a svn-remote.<remote>.url config
entry without a --trunk argument.

Also, The svm:mirror property is used by SVN::Mirror to track
the path of the repository that we are mirroring.  We need to
append that to the source (which is (presumably) just the URL of
the repository root).

Lastly, we now look harder for svm:(source|mirror|uuid) properties
in sub and parent directories.  Since our relative path could
be tweaked.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
c3560e535c git-svn: write the highest maxRex out for branches and tags
Even if nothing touched paths we care about in a fetch;
increment the maxRev like we do with rev_db since
we don't like having to run get_log on revisions we've
seen before.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
26a62d57a2 git-svn: use separate, per-repository .rev_db files
We need a separate .rev_db file for each repository we're
tracking.  This allows us to track the same logical path off
multiple mirrors.  We preserve a symlink to the old .rev_db
(no-UUID) if we're (auto-)migrating from an old version to
preserve backwards compatibility.

Also, get rid of the uuid() wrapper since we cache UUID in our
private config, and the SVN::Ra::get_uuid() function memoizes
the return value per-connection.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
97ae091169 git-svn: extra safety for noMetadata and useSvmProps users
Make sure we flush our userspace buffers and and fsync(2)
.rev_db information to disk if we use these options because
we really don't want to lose this information.

Also, disallow --use-svm-props and --no-metadata from the
command-line because history will be inconsistent if they're
only used occasionally.  If a user wants to use these options,
they must be set in the config so they're always on.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
93f2689ccd git-svn: use private $GIT_DIR/svn/config file more
Switch max_rev storage over to using it for globbing
branches and tags.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
91b03282b5 git-svn: add support for per-[svn-remote "..."] options
Available options are currently:

  svn-remote.<remote>.{noMetadata,useSvmProps,followParent}

These boolean switches will override options set globally in
[svn], and even override options set on the command-line (this
should probably change in the future, however).

Note that the noMetadata and useSvmProps options conflict.  It's
both technically and logically impossible to use them together.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
8a49ee9759 git-svn: add support for SVN::Mirror/svk using revprops for metadata
Pass --use-svm-props or set the svn.usesvmprops key with git-config
to enable using properties set by SVN::Mirror when it mirrored the
upstream URL.

This is heavily based on work from Sam Vilain:
> From: Sam Vilain <sam@vilain.net>
> Date: Sun, 11 Feb 2007 12:34:45 +1300
> Subject: [PATCH] git-svn: re-map repository URLs and UUIDs on SVK mirror paths
>
> If an SVN revision has a property, "svm:headrev", it is likely that
> the revision was created by SVN::Mirror (a part of SVK).  The property
> contains a repository UUID and a revision.  We want to make it look
> like we are mirroring the original URL, so introduce a helper function
> that returns the original identity URL and UUID, and use it when
> generating commit messages.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
490f49ea58 git-svn: remove optimized commit stuff for set-tree
I may resurrect it for dcommit at some point, but nobody really
uses set-tree anymore and I don't feel like introducing more
complexity into the code at this point.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
74a81227f9 git-svn: correctly handle globs with a right-hand-side path component
Several bugs were found and fixed while getting this to work:

 * Remember the 'R'(eplace) case of actions and treat it like we
   would an 'A'(dd) case.

 * Fix a small case of follow-parent missing a parent if a
   subdirectory was modified in the revision where the parent was
   copied.

 * dirents returned by get_dir sometimes expire if the data
   structure is too big and the pool is destroyed, so we
   cache get_dir (along with check_path and get_revprops)
   temporarily along with its pool.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
9e3cdbd4f2 git-svn: correctly handle the -q flag in SVN::Git::Fetcher
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
4e9f6cc78e git-svn: fix buggy regular expression usage in several places
I incorrectly used $path/? and $path/* to strip off leading
directories, but places where $path = 'branches/0.17' would
incorrectly strip changes to 'branches/0.17.1' as well.

For globs, we require that our '*' is its own path component
(surrounded by '/' or nothing).  Enforce this when --prefix= is
passed to us, too.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong
0bed5eaa0e git-svn: enable follow-parent functionality by default
--no-follow-parent disables and reverts it back to the old
default behavior of not following parents (if you don't care for
full history).

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
e20bea6545 git-svn: remove some noisy debugging messages
We don't need them anymore, all the rough points of
the --follow-parent implementation have been worked out.

The only improvement in the future will probably be
--follow-parent-harder, which will track subdirectories and
follow individual file history (so annotate/blame can be
complete); but that is still a ways off.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
d542aedb94 git-svn: remove check_path calls before calling do_update
These checks were needed before git-svn got smarter about
match_paths() and using path information returned by get_log().
We also have extra checking against fetching revisions
out-of-order these days; so we don't have to worry about that as
much.  We also check for tree deletions in match_paths() and
skip those as well.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
b9dffd8cad git-svn: --follow-parent tracks multi-parent paths
We can have a branch that was deleted, then re-added under the
same name but copied from another path, in which case we'll have
multiple parents (we don't want to break the original ref, nor
lose copypath info).

Add a test for this, too, of course.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
e518192f3b git-svn: implement auto-discovery of branches/tags
This is similar to the way git proper handles refs, except we
use the keys 'branches' and 'tags' to distinguish when we want
to use wildcards.

The left-hand side of the ':' contains the remote path, and must
have one asterisk ('*') in it for the branch name.  The asterisk
may be in any component of the path as long as is it on its own
directory level.

The right-hand side contains the refname and must have the
asterisk as the last path component.

        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
d2ae14346c git-svn: run get_log() on a sub-directory if possible
This is an optimization that should conserve network
bandwidth on certain repositories and configurations.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
fbcc1737d6 git-svn: reintroduce using a single get_log() to fetch
We'll need to rely on path matching to handle wildcard support for branches and
tags.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
4bb9ed0466 git-svn: prepare multi-init for wildcard support
Update the tests since we no longer write so many things to the
config.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
9fa00b655c git-svn: just name the default svn-remote "svn" instead of "git-svn"
It can be confusing and redundant, since historically the
default remote ref (not remote itself) has been "git-svn", too.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
502c1bf629 git-svn: avoid extra get_log calls when refspecs are added for fetching
Since fetch_loop_common starts from the lowest revision number
in a group of Git::SVN objects; we want to avoid refetching
get_log for current users for things we've already cut it.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
ef70de9685 git-svn: get rid of revisions_eq check for --follow-parent
This was originally needed before we used the delta fetcher and
had a less-clean follow-parent implementation that could leave
holes in the history.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
471bc00052 git-svn: migrations default to [svn-remote "git-svn"]
It looks better (like [remote "origin"]) instead of whatever
refname came up first in our directory traversal.  Of course
--remote= overrides this.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
88cf4107eb git-svn: save paths to tags/branches with for future reuse
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
d8115c5104 git-svn: don't write to the config file from --follow-parent
Having 'fetch' entries in the config file created from
--follow-parent is wasteful because it can cause *future* of
invocations to follow revisions we were never interested in
in the first place.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
ce4b4af7ff git-svn: use sys* IO functions for reading rev_db
Using buffered IO for reading 40-41 bytes at a time isn't very
efficient.  Buffering writes for a short duration is alright
since we close() right away and buffers will be flushed.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong
9c93fee51e git-svn: avoid redundant get_log calls between invocations
Prefill .rev_db to the maximum revision we tried to fetch;
and take advantage of that so we can avoid using get_log()
on ranges we've already seen (and have deemed uninteresting).

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00