1# 2# Tcl Library for TkCVS 3# 4 5# 6# Adds a new document to the repository. 7# 8 9proc svn_import_run {} { 10 global incvs insvn 11 global cvsglb 12 global cvscfg 13 14 gen_log:log T "ENTER" 15 16 cvsroot_check [pwd] 17 if {$insvn} { 18 cvsok "This directory is already in Subversion.\nCan\'t import here!" .svn_import 19 gen_log:log T "LEAVE" 20 return 21 } elseif {$incvs} { 22 cvsok "There are CVS directories here.\nPlease remove them first." .svn_import 23 gen_log:log T "LEAVE" 24 return 25 } 26 27 set cvsglb(imdir) [file tail [pwd]] 28 # This is just a default. The user can change it. 29 if {[info exists cvscfg(svnroot)] && $cvscfg(svnroot) != ""} { 30 set cvsglb(imtop) $cvscfg(svnroot) 31 } else { 32 set cvsglb(imtop) "< URL Required >" 33 } 34 # Can't use file join or it will mess up the URL 35 set cvsglb(imtop) "$cvsglb(imtop)/trunk" 36 37 if {[winfo exists .svn_import]} { 38 wm deiconify .svn_import 39 raise .svn_import 40 grab set .svn_import 41 gen_log:log T "LEAVE" 42 return 43 } 44 45 toplevel .svn_import 46 grab set .svn_import 47 48 frame .svn_import.top 49 50 message .svn_import.top.explain -justify left -width 500 -relief groove \ 51 -text "This will import the current directory and its sub-directories\ 52 into SVN. If you haven't created a Subversion repository,\ 53 you must do that first with \"svnadmin create.\"" 54 label .svn_import.top.lsvnroot -text "URL of SVN Repository" -anchor w 55 56 entry .svn_import.top.tsvnroot -textvariable cvsglb(imtop) 57 58 grid .svn_import.top.explain -column 0 -row 0 -columnspan 3 -sticky ew 59 #grid .svn_import.top.lnewdir -column 0 -row 1 -sticky w 60 #grid .svn_import.top.tnewdir -column 1 -row 1 -sticky ew 61 grid .svn_import.top.lsvnroot -column 0 -row 2 -sticky e 62 grid .svn_import.top.tsvnroot -column 1 -row 2 -sticky ew 63 64 65 frame .svn_import.down -relief groove -border 2 66 button .svn_import.down.ok -text "OK" \ 67 -command { 68 grab release .svn_import 69 wm withdraw .svn_import 70 svn_do_import $cvsglb(imtop) $cvsglb(imdir) 71 } 72 button .svn_import.down.quit -text "Cancel" \ 73 -command { 74 grab release .svn_import 75 wm withdraw .svn_import 76 } 77 78 pack .svn_import.down -side bottom -expand yes -fill x 79 pack .svn_import.top -side top -expand yes -fill x 80 pack .svn_import.down.ok -side left -expand yes 81 pack .svn_import.down.quit -side left -expand yes 82 83 84 wm title .svn_import "Import a Project into Subversion" 85 wm minsize .svn_import 1 1 86 87 gen_log:log T "LEAVE" 88} 89 90proc svn_do_import {imtop imdir} { 91 global cvscfg 92 93 gen_log:log T "ENTER" 94 set imdir [pwd] 95 set cwd [pwd] 96 97 set commandline "svn import . $imtop -m \"Imported using TkCVS\"" 98 set v [viewer::new "Import Project"] 99 $v\::log "\nSVN Import\n" 100 $v\::do "$commandline" 101 $v\::wait 102 update 103 104 105 # Now check out the new module 106 cd .. 107 gen_log:log F "CD [pwd]" 108 # We have to move the original stuff entirely out of the way. 109 # Otherwise checkout won't do the whole tree. 110 gen_log:log F "MOVE $imdir $imdir.orig" 111 if {[file isdirectory $imdir.orig]} { 112 file delete -force -- $imdir.orig 113 } 114 file rename $imdir $imdir.orig 115 set commandline "svn checkout $imtop $imdir" 116 117 $v\::log "\nSVN Checkout\n" 118 $v\::do "$commandline" 119 $v\::wait 120 121 if {[catch "cd $imdir" err]} { 122 # If we didn't check out the new dir sucessfully, put the old one back 123 file rename $imdir.orig $imdir 124 cvsok "$err" .isvn_mport 125 } else { 126 gen_log:log F "CD [pwd]" 127 } 128 129 setup_dir 130 modbrowse_run svn 131 gen_log:log T "LEAVE" 132} 133 134