[755] | 1 | # TODO: svn mv --parents Various/Swierszcz_Piotr/Energy_1_2.sap Various/Swierszcz_Piotr/Last_World.sap |
---|
| 2 | |
---|
| 3 | use File::Basename; |
---|
| 4 | use File::Find; |
---|
| 5 | use POSIX qw(strftime); |
---|
| 6 | |
---|
| 7 | #my $repo = 'file:///C:/0/a8/asap/aasma/import/repo'; |
---|
| 8 | my $repo = 'svn://asma.scene.pl/asma'; |
---|
| 9 | my $globopt = '--username pfusik'; |
---|
| 10 | |
---|
| 11 | my @dirs; |
---|
| 12 | |
---|
| 13 | sub wanted() { |
---|
| 14 | push @dirs, $File::Find::name if -d; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | sub dirs($) { |
---|
| 18 | my ($dir) = @_; |
---|
| 19 | @dirs = (); |
---|
| 20 | find(\&wanted, $dir); |
---|
| 21 | shift @dirs; |
---|
| 22 | return map { s!^\Q$dir\E/!!; $_; } @dirs; |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | sub indir($\@) { |
---|
| 26 | my ($file, $dirs) = @_; |
---|
| 27 | my @r = grep $file =~ m!^$_/!, @$dirs; |
---|
| 28 | return pop @r; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | sub shell($) { |
---|
| 32 | print @_, "\n"; |
---|
| 33 | # system @_; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | sub commit($$$$) { |
---|
| 37 | my ($d, $log, $tag, $taglog) = @_; |
---|
| 38 | shell "svn commit $globopt -m '$log' .."; |
---|
| 39 | my $f = (-e "$d/Docs/Asma.txt") ? "$d/Docs/Asma.txt" : "$d/Docs/Readme.txt"; |
---|
| 40 | my $t = POSIX::strftime('%FT%T.000000Z', localtime((stat $f)[9])); |
---|
| 41 | shell "svn propset $globopt svn:date --revprop -r HEAD $t"; |
---|
| 42 | shell "svn cp $globopt -m '$taglog' $repo/trunk/asma $repo/tags/$tag"; |
---|
| 43 | shell "svn propset $globopt svn:date --revprop -r HEAD $t"; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | if (0) { |
---|
| 47 | shell "rm -rf trunk repo"; |
---|
| 48 | shell "svnadmin create --fs-type fsfs repo"; |
---|
| 49 | shell "touch repo/hooks/pre-revprop-change.bat"; |
---|
| 50 | shell "svn mkdir -m 'Repository init' $repo/trunk $repo/tags $repo/branches"; |
---|
| 51 | shell "svn co $repo/trunk trunk"; |
---|
| 52 | } |
---|
| 53 | shell 'set -e'; |
---|
| 54 | shell 'cd trunk'; |
---|
| 55 | shell 'mkdir asma && svn add asma && cd asma'; |
---|
| 56 | shell "cp -r ../../ASMA05/* ."; |
---|
| 57 | shell "svn add *"; |
---|
| 58 | commit('ASMA05', 'Imported ASMA 0.5', 'asma-0.5', 'PRE-RELEASE ASMA 0.5'); |
---|
| 59 | my $p = 'ASMA05'; |
---|
| 60 | for my $d ('ASMA06' .. 'ASMA35') { |
---|
| 61 | shell "echo -------- $d --------"; |
---|
| 62 | my @pd = dirs($p); |
---|
| 63 | my @cd = dirs($d); |
---|
| 64 | my %pd = map { $_ => 1 } @pd; |
---|
| 65 | my %cd = map { $_ => 1 } @cd; |
---|
| 66 | my @rd = grep !$cd{$_}, @pd; |
---|
| 67 | my @ad = grep !$pd{$_}, @cd; |
---|
| 68 | my %md; |
---|
| 69 | my %nd; |
---|
| 70 | my @g = `git diff -M -l99999 --name-status $p $d`; |
---|
| 71 | my @a; |
---|
| 72 | if ($d eq 'ASMA29') { |
---|
| 73 | shell "svn mv Docs/Update1$_.txt Docs/Update2$_.txt" for 0 .. 8; |
---|
| 74 | shell "svn mv Docs/Update0$_.txt Docs/Update1$_.txt" for 1 .. 9; |
---|
| 75 | } |
---|
| 76 | elsif ($d eq 'ASMA33') { |
---|
| 77 | shell "svn mv Various Composers"; |
---|
| 78 | shell "svn mv Composers/Benoth_Sukkor Composers/Stanik_Krzysztof"; |
---|
| 79 | $md{'Composers/Benoth_Sukkor'} = 'Composers/Stanik_Krzysztof'; |
---|
| 80 | shell "svn mv Composers/Trokowicz_B Composers/Trokowicz_Bartolomiej"; |
---|
| 81 | $md{'Composers/Trokowicz_B'} = 'Composers/Trokowicz_Bartolomiej'; |
---|
| 82 | shell "svn mv Composers/Zur-soft Composers/Zur_soft"; |
---|
| 83 | $md{'Various/Zur-soft'} = 'Composers/Zur_soft'; |
---|
| 84 | } |
---|
| 85 | for (@g) { |
---|
| 86 | if ($d eq 'ASMA29' && m!^(A\t$d|D\t$p)/Docs/Update\d\d\.txt$!) { |
---|
| 87 | } |
---|
| 88 | if (m!^A\t$d/(.+)$!) { |
---|
| 89 | push @a, $1 if $1 ne 'Various/Ramzes/Endless_Dream_5.sap'; |
---|
| 90 | } |
---|
| 91 | elsif (m!^R0*(\d+)\t$p/(.+?)\t$d/(.+)$!) { |
---|
| 92 | my ($perc, $rf, $af) = ($1, $2, $3); |
---|
| 93 | my $rd = indir($rf, @rd); |
---|
| 94 | my $ad = indir($af, @ad); |
---|
| 95 | if (defined($rd) && defined($ad) |
---|
| 96 | && $ad ne 'Various/Grayscale' && $ad ne 'Composers/Kuczek_Ireneusz/Worktunes' |
---|
| 97 | && $rd ne 'Unsorted' && $rd ne 'Demos' && $rd ne 'Games/Various') { |
---|
| 98 | if (exists($md{$rd})) { |
---|
| 99 | die $_ if $md{$rd} ne $ad; |
---|
| 100 | } |
---|
| 101 | else { |
---|
| 102 | $md{$rd} = $ad; |
---|
| 103 | shell "svn mv --parents $rd $ad" unless "$rd $ad" =~ m!^Various/(.+?) Composers/\1$!; |
---|
| 104 | } |
---|
| 105 | $rf =~ s/^$rd/$ad/; |
---|
| 106 | shell "svn mv $rf $af # RENAME $perc%" if $rf ne $af; |
---|
| 107 | } |
---|
| 108 | else { |
---|
| 109 | if ($af eq 'Demos/Ray_of_Hope_2.sap') { |
---|
| 110 | push @a, $af; |
---|
| 111 | $af = 'Various/Ramzes/Endless_Dream_5.sap' ; |
---|
| 112 | } |
---|
| 113 | if ($af eq 'Various/Szpilowski_Michal/Sej-mik.sap') { |
---|
| 114 | push @a, $af; |
---|
| 115 | shell "svn rm $rf"; |
---|
| 116 | next; |
---|
| 117 | } |
---|
| 118 | # --parents does this |
---|
| 119 | #$ad = dirname($af); |
---|
| 120 | #unless ($nd{$ad} || -d "$p/$ad") { |
---|
| 121 | # shell "mkdir -p $ad && svn add $ad"; |
---|
| 122 | # $nd{$ad} = 1; |
---|
| 123 | #} |
---|
| 124 | $rf =~ s/^.*?'.*$/"$&"/; |
---|
| 125 | shell "svn mv --parents $rf $af # $perc%"; |
---|
| 126 | } |
---|
| 127 | } |
---|
| 128 | elsif (m!^D\t$p/(.+)$!) { |
---|
| 129 | my $f = $1; |
---|
| 130 | shell "svn rm $f" unless defined indir($f, @rd); |
---|
| 131 | } |
---|
| 132 | elsif (m!^M!) { |
---|
| 133 | } |
---|
| 134 | else { |
---|
| 135 | die $_; |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | shell "cp -r ../../$d/* ."; |
---|
| 139 | exists($md{$_}) || shell "svn rm $_" for @rd; |
---|
| 140 | s/^.*?'.*$/"$&"/, shell "svn add --parents $_" for @a; |
---|
| 141 | $d =~ /(\d)(\d)/; |
---|
| 142 | my $r = "$1.$2"; |
---|
| 143 | my $pre = $1 ? '' : 'PRE-'; |
---|
| 144 | commit($d, "Imported ASMA $r", "asma-$r", "${pre}RELEASE ASMA $r"); |
---|
| 145 | $p = $d; |
---|
| 146 | shell "svn up"; |
---|
| 147 | } |
---|