forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'extract-remaining' of git://git.bogomips.org/git-svn
* 'extract-remaining' of git://git.bogomips.org/git-svn: Extract Git::SVN::GlobSpec from git-svn. Move Git::IndexInfo into its own file. Load all the modules in one place and before running code. Extract Git::SVN::Migration from git-svn. Prepare Git::SVN::Migration for extraction from git-svn. Extract Git::SVN::Log from git-svn. Prepare Git::SVN::Log for extraction from git-svn.
- Loading branch information
Showing
9 changed files
with
795 additions
and
761 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package Git::IndexInfo; | ||
use strict; | ||
use warnings; | ||
use Git qw/command_input_pipe command_close_pipe/; | ||
|
||
sub new { | ||
my ($class) = @_; | ||
my ($gui, $ctx) = command_input_pipe(qw/update-index -z --index-info/); | ||
bless { gui => $gui, ctx => $ctx, nr => 0}, $class; | ||
} | ||
|
||
sub remove { | ||
my ($self, $path) = @_; | ||
if (print { $self->{gui} } '0 ', 0 x 40, "\t", $path, "\0") { | ||
return ++$self->{nr}; | ||
} | ||
undef; | ||
} | ||
|
||
sub update { | ||
my ($self, $mode, $hash, $path) = @_; | ||
if (print { $self->{gui} } $mode, ' ', $hash, "\t", $path, "\0") { | ||
return ++$self->{nr}; | ||
} | ||
undef; | ||
} | ||
|
||
sub DESTROY { | ||
my ($self) = @_; | ||
command_close_pipe($self->{gui}, $self->{ctx}); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package Git::SVN::GlobSpec; | ||
use strict; | ||
use warnings; | ||
|
||
sub new { | ||
my ($class, $glob, $pattern_ok) = @_; | ||
my $re = $glob; | ||
$re =~ s!/+$!!g; # no need for trailing slashes | ||
my (@left, @right, @patterns); | ||
my $state = "left"; | ||
my $die_msg = "Only one set of wildcard directories " . | ||
"(e.g. '*' or '*/*/*') is supported: '$glob'\n"; | ||
for my $part (split(m|/|, $glob)) { | ||
if ($part =~ /\*/ && $part ne "*") { | ||
die "Invalid pattern in '$glob': $part\n"; | ||
} elsif ($pattern_ok && $part =~ /[{}]/ && | ||
$part !~ /^\{[^{}]+\}/) { | ||
die "Invalid pattern in '$glob': $part\n"; | ||
} | ||
if ($part eq "*") { | ||
die $die_msg if $state eq "right"; | ||
$state = "pattern"; | ||
push(@patterns, "[^/]*"); | ||
} elsif ($pattern_ok && $part =~ /^\{(.*)\}$/) { | ||
die $die_msg if $state eq "right"; | ||
$state = "pattern"; | ||
my $p = quotemeta($1); | ||
$p =~ s/\\,/|/g; | ||
push(@patterns, "(?:$p)"); | ||
} else { | ||
if ($state eq "left") { | ||
push(@left, $part); | ||
} else { | ||
push(@right, $part); | ||
$state = "right"; | ||
} | ||
} | ||
} | ||
my $depth = @patterns; | ||
if ($depth == 0) { | ||
die "One '*' is needed in glob: '$glob'\n"; | ||
} | ||
my $left = join('/', @left); | ||
my $right = join('/', @right); | ||
$re = join('/', @patterns); | ||
$re = join('\/', | ||
grep(length, quotemeta($left), "($re)", quotemeta($right))); | ||
my $left_re = qr/^\/\Q$left\E(\/|$)/; | ||
bless { left => $left, right => $right, left_regex => $left_re, | ||
regex => qr/$re/, glob => $glob, depth => $depth }, $class; | ||
} | ||
|
||
sub full_path { | ||
my ($self, $path) = @_; | ||
return (length $self->{left} ? "$self->{left}/" : '') . | ||
$path . (length $self->{right} ? "/$self->{right}" : ''); | ||
} | ||
|
||
1; |
Oops, something went wrong.