All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
7 # Controls whether to print what is being done.
10 # Controls whether to actually check anything out.
13 # Controls whether to perfer repos that use authentication.
16 # Controls where to check out to. If not set, the vcs is allowed to
20 # how to perform checkouts
22 git => sub { doit("git", "clone", shift, $destdir) },
23 svn => sub { doit("svn", "checkout", shift, $destdir) },
24 bzr => sub { doit("bzr", "branch", shift, $destdir) },
27 # Regexps matching urls that are used for anonymous
28 # repository checkouts. The order is significant:
29 # urls matching earlier in the list are preferred over
30 # those matching later.
35 qr/^http:\/\//i, # generally the worst transport
39 my @args=grep { defined } @_;
40 print join(" ", @args)."\n" if $verbose;
45 # Is repo a better than repo b?
50 foreach my $r (@anon_urls) {
51 if ($a->{href} =~ /$r/) {
55 elsif ($b->{href} =~ /$r/) {
62 return $firstanon != $a;
65 return $firstanon == $a;
69 # Eliminate duplicate repositories from list.
70 # Duplicate repositories have the same title, or the same href.
74 foreach my $repo (@_) {
75 if (exists $repo->{title} &&
76 length $repo->{title} &&
77 exists $bytitle{$repo->{title}}) {
78 my $other=$bytitle{$repo->{title}};
79 next unless better($repo, $other);
80 delete $bytitle{$other->{title}}
83 if (! $seenhref{$repo->{href}}++) {
84 $bytitle{$repo->{title}}=$repo;
88 return values %bytitle;
95 my $parser=HTML::Parser->new(api_version => 3);
96 $parser->handler(start => sub {
99 return if lc $tagname ne 'link';
100 return if ! exists $attr->{rel} || lc $attr->{rel} ne 'vcs';
101 return if ! exists $attr->{href} || ! length $attr->{href};
102 return if ! exists $attr->{type} || ! length $attr->{type};
105 $parser->parse($page);
112 if (! defined $url) {
113 die "usage: webcheckout url\n";
117 if (! defined $page) {
118 die "failed to download $url\n";
121 my @repos=dedup(parse($page));
123 die "no repositories found on $url\n";
127 foreach my $repo (@repos) {
128 my $handler=$handlers{$repo->{type}};
130 if ($handler->($repo->{href}) != 0) {
131 print STDERR "failed to checkout ".$repo->{href}."\n";
136 print STDERR "unknown repository type ".$repo->{type}.
137 " for ".$repo->{href}."\n";
144 #print Dumper(\@repos);