#!/usr/bin/expect -- # # Wrap the svnmerge script, so we're only prompted for our password once. # # Written by Tilghman Lesher # # Best way to use this would be to rename /usr/bin/svnmerge to # /usr/bin/svnmerge.real and install this script as /usr/bin/svnmerge. # Then when you run svnmerge with any arguments, they're passed on # transparently to the actual svnmerge, but you only have to type your # password once. This is how I'm using it, and it works great. # # May be useful to adjust if your connection (or the svn server) is slow # or you are merging many revisions (Use -1 for infinity) set timeout @@TIMEOUT@@ set svnmerge "@@BINDIR@@/svnmerge.real" set command2 ":" set command3 ":" set command4 ":" set havepasswd "0" set haveintegration "0" set which [ lindex [ split $argv0 / ] end ] set s_cmd "" if [ expr [ string first "13trunk" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "13trunk" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-13-merged -B branch-13-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] set command2 "svn --non-interactive pd branch-12-merged . > /dev/null 2>&1 || /bin/true" set command3 "svn --non-interactive pd branch-12-blocked . > /dev/null 2>&1 || /bin/true" set command4 "rm -f dir_conflicts.prej || /bin/true" } elseif [ expr [ string first "24" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "24" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-1.2-merged -B branch-1.2-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] } elseif [ expr [ string first "46" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "46" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-1.4-merged -B branch-1.4-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] set command2 "svn --non-interactive pd branch-1.2-merged . > /dev/null 2>&1 || /bin/true" set command3 "svn --non-interactive pd branch-1.2-blocked . > /dev/null 2>&1 || /bin/true" set command4 "rm -f dir_conflicts.prej || /bin/true" } elseif [ expr [ string first "68" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "68" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-1.6.2-merged -B branch-1.6.2-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] set command2 "svn --non-interactive pd branch-1.4-merged . > /dev/null 2>&1 || /bin/true" set command3 "svn --non-interactive pd branch-1.4-blocked . > /dev/null 2>&1 || /bin/true" set command4 "rm -f dir_conflicts.prej || /bin/true" } elseif [ expr [ string first "810" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "810" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-1.8-merged -B branch-1.8-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] set command2 "svn --non-interactive pd branch-1.6.2-merged . > /dev/null 2>&1 || /bin/true" set command3 "svn --non-interactive pd branch-1.6.2-blocked . > /dev/null 2>&1 || /bin/true" set command4 "rm -f dir_conflicts.prej || /bin/true" } elseif [ expr [ string first "811" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "811" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-1.8-merged -B branch-1.8-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] set command2 "svn --non-interactive pd branch-1.6.2-merged . > /dev/null 2>&1 || /bin/true" set command3 "svn --non-interactive pd branch-1.6.2-blocked . > /dev/null 2>&1 || /bin/true" set command4 "rm -f dir_conflicts.prej || /bin/true" } elseif [ expr [ string first "1011" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "1011" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-10-merged -B branch-10-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] set command2 "svn --non-interactive pd branch-1.8-merged . > /dev/null 2>&1 || /bin/true" set command3 "svn --non-interactive pd branch-1.8-blocked . > /dev/null 2>&1 || /bin/true" set command4 "rm -f dir_conflicts.prej || /bin/true" } elseif [ expr [ string first "1112" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "1112" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-11-merged -B branch-11-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] set command2 "svn --non-interactive pd branch-10-merged . > /dev/null 2>&1 || /bin/true" set command3 "svn --non-interactive pd branch-10-blocked . > /dev/null 2>&1 || /bin/true" set command4 "rm -f dir_conflicts.prej || /bin/true" } elseif [ expr [ string first "1113" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "1113" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-11-merged -B branch-11-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] set command2 "svn --non-interactive pd branch-1.8-merged . > /dev/null 2>&1 || /bin/true" set command3 "svn --non-interactive pd branch-1.8-blocked . > /dev/null 2>&1 || /bin/true" set command4 "rm -f dir_conflicts.prej || /bin/true" } elseif [ expr [ string first "1213" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "1213" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P branch-12-merged -B branch-12-blocked -f ../merge.msg -r" [ lrange $argv 0 end ] ] set command2 "svn --non-interactive pd branch-11-merged . > /dev/null 2>&1 || /bin/true" set command3 "svn --non-interactive pd branch-11-blocked . > /dev/null 2>&1 || /bin/true" set command4 "rm -f dir_conflicts.prej || /bin/true" } elseif [ expr [ string first "devtrunk" $which ] > -1 ] { set s_cmd [ string range $which 0 [ expr [ string first "devtrunk" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -f ../merge.msg -r" [ lrange $argv 0 end ] ] } elseif [ expr [ string first "from" $which ] > -1 ] { set branch [ lrange $argv 0 0 ] set s_cmd [ string range $which 0 [ expr [ string first "from" $which ] - 1 ] ] set command [ concat [ expr [ string equal $s_cmd "record" ] ? "\"merge --record-only\"" : "\"$s_cmd\"" ] " -P $branch-merged -B $branch-blocked -f ../merge.msg -r" [ lrange $argv 1 end ] ] } elseif [ string equal $which "mergeinit" ] { set command "init" } elseif [ string equal $which "autoinit" ] { set command "init" set haveintegration "1" set command2 "svn --non-interactive ps 'automerge' '*' ." if [ file isfile "~/.automerge" ] { set command3 "svn --non-interactive ps 'automerge-email' `cat ~/.automerge` ." } else { set username [ exec whoami ] set fp [ open "@@REPOTOOLS@@/authors" ] fconfigure $fp -buffering line gets $fp line while {$line != ""} { if [ string equal [ string range $line 0 [ expr [ string first "\t" $line ] - 1 ] ] $username ] { set email [ string range $line [ expr [ string first "<" $line ] + 1 ] [ expr [ string first ">" $line ] - 1 ] ] set command3 "svn --non-interactive ps 'automerge-email' '$email' ." break } gets $fp line } close $fp } } elseif [ string equal $which "svnmerge" ] { set command [ concat [ lrange $argv 0 end ] ] } else { puts -nonewline "Command not recognized: " puts [ lindex [ split $argv0 / ] end ] exit 2 } # Avail doesn't use the -f or -r options if [ string equal $s_cmd "avail" ] { set command [ string range $command 0 [ expr [ string first " -f " $command ] - 1 ] ] } eval [ concat "spawn" $svnmerge $command ] expect { "Passphrase for" { stty -echo expect_user -re "(.*)\n" stty echo send "$expect_out(1,string)\r" set havepasswd "1" } eof { } } while ([string equal $havepasswd "1"]) { expect { "Passphrase for" { send "$expect_out(1,string)\r" set haveintegration "1" } eof { break } } } if [ string equal $haveintegration "1" ] { system $command2 system $command3 system $command4 } exit