* [PATCH 0/4] some git-svnimport improvements
@ 2006-02-26 5:03 Karl Hasselström
2006-02-26 5:11 ` [PATCH 1/4] Mention -r in usage summary Karl Hasselström
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Karl Hasselström @ 2006-02-26 5:03 UTC (permalink / raw)
To: Git Mailing List
This patch series teaches git-svnimport about the svn:executable and
svn:ignore Subversion properties (try to guess from their names what
they do!), and lets the user specify a file with username -> Full Name
<email@address> mappings.
I vaguely recall some discussion some time ago about the format of
this kind of username mapping file, but I ended up just picking the
simplest format I could think of since that was the boring part.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/4] Mention -r in usage summary
2006-02-26 5:03 [PATCH 0/4] some git-svnimport improvements Karl Hasselström
@ 2006-02-26 5:11 ` Karl Hasselström
2006-02-26 5:11 ` [PATCH 2/4] Convert executable flag Karl Hasselström
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Karl Hasselström @ 2006-02-26 5:11 UTC (permalink / raw)
To: Git Mailing List
I added the -r option to git-svnimport some time ago, but forgot to
update the usage summary in the documentation.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
Documentation/git-svnimport.txt | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt
index 5c543d5..b5c7721 100644
--- a/Documentation/git-svnimport.txt
+++ b/Documentation/git-svnimport.txt
@@ -10,10 +10,10 @@ git-svnimport - Import a SVN repository
SYNOPSIS
--------
'git-svnimport' [ -o <branch-for-HEAD> ] [ -h ] [ -v ] [ -d | -D ]
- [ -C <GIT_repository> ] [ -i ] [ -u ] [-l limit_rev]
- [ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
- [ -s start_chg ] [ -m ] [ -M regex ]
- <SVN_repository_URL> [ <path> ]
+ [ -C <GIT_repository> ] [ -i ] [ -u ] [-l limit_rev]
+ [ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
+ [ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
+ <SVN_repository_URL> [ <path> ]
DESCRIPTION
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/4] Convert executable flag
2006-02-26 5:03 [PATCH 0/4] some git-svnimport improvements Karl Hasselström
2006-02-26 5:11 ` [PATCH 1/4] Mention -r in usage summary Karl Hasselström
@ 2006-02-26 5:11 ` Karl Hasselström
2006-02-26 5:11 ` [PATCH 3/4] Convert the svn:ignore property Karl Hasselström
2006-02-26 5:11 ` [PATCH 4/4] Read author names and emails from a file Karl Hasselström
3 siblings, 0 replies; 12+ messages in thread
From: Karl Hasselström @ 2006-02-26 5:11 UTC (permalink / raw)
To: Git Mailing List
Convert the svn:executable property to file mode 755 when converting
an SVN repository to GIT.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
git-svnimport.perl | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/git-svnimport.perl b/git-svnimport.perl
index ee2940f..6603b96 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -112,16 +112,22 @@ sub file {
DIR => File::Spec->tmpdir(), UNLINK => 1);
print "... $rev $path ...\n" if $opt_v;
- my $pool = SVN::Pool->new();
- eval { $self->{'svn'}->get_file($path,$rev,$fh,$pool); };
- $pool->clear;
+ my (undef, $properties);
+ eval { (undef, $properties)
+ = $self->{'svn'}->get_file($path,$rev,$fh); };
if($@) {
return undef if $@ =~ /Attempted to get checksum/;
die $@;
}
+ my $mode;
+ if (exists $properties->{'svn:executable'}) {
+ $mode = '0755';
+ } else {
+ $mode = '0644';
+ }
close ($fh);
- return $name;
+ return ($name, $mode);
}
package main;
@@ -296,7 +302,7 @@ sub get_file($$$) {
my $svnpath = revert_split_path($branch,$path);
# now get it
- my $name;
+ my ($name,$mode);
if($opt_d) {
my($req,$res);
@@ -316,8 +322,9 @@ sub get_file($$$) {
return undef if $res->code == 301; # directory?
die $res->status_line." at $url\n";
}
+ $mode = '0644'; # can't obtain mode via direct http request?
} else {
- $name = $svn->file("$svnpath",$rev);
+ ($name,$mode) = $svn->file("$svnpath",$rev);
return undef unless defined $name;
}
@@ -331,7 +338,6 @@ sub get_file($$$) {
chomp $sha;
close $F;
unlink $name;
- my $mode = "0644"; # SV does not seem to store any file modes
return [$mode, $sha, $path];
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/4] Convert the svn:ignore property
2006-02-26 5:03 [PATCH 0/4] some git-svnimport improvements Karl Hasselström
2006-02-26 5:11 ` [PATCH 1/4] Mention -r in usage summary Karl Hasselström
2006-02-26 5:11 ` [PATCH 2/4] Convert executable flag Karl Hasselström
@ 2006-02-26 5:11 ` Karl Hasselström
2006-02-26 5:11 ` [PATCH 4/4] Read author names and emails from a file Karl Hasselström
3 siblings, 0 replies; 12+ messages in thread
From: Karl Hasselström @ 2006-02-26 5:11 UTC (permalink / raw)
To: Git Mailing List
Put the value of the svn:ignore property in a regular file when
converting a Subversion repository to GIT. The Subversion and GIT
ignore syntaxes are similar enough that it often just works to set the
filename to .gitignore and do nothing else.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
Documentation/git-svnimport.txt | 8 +++++
git-svnimport.perl | 60 +++++++++++++++++++++++++++++++++++++--
2 files changed, 64 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt
index b5c7721..c95ff84 100644
--- a/Documentation/git-svnimport.txt
+++ b/Documentation/git-svnimport.txt
@@ -13,7 +13,7 @@ SYNOPSIS
[ -C <GIT_repository> ] [ -i ] [ -u ] [-l limit_rev]
[ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
[ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
- <SVN_repository_URL> [ <path> ]
+ [ -I <ignorefile_name> ] <SVN_repository_URL> [ <path> ]
DESCRIPTION
@@ -65,6 +65,12 @@ When importing incrementally, you might
Prepend 'rX: ' to commit messages, where X is the imported
subversion revision.
+-I <ignorefile_name>::
+ Import the svn:ignore directory property to files with this
+ name in each directory. (The Subversion and GIT ignore
+ syntaxes are similar enough that using the Subversion patterns
+ directly with "-I .gitignore" will almost always just work.)
+
-m::
Attempt to detect merges based on the commit message. This option
will enable default regexes that try to capture the name source
diff --git a/git-svnimport.perl b/git-svnimport.perl
index 6603b96..0dd9fab 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -29,19 +29,21 @@ die "Need SVN:Core 1.2.1 or better" if $
$SIG{'PIPE'}="IGNORE";
$ENV{'TZ'}="UTC";
-our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,$opt_b,$opt_r,$opt_s,$opt_l,$opt_d,$opt_D);
+our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,
+ $opt_b,$opt_r,$opt_I,$opt_s,$opt_l,$opt_d,$opt_D);
sub usage() {
print STDERR <<END;
Usage: ${\basename $0} # fetch/update GIT from SVN
[-o branch-for-HEAD] [-h] [-v] [-l max_rev]
[-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]
- [-d|-D] [-i] [-u] [-r] [-s start_chg] [-m] [-M regex] [SVN_URL]
+ [-d|-D] [-i] [-u] [-r] [-I ignorefilename] [-s start_chg]
+ [-m] [-M regex] [SVN_URL]
END
exit(1);
}
-getopts("b:C:dDhil:mM:o:rs:t:T:uv") or usage();
+getopts("b:C:dDhiI:l:mM:o:rs:t:T:uv") or usage();
usage if $opt_h;
my $tag_name = $opt_t || "tags";
@@ -130,6 +132,24 @@ sub file {
return ($name, $mode);
}
+sub ignore {
+ my($self,$path,$rev) = @_;
+
+ print "... $rev $path ...\n" if $opt_v;
+ my (undef,undef,$properties)
+ = $self->{'svn'}->get_dir($path,$rev,undef);
+ if (exists $properties->{'svn:ignore'}) {
+ my ($fh, $name) = tempfile('gitsvn.XXXXXX',
+ DIR => File::Spec->tmpdir(),
+ UNLINK => 1);
+ print $fh $properties->{'svn:ignore'};
+ close($fh);
+ return $name;
+ } else {
+ return undef;
+ }
+}
+
package main;
use URI;
@@ -341,6 +361,34 @@ sub get_file($$$) {
return [$mode, $sha, $path];
}
+sub get_ignore($$$$$) {
+ my($new,$old,$rev,$branch,$path) = @_;
+
+ return unless $opt_I;
+ my $svnpath = revert_split_path($branch,$path);
+ my $name = $svn->ignore("$svnpath",$rev);
+ if ($path eq '/') {
+ $path = $opt_I;
+ } else {
+ $path = File::Spec->catfile($path,$opt_I);
+ }
+ if (defined $name) {
+ my $pid = open(my $F, '-|');
+ die $! unless defined $pid;
+ if (!$pid) {
+ exec("git-hash-object", "-w", $name)
+ or die "Cannot create object: $!\n";
+ }
+ my $sha = <$F>;
+ chomp $sha;
+ close $F;
+ unlink $name;
+ push(@$new,['0644',$sha,$path]);
+ } else {
+ push(@$old,$path);
+ }
+}
+
sub split_path($$) {
my($rev,$path) = @_;
my $branch;
@@ -546,6 +594,9 @@ sub commit {
my $opath = $action->[3];
print STDERR "$revision: $branch: could not fetch '$opath'\n";
}
+ } elsif ($node_kind eq $SVN::Node::dir) {
+ get_ignore(\@new, \@old, $revision,
+ $branch,$path);
}
} elsif ($action->[0] eq "D") {
push(@old,$path);
@@ -554,6 +605,9 @@ sub commit {
if ($node_kind eq $SVN::Node::file) {
my $f = get_file($revision,$branch,$path);
push(@new,$f) if $f;
+ } elsif ($node_kind eq $SVN::Node::dir) {
+ get_ignore(\@new, \@old, $revision,
+ $branch,$path);
}
} else {
die "$revision: unknown action '".$action->[0]."' for $path\n";
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/4] Read author names and emails from a file
2006-02-26 5:03 [PATCH 0/4] some git-svnimport improvements Karl Hasselström
` (2 preceding siblings ...)
2006-02-26 5:11 ` [PATCH 3/4] Convert the svn:ignore property Karl Hasselström
@ 2006-02-26 5:11 ` Karl Hasselström
2006-02-26 11:49 ` Andreas Ericsson
3 siblings, 1 reply; 12+ messages in thread
From: Karl Hasselström @ 2006-02-26 5:11 UTC (permalink / raw)
To: Git Mailing List
Read a file with lines on the form
username User's Full Name <email@addres.org>
and use "User's Full Name <email@addres.org>" as the GIT author and
committer for Subversion commits made by "username". If encountering a
commit made by a user not in the list, abort.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
Documentation/git-svnimport.txt | 13 ++++++++++++-
git-svnimport.perl | 23 ++++++++++++++++++++---
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt
index c95ff84..e0e3a5d 100644
--- a/Documentation/git-svnimport.txt
+++ b/Documentation/git-svnimport.txt
@@ -13,7 +13,8 @@ SYNOPSIS
[ -C <GIT_repository> ] [ -i ] [ -u ] [-l limit_rev]
[ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
[ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
- [ -I <ignorefile_name> ] <SVN_repository_URL> [ <path> ]
+ [ -I <ignorefile_name> ] [ -A <author_file> ]
+ <SVN_repository_URL> [ <path> ]
DESCRIPTION
@@ -71,6 +72,16 @@ When importing incrementally, you might
syntaxes are similar enough that using the Subversion patterns
directly with "-I .gitignore" will almost always just work.)
+-A <author_file>::
+ Read a file with lines on the form
+
+ username User's Full Name <email@addres.org>
+
+ and use "User's Full Name <email@addres.org>" as the GIT
+ author and committer for Subversion commits made by
+ "username". If encountering a commit made by a user not in the
+ list, abort.
+
-m::
Attempt to detect merges based on the commit message. This option
will enable default regexes that try to capture the name source
diff --git a/git-svnimport.perl b/git-svnimport.perl
index 0dd9fab..75ce8e0 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -30,7 +30,7 @@ $SIG{'PIPE'}="IGNORE";
$ENV{'TZ'}="UTC";
our($opt_h,$opt_o,$opt_v,$opt_u,$opt_C,$opt_i,$opt_m,$opt_M,$opt_t,$opt_T,
- $opt_b,$opt_r,$opt_I,$opt_s,$opt_l,$opt_d,$opt_D);
+ $opt_b,$opt_r,$opt_I,$opt_A,$opt_s,$opt_l,$opt_d,$opt_D);
sub usage() {
print STDERR <<END;
@@ -38,12 +38,12 @@ Usage: ${\basename $0} # fetch/updat
[-o branch-for-HEAD] [-h] [-v] [-l max_rev]
[-C GIT_repository] [-t tagname] [-T trunkname] [-b branchname]
[-d|-D] [-i] [-u] [-r] [-I ignorefilename] [-s start_chg]
- [-m] [-M regex] [SVN_URL]
+ [-m] [-M regex] [-A author_file] [SVN_URL]
END
exit(1);
}
-getopts("b:C:dDhiI:l:mM:o:rs:t:T:uv") or usage();
+getopts("A:b:C:dDhiI:l:mM:o:rs:t:T:uv") or usage();
usage if $opt_h;
my $tag_name = $opt_t || "tags";
@@ -68,6 +68,19 @@ if ($opt_M) {
push (@mergerx, qr/$opt_M/);
}
+our %users = ();
+if ($opt_A) {
+ die "Cannot open $opt_A\n" unless -f $opt_A;
+ open(my $authors,$opt_A);
+ while(<$authors>) {
+ chomp;
+ next unless /^(\S+)\s+(.+?)\s+<(\S+)>$/;
+ (my $user,my $name,my $email) = ($1,$2,$3);
+ $users{$user} = [$name,$email];
+ }
+ close($authors);
+}
+
select(STDERR); $|=1; select(STDOUT);
@@ -485,6 +498,10 @@ sub commit {
if (not defined $author) {
$author_name = $author_email = "unknown";
+ } elsif ($opt_A) {
+ die "User $author is not listed in $opt_A\n"
+ unless exists $users{$author};
+ ($author_name,$author_email) = @{$users{$author}};
} elsif ($author =~ /^(.*?)\s+<(.*)>$/) {
($author_name, $author_email) = ($1, $2);
} else {
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] Read author names and emails from a file
2006-02-26 5:11 ` [PATCH 4/4] Read author names and emails from a file Karl Hasselström
@ 2006-02-26 11:49 ` Andreas Ericsson
2006-02-27 5:51 ` Junio C Hamano
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Andreas Ericsson @ 2006-02-26 11:49 UTC (permalink / raw)
To: Karl Hasselström; +Cc: Git Mailing List
Karl Hasselström wrote:
> Read a file with lines on the form
>
> username User's Full Name <email@addres.org>
>
> and use "User's Full Name <email@addres.org>" as the GIT author and
> committer for Subversion commits made by "username". If encountering a
> commit made by a user not in the list, abort.
>
This is a good thing, but wouldn't it be better to use the same format
as that of cvsimport's -A flag? Also, I imagine one would like to save
those files within the .git directory for incremental importing, also
like cvsimport does.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] Read author names and emails from a file
2006-02-26 11:49 ` Andreas Ericsson
@ 2006-02-27 5:51 ` Junio C Hamano
2006-02-27 23:00 ` Karl Hasselström
2006-02-27 23:08 ` [PATCH 1/2] Let git-svnimport's author file use same syntax as git-cvsimport's Karl Hasselström
2006-02-27 23:08 ` [PATCH 2/2] Save username -> Full Name <email@addr.es> map file Karl Hasselström
2 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2006-02-27 5:51 UTC (permalink / raw)
To: Andreas Ericsson; +Cc: git, Karl Hasselström
Andreas Ericsson <ae@op5.se> writes:
> Karl Hasselström wrote:
>> Read a file with lines on the form
>> username User's Full Name <email@addres.org>
>> and use "User's Full Name <email@addres.org>" as the GIT author and
>> committer for Subversion commits made by "username". If encountering a
>> commit made by a user not in the list, abort.
>
> This is a good thing, but wouldn't it be better to use the same format
> as that of cvsimport's -A flag?
If both CVS and SVN have their own native format to express
things like this, and if the format they use are different, then
that is a valid reason for git-{cvs,svn}import to use different
file format.
But if that is not the case, I tend to agree that it might be
easier for users if we had just one format. I do not think,
however, any single project is likely to have to deal with both
CVS and SVN upstream, importing into the same git repository, so
reusing the mapping file would not be an issue, but having to
learn how to write the mapping just once is a good thing.
I do not offhand recall if SVN has its own native format; if it
has, it may be better to use that, instead of matching what
git-cvsimport does, since I do not think of a reason why the
version with an equal sign is preferrable over the version with
a space. If the version with '=' were the CVS native format
then that might be a reason to prefer it, but if I recall
correctly that is not the case. so...
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/4] Read author names and emails from a file
2006-02-27 5:51 ` Junio C Hamano
@ 2006-02-27 23:00 ` Karl Hasselström
0 siblings, 0 replies; 12+ messages in thread
From: Karl Hasselström @ 2006-02-27 23:00 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Andreas Ericsson, git
On 2006-02-26 21:51:12 -0800, Junio C Hamano wrote:
> Andreas Ericsson <ae@op5.se> writes:
>
> > This is a good thing, but wouldn't it be better to use the same
> > format as that of cvsimport's -A flag?
>
> If both CVS and SVN have their own native format to express things
> like this, and if the format they use are different, then that is a
> valid reason for git-{cvs,svn}import to use different file format.
>
> But if that is not the case, I tend to agree that it might be easier
> for users if we had just one format. I do not think, however, any
> single project is likely to have to deal with both CVS and SVN
> upstream, importing into the same git repository, so reusing the
> mapping file would not be an issue, but having to learn how to write
> the mapping just once is a good thing.
>
> I do not offhand recall if SVN has its own native format; if it has,
> it may be better to use that, instead of matching what git-cvsimport
> does, since I do not think of a reason why the version with an equal
> sign is preferrable over the version with a space. If the version
> with '=' were the CVS native format then that might be a reason to
> prefer it, but if I recall correctly that is not the case. so...
I don't know of any SVN native format for this, so it seems silly to
use a different format than git-cvsimport. I've also made a patch that
saves the author information, again just like git-cvsimport.
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/2] Let git-svnimport's author file use same syntax as git-cvsimport's
2006-02-26 11:49 ` Andreas Ericsson
2006-02-27 5:51 ` Junio C Hamano
@ 2006-02-27 23:08 ` Karl Hasselström
2006-03-01 21:19 ` Jon Loeliger
2006-02-27 23:08 ` [PATCH 2/2] Save username -> Full Name <email@addr.es> map file Karl Hasselström
2 siblings, 1 reply; 12+ messages in thread
From: Karl Hasselström @ 2006-02-27 23:08 UTC (permalink / raw)
To: Git Mailing List
git-cvsimport uses a username => Full Name <email@addr.es> mapping
file with this syntax:
kha=Karl Hasselström <kha@treskal.com>
Since there is no reason to use another format for git-svnimport, use
the same format.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
Documentation/git-svnimport.txt | 4 ++--
git-svnimport.perl | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt
index e0e3a5d..912a808 100644
--- a/Documentation/git-svnimport.txt
+++ b/Documentation/git-svnimport.txt
@@ -75,9 +75,9 @@ When importing incrementally, you might
-A <author_file>::
Read a file with lines on the form
- username User's Full Name <email@addres.org>
+ username = User's Full Name <email@addr.es>
- and use "User's Full Name <email@addres.org>" as the GIT
+ and use "User's Full Name <email@addr.es>" as the GIT
author and committer for Subversion commits made by
"username". If encountering a commit made by a user not in the
list, abort.
diff --git a/git-svnimport.perl b/git-svnimport.perl
index 75ce8e0..86837ed 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -74,7 +74,7 @@ if ($opt_A) {
open(my $authors,$opt_A);
while(<$authors>) {
chomp;
- next unless /^(\S+)\s+(.+?)\s+<(\S+)>$/;
+ next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
(my $user,my $name,my $email) = ($1,$2,$3);
$users{$user} = [$name,$email];
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/2] Save username -> Full Name <email@addr.es> map file
2006-02-26 11:49 ` Andreas Ericsson
2006-02-27 5:51 ` Junio C Hamano
2006-02-27 23:08 ` [PATCH 1/2] Let git-svnimport's author file use same syntax as git-cvsimport's Karl Hasselström
@ 2006-02-27 23:08 ` Karl Hasselström
2 siblings, 0 replies; 12+ messages in thread
From: Karl Hasselström @ 2006-02-27 23:08 UTC (permalink / raw)
To: Git Mailing List
When the user specifies a username -> Full Name <email@addr.es> map
file with the -A option, save a copy of that file as
$git_dir/svn-authors. When running git-svnimport with an existing GIT
directory, use $git_dir/svn-authors (if it exists) unless a file was
explicitly specified with -A.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
Documentation/git-svnimport.txt | 5 +++++
git-svnimport.perl | 25 ++++++++++++++++++++-----
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt
index 912a808..a158813 100644
--- a/Documentation/git-svnimport.txt
+++ b/Documentation/git-svnimport.txt
@@ -82,6 +82,11 @@ When importing incrementally, you might
"username". If encountering a commit made by a user not in the
list, abort.
+ For convenience, this data is saved to $GIT_DIR/svn-authors
+ each time the -A option is provided, and read from that same
+ file each time git-svnimport is run with an existing GIT
+ repository without -A.
+
-m::
Attempt to detect merges based on the commit message. This option
will enable default regexes that try to capture the name source
diff --git a/git-svnimport.perl b/git-svnimport.perl
index 86837ed..639aa41 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -13,6 +13,7 @@
use strict;
use warnings;
use Getopt::Std;
+use File::Copy;
use File::Spec;
use File::Temp qw(tempfile);
use File::Path qw(mkpath);
@@ -68,10 +69,16 @@ if ($opt_M) {
push (@mergerx, qr/$opt_M/);
}
+# Absolutize filename now, since we will have chdir'ed by the time we
+# get around to opening it.
+$opt_A = File::Spec->rel2abs($opt_A) if $opt_A;
+
our %users = ();
-if ($opt_A) {
- die "Cannot open $opt_A\n" unless -f $opt_A;
- open(my $authors,$opt_A);
+our $users_file = undef;
+sub read_users($) {
+ $users_file = File::Spec->rel2abs(@_);
+ die "Cannot open $users_file\n" unless -f $users_file;
+ open(my $authors,$users_file);
while(<$authors>) {
chomp;
next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
@@ -302,6 +309,14 @@ EOM
-d $git_dir
or die "Could not create git subdir ($git_dir).\n";
+my $default_authors = "$git_dir/svn-authors";
+if ($opt_A) {
+ read_users($opt_A);
+ copy($opt_A,$default_authors) or die "Copy failed: $!";
+} else {
+ read_users($default_authors) if -f $default_authors;
+}
+
open BRANCHES,">>", "$git_dir/svn2git";
sub node_kind($$$) {
@@ -498,8 +513,8 @@ sub commit {
if (not defined $author) {
$author_name = $author_email = "unknown";
- } elsif ($opt_A) {
- die "User $author is not listed in $opt_A\n"
+ } elsif (defined $users_file) {
+ die "User $author is not listed in $users_file\n"
unless exists $users{$author};
($author_name,$author_email) = @{$users{$author}};
} elsif ($author =~ /^(.*?)\s+<(.*)>$/) {
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] Let git-svnimport's author file use same syntax as git-cvsimport's
2006-02-27 23:08 ` [PATCH 1/2] Let git-svnimport's author file use same syntax as git-cvsimport's Karl Hasselström
@ 2006-03-01 21:19 ` Jon Loeliger
2006-03-02 9:20 ` Karl Hasselström
0 siblings, 1 reply; 12+ messages in thread
From: Jon Loeliger @ 2006-03-01 21:19 UTC (permalink / raw)
To: Karl Hasselström; +Cc: Git Mailing List
On Mon, 2006-02-27 at 17:08, Karl Hasselström wrote:
> diff --git a/Documentation/git-svnimport.txt b/Documentation/git-svnimport.txt
> index e0e3a5d..912a808 100644
> --- a/Documentation/git-svnimport.txt
> +++ b/Documentation/git-svnimport.txt
> @@ -75,9 +75,9 @@ When importing incrementally, you might
> -A <author_file>::
> Read a file with lines on the form
>
> - username User's Full Name <email@addres.org>
> + username = User's Full Name <email@addr.es>
>
> - and use "User's Full Name <email@addres.org>" as the GIT
> + and use "User's Full Name <email@addr.es>" as the GIT
> author and committer for Subversion commits made by
> "username". If encountering a commit made by a user not in the
> list, abort.
Actually, I believe that "example.com" was reserved
specifically for instances such as this.
See:
http://www.faqs.org/rfcs/rfc2606.html
jdl
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/2] Let git-svnimport's author file use same syntax as git-cvsimport's
2006-03-01 21:19 ` Jon Loeliger
@ 2006-03-02 9:20 ` Karl Hasselström
0 siblings, 0 replies; 12+ messages in thread
From: Karl Hasselström @ 2006-03-02 9:20 UTC (permalink / raw)
To: Jon Loeliger; +Cc: Git Mailing List
On 2006-03-01 15:19:53 -0600, Jon Loeliger wrote:
> On Mon, 2006-02-27 at 17:08, Karl Hasselström wrote:
>
> > Read a file with lines on the form
> >
> > - username User's Full Name <email@addres.org>
> > + username = User's Full Name <email@addr.es>
> >
> > - and use "User's Full Name <email@addres.org>" as the GIT
> > + and use "User's Full Name <email@addr.es>" as the GIT
> > author and committer for Subversion commits made by
> > "username". If encountering a commit made by a user not in the
> > list, abort.
>
> Actually, I believe that "example.com" was reserved specifically for
> instances such as this.
Yes, I know. But email.address@example.com is much longer then
email@addr.es, and not half as funny. :-)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2006-03-02 9:20 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-26 5:03 [PATCH 0/4] some git-svnimport improvements Karl Hasselström
2006-02-26 5:11 ` [PATCH 1/4] Mention -r in usage summary Karl Hasselström
2006-02-26 5:11 ` [PATCH 2/4] Convert executable flag Karl Hasselström
2006-02-26 5:11 ` [PATCH 3/4] Convert the svn:ignore property Karl Hasselström
2006-02-26 5:11 ` [PATCH 4/4] Read author names and emails from a file Karl Hasselström
2006-02-26 11:49 ` Andreas Ericsson
2006-02-27 5:51 ` Junio C Hamano
2006-02-27 23:00 ` Karl Hasselström
2006-02-27 23:08 ` [PATCH 1/2] Let git-svnimport's author file use same syntax as git-cvsimport's Karl Hasselström
2006-03-01 21:19 ` Jon Loeliger
2006-03-02 9:20 ` Karl Hasselström
2006-02-27 23:08 ` [PATCH 2/2] Save username -> Full Name <email@addr.es> map file Karl Hasselström
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).