* [PATCH] git-svn: added an --include-path flag
@ 2013-04-17 21:42 Paul Walmsley
0 siblings, 0 replies; 6+ messages in thread
From: Paul Walmsley @ 2013-04-17 21:42 UTC (permalink / raw)
To: git
The SVN::Fetcher module is now able to filter for inclusion as well
as exclusion (as used by --ignore-path). Also added tests, documentation
changes and git completion script.
If you have an SVN repository with many top level directories and you
only want a git-svn clone of some of them then using --ignore-path is
difficult as it requires a very long regexp. In this case it's much
easier to filter for inclusion.
Signed-off-by: Paul Walmsley <pjwhams@gmail.com>
---
Documentation/git-svn.txt | 12 +++
contrib/completion/git-completion.bash | 2 +-
git-svn.perl | 4 +
perl/Git/SVN/Fetcher.pm | 13 ++-
t/t9147-git-svn-include-paths.sh | 150 ++++++++++++++++++++++++++++++++
5 files changed, 179 insertions(+), 2 deletions(-)
create mode 100755 t/t9147-git-svn-include-paths.sh
--------------1.7.10.4
Content-Type: text/x-patch; name="0001-git-svn-added-an-include-path-flag.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-git-svn-added-an-include-path-flag.patch"
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 69decb1..df1f40c 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -85,6 +85,10 @@ COMMANDS
When passed to 'init' or 'clone' this regular expression will
be preserved as a config key. See 'fetch' for a description
of '--ignore-paths'.
+--include-paths=<regex>;;
+ When passed to 'init' or 'clone' this regular expression will
+ be preserved as a config key. See 'fetch' for a description
+ of '--include-paths'.
--no-minimize-url;;
When tracking multiple directories (using --stdlayout,
--branches, or --tags options), git svn will attempt to connect
@@ -146,6 +150,14 @@ Skip "branches" and "tags" of first level directories;;
------------------------------------------------------------------------
--
+--include-paths=<regex>;;
+ This allows one to specify a Perl regular expression that will
+ cause the inclusion of only matching paths from checkout from SVN.
+ The '--include-paths' option should match for every 'fetch'
+ (including automatic fetches due to 'clone', 'dcommit',
+ 'rebase', etc) on a given repository. '--ignore-paths' takes
+ precedence over '--include-paths'.
+
--log-window-size=<n>;;
Fetch <n> log entries per request when scanning Subversion history.
The default is 100. For very large Subversion repositories, larger
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 39c7ff8..8b75d01 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2222,7 +2222,7 @@ _git_svn ()
--no-metadata --use-svm-props --use-svnsync-props
--log-window-size= --no-checkout --quiet
--repack-flags --use-log-author --localtime
- --ignore-paths= $remote_opts
+ --ignore-paths= --include-paths= $remote_opts
"
local init_opts="
--template= --shared= --trunk= --tags=
diff --git a/git-svn.perl b/git-svn.perl
index bd5266c..6d713e1 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -127,6 +127,7 @@ my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
'ignore-paths=s' => \$Git::SVN::Fetcher::_ignore_regex,
+ 'include-paths=s' => \$Git::SVN::Fetcher::_include_regex,
'ignore-refs=s' => \$Git::SVN::Ra::_ignore_refs_regex );
my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
'authors-file|A=s' => \$_authors,
@@ -477,6 +478,9 @@ sub do_git_init_db {
my $ignore_paths_regex = \$Git::SVN::Fetcher::_ignore_regex;
command_noisy('config', "$pfx.ignore-paths", $$ignore_paths_regex)
if defined $$ignore_paths_regex;
+ my $include_paths_regex = \$Git::SVN::Fetcher::_include_regex;
+ command_noisy('config', "$pfx.include-paths", $$include_paths_regex)
+ if defined $$include_paths_regex;
my $ignore_refs_regex = \$Git::SVN::Ra::_ignore_refs_regex;
command_noisy('config', "$pfx.ignore-refs", $$ignore_refs_regex)
if defined $$ignore_refs_regex;
diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 046a7a2..27824e7 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -1,5 +1,5 @@
package Git::SVN::Fetcher;
-use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename
+use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs $_placeholder_filename
@deleted_gpath %added_placeholder $repo_id/;
use strict;
use warnings;
@@ -33,6 +33,10 @@ sub new {
my $v = eval { command_oneline('config', '--get', $k) };
$self->{ignore_regex} = $v;
+ $k = "svn-remote.$repo_id.include-paths";
+ $v = eval { command_oneline('config', '--get', $k) };
+ $self->{include_regex} = $v;
+
$k = "svn-remote.$repo_id.preserve-empty-dirs";
$v = eval { command_oneline('config', '--get', '--bool', $k) };
if ($v && $v eq 'true') {
@@ -117,11 +121,18 @@ sub in_dot_git {
}
# return value: 0 -- don't ignore, 1 -- ignore
+# This will also check whether the path is explicitly included
sub is_path_ignored {
my ($self, $path) = @_;
return 1 if in_dot_git($path);
return 1 if defined($self->{ignore_regex}) &&
$path =~ m!$self->{ignore_regex}!;
+ return 0 if defined($self->{include_regex}) &&
+ $path =~ m!$self->{include_regex}!;
+ return 0 if defined($_include_regex) &&
+ $path =~ m!$_include_regex!;
+ return 1 if defined($self->{include_regex});
+ return 1 if defined($_include_regex);
return 0 unless defined($_ignore_regex);
return 1 if $path =~ m!$_ignore_regex!o;
return 0;
diff --git a/t/t9147-git-svn-include-paths.sh b/t/t9147-git-svn-include-paths.sh
new file mode 100755
index 0000000..e2e9812
--- /dev/null
+++ b/t/t9147-git-svn-include-paths.sh
@@ -0,0 +1,150 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Vitaly Shukela
+# Copyright (c) 2009 Eric Wong
+#
+
+test_description='git svn property tests'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup test repository' '
+ svn_cmd co "$svnrepo" s &&
+ (
+ cd s &&
+ mkdir qqq www xxx &&
+ echo test_qqq > qqq/test_qqq.txt &&
+ echo test_www > www/test_www.txt &&
+ echo test_xxx > xxx/test_xxx.txt &&
+ svn_cmd add qqq &&
+ svn_cmd add www &&
+ svn_cmd add xxx &&
+ svn_cmd commit -m "create some files" &&
+ svn_cmd up &&
+ echo hi >> www/test_www.txt &&
+ svn_cmd commit -m "modify www/test_www.txt" &&
+ svn_cmd up
+ )
+'
+
+test_expect_success 'clone an SVN repository with filter to include qqq directory' '
+ git svn clone --include-paths="qqq" "$svnrepo" g &&
+ echo test_qqq > expect &&
+ for i in g/*/*.txt; do cat $i >> expect2; done &&
+ test_cmp expect expect2
+'
+
+
+test_expect_success 'init+fetch an SVN repository with included qqq directory' '
+ git svn init "$svnrepo" c &&
+ ( cd c && git svn fetch --include-paths="qqq" ) &&
+ rm expect2 &&
+ echo test_qqq > expect &&
+ for i in c/*/*.txt; do cat $i >> expect2; done &&
+ test_cmp expect expect2
+'
+
+test_expect_success 'verify include-paths config saved by clone' '
+ (
+ cd g &&
+ git config --get svn-remote.svn.include-paths | fgrep "qqq"
+ )
+'
+
+test_expect_success 'SVN-side change outside of www' '
+ (
+ cd s &&
+ echo b >> qqq/test_qqq.txt &&
+ svn_cmd commit -m "SVN-side change outside of www" &&
+ svn_cmd up &&
+ svn_cmd log -v | fgrep "SVN-side change outside of www"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (config include)' '
+ (
+ cd g &&
+ git svn rebase &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (option include)' '
+ (
+ cd c &&
+ git svn rebase --include-paths="qqq" &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'SVN-side change inside of ignored www' '
+ (
+ cd s &&
+ echo zaq >> www/test_www.txt
+ svn_cmd commit -m "SVN-side change inside of www/test_www.txt" &&
+ svn_cmd up &&
+ svn_cmd log -v | fgrep "SVN-side change inside of www/test_www.txt"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (config include)' '
+ (
+ cd g &&
+ git svn rebase &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (option include)' '
+ (
+ cd c &&
+ git svn rebase --include-paths="qqq" &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'SVN-side change in and out of included qqq' '
+ (
+ cd s &&
+ echo cvf >> www/test_www.txt
+ echo ygg >> qqq/test_qqq.txt
+ svn_cmd commit -m "SVN-side change in and out of ignored www" &&
+ svn_cmd up &&
+ svn_cmd log -v | fgrep "SVN-side change in and out of ignored www"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo again (config include)' '
+ (
+ cd g &&
+ git svn rebase &&
+ printf "test_qqq\nb\nygg\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'update git svn-cloned repo again (option include)' '
+ (
+ cd c &&
+ git svn rebase --include-paths="qqq" &&
+ printf "test_qqq\nb\nygg\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_done
--------------1.7.10.4--
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: Fwd: [PATCH] git-svn: added an --include-path flag
[not found] <CAHpQJx0iT_+pOzdEJ-uyn7GjkXs8ZwhfPoMYpQDxwAB5mQ1xrw@mail.gmail.com>
@ 2013-04-24 21:28 ` Eric Wong
2013-04-24 22:33 ` [PATCH] git-svn: added an --include-path flag (resent fixing mail format) Paul Walmsley
0 siblings, 1 reply; 6+ messages in thread
From: Eric Wong @ 2013-04-24 21:28 UTC (permalink / raw)
To: Paul Walmsley; +Cc: Jonathan Nieder, git
Paul Walmsley <pjwhams@gmail.com> wrote:
> Hi,
> Please forgive the direct approach, but I submitted a git-svn patch to the
> git list which sank without any comment. As major contributors to git-svn I
> would like to solicit your feedback on it. The patch is so that git svn
> clone supports '--include-path' as a complement to '--ignore-path'. I had
> a need for this as our SVN repository has many top level folders of which
> only a few may be needed for any project. I wanted to contribute the patch
> back as I think it may be useful to others. I've included unit tests too.
No forgivness necessary, it's standard practice to Cc maintainers in git
(and Linux kernel) patch submissions :)
(Re-adding git ML-as Cc)
> --- /dev/null
> +++ b/t/t9147-git-svn-include-paths.sh
> @@ -0,0 +1,150 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2009 Vitaly Shukela
> +# Copyright (c) 2009 Eric Wong
Use your name (and current year) in copyright headers for your
submissions.
I'll take a closer look at the rest of the patch later, but your patch
below appears line-wrapped and mangled (see
Documentation/SubmittingPatches).
Also, we'd greatly appreciate you omit HTML from emails in the future.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] git-svn: added an --include-path flag (resent fixing mail format)
2013-04-24 21:28 ` Fwd: [PATCH] git-svn: added an --include-path flag Eric Wong
@ 2013-04-24 22:33 ` Paul Walmsley
2013-05-01 20:46 ` Eric Wong
0 siblings, 1 reply; 6+ messages in thread
From: Paul Walmsley @ 2013-04-24 22:33 UTC (permalink / raw)
To: git; +Cc: Paul Walmsley, Jonathan Nieder, Eric Wong
The SVN::Fetcher module is now able to filter for inclusion as well
as exclusion (as used by --ignore-path). Also added tests, documentation
changes and git completion script.
If you have an SVN repository with many top level directories and you
only want a git-svn clone of some of them then using --ignore-path is
difficult as it requires a very long regexp. In this case it's much
easier to filter for inclusion.
---
Documentation/git-svn.txt | 12 +++
contrib/completion/git-completion.bash | 2 +-
git-svn.perl | 4 +
perl/Git/SVN/Fetcher.pm | 13 ++-
t/t9147-git-svn-include-paths.sh | 150 ++++++++++++++++++++++++++++++++
5 files changed, 179 insertions(+), 2 deletions(-)
create mode 100755 t/t9147-git-svn-include-paths.sh
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 69decb1..df1f40c 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -85,6 +85,10 @@ COMMANDS
When passed to 'init' or 'clone' this regular expression will
be preserved as a config key. See 'fetch' for a description
of '--ignore-paths'.
+--include-paths=<regex>;;
+ When passed to 'init' or 'clone' this regular expression will
+ be preserved as a config key. See 'fetch' for a description
+ of '--include-paths'.
--no-minimize-url;;
When tracking multiple directories (using --stdlayout,
--branches, or --tags options), git svn will attempt to connect
@@ -146,6 +150,14 @@ Skip "branches" and "tags" of first level directories;;
------------------------------------------------------------------------
--
+--include-paths=<regex>;;
+ This allows one to specify a Perl regular expression that will
+ cause the inclusion of only matching paths from checkout from SVN.
+ The '--include-paths' option should match for every 'fetch'
+ (including automatic fetches due to 'clone', 'dcommit',
+ 'rebase', etc) on a given repository. '--ignore-paths' takes
+ precedence over '--include-paths'.
+
--log-window-size=<n>;;
Fetch <n> log entries per request when scanning Subversion history.
The default is 100. For very large Subversion repositories, larger
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 39c7ff8..8b75d01 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2222,7 +2222,7 @@ _git_svn ()
--no-metadata --use-svm-props --use-svnsync-props
--log-window-size= --no-checkout --quiet
--repack-flags --use-log-author --localtime
- --ignore-paths= $remote_opts
+ --ignore-paths= --include-paths= $remote_opts
"
local init_opts="
--template= --shared= --trunk= --tags=
diff --git a/git-svn.perl b/git-svn.perl
index bd5266c..6d713e1 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -127,6 +127,7 @@ my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
'ignore-paths=s' => \$Git::SVN::Fetcher::_ignore_regex,
+ 'include-paths=s' => \$Git::SVN::Fetcher::_include_regex,
'ignore-refs=s' => \$Git::SVN::Ra::_ignore_refs_regex );
my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
'authors-file|A=s' => \$_authors,
@@ -477,6 +478,9 @@ sub do_git_init_db {
my $ignore_paths_regex = \$Git::SVN::Fetcher::_ignore_regex;
command_noisy('config', "$pfx.ignore-paths", $$ignore_paths_regex)
if defined $$ignore_paths_regex;
+ my $include_paths_regex = \$Git::SVN::Fetcher::_include_regex;
+ command_noisy('config', "$pfx.include-paths", $$include_paths_regex)
+ if defined $$include_paths_regex;
my $ignore_refs_regex = \$Git::SVN::Ra::_ignore_refs_regex;
command_noisy('config', "$pfx.ignore-refs", $$ignore_refs_regex)
if defined $$ignore_refs_regex;
diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 046a7a2..27824e7 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -1,5 +1,5 @@
package Git::SVN::Fetcher;
-use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename
+use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs $_placeholder_filename
@deleted_gpath %added_placeholder $repo_id/;
use strict;
use warnings;
@@ -33,6 +33,10 @@ sub new {
my $v = eval { command_oneline('config', '--get', $k) };
$self->{ignore_regex} = $v;
+ $k = "svn-remote.$repo_id.include-paths";
+ $v = eval { command_oneline('config', '--get', $k) };
+ $self->{include_regex} = $v;
+
$k = "svn-remote.$repo_id.preserve-empty-dirs";
$v = eval { command_oneline('config', '--get', '--bool', $k) };
if ($v && $v eq 'true') {
@@ -117,11 +121,18 @@ sub in_dot_git {
}
# return value: 0 -- don't ignore, 1 -- ignore
+# This will also check whether the path is explicitly included
sub is_path_ignored {
my ($self, $path) = @_;
return 1 if in_dot_git($path);
return 1 if defined($self->{ignore_regex}) &&
$path =~ m!$self->{ignore_regex}!;
+ return 0 if defined($self->{include_regex}) &&
+ $path =~ m!$self->{include_regex}!;
+ return 0 if defined($_include_regex) &&
+ $path =~ m!$_include_regex!;
+ return 1 if defined($self->{include_regex});
+ return 1 if defined($_include_regex);
return 0 unless defined($_ignore_regex);
return 1 if $path =~ m!$_ignore_regex!o;
return 0;
diff --git a/t/t9147-git-svn-include-paths.sh b/t/t9147-git-svn-include-paths.sh
new file mode 100755
index 0000000..e2e9812
--- /dev/null
+++ b/t/t9147-git-svn-include-paths.sh
@@ -0,0 +1,150 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Vitaly Shukela
+# Copyright (c) 2009 Eric Wong
+#
+
+test_description='git svn property tests'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup test repository' '
+ svn_cmd co "$svnrepo" s &&
+ (
+ cd s &&
+ mkdir qqq www xxx &&
+ echo test_qqq > qqq/test_qqq.txt &&
+ echo test_www > www/test_www.txt &&
+ echo test_xxx > xxx/test_xxx.txt &&
+ svn_cmd add qqq &&
+ svn_cmd add www &&
+ svn_cmd add xxx &&
+ svn_cmd commit -m "create some files" &&
+ svn_cmd up &&
+ echo hi >> www/test_www.txt &&
+ svn_cmd commit -m "modify www/test_www.txt" &&
+ svn_cmd up
+ )
+'
+
+test_expect_success 'clone an SVN repository with filter to include qqq directory' '
+ git svn clone --include-paths="qqq" "$svnrepo" g &&
+ echo test_qqq > expect &&
+ for i in g/*/*.txt; do cat $i >> expect2; done &&
+ test_cmp expect expect2
+'
+
+
+test_expect_success 'init+fetch an SVN repository with included qqq directory' '
+ git svn init "$svnrepo" c &&
+ ( cd c && git svn fetch --include-paths="qqq" ) &&
+ rm expect2 &&
+ echo test_qqq > expect &&
+ for i in c/*/*.txt; do cat $i >> expect2; done &&
+ test_cmp expect expect2
+'
+
+test_expect_success 'verify include-paths config saved by clone' '
+ (
+ cd g &&
+ git config --get svn-remote.svn.include-paths | fgrep "qqq"
+ )
+'
+
+test_expect_success 'SVN-side change outside of www' '
+ (
+ cd s &&
+ echo b >> qqq/test_qqq.txt &&
+ svn_cmd commit -m "SVN-side change outside of www" &&
+ svn_cmd up &&
+ svn_cmd log -v | fgrep "SVN-side change outside of www"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (config include)' '
+ (
+ cd g &&
+ git svn rebase &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (option include)' '
+ (
+ cd c &&
+ git svn rebase --include-paths="qqq" &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'SVN-side change inside of ignored www' '
+ (
+ cd s &&
+ echo zaq >> www/test_www.txt
+ svn_cmd commit -m "SVN-side change inside of www/test_www.txt" &&
+ svn_cmd up &&
+ svn_cmd log -v | fgrep "SVN-side change inside of www/test_www.txt"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (config include)' '
+ (
+ cd g &&
+ git svn rebase &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (option include)' '
+ (
+ cd c &&
+ git svn rebase --include-paths="qqq" &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'SVN-side change in and out of included qqq' '
+ (
+ cd s &&
+ echo cvf >> www/test_www.txt
+ echo ygg >> qqq/test_qqq.txt
+ svn_cmd commit -m "SVN-side change in and out of ignored www" &&
+ svn_cmd up &&
+ svn_cmd log -v | fgrep "SVN-side change in and out of ignored www"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo again (config include)' '
+ (
+ cd g &&
+ git svn rebase &&
+ printf "test_qqq\nb\nygg\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'update git svn-cloned repo again (option include)' '
+ (
+ cd c &&
+ git svn rebase --include-paths="qqq" &&
+ printf "test_qqq\nb\nygg\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_done
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] git-svn: added an --include-path flag (resent fixing mail format)
2013-04-24 22:33 ` [PATCH] git-svn: added an --include-path flag (resent fixing mail format) Paul Walmsley
@ 2013-05-01 20:46 ` Eric Wong
2013-05-03 23:10 ` [PATCH] git-svn: added an --include-path flag Paul Walmsley
0 siblings, 1 reply; 6+ messages in thread
From: Eric Wong @ 2013-05-01 20:46 UTC (permalink / raw)
To: Paul Walmsley; +Cc: git, Jonathan Nieder
Paul Walmsley <pjwhams@gmail.com> wrote:
> The SVN::Fetcher module is now able to filter for inclusion as well
> as exclusion (as used by --ignore-path). Also added tests, documentation
> changes and git completion script.
>
> If you have an SVN repository with many top level directories and you
> only want a git-svn clone of some of them then using --ignore-path is
> difficult as it requires a very long regexp. In this case it's much
> easier to filter for inclusion.
Thanks, comments inline.
A Signed-off-by is necessary (especially for new contributors)
(not _my_ policy, but project policy, see Documentation/SubmittingPatches)
> @@ -1,5 +1,5 @@
> package Git::SVN::Fetcher;
> -use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename
> +use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs $_placeholder_filename
> @deleted_gpath %added_placeholder $repo_id/;
Please wrap long lines at 80 columns.
> --- /dev/null
> +++ b/t/t9147-git-svn-include-paths.sh
> @@ -0,0 +1,150 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2009 Vitaly Shukela
> +# Copyright (c) 2009 Eric Wong
> +#
I already commented on this in the previous email, please add your
own copyright header (you can add a note saying this is based on
t9134 by Vitaly).
Thanks again.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] git-svn: added an --include-path flag
2013-05-01 20:46 ` Eric Wong
@ 2013-05-03 23:10 ` Paul Walmsley
2013-05-09 1:19 ` Eric Wong
0 siblings, 1 reply; 6+ messages in thread
From: Paul Walmsley @ 2013-05-03 23:10 UTC (permalink / raw)
To: git; +Cc: Eric Wong, Jonathan Nieder, Paul Walmsley
The SVN::Fetcher module is now able to filter for inclusion as well
as exclusion (as used by --ignore-path). Also added tests, documentation
changes and git completion script.
If you have an SVN repository with many top level directories and you
only want a git-svn clone of some of them then using --ignore-path is
difficult as it requires a very long regexp. In this case it's much
easier to filter for inclusion.
Signed-off-by: Paul Walmsley <pjwhams@gmail.com>
---
Documentation/git-svn.txt | 12 +++
contrib/completion/git-completion.bash | 2 +-
git-svn.perl | 4 +
perl/Git/SVN/Fetcher.pm | 16 +++-
t/t9147-git-svn-include-paths.sh | 149 ++++++++++++++++++++++++++++++++
5 files changed, 180 insertions(+), 3 deletions(-)
create mode 100755 t/t9147-git-svn-include-paths.sh
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 1b8b649..698a6bb 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -85,6 +85,10 @@ COMMANDS
When passed to 'init' or 'clone' this regular expression will
be preserved as a config key. See 'fetch' for a description
of '--ignore-paths'.
+--include-paths=<regex>;;
+ When passed to 'init' or 'clone' this regular expression will
+ be preserved as a config key. See 'fetch' for a description
+ of '--include-paths'.
--no-minimize-url;;
When tracking multiple directories (using --stdlayout,
--branches, or --tags options), git svn will attempt to connect
@@ -146,6 +150,14 @@ Skip "branches" and "tags" of first level directories;;
------------------------------------------------------------------------
--
+--include-paths=<regex>;;
+ This allows one to specify a Perl regular expression that will
+ cause the inclusion of only matching paths from checkout from SVN.
+ The '--include-paths' option should match for every 'fetch'
+ (including automatic fetches due to 'clone', 'dcommit',
+ 'rebase', etc) on a given repository. '--ignore-paths' takes
+ precedence over '--include-paths'.
+
--log-window-size=<n>;;
Fetch <n> log entries per request when scanning Subversion history.
The default is 100. For very large Subversion repositories, larger
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 2ba1461..8427df2 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2451,7 +2451,7 @@ _git_svn ()
--no-metadata --use-svm-props --use-svnsync-props
--log-window-size= --no-checkout --quiet
--repack-flags --use-log-author --localtime
- --ignore-paths= $remote_opts
+ --ignore-paths= --include-paths= $remote_opts
"
local init_opts="
--template= --shared= --trunk= --tags=
diff --git a/git-svn.perl b/git-svn.perl
index 6c7bd95..5e56dc7 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -126,6 +126,7 @@ my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
'ignore-paths=s' => \$Git::SVN::Fetcher::_ignore_regex,
+ 'include-paths=s' => \$Git::SVN::Fetcher::_include_regex,
'ignore-refs=s' => \$Git::SVN::Ra::_ignore_refs_regex );
my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
'authors-file|A=s' => \$_authors,
@@ -470,6 +471,9 @@ sub do_git_init_db {
my $ignore_paths_regex = \$Git::SVN::Fetcher::_ignore_regex;
command_noisy('config', "$pfx.ignore-paths", $$ignore_paths_regex)
if defined $$ignore_paths_regex;
+ my $include_paths_regex = \$Git::SVN::Fetcher::_include_regex;
+ command_noisy('config', "$pfx.include-paths", $$include_paths_regex)
+ if defined $$include_paths_regex;
my $ignore_refs_regex = \$Git::SVN::Ra::_ignore_refs_regex;
command_noisy('config', "$pfx.ignore-refs", $$ignore_refs_regex)
if defined $$ignore_refs_regex;
diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 046a7a2..d25524c 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -1,6 +1,7 @@
package Git::SVN::Fetcher;
-use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename
- @deleted_gpath %added_placeholder $repo_id/;
+use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs
+ $_placeholder_filename @deleted_gpath %added_placeholder
+ $repo_id/;
use strict;
use warnings;
use SVN::Delta;
@@ -33,6 +34,10 @@ sub new {
my $v = eval { command_oneline('config', '--get', $k) };
$self->{ignore_regex} = $v;
+ $k = "svn-remote.$repo_id.include-paths";
+ $v = eval { command_oneline('config', '--get', $k) };
+ $self->{include_regex} = $v;
+
$k = "svn-remote.$repo_id.preserve-empty-dirs";
$v = eval { command_oneline('config', '--get', '--bool', $k) };
if ($v && $v eq 'true') {
@@ -117,11 +122,18 @@ sub in_dot_git {
}
# return value: 0 -- don't ignore, 1 -- ignore
+# This will also check whether the path is explicitly included
sub is_path_ignored {
my ($self, $path) = @_;
return 1 if in_dot_git($path);
return 1 if defined($self->{ignore_regex}) &&
$path =~ m!$self->{ignore_regex}!;
+ return 0 if defined($self->{include_regex}) &&
+ $path =~ m!$self->{include_regex}!;
+ return 0 if defined($_include_regex) &&
+ $path =~ m!$_include_regex!;
+ return 1 if defined($self->{include_regex});
+ return 1 if defined($_include_regex);
return 0 unless defined($_ignore_regex);
return 1 if $path =~ m!$_ignore_regex!o;
return 0;
diff --git a/t/t9147-git-svn-include-paths.sh b/t/t9147-git-svn-include-paths.sh
new file mode 100755
index 0000000..6a7ce30
--- /dev/null
+++ b/t/t9147-git-svn-include-paths.sh
@@ -0,0 +1,149 @@
+#!/bin/sh
+#
+# Copyright (c) 2013 Paul Walmsley - based on t9134 by Vitaly Shukela
+#
+
+test_description='git svn property tests'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup test repository' '
+ svn_cmd co "$svnrepo" s &&
+ (
+ cd s &&
+ mkdir qqq www xxx &&
+ echo test_qqq > qqq/test_qqq.txt &&
+ echo test_www > www/test_www.txt &&
+ echo test_xxx > xxx/test_xxx.txt &&
+ svn_cmd add qqq &&
+ svn_cmd add www &&
+ svn_cmd add xxx &&
+ svn_cmd commit -m "create some files" &&
+ svn_cmd up &&
+ echo hi >> www/test_www.txt &&
+ svn_cmd commit -m "modify www/test_www.txt" &&
+ svn_cmd up
+ )
+'
+
+test_expect_success 'clone an SVN repository with filter to include qqq directory' '
+ git svn clone --include-paths="qqq" "$svnrepo" g &&
+ echo test_qqq > expect &&
+ for i in g/*/*.txt; do cat $i >> expect2; done &&
+ test_cmp expect expect2
+'
+
+
+test_expect_success 'init+fetch an SVN repository with included qqq directory' '
+ git svn init "$svnrepo" c &&
+ ( cd c && git svn fetch --include-paths="qqq" ) &&
+ rm expect2 &&
+ echo test_qqq > expect &&
+ for i in c/*/*.txt; do cat $i >> expect2; done &&
+ test_cmp expect expect2
+'
+
+test_expect_success 'verify include-paths config saved by clone' '
+ (
+ cd g &&
+ git config --get svn-remote.svn.include-paths | fgrep "qqq"
+ )
+'
+
+test_expect_success 'SVN-side change outside of www' '
+ (
+ cd s &&
+ echo b >> qqq/test_qqq.txt &&
+ svn_cmd commit -m "SVN-side change outside of www" &&
+ svn_cmd up &&
+ svn_cmd log -v | fgrep "SVN-side change outside of www"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (config include)' '
+ (
+ cd g &&
+ git svn rebase &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (option include)' '
+ (
+ cd c &&
+ git svn rebase --include-paths="qqq" &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'SVN-side change inside of ignored www' '
+ (
+ cd s &&
+ echo zaq >> www/test_www.txt
+ svn_cmd commit -m "SVN-side change inside of www/test_www.txt" &&
+ svn_cmd up &&
+ svn_cmd log -v | fgrep "SVN-side change inside of www/test_www.txt"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (config include)' '
+ (
+ cd g &&
+ git svn rebase &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'update git svn-cloned repo (option include)' '
+ (
+ cd c &&
+ git svn rebase --include-paths="qqq" &&
+ printf "test_qqq\nb\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'SVN-side change in and out of included qqq' '
+ (
+ cd s &&
+ echo cvf >> www/test_www.txt
+ echo ygg >> qqq/test_qqq.txt
+ svn_cmd commit -m "SVN-side change in and out of ignored www" &&
+ svn_cmd up &&
+ svn_cmd log -v | fgrep "SVN-side change in and out of ignored www"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo again (config include)' '
+ (
+ cd g &&
+ git svn rebase &&
+ printf "test_qqq\nb\nygg\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'update git svn-cloned repo again (option include)' '
+ (
+ cd c &&
+ git svn rebase --include-paths="qqq" &&
+ printf "test_qqq\nb\nygg\n" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_done
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] git-svn: added an --include-path flag
2013-05-03 23:10 ` [PATCH] git-svn: added an --include-path flag Paul Walmsley
@ 2013-05-09 1:19 ` Eric Wong
0 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2013-05-09 1:19 UTC (permalink / raw)
To: Paul Walmsley; +Cc: git, Jonathan Nieder
Paul Walmsley <pjwhams@gmail.com> wrote:
> The SVN::Fetcher module is now able to filter for inclusion as well
> as exclusion (as used by --ignore-path). Also added tests, documentation
> changes and git completion script.
>
> If you have an SVN repository with many top level directories and you
> only want a git-svn clone of some of them then using --ignore-path is
> difficult as it requires a very long regexp. In this case it's much
> easier to filter for inclusion.
>
> Signed-off-by: Paul Walmsley <pjwhams@gmail.com>
Thanks, signed-off and applied, will push.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-09 1:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAHpQJx0iT_+pOzdEJ-uyn7GjkXs8ZwhfPoMYpQDxwAB5mQ1xrw@mail.gmail.com>
2013-04-24 21:28 ` Fwd: [PATCH] git-svn: added an --include-path flag Eric Wong
2013-04-24 22:33 ` [PATCH] git-svn: added an --include-path flag (resent fixing mail format) Paul Walmsley
2013-05-01 20:46 ` Eric Wong
2013-05-03 23:10 ` [PATCH] git-svn: added an --include-path flag Paul Walmsley
2013-05-09 1:19 ` Eric Wong
2013-04-17 21:42 Paul Walmsley
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).