Farbflash projects: Imaging lingo table | 3-D scene list | Find all | Handler menu | Lingo message window

source: trunk/lingosource/castlib1/svn_Utilities.ls

Last change on this file was 253, checked in by alex, 8 months ago

updated scripts, fixed personal folder on windows, which points to documents on NOT to home as I thought, added fix for subversion 1.7

File size: 110.4 KB
Line 
1-- svn_Utilities
2-----------------------------------
3-- PROPERTIES:
4--!memberProperties: [#name: "svn_Utilities", #scripttype: #parent, #scriptSyntax: #lingo, #comments: "~/Documents/Scripts/lingo/commonMovieScript.ls"]
5--
6-- DESCRIPTION:
7--               This script externalizes all functions which are related to the use of subversion with director
8--               
9--
10-- REQUIRES:
11--               script "alexUtilities" -> ancestor -> basic function provider
12--               most functionality is provided through the shell xtra and buddyApi xtra
13--               although it should fail gracefully, if those are not present
14--               not much will work without them
15--               It also requires the svn command line client to be installed on the machine
16--
17-- USAGE:
18--               This script is instantiated and used in the "tell the stage" block and one of the functions
19--               which are defined in script "OSCmenu_Utilities" and which was selected by the user
20--               will be executed in "stage scope". That means, that references are made form within the stage context
21--               e.g. member("foo") will refer to a member in one of the stages castlibs
22--               sprite(x) will refere to sprite(x) in the stages score and so on
23--
24--               Please see the descriptions of many of those handlers at: http://www.farbflash.org/trac/HandlerMenu/wiki/utilityHandlers
25-----------------------------------
26
27property ancestor
28
29on new me
30  ancestor = new(script "alexUtilities")
31  return me
32end
33
34-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
35on _______________SVN_SCRIPT_TEXT me
36end
37-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
38
39
40on mCompareCurrentScriptToWorkingCopy me, convertLineBreaksToUnix
41 
42  if not(the platform contains "mac") then
43   
44    --    alert "This function only works with BBDiff, a command line tool provided by the OSX app BBEdit. I am sure, something similar exists for windows too, but you'll need to change this script yourself for windows"
45    --    exit
46   
47    bbdiffpath = mGetSVNDiffBinaryPath(me)
48   
49    if length(bbdiffpath) < 1 then exit
50   
51    isMac = 0
52  else
53    isMac = 1
54    bbdiffpath = mFindUnixAppInPath(me, "bbdiff")
55    if length(bbdiffpath) < 1 then
56      alert "This function only works with BBDiff, a command line tool provided by BBEdit. Consider installing BBEdits command line tools, it is really helpful."
57      exit
58    end if
59   
60  end if
61 
62 
63  if  mCheckForXtra(me, "ff_shell") = 0 then
64    if mCheckForXtra(me, "Shell") = 0 then
65      mShellXtraMissing me
66      exit
67    end if
68  end if
69 
70 
71  cl = the activecastlib
72  sel = the selection of castlib cl
73 
74  repeat with sub in sel
75    repeat with mem = sub[1] to sub[2]
76      memref = member(mem,cl)
77     
78      memtype = memref.type
79      if [#script, #field, #text].getPos(memtype) > 0 then
80       
81        case memtype of
82           
83            -----------------------
84          #script:
85            ext = ".ls"
86            st = memref.scripttext
87           
88            -----------------------
89          #field:
90            ext = ".txt"
91            st = memref.text
92           
93            -----------------------
94          #text:
95            ext = ".html"
96            st = memref.html
97           
98            -----------------------
99          otherwise:
100            ext = ".txt"
101            st = memref.text
102           
103        end case
104       
105        thePath = mFindWorkingCopyCounterpart(me, memref, ext)
106       
107        if length(thePath) < 1 then
108         
109          put "Corresponding file for member " & memref.name && "(" & memref & ") was not found"
110         
111         
112        else
113         
114          tempSrcHFSPath = mGetTempFilePath(me, "temp_SVN_Diff_file1.ls")
115         
116          if isMac then
117            tempSrcPath = mConvertHfs2unix(me, tempSrcHFSPath)
118          else
119            tempSrcPath = tempSrcHFSPath
120          end if
121         
122          ------------------------------------------ trac subversion support works better with unix linebreaks...
123          if voidP(convertLineBreaksToUnix) then convertLineBreaksToUnix = 1
124          if convertLineBreaksToUnix = "" then convertLineBreaksToUnix = 1
125         
126          if convertLineBreaksToUnix = 1 then
127           
128            if mCheckForXtra(me, "Pregex") = 1 then
129             
130              scrTextLi = [st]
131              pregex_replace(scrTextLi, "\x0D\x0A?", "g", "\x0A")
132              st = scrTextLi[1]
133             
134            else
135             
136              fndStr = numToChar(13) & numToChar(10)
137              offs = offset(fndStr, st)
138              repeat while offs > 0
139                delete char offs of st
140                offs = offset(fndStr, st)
141              end repeat
142             
143              fndStr = numToChar(13)
144              offs = offset(fndStr, st)
145              repeat while offs > 0
146                put numToChar(10) into char offs of st
147                offs = offset(fndStr, st)
148              end repeat
149             
150            end if
151          end if
152          -----------------------------------------
153         
154          theResult = mSaveTextToTempFile(me, st, tempSrcHFSPath)
155          ---------------------
156         
157         
158          if theResult <> 0 then
159           
160           
161           
162           
163            if isMac then
164             
165              comm = mConvertHFS2Unix(me, thePath)
166             
167              theResult = mDoShellCmd(me, QUOTE & bbdiffpath & QUOTE & " --ignore-curly-quotes --ignore-spaces --wait --resume " &QUOTE& tempSrcPath &QUOTE&&QUOTE& comm &QUOTE && "2>&1", RETURN, 0, 1)
168             
169              -- since we used the --wait and the --resume switch, we will only come to this line AFTER the diff process in bbedit is finished
170             
171              if count(theResult) > 0 then
172                if theResult[1] contains "no such file or directory" then
173                  put theResult[1]
174                else
175                  put "No differences found for member: " & memref.name && "(" & memref & ")"
176                end if
177                writeBack = 0
178               
179              else
180               
181                -------- now write the results of the BBEdit diff back into the script members
182                scrText = mGetTextFromFile(me, tempSrcHFSPath)
183               
184                writeBack = 1
185               
186               
187              end if
188             
189             
190              ---------------------- windows
191            else
192             
193             
194              theResult = mDoShellCmd(me, QUOTE & bbdiffpath & QUOTE && QUOTE & tempSrcPath &QUOTE&&QUOTE& thePath &QUOTE, RETURN, 0, 0, 0)
195             
196              -------- now write the results of the BBEdit diff back into the script members
197              scrText = mGetTextFromFile(me, tempSrcHFSPath)
198             
199              writeBack = 1
200            end if
201           
202           
203            if writeBack = 1 then
204             
205              if convertLineBreaksToUnix = 1 then
206                ------------------------------------------ trac subversion support works better with unix linebreaks...
207                if mCheckForXtra(me, "Pregex") = 1 then
208                 
209                  scrTextLi = [scrText]
210                  ----------- always convert to mac linebreaks as director internally uses mac linebreaks
211                  pregex_replace(scrTextLi, "\x0D?\x0A", "g", "\x0D")
212                  scrText = scrTextLi[1]
213                 
214                else
215                 
216                  ----------- always convert to mac linebreaks as director internally uses mac linebreaks
217                  -- if the platform contains "mac" then
218                 
219                  -- first convert windows to mac
220                  fndStr = numToChar(13) & numToChar(10)
221                  offs = offset(fndStr, scrText)
222                  repeat while offs > 0
223                    put numToChar(13) into char offs to offs+1 of scrText
224                    offs = offset(fndStr, scrText)
225                  end repeat
226                 
227                  -- now convert unix to mac
228                  fndStr = numToChar(10)
229                  offs = offset(fndStr, scrText)
230                  repeat while offs > 0
231                    put numToChar(13) into char offs of scrText
232                    offs = offset(fndStr, scrText)
233                  end repeat
234                 
235                 
236                end if
237                -----------------------------------------
238              end if
239             
240             
241             
242              case memtype of
243                 
244                  -----------------------
245                #script:
246                  memref.scripttext = scrText
247                 
248                  -----------------------
249                #field:
250                  memref.text = scrText
251                 
252                  -----------------------
253                #text:
254                  memref.html = scrText
255                 
256                  -----------------------
257                otherwise:
258                  memref.text = scrText
259                 
260              end case
261             
262            end if
263           
264          end if
265         
266          -- exit -- we only proceed one script member, WHY ???
267         
268         
269        end if
270       
271      end if -- corresponding file not found for this member
272     
273    end repeat
274  end repeat
275 
276 
277end
278
279-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
280-- this can be used to open the corresponding script in bbedit and svn compare it to head
281
282on mExportCurrentScriptToWorkingCopyAndOpen me, convertLineBreaksToUnix
283 
284  mExportScriptsToFolder me, 1, 1, convertLineBreaksToUnix
285 
286  cl = the activecastlib
287  sel = the selection of castlib cl
288 
289  repeat with sub in sel
290    repeat with mem = sub[1] to sub[2]
291      memref = member(mem,cl)   
292      memtype = memref.type
293      if [#script, #field, #text].getPos(memtype) > 0 then
294       
295        case memtype of
296           
297            -----------------------
298          #script:
299            ext = ".ls"
300            st = memref.scripttext
301           
302            -----------------------
303          #field:
304            ext = ".txt"
305            st = memref.text
306           
307            -----------------------
308          #text:
309            ext = ".html"
310            st = memref.html
311           
312            -----------------------
313          otherwise:
314            ext = ".txt"
315            st = memref.text
316           
317        end case
318       
319       
320        thePath = mFindWorkingCopyCounterpart(me, memref, ext)
321       
322        if length(thePath) < 1 then
323          alert "Corresponding member was not found"
324          exit 
325        end if
326       
327        ------------------- export will now be done in "mExportScriptsToFolder"
328        --        st = memref.scripttext
329        --        mSaveToTextFile me, st, thePath
330       
331        if the platform contains "mac" then
332          if (mCheckForXtra(me, "budapi") + (mCheckForXtra(me, "Shell") + mCheckForXtra(me, "ff_shell"))) > 1 then
333           
334            bbeditBinary = mFindUnixAppInPath(me, "bbedit")
335            if length(bbeditBinary) > 0 then
336              mDoShellCmd(me, QUOTE & bbeditBinary & QUOTE && QUOTE & mConvertHFS2Unix(me, thePath) & QUOTE)
337              exit
338            end if
339           
340          end if
341        end if
342       
343       
344        bbdiffpath = mGetSVNDiffBinaryPath(me)
345        if length(bbdiffpath) then
346          mDoShellCmd(me, QUOTE & bbdiffpath & QUOTE && QUOTE & thePath & QUOTE, RETURN, 0, 0, 0)
347        else
348          open thePath
349        end if
350       
351        exit
352       
353      end if
354     
355    end repeat
356  end repeat
357 
358end
359
360-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
361
362on mFindWorkingCopyCounterpart me, memref, file_extension
363 
364  file_extension = string(file_extension)
365  if length(file_extension) < 1 then file_extension = ".ls"
366 
367  workingCopies = value(getPref("svn_workingCopies_paths.txt"))
368  if ilk(workingCopies) <> #proplist then workingCopies = [:]
369 
370  theFolder = mGetWorkingCopyPath(me, the moviepath & the moviename, 0, workingCopies, "No working copy is specified for this movies scripttext. Please select a working copy for the scripttext now.")
371  --  put "mFindWorkingCopyCounterpart: theFolder:" && theFolder
372 
373  if length(theFolder) < 1 then return ""
374 
375 
376  m = memref.castlibnum
377 
378  delim = the last char of the applicationpath
379  olddelim = the itemdelimiter
380  the itemdelimiter = delim
381  theFoldername = theFolder
382  if the last char of theFoldername = delim then delete the last char of theFoldername
383  else put delim after theFolder
384  theFoldername = the last item of theFoldername
385  the itemdelimiter = olddelim
386 
387  infolist = 0
388 
389  if theFoldername <> "castlib" & m then
390   
391    newPath = theFolder & "castlib" & m & delim
392   
393    if baFolderExists(newPath) = 0 then
394     
395      infolistPath = theFolder & "memberInfo.xml"
396     
397      infolist = mReadXML_2_List(me, infolistPath)
398     
399      if ilk(infolist) <> #proplist then
400       
401        alert "The specified folder doesn't seem to contain info for this castlib: file memberInfo.xml missing."
402        return ""
403       
404      else
405       
406        if count(infolist) < 1 then
407         
408          alert "The specified folder doesn't seem to contain info for this castlib: file memberInfo.xml missing."
409          return ""
410         
411        else
412          theFolder = newPath
413        end if
414       
415      end if
416     
417    else
418     
419      theFolder = newPath
420     
421    end if
422   
423  end if
424 
425 
426  if infolist = 0 then
427   
428    infolistPath = theFolder & "memberInfo.xml"
429   
430    infolist = mReadXML_2_List(me, infolistPath)
431   
432    if ilk(infolist) <> #proplist then
433     
434      alert "The specified folder doesn't seem to contain info for this castlib: file memberInfo.xml missing."
435      return ""
436     
437    end if
438   
439  end if
440 
441 
442  cnt = count(infolist)
443 
444  repeat with l = 1 to cnt
445    li = infolist[l]
446   
447    if li.getaprop(#memberName) = memref.name then
448     
449      fname = string(infolist[l].getaprop(#fname))
450      if length(fname) < 1 then fname = string(infolist.getpropat(l))
451      fpath = theFolder & fname & file_extension
452     
453      if length(baShortFilename(fpath)) > 0 then return fpath
454     
455    end if
456  end repeat
457 
458 
459  return ""
460 
461end
462
463-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
464-- export all scripts into a folder (I use this to compare to versions of a movie, open movie 1, export all scripts, open movie 2 and export all scripts and then compare with bbdiff both folders)
465
466on mExportScriptsToFolder me, skipIcons, selectionOnly, convertLineBreaksToUnix, chooseNewPath
467 
468  mExportAllScriptsToDiskWithFolder me, skipIcons, selectionOnly, convertLineBreaksToUnix, void, chooseNewPath
469 
470end
471
472-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
473
474on mExportAllScriptsToDiskWithFolder me, skipIcons, selectionOnly, convertLineBreaksToUnix, theFolder, chooseNewPath
475 
476 
477  theFolder = string(theFolder)
478  if length(theFolder) < 1 then
479   
480    if chooseNewPath <> 1 then
481      workingCopies = value(getPref("svn_workingCopies_paths.txt"))
482      if ilk(workingCopies) <> #proplist then workingCopies = [:]
483     
484      theFolder = mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies scripttext. Please select a working copy for the scripttext now.")
485    end if
486   
487    if length(theFolder) < 1 then
488     
489      theFolder = mGetFolderPathFromUser(me)
490     
491    end if
492   
493  end if
494 
495  if length(theFolder) < 1 then exit
496 
497  if the last char of theFolder <> the last char of the moviepath then put the last char of the moviepath after theFolder
498 
499  if ilk(selectionOnly) = #castlib then
500    firstCastNum = selectionOnly.number
501    lastCastNum = firstCastNum
502    selectionOnly = 0
503   
504  else
505    if selectionOnly = 1 then
506      cl = the activecastlib
507      sel = the selection of castlib cl
508     
509      firstCastNum = cl
510      lastCastNum = cl   
511     
512    else
513      firstCastNum = 1
514      lastCastNum = the number of castlibs
515    end if
516  end if
517 
518 
519  DirectImageInstance = 0
520  if skipIcons <> 1 then
521    if mCheckForXtra(me, "SharpExport") = 1 then
522      SharpExportInst = new(xtra "SharpExport")
523    else
524      skipIcons = 1
525    end if
526  end if
527 
528 
529  isMac = (the platform contains "mac") -- we need the differentiation because of the dreaded 31 char limit
530 
531  -----------------------
532  resetUNames = 0
533  if isMac then
534    if baSysFolder("prefs") starts "/" then
535      baReturnUnixNames(0)
536      resetUNames = 1
537    end if
538  end if
539  -----------------------
540 
541  doit = 0
542 
543  statusSwitched = mSwitchToStatusMode(me, 1)
544 
545  repeat with m = firstCastNum to lastCastNum
546   
547    listOfAllFiles = ["memberinfo"]
548   
549    thisFolder = theFolder & "castlib" & m
550    if baFolderExists(thisFolder) <> 1 then
551      err = baCreateFolder(thisFolder)
552      if err <> 1 then
553        alert "Failed to create directory:" && thisFolder
554        if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
555        DirectImageInstance = 0
556        exit
557      end if
558    end if
559   
560    thisFolder = thisFolder & the last char of the applicationpath
561   
562   
563    doit = 0
564    infolistPath = thisFolder & "memberInfo.xml"
565    infolist = mReadXML_2_List(me, infolistPath)
566    if ilk(infolist) <> #proplist then infolist = [:]
567   
568   
569    if selectionOnly = 1 then
570      sel = the selection of castlib m
571    else
572      cnt = the number of members of castlib m
573      sel = [[1, cnt]]
574    end if
575   
576    repeat with sub in sel
577      repeat with n = sub[1] to sub[2]   
578       
579        memref = member(n, m)
580       
581        memtype = memref.type
582       
583       
584        convertLineBreaksToUnixT = 0
585       
586        -- if [#script].getPos(memtype) > 0 then
587        if [#script, #field, #text].getPos(memtype) > 0 then
588         
589          case memtype of
590             
591              -----------------------
592            #script:
593              ext = ".ls"
594              scrText = memref.scripttext
595              scrtype = memref.scripttype
596              -----------------------
597            #field:
598              ext = ".txt"
599              scrText = memref.text
600              scrtype = #field
601              -----------------------
602            #text:
603              ext = ".html"
604              scrText = memref.html
605              convertLineBreaksToUnixT = 0
606              scrtype = #text
607              -----------------------
608            otherwise:
609              ext = ".txt"
610              scrText = memref.text
611              scrtype = #field
612          end case
613         
614         
615         
616          memname = memref.name
617         
618         
619          mDisplayWaitStatusText me, "Processing member:" && memname
620         
621         
622          -- scrText = memref.scripttext
623         
624         
625          ------------- once I thought about adding the support for metadata directly to the script
626          ------------- metadata like thumbnail path, script type etc.
627          ------------- but currently I stick to the memberInfo.xml approach to store the metadata
628          ------------- so the following is disabled ... meanwhile...
629          ------------- the "memberInfo.xml" approach is more svn like anyway
630         
631         
632          --          ------------------------------ check for existing meta data
633          --         
634          --          export_meta_data = scrText&""
635          --          offs = offset("-- -- -- export_meta_data", export_meta_data)
636          --          if offs > 0 then
637          --            delete char 1 to offs + 24 of export_meta_data
638          --            offs = offset("-- -- -- // export_meta_data", export_meta_data)
639          --            if offs > 0 then
640          --              delete char offs to length(export_meta_data) of export_meta_data
641          --            end if
642          --            numlines = export_meta_data.line.count
643          --            repeat with l = 1 to numlines
644          --              thisLine = export_meta_data.line[l]
645          --             
646          --            end repeat
647          --          end if
648          --         
649          --          ------------------------------
650         
651         
652          theDefaultName = memname
653         
654          doit = 1
655         
656          if length(theDefaultName) < 1 then
657            theDefaultName =  "member" & n & "_" & m
658            memref.name = theDefaultName
659            -- alert memref && "has no membername! Member without names will cause trouble when re-importing the scripts."
660            put "renamed member" && memref && "to member(" & QUOTE & theDefaultName & QUOTE & ") as member without names are not supported"
661           
662          else
663           
664            if memref <> member(theDefaultName, m) then
665              put "Member" && memref && "is duplicate. Member with duplicate names are not supported. (Can't have the same file twice in one folder.)"
666              next repeat
667            end if
668           
669          end if
670         
671         
672         
673          -- if offset(".", theDefaultName) < 1 then put ".ls" after theDefaultName
674         
675          theDefaultName = mStripFunnyCharsFromFileName(me, theDefaultName)
676         
677         
678          origname = theDefaultName&""
679          if length(theDefaultName) > 25 and isMac then
680           
681            ms = string(the milliseconds)
682            mlen = length(ms)
683            ms = char mlen - 6 to mlen of ms
684           
685            theDefaultName = char 1 to 18 of theDefaultName
686            theDefaultName = theDefaultName & ms -- trim filenames as the mac version of fileio wants to deal with 31 chars
687           
688          end if
689         
690         
691         
692          ------------------------------------------ trac subversion support works better with unix linebreaks...
693          if voidP(convertLineBreaksToUnix) then convertLineBreaksToUnix = 1
694          if convertLineBreaksToUnix = "" then convertLineBreaksToUnix = 1
695         
696          if convertLineBreaksToUnix = 1 then
697            if convertLineBreaksToUnixT <> 1 then
698              if mCheckForXtra(me, "Pregex") = 1 then
699               
700                scrTextLi = [scrText]
701                pregex_replace(scrTextLi, "\x0D\x0A?", "g", "\x0A")
702                scrText = scrTextLi[1]
703               
704              else
705               
706                fndStr = numToChar(13) & numToChar(10)
707                offs = offset(fndStr, scrText)
708                repeat while offs > 0
709                  delete char offs of scrText
710                  offs = offset(fndStr, scrText)
711                end repeat
712               
713                fndStr = numToChar(13)
714                offs = offset(fndStr, scrText)
715                repeat while offs > 0
716                  put numToChar(10) into char offs of scrText
717                  offs = offset(fndStr, scrText)
718                end repeat
719              end if 
720            end if
721          end if
722          -----------------------------------------
723         
724          if theDefaultName <> origname then
725            alterText = ""
726            snam = baShortFileName(thisFolder & origname & ext)
727            if length(snam) > 0 then
728              -- alterText = mGetTextFromFile(me, thisFolder & origname & ext)
729              alterText = mGetTextFromFile(me, snam)
730            else
731              alterText = mGetTextFromFile(me, thisFolder & origname & ext)
732            end if
733          else
734            alterText = mGetTextFromFile(me, thisFolder & theDefaultName & ext)
735          end if
736         
737          listOfAllFiles.add(mLowerCase(me, origname))
738         
739          if alterText <> scrText then
740           
741            --------------------- compare without whitespaces:
742            noChanges = (mRemoveWhiteSpaces(me, scrText&"") = mRemoveWhiteSpaces(me, alterText&""))
743           
744           
745            if noChanges = 0 then
746             
747              mSaveToTextFile me, scrText, thisFolder & theDefaultName & ext
748             
749             
750             
751              bmexp = 0
752              if skipIcons <> 1 then
753               
754                thumbmember = new(#bitmap)
755                thumbmember.picture = memref.thumbnail
756               
757                if thumbmember.width > 0 then
758                  bmexp = 1
759                  if baFileExists(thisFolder & theDefaultName & ".png") then baDeleteFile(thisFolder & theDefaultName & ".png")
760                 
761                  if objectP(DirectImageInstance) then
762                   
763                    DirectImageInstance.imageLoadFromMember(thumbmember)
764                    DirectImageInstance.imageSaveToFile(thisFolder & theDefaultName & ".png", 100, 1,1)
765                   
766                  else if objectP(SharpExportInst) then
767                    mExportBM me, thumbmember, thisFolder & theDefaultName & ".png", "png", 100, SharpExportInst
768                   
769                  end if
770                 
771                end if
772               
773                thumbmember.erase()
774               
775              end if
776             
777             
778              if theDefaultName <> origname then
779               
780                snam = baShortFileName(thisFolder & origname & ext)
781                if length(snam) > 0 then baDeleteFile(snam)
782                erg = baRenameFile(thisFolder & theDefaultName & ext, thisFolder & origname & ext)
783                if erg <> 1 then put "Couldn't rename file " & thisFolder & theDefaultName & ext & " to " & thisFolder & origname & ext
784                if bmexp = 1 then
785                  snam = baShortFileName(thisFolder & origname & ".png")
786                  if length(snam) > 0 then baDeleteFile(snam)
787                  erg = baRenameFile(thisFolder & theDefaultName & ".png", thisFolder & origname & ".png")
788                  if erg <> 1 then put "Couldn't rename file " & thisFolder & theDefaultName & ".png to " & thisFolder & origname & ".png"
789                end if
790               
791              end if
792             
793              if origname <> memname then
794                put "Renamed member" && memref && "to" && origname & ". Scriptmember names must not be emoty or contain illegal characters (SPACE, /, :, \, &)"
795              end if
796             
797            end if
798          end if
799         
800         
801          infolist.setaprop(symbol(origname), [#scripttype: scrtype, #comments: memref.comments, #membername: memname, #fname: origname])
802          -- we need to store origname as string additionally to symbol, as the symbol may change the case (although only ufs is case sensitive
803          -- I am more comfortable with not relying on case insensitivity of filesystems)
804         
805        end if
806       
807       
808      end repeat
809    end repeat
810   
811    if doit = 1 then
812      --      mSaveList_2_XML me, infolist, infolistPath
813     
814      mRefreshMemberInfoList me, thisFolder, m, infolist
815    end if
816   
817   
818    -----------------------
819    if isMac then baReturnUnixNames(1)
820    -----------------------
821   
822    flist = baFileList(thisFolder, "*.*")
823   
824   
825    --    put "flist =" && flist
826    --    put "listOfAllFiles =" && listOfAllFiles
827    repeat with thisFile in flist
828      split = mSplitPath(me, thisFile)
829      if listOfAllFiles.getPos(mLowerCase(me, split[#basename])) < 1 then
830        if isMac then
831          erg = baDeleteFile(mConvertHFS2Unix(me, thisFolder & thisFile))
832        else
833          erg = baDeleteFile(thisFolder & thisFile)
834        end if
835        if erg = 1 then
836          put "Deleted file" && thisFolder & thisFile
837        else
838          put "Unable to delete file" && thisFolder & thisFile
839        end if
840      end if
841    end repeat
842   
843    -----------------------
844    if isMac then baReturnUnixNames(0)
845    -----------------------
846   
847   
848  end repeat
849 
850  if resetUNames = 1 then baReturnUnixNames(1)
851 
852  DirectImageInstance = 0
853  SharpExportInst = 0
854 
855  if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
856 
857end
858
859-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
860
861on mRefreshMemberInfoList me, thisFolder, theCastlibNumber, infolist
862 
863  infolistPath = thisFolder & "memberInfo.xml"
864 
865  if ilk(infolist) <> #proplist then infolist = mReadXML_2_List(me, infolistPath)
866  if ilk(infolist) <> #proplist then infolist = [:]
867  newInfolist = [:]
868 
869  isMac = (the platform contains "mac")
870 
871  cnt = the number of members of castlib theCastlibNumber
872 
873  repeat with n = 1 to cnt 
874   
875    memref = member(n, theCastlibNumber)
876   
877    memtype = memref.type
878   
879    -- if [#script].getPos(memtype) > 0 then
880    if [#script, #field, #text].getPos(memtype) > 0 then
881     
882      case memtype of
883         
884          -----------------------
885        #script:
886          ext = ".ls"
887          scrtype = memref.scripttype
888          -----------------------
889        #field:
890          ext = ".txt"
891          scrtype = #field
892          -----------------------
893        #text:
894          ext = ".html"
895          scrtype = #text
896          -----------------------
897        otherwise:
898          ext = ".txt"
899          scrtype = #field
900         
901      end case
902     
903      memname = memref.name
904     
905      theDefaultName = memname
906     
907      doit = 1
908     
909      if length(theDefaultName) < 1 then
910       
911        put "Member" && memref && "has no name, therefore skipped"
912       
913        --      if length(theDefaultName) < 1 then
914        --        theDefaultName =  "member" & n & "_" & theCastlibNumber
915        --        alert memref && "has no membername! Member without names will cause trouble when re-importing the scripts."
916        --      end if
917       
918      else
919       
920        if memref <> member(theDefaultName, theCastlibNumber) then
921          put "Member" && memref && "is duplicate. Member with duplicate names are not supported"
922         
923        else
924          theDefaultName = mStripFunnyCharsFromFileName(me, theDefaultName)
925         
926         
927          origname = theDefaultName&""
928         
929          oldlist = infolist.getaprop(symbol(origname))
930          if not(listP(oldlist)) then
931            oldlist = [:]
932            fname = origname
933            snam = baShortFileName(thisFolder & origname & ext)
934            if length(snam) < 1 then
935              put "Something seems wrong here. baShortFileName for " & thisFolder & origname & ext && "returned false. The file doesn't seem to exist!"
936            end if
937            oldlist.setaprop(#fname, origname)
938          end if
939          oldlist.setaprop(#scripttype, scrtype)
940          oldlist.setaprop(#comments, memref.comments)
941          oldlist.setaprop(#membername, memname)
942         
943         
944          newInfolist.setaprop(symbol(origname), oldlist)
945          -- we need to store origname as string additionally to symbol, as the symbol may change the case (although only ufs is case sensitive
946          -- I am more comfortable with not relying on case insensitivity of filesystems)
947         
948        end if
949      end if
950    end if
951   
952  end repeat
953 
954  if doit = 1 then mSaveList_2_XML me, newInfolist, infolistPath
955 
956 
957end
958
959-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
960
961on mSVN_Update_And_Import_ScriptsFromFolder me, chooseNewPath, selectionOnly
962 
963  if selectionOnly = 1 then
964    mUpdateSelectedScriptsFromFolder me, chooseNewPath
965    exit
966  end if
967 
968 
969  workingCopies = value(getPref("svn_workingCopies_paths.txt"))
970  if ilk(workingCopies) <> #proplist then workingCopies = [:]
971 
972  if chooseNewPath = 1 then
973    thePath = ""
974  else
975    thePath = string(mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies scripttext. Please select a working copy for the scripttext now."))
976  end if
977 
978 
979  if length(thePath) < 1 then thePath = mGetFolderPathFromUser(me)
980 
981  if length(thePath) < 1 then exit
982 
983  if mCheckForXtra(me, "budapi") then
984   
985    statusSwitched = mSwitchToStatusMode(me, 1)
986   
987    if baFileExists(thePath & "memberInfo.xml") then
988      mUpdateScriptCastlibFromFolder me, thePath
989    else
990      folderlist = bafolderlist(thePath)
991      delim = the last char of the applicationpath
992      cnt = count(folderlist)
993      repeat with n = 1 to cnt
994        if folderlist[n] starts "castlib" then
995          mUpdateScriptCastlibFromFolder me, thePath & folderlist[n] & delim
996        end if
997      end repeat
998    end if
999   
1000    if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
1001   
1002  else
1003   
1004    alert "Hey, buddyAPI not found! Please install this must-have xtra. And try again."
1005   
1006  end if
1007 
1008end
1009
1010
1011-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1012
1013on mUpdateScriptCastlibFromFolder me, thePath
1014 
1015  infoList = mReadXML_2_List(me, thePath & "memberInfo.xml")
1016 
1017  if ilk(infoList) <> #proplist then
1018    alert thePath && "memberInfo.xml has no data! Can't update folder:" & thePath
1019    return false
1020  end if
1021 
1022  olddelim = the itemdelimiter
1023  delim = the last char of the applicationpath
1024  the itemdelimiter = delim
1025  fd = thePath
1026  if the last char of fd = delim then delete the last char of fd
1027  fd = the last item of fd
1028  the itemdelimiter = olddelim
1029 
1030  if not(fd starts "castlib") then
1031    alert thePath && "does not seem to be valid, as its name doesn't start with " & QUOTE & "castlib" & QUOTE
1032    return false
1033  end if
1034 
1035  delete char 1 to 7 of fd
1036  fd = integer(word 1 of fd)
1037 
1038  if not(integerP(fd)) then
1039    alert thePath && "does not seem to be valid, as its name doesn't yield a castlib number:" && fd
1040    return false
1041  end if
1042 
1043 
1044  if fd > the number of castlibs then
1045    alert thePath && "points to a non-existant castlib (castlib" && fd & "). Please create the castlib before improting the scripts."
1046    return false
1047  end if
1048 
1049  cnt = count(infoList)
1050  repeat with n = 1 to cnt
1051    thisMemberInfo = infoList[n]
1052    fname = string(thisMemberInfo.getaprop(#fname))
1053    if length(fname) < 1 then fname = string(infoList.getPropAt(n))
1054    fpath = thePath & fname
1055   
1056    scrtype = thisMemberInfo.getaprop(#scripttype)
1057    case scrtype of
1058      #field: ext = ".txt"
1059      #text: ext = ".html"
1060      otherwise: ext = ".ls"
1061    end case
1062   
1063    mImportScriptWithThumbnail me, fpath & ext, fd, 1, thisMemberInfo
1064   
1065  end repeat
1066 
1067 
1068  return true
1069end
1070
1071
1072-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1073
1074on mUpdateSelectedScriptsFromFolder me, chooseNewPath
1075 
1076  workingCopies = value(getPref("svn_workingCopies_paths.txt"))
1077  if ilk(workingCopies) <> #proplist then workingCopies = [:]
1078 
1079  if chooseNewPath = 1 then
1080    thePath = ""
1081  else
1082    thePath = string(mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies scripttext. Please select a working copy for the scripttext now."))
1083  end if
1084 
1085 
1086  if length(thePath) < 1 then thePath = mGetFolderPathFromUser(me)
1087 
1088  if length(thePath) < 1 then exit
1089 
1090  cl = the activecastlib
1091 
1092  olddelim = the itemdelimiter
1093  the itemdelimiter = the last char of the applicationpath
1094  fname = thePath
1095  delete the last item of fname
1096  fname = the last item of fname
1097  the itemdelimiter = olddelim
1098 
1099  infolist = 0
1100 
1101  if fname <> "castlib" & the number of castlib cl then
1102   
1103    newPath = thePath & "castlib" & the number of castlib cl & the last char of the applicationpath
1104   
1105    if baFolderExists(newPath) = 0 then
1106     
1107      infolistPath = thePath & "memberInfo.xml"
1108     
1109      infolist = mReadXML_2_List(me, infolistPath)
1110     
1111      if ilk(infolist) <> #proplist then
1112       
1113        alert "The specified folder doesn't seem to contain info for this castlib: file memberInfo.xml missing."
1114        return 0
1115       
1116      else
1117       
1118        thePath = newPath
1119       
1120      end if
1121     
1122    else
1123     
1124      thePath = newPath
1125     
1126    end if
1127   
1128  end if
1129 
1130 
1131  if infolist = 0 then
1132   
1133    infolistPath = thePath & "memberInfo.xml"
1134    infolist = mReadXML_2_List(me, infolistPath)
1135   
1136    if ilk(infolist) <> #proplist then
1137     
1138      alert "The specified folder (" & infolistPath & ") doesn't seem to contain info for this castlib: file memberInfo.xml missing."
1139      return 0
1140     
1141    end if
1142   
1143  end if
1144 
1145 
1146  if count(infolist) < 1 then
1147   
1148    alert "The specified folder (" & infolistPath & ") doesn't seem to contain info for this castlib: file memberInfo.xml missing."
1149    return 0
1150   
1151  end if
1152 
1153 
1154  cl = the activecastlib
1155  sel = the selection of castlib cl
1156  anz = sel.count
1157  cnt = count(infolist)
1158 
1159  --  put "mUpdateSelectedScriptsFromFolder: infolist = " & infolist
1160 
1161  repeat with n = 1 to anz
1162    repeat with m = sel[n][1] to sel[n][2]
1163      memref = member(m, cl)
1164      dertyp = memref.type
1165     
1166      if [#script, #text, #field].getPos(dertyp) > 0 then
1167       
1168        found = 0
1169        repeat with l = 1 to cnt
1170          li = infolist[l]
1171          if li.getaprop(#memberName) = memref.name then
1172           
1173            fname = string(infolist[l].getaprop(#fname))
1174            if length(fname) < 1 then fname = string(infolist.getpropat(l))
1175           
1176            case dertyp of
1177              #text: ext = ".html"
1178              #field: ext = ".txt"
1179              otherwise: ext = ".ls"   
1180            end case
1181           
1182            fpath = thePath & fname & ext
1183           
1184            found = 1
1185           
1186            if baFileExists(fpath) then
1187              mImportScriptWithThumbnail me, fpath, the number of castlib cl, 1, li
1188             
1189              put "mUpdateSelectedScriptsFromFolder: imported scripttext of" && memref && "from" && fpath
1190             
1191            else
1192              put "mUpdateSelectedScriptsFromFolder: file doesn't exist ?? fpath = " & fpath
1193             
1194            end if
1195           
1196          end if
1197        end repeat
1198       
1199       
1200        if found = 0 then
1201          put "Info for member" && memref && "was not found in memberinfo.xml"
1202        end if
1203       
1204      end if
1205    end repeat
1206  end repeat
1207 
1208 
1209 
1210  return 1
1211 
1212end
1213
1214-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1215
1216on mImportScriptWithThumbnail me, thePath, castlibNumber, dontWarn, infolist
1217 
1218  -- <castlibNumber> is optional and will replace an existing script, if it exists
1219 
1220  castlibNumber = integer(castlibNumber)
1221  if ilk(castlibNumber, #number) <> 1 then castlibNumber = 0
1222  if castlibNumber > the number of castlibs or castlibNumber = 0 then
1223    cl = the activecastlib
1224    castlibNumber = the number of castlib cl
1225  end if
1226 
1227 
1228  thePath = string(thePath)
1229  if length(thePath) < 1 then thePath = mGetFilePathFromUser(me)
1230 
1231  if length(thePath) < 1 then exit
1232 
1233  if mCheckForXtra(me, "budapi") then
1234    buddyApiPresent = 1
1235    spath = bashortfilename(thePath)
1236    if length(spath) < 1 then
1237      alert "file does not exist:" && spath
1238      exit
1239    end if
1240  else
1241    buddyApiPresent = 0
1242    spath = thePath
1243  end if
1244 
1245 
1246  mDisplayWaitStatusText me, "Importing file:" && spath
1247 
1248 
1249  scrtext = mGetTextFromFile(me, spath)
1250 
1251  if length(scrtext) < 1 then
1252    alert "file not found:" && spath
1253    return 0
1254  end if
1255 
1256  oldd = the itemdelimiter
1257  the itemdelimiter = the last char of the applicationpath
1258  fname = the last item of thePath
1259  delete the last item of thePath
1260  put the itemdelimiter after thePath
1261 
1262  splitpath = mSplitPath(me, fname)
1263  extension = splitpath[#extension]
1264  --  extension = ""
1265  --  repeat while length(fname)
1266  --    put the last char of fname before extension
1267  --    delete the last char of fname
1268  --    if char 1 of extension = "." then exit repeat
1269  --  end repeat
1270  --  if char 1 of extension <> "." then
1271  --    put extension after fname
1272  --    extension = ""
1273  --  end if
1274 
1275  if ilk(infolist) <> #proplist then
1276   
1277    offs = offset("--!memberProperties:", scrtext)
1278   
1279    if offs > 0 then
1280      infolist = scrtext.char[offs + 20 .. length(scrtext)]
1281      offs = offset("]", infolist)
1282      if offs > 0 then
1283        infolist = value(infolist.char[1 .. offs])
1284      end if
1285    end if
1286   
1287    if ilk(infolist) <> #proplist then
1288      infolistPath = thePath & "memberInfo.xml"
1289      infolist = mReadXML_2_List(me, infolistPath)
1290      if ilk(infolist) <> #proplist then infolist = [:]
1291     
1292      infolist = infolist.getaprop(symbol(fname))
1293      if ilk(infolist) <> #proplist then infolist = [:]
1294    end if
1295   
1296  end if
1297 
1298  scrtype = infolist.getaprop(#scripttype)
1299  if ilk(scrtype) <> #symbol then
1300    ident = "-- scripttype = "
1301    scrtype = offset(ident, scrtext)
1302    if scrtype > 0 then
1303      scrtype = scrtext.word[scrtext.char[1 .. scrtype+length(ident) - 1].word.count + 1]
1304      scrtype = value(scrtype)
1305      if ilk(scrtype) <> #symbol then scrtype = 0
1306    end if
1307  end if
1308 
1309 
1310  cmts = infolist.getaprop(#comments)
1311  if voidP(cmts) then
1312    ident = "-- comments = "
1313    cmts = offset(ident, scrtext)
1314    if cmts > 0 then
1315      cmts = scrtext.line[scrtext.char[1 .. cmts+length(ident) - 1].line.count]
1316      delete char 1 to length(ident) - 1 of cmts
1317    end if
1318  end if
1319 
1320 
1321  theIcon = thePath & splitpath[#basename] & ".png"
1322 
1323  --  if length(fname & ".png") > 31 and (the platform contains "mac") then
1324  --   
1325  --    unixname = baUnixName(theIcon)
1326  --    if length(unixname) > 0 then
1327  --      tempSrcPath = shell_cmd_list("mktemp -t temp_icon_file.XXXX")
1328  --      tempSrcPath = tempSrcPath[1] & ".png"
1329  --      shell_cmd_list("cp " & QUOTE & unixname & QUOTE && QUOTE& tempSrcPath &QUOTE)
1330  --      theIcon = baHFSName(tempSrcPath)
1331  --    else
1332  --      theIcon = ""
1333  --    end if
1334  --   
1335  --  end if
1336 
1337  if buddyApiPresent = 1 then theIcon = bashortfilename(theIcon)
1338 
1339 
1340  fio = new(xtra "fileio")
1341  if length(theIcon) > 0 then
1342    fio.openFile(theIcon, 1)
1343    if fio.status() = 0 then
1344      i = new(#bitmap)
1345      i.importFileInto(theIcon)
1346      theIcon = i.picture
1347      fio.closeFile()
1348    end if
1349  end if
1350 
1351 
1352  membername = infolist.getaprop(#membername)
1353  if voidP(membername) then
1354    scrname = fname
1355  else
1356    scrname = string(membername)
1357  end if
1358 
1359 
1360  case scrtype of
1361    #field, #text: memtype = scrtype
1362    otherwise: memtype = #script
1363  end case
1364 
1365 
1366  askreplace = 1
1367  scr = member(scrname, castlibNumber)
1368  if voidP(scr) then
1369    scr = new(memtype, castlib(castlibNumber))
1370    askreplace = 0
1371  end if
1372  if scr.type <> #script then
1373    scr = new(memtype, castlib(castlibNumber))
1374    askreplace = 0
1375  end if
1376 
1377  if dontWarn = 1 then askreplace = 0
1378 
1379  if askreplace = 1 then
1380    if buddyApiPresent = 1 then
1381      if baMsgBox("Replace member" && scrname, "Replace", "Yesno", "Warning", 1) = "No" then
1382        if ilk(i) = #member then i.erase()
1383        fio = 0
1384        return 0
1385      end if
1386    end if
1387  end if
1388 
1389  scr.name = scrname
1390 
1391 
1392 
1393  ------------------------------------------ trac subversion support works better with unix linebreaks...
1394  if mCheckForXtra(me, "Pregex") = 1 then
1395   
1396    scrTextLi = [scrText]
1397    if the platform contains "mac" then
1398      pregex_replace(scrTextLi, "\x0D?\x0A", "g", "\x0D")
1399    else
1400      pregex_replace(scrTextLi, "\x0D([^\x0A])", "g", "\x0D\x0A\1")
1401      pregex_replace(scrTextLi, "([^\x0D])\x0A", "g", "\1\x0D\x0A")
1402    end if
1403    scrText = scrTextLi[1]
1404   
1405  else
1406   
1407    if the platform contains "mac" then
1408     
1409      -- first convert windows to mac
1410      fndStr = numToChar(13) & numToChar(10)
1411      offs = offset(fndStr, scrText)
1412      repeat while offs > 0
1413        put numToChar(13) into char offs to offs+1 of scrText
1414        offs = offset(fndStr, scrText)
1415      end repeat
1416     
1417      -- now convert unix to mac
1418      fndStr = numToChar(10)
1419      offs = offset(fndStr, scrText)
1420      repeat while offs > 0
1421        put numToChar(13) into char offs of scrText
1422        offs = offset(fndStr, scrText)
1423      end repeat
1424     
1425    else
1426     
1427     
1428      --      fndStr = numToChar(13) & numToChar(10)
1429      --      offs = offset(fndStr, scrText)
1430      --      repeat while offs > 0
1431      --        delete char offs of scrText
1432      --        offs = offset(fndStr, scrText)
1433      --      end repeat
1434     
1435      fndStr = numToChar(13) & numToChar(10)
1436      offs = offset(fndStr, scrText)
1437      repeat while offs > 0
1438        put numToChar(13) into char offs+1 of scrText
1439        offs = offset(fndStr, scrText)
1440      end repeat
1441     
1442     
1443      fndStr = numToChar(10)
1444      offs = offset(fndStr, scrText)
1445      repeat while offs > 0
1446        put numToChar(13) into char offs of scrText
1447        offs = offset(fndStr, scrText)
1448      end repeat
1449     
1450    end if
1451   
1452  end if
1453  -----------------------------------------
1454 
1455 
1456 
1457  case scrtype of
1458    #field: scr.text = scrtext
1459    #text: scr.html = scrtext
1460    otherwise: scr.scripttext = scrtext
1461  end case
1462 
1463 
1464  if [#movie, #parent, #score].getPos(scrtype) > 0 then scr.scripttype = scrtype
1465  if cmts <> 0 then scr.comments = cmts
1466  if ilk(theIcon) = #picture then scr.thumbnail = theIcon
1467 
1468  if ilk(i) = #member then i.erase()
1469  fio = 0
1470 
1471 
1472  mDisplayWaitStatusText me, "Imported file:" && spath && "into member" && scr
1473 
1474 
1475  return 1
1476 
1477end
1478
1479
1480-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1481on _______________SVN_FIELD_TEXT me
1482end
1483-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1484
1485on mExportTextAndFieldsToFolder me, skipIcons_optional, selectionOnly_optional, convertLineBreaksToUnix, chooseNewPath_optional
1486  mExportScriptsToFolder me, skipIcons_optional, selectionOnly_optional, convertLineBreaksToUnix, chooseNewPath_optional
1487end
1488
1489-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1490
1491on mImportTextAndFields me, thePath_optional, castlibNumber_optional, dontWarn_optional, infolist_optional
1492  mImportScriptWithThumbnail me, thePath_optional, castlibNumber_optional, dontWarn_optional, infolist_optional
1493end
1494
1495-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1496on _______________SVN_SUPPORT me
1497end
1498-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1499
1500on mSVN_Update_Working_Copy_ScriptText me, revisionNumber, chooseNewPath, selectionList, dontShowAlert
1501 
1502  workingCopies = value(getPref("svn_workingCopies_paths.txt"))
1503  if ilk(workingCopies) <> #proplist then workingCopies = [:]
1504 
1505  svnBinary = mGetSVNBinaryPath(me, workingCopies)
1506  if length(svnBinary) < 1 then exit
1507 
1508  workingFolder = mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies scripttext. Please select a working copy for the scripttext now.")
1509  if length(workingFolder) < 1 then exit
1510 
1511  if the platform contains "mac" then
1512    svnBinary = mConvertHFS2Unix(me, svnBinary)
1513    workingFolder = mConvertHFS2Unix(me, workingFolder)
1514  else
1515    if the last char of workingFolder = the last char of the applicationpath then delete the last char of workingFolder
1516  end if
1517 
1518  statusSwitched = mSwitchToStatusMode(me, 1)
1519  mDisplayWaitStatusText me, "Updating folder:" && workingFolder
1520 
1521 
1522  revisionNumber = getValidRevNumber(me, revisionNumber)
1523 
1524  castlibList = getCastlibList(me, selectionList)
1525 
1526  if count(castlibList) < 1 then
1527    theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" && QUOTE & workingFolder & QUOTE, RETURN, 0, 1)
1528   
1529  else
1530   
1531    theresult = []
1532    if the platform contains "mac" then pdelim = "/"
1533    else pdelim = the last char of the moviepath
1534    repeat with num in castlibList
1535     
1536      thePath = workingFolder & pdelim & "castlib" & num & pdelim
1537     
1538      ret = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" && "-r" && revisionNumber && QUOTE & thePath & QUOTE, RETURN, 0, 1)
1539      if count(ret) > 0 then theresult.add(ret[1])
1540     
1541    end repeat
1542   
1543  end if
1544 
1545  if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
1546 
1547  if count(theresult) > 0 then
1548    repeat with n = 1 to count(theresult)
1549      put theresult[n]
1550    end repeat
1551    if dontShowAlert <> 1 then
1552      alert "Done, see the results of the svn operation in the message window."
1553    end if
1554  else
1555    if dontShowAlert <> 1 then
1556      alert "svn application did not respond, something seems to have failed. :-("
1557    end if
1558  end if
1559 
1560  setPref("svn_workingCopies_paths.txt", string(workingCopies))
1561 
1562end
1563
1564-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1565
1566on getValidRevNumber me, revisionNumber
1567  if integerP(integer(revisionNumber)) then return string(revisionNumber)
1568 
1569  revisionNumber = string(revisionNumber)
1570  if length(revisionNumber) < 1 then
1571    revisionNumber = "HEAD"
1572  else
1573    if char 1 of revisionNumber = "'" then delete char 1 of revisionNumber
1574    if the last char of revisionNumber = "'" then delete the last char of revisionNumber
1575  end if
1576 
1577  return QUOTE & revisionNumber & QUOTE
1578end
1579
1580-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1581
1582on mSVN_Delete_Selected_Scripts me, chooseNewPath
1583 
1584 
1585  workingCopies = value(getPref("svn_workingCopies_paths.txt"))
1586  if ilk(workingCopies) <> #proplist then workingCopies = [:]
1587 
1588  svnBinary = mGetSVNBinaryPath(me, workingCopies)
1589  if length(svnBinary) < 1 then exit
1590 
1591  workingFolder = mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies scripttext. Please select a working copy for the scripttext now.")
1592  if length(workingFolder) < 1 then exit
1593 
1594 
1595  if the platform contains "mac" then
1596    isMac = 1
1597    svnBinary = mConvertHFS2Unix(me, svnBinary)
1598   
1599  else
1600    isMac = 0
1601   
1602  end if
1603 
1604 
1605  thePath = workingFolder
1606 
1607  cl = the activecastlib
1608 
1609  pathdelim = the last char of the applicationpath
1610  olddelim = the itemdelimiter
1611  the itemdelimiter = pathdelim
1612  fname = thePath
1613  delete the last item of fname
1614  fname = the last item of fname
1615  the itemdelimiter = olddelim
1616 
1617  infolist = 0
1618 
1619  if fname <> "castlib" & the number of castlib cl then
1620   
1621    newPath = thePath & "castlib" & the number of castlib cl
1622   
1623    if baFolderExists(newPath) = 0 then
1624     
1625      infolistPath = thePath & pathdelim & "memberInfo.xml"
1626     
1627      infolist = mReadXML_2_List(me, infolistPath)
1628     
1629      if ilk(infolist) <> #proplist then
1630       
1631        alert "The specified folder doesn't seem to contain info for this castlib: file memberInfo.xml missing."
1632        return 0
1633       
1634      else
1635       
1636        thePath = newPath & pathdelim
1637       
1638      end if
1639     
1640    else
1641     
1642      thePath = newPath & pathdelim
1643     
1644    end if
1645  end if
1646 
1647 
1648  if infolist = 0 then
1649   
1650    infolistPath = thePath & "memberInfo.xml"
1651    infolist = mReadXML_2_List(me, infolistPath)
1652   
1653    if ilk(infolist) <> #proplist then
1654     
1655      alert "The specified folder doesn't seem to contain info for this castlib: file memberInfo.xml missing."
1656      return 0
1657     
1658    end if
1659   
1660  end if
1661 
1662  if ilk(infolist) <> #proplist then
1663   
1664    alert "The specified folder doesn't seem to contain info for this castlib: file memberInfo.xml missing."
1665    return 0
1666   
1667  end if
1668 
1669  if count(infolist) < 1 then
1670   
1671    alert "The specified folder doesn't seem to contain info for this castlib: file memberInfo.xml missing."
1672    return 0
1673   
1674  end if
1675 
1676  doCommit = 0
1677  saveRequired = 0
1678 
1679  cl = the activecastlib
1680  sel = the selection of castlib cl
1681  anz = sel.count
1682  cnt = count(infolist)
1683  repeat with n = 1 to anz
1684    repeat with m = sel[n][1] to sel[n][2]
1685      memref = member(m, cl)
1686      dertyp = memref.type
1687     
1688      put "processing member" && memref
1689     
1690      if [#script, #field, #text].getPos(dertyp) then
1691       
1692        putstr = ""
1693        repeat with l = 1 to cnt
1694          li = infolist[l]
1695         
1696          -- put "listref  =" && li
1697         
1698          if li.getaprop(#memberName) = memref.name then
1699           
1700            theFilename = string(li.getaprop(#fname))
1701            if length(theFilename) < 1 then theFilename = string(infolist.getpropat(l))
1702           
1703            scrtype = li.getaprop(#scripttype)
1704            case scrtype of
1705              #field: ext = ".txt"
1706              #text: ext = ".html"
1707              otherwise: ext = ".ls"
1708            end case
1709           
1710            fpath = thePath & theFilename & ext
1711           
1712            put "checking for file" && fpath
1713           
1714            if isMac = 1 then
1715              sname = baShortFileName(fpath)
1716            else
1717              sname = fpath
1718            end if
1719           
1720            if baFileExists(fpath) then
1721             
1722              if isMac = 1 then
1723                ufpath =  mConvertHFS2Unix(me, fpath)
1724              else
1725                ufpath =  fpath
1726              end if
1727             
1728              theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "delete" && QUOTE & ufpath & QUOTE, RETURN, 0, 1)
1729              if count(theresult) < 1 then
1730                put "failed to svn delete member " & memref & " no result from svn?!"
1731              else
1732                put theresult[1]
1733                doCommit = 1
1734              end if
1735             
1736              infolist.deleteAt(l)
1737              memref.erase()
1738              saveRequired = 1
1739              put "Erase member:" && memref.name
1740             
1741              putstr = ""
1742             
1743              exit repeat
1744             
1745            else
1746             
1747              putstr = "No corresponding file o disk was found for member" && memref.name && "(" & memref & ") erase the member manually:" & RETURN & memref & ".erase()" & RETURN
1748             
1749            end if
1750           
1751          end if
1752         
1753        end repeat
1754       
1755        if length(putstr) then put putstr
1756       
1757      end if
1758    end repeat
1759  end repeat
1760 
1761 
1762  if saveRequired = 1 then
1763   
1764    if (baMsgBoxEx("The movie has been changed. Save changes to this movie?", "Save changes?", "Save", "Don't save", "", "Question", 1, "left", "Arial", 14, 4, -2, -2) = "Save") then
1765      saveMovie()
1766    end if
1767   
1768    mRefreshMemberInfoList me, thePath, castlib(cl).number
1769   
1770  end if
1771 
1772 
1773  if doCommit = 1 then
1774   
1775    msg = baPrompt("Commit message", "Enter commit message", "Commitmessage", 0, -2, -2)
1776   
1777    if length(msg) < 1 then
1778      alert "You must enter a message for the commit action."
1779      exit
1780    end if
1781   
1782    if isMac = 1 then
1783      workingFolder = mConvertHFS2Unix(me, workingFolder)
1784    else
1785      if the last char of workingFolder = the last char of the applicationpath then delete the last char of workingFolder
1786    end if
1787   
1788    theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "ci --message" && QUOTE & msg & QUOTE && QUOTE & workingFolder & QUOTE, RETURN, 0, 1)
1789   
1790    if count(theresult) > 0 then
1791      put theresult[1]
1792      alert "Done, see the results of the svn operation in the message window."
1793    else
1794      alert "svn application did not respond, something seems to have failed. :-("
1795    end if
1796   
1797  else
1798   
1799    alert "Nothing has been committed!"
1800   
1801  end if
1802 
1803  return 1
1804 
1805end
1806
1807
1808-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1809
1810on mSVN_Commit_CurrentMovie_Binaries_AND_Scripttext me, chooseNewPath, commitMsg
1811 
1812  commitMsg = string(commitMsg)
1813  if length(commitMsg) < 1 then
1814    commitMsg = baPrompt("Commit message", "Enter commit message", "Commitmessage", 0, -2, -2)
1815   
1816    if length(commitMsg) < 1 then
1817      alert "You must enter a message for the commit action."
1818      exit
1819    end if
1820  end if
1821 
1822 
1823  theResult = mSVN_Commit_CurrentScripts_ScriptText(me, 0, chooseNewPath, commitMsg, 1, void, 2)
1824 
1825  if theResult = 0 then exit
1826 
1827  theResult = mSVN_Commit_CurrentMovie_Binaries(me, chooseNewPath, commitMsg, 1)
1828 
1829end
1830
1831-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1832
1833on mGetCurrentRevision me, svnBinary, WorkingFolder
1834 
1835  versionNumber = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && QUOTE & WorkingFolder & QUOTE, RETURN, 0, 1)
1836  if count(versionNumber) < 1 then return void
1837  versionNumber = versionNumber[1]
1838 
1839  offs = offset(":", versionNumber)
1840  if offs > 0 then delete char 1 to offs of versionNumber
1841 
1842  if length(versionNumber) < 1 then return void
1843 
1844  versionNumberInt = integer(versionNumber)
1845  repeat while not(integerP(versionNumberInt))
1846    if length(versionNumber) < 1 then return void
1847    delete the last char of versionNumber
1848    versionNumberInt = integer(versionNumber)
1849  end repeat
1850 
1851  return versionNumberInt
1852 
1853end
1854
1855-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1856
1857on mSVN_Commit_SelectedCastlib_AND_Scripttext me, chooseNewPath, commitMsg, selectionList
1858 
1859  commitMsg = string(commitMsg)
1860  if length(commitMsg) < 1 then
1861    commitMsg = baPrompt("Commit message", "Enter commit message", "Commitmessage", 0, -2, -2)
1862   
1863    if length(commitMsg) < 1 then
1864      alert "You must enter a message for the commit action."
1865      exit
1866    end if
1867  end if
1868 
1869 
1870  theResult = mSVN_Commit_CurrentScripts_ScriptText(me, castlib(the activecastlib), chooseNewPath, commitMsg, 1, selectionList, 2)
1871 
1872  if theResult = 0 then exit
1873 
1874  theResult = mSVN_Commit_SelectedCastlib(me, chooseNewPath, commitMsg, 1, 0, selectionList)
1875 
1876 
1877end
1878
1879-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1880
1881on mSVN_Commit_SelectedCastlib me, chooseNewPath, commitMsg, dontSave, dontShowAlert, selectionList
1882 
1883 
1884  castlibList = getCastlibList(me, selectionList, the activecastlib)
1885 
1886  mpname = the moviepath & the moviename
1887  isInternal = 0
1888  repeat with cl in castlibList
1889    if castlib(cl).filename = mpname then
1890      isInternal = 1
1891      exit repeat
1892    end if
1893  end repeat
1894 
1895 
1896  if count(castlibList) < 1 then
1897    alert "No castlib selected. The parameter didn't yield a valid list. Make sure, that you provide a linear list with integers, specifying a number of a castlib each."
1898    return 0
1899  end if
1900 
1901 
1902 
1903  put "Committing castlibs:" && castlibList
1904 
1905 
1906  workingCopies = value(getPref("svn_wCopies_paths_Binary.txt"))
1907  if ilk(workingCopies) <> #proplist then workingCopies = [:]
1908 
1909  svnBinary = mGetSVNBinaryPath(me, workingCopies)
1910  if length(svnBinary) < 1 then return 0
1911 
1912  workingFolder = mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies binaries (director files). Please select a working copy of the director files.")
1913  if length(workingFolder) < 1 then return 0
1914 
1915 
1916  ---------------------------------------
1917  msg = string(commitMsg)
1918  if length(msg) < 1 then
1919    msg = baPrompt("Commit message", "Enter commit message", "Commitmessage", 0, -2, -2)
1920   
1921    if length(msg) < 1 then
1922      alert "You must enter a message for the commit action."
1923      return 0
1924    end if
1925  end if
1926  ---------------------------------------
1927 
1928 
1929  ---------------------------------------
1930  if dontSave <> 1 then
1931    -- this flag is only for the case, we come here from the combined commit call "mSVN_Commit_CurrentMovie_Binaries_AND_Scripttext"
1932    -- as the movie was already saved in "mSVN_Commit_CurrentScripts_ScriptText"
1933   
1934    if workingCopies.getaprop(#dontWarnWhenSaving) <> 1 then
1935      answer = baMsgBoxEx("The castlib will be saved before committing.", "Save castlib?", "Save", "Cancel", "Always save", "Question", 1, "left", "Arial", 14, 4, -2, -2)
1936      if answer = "Cancel" then return 0
1937      if answer = "Always save" then workingCopies.setaprop(#dontWarnWhenSaving, 1)
1938    end if
1939   
1940    --    if the moviepath & the moviename = castlib(actCL).filename then
1941    --      savemovie()
1942    --    else
1943    --      castlib(actCL).save()
1944    --   end if
1945   
1946   
1947    -------------------- get version number:
1948    if the platform contains "mac" then
1949      svnBin = mConvertHFS2Unix(me, svnBinary)
1950      workFolder = mConvertHFS2Unix(me, workingFolder)
1951    else
1952      workFolder = workingFolder
1953      if the last char of workFolder = the last char of the applicationpath then delete the last char of workFolder
1954    end if
1955    versionNumber = mGetCurrentRevision(me, svnBin & "version", workFolder)
1956   
1957    if integerP(versionNumber) then
1958     
1959      versionNumber = versionNumber + 2 -- the version will raise
1960     
1961      VersionCheckUrl = string(mGetVersionCheckUrl(me, the moviepath & the moviename, workingCopies, "Select an URL to use for version checking."))
1962      if length(VersionCheckUrl) > 0 then
1963        mscript = member("aleXtrasMovieScript")
1964        ident = ""
1965        if mGetMemType(me, mscript) = #script then ident = string(xscr().mGetThisMovieName())
1966        if length(ident) < 1 then ident = the moviename
1967       
1968        thePassword = ""
1969        placeholder = "%%password:"
1970        offs = offset(placeholder, VersionCheckUrl)
1971        if offs > 0 then
1972          thePassword = VersionCheckUrl.char[offs+length(placeholder) .. length(VersionCheckUrl)]
1973          thePassword = word 1 to thePassword.word.count of thePassword
1974          delete char offs to length(VersionCheckUrl) of VersionCheckUrl
1975        end if
1976       
1977        VersionCheckUrl = word 1 to VersionCheckUrl.word.count of VersionCheckUrl & "?movieName=" & ident
1978       
1979      end if
1980     
1981      updateurl = 0
1982      repeat with cl in castlibList
1983        versmem = member("subversion_version_field", cl)
1984        if [#field, #text].getPos(mGetMemType(me, versmem)) > 0 then
1985          if updateurl = 0 then updateurl = 1
1986          curr = versmem.text
1987          if char 1 of curr = "r" then delete char 1 of curr
1988          curr = integer(curr)
1989          if not(integerP(curr)) then curr = 0
1990          if curr < versionNumber then
1991            versmem.text = "r" & versionNumber
1992            if length(VersionCheckUrl) > 0 then
1993              versmem.comments = VersionCheckUrl
1994            end if
1995          else
1996            updateurl = 2
1997          end if
1998        end if
1999      end repeat
2000     
2001      if length(VersionCheckUrl) > 0 then
2002        if updateurl = 1 then
2003          if length(thePassword) then
2004            id = getnettext(VersionCheckUrl & "&version=" & thePassword & versionNumber)
2005          end if
2006        end if
2007      end if
2008     
2009    end if
2010    --------------------- // version number
2011   
2012   
2013    if isInternal = 1 then
2014      savemovie()
2015    else
2016      repeat with cl in castlibList
2017        castlib(cl).save()
2018      end repeat
2019    end if
2020   
2021  end if
2022  ----------------------------------------
2023 
2024 
2025  statusSwitched = mSwitchToStatusMode(me, 1)
2026  mDisplayWaitStatusText me, "Committing castlibs:" && castlibList
2027 
2028 
2029 
2030  --  fname = castlib(actCL).filename
2031 
2032 
2033  ---------------------------------------
2034  if workingFolder <> the moviepath then
2035   
2036    mp = the moviepath
2037    mplen = length(mp)
2038    olddelim = the itemdelimiter
2039    the itemdelimiter = mp
2040   
2041   
2042    castlibListCnt = count(castlibList)
2043    repeat with r = 1 to castlibListCnt
2044      cl = castlibList[r]
2045     
2046      fname = castlib(cl).filename
2047     
2048      if length(fname) > 0 then
2049       
2050        offs = offset(mp, fname)
2051        if offs <> 1 then
2052          alert "Castlib" && castlib(cl) && "is not within your current moviepath. This is not supported."
2053          if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2054          return 0
2055        end if
2056       
2057        relpath = fname
2058        delete char 1 to mplen of relpath
2059       
2060        newpath = workingFolder & relpath
2061        newpathDir = newpath
2062        delete the last item of newpathDir
2063        if baFolderExists(newpathDir) <> 1 then baCreateFolder(newpathDir)
2064        baCopyFileProgress(fname, newpath, "Always", "Copying castlib " & cl & " to working folder", "", 33)
2065       
2066        castlibList[r] = [cl, fname, newpath, newpathDir]
2067       
2068      else
2069       
2070        -- must be something REALLY wrong, as the filename should ALWAYS be of any length (internal castlibs )
2071        if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2072        return 0
2073       
2074      end if
2075     
2076    end repeat
2077   
2078   
2079    the itemdelimiter = olddelim
2080   
2081  else
2082   
2083    castlibListCnt = count(castlibList)
2084    repeat with r = 1 to castlibListCnt
2085      cl = castlibList[r]
2086      fname = castlib(cl).filename
2087      newpath = fname
2088      castlibList[r] = [cl, fname, fname]
2089    end repeat
2090   
2091  end if
2092  ---------------------------------------
2093 
2094 
2095  ---------------------------------------
2096  if the platform contains "mac" then
2097    svnBinary = mConvertHFS2Unix(me, svnBinary)
2098    workingFolder = mConvertHFS2Unix(me, workingFolder)
2099   
2100    castlibListCnt = count(castlibList)
2101    repeat with r = 1 to castlibListCnt
2102      castlibList[r][3] = mConvertHFS2Unix(me, castlibList[r][3])
2103    end repeat
2104   
2105  else
2106    if the last char of workingFolder = the last char of the applicationpath then delete the last char of workingFolder
2107  end if
2108  ---------------------------------------
2109 
2110 
2111  isChanged = 0
2112  castlibListCnt = count(castlibList)
2113  repeat with r = 1 to castlibListCnt
2114    --    cl = castlibList[r]
2115    --  repeat with cl in castlibList
2116    ---------------------------------------
2117   
2118    mDisplayWaitStatusText me, "SVN update of:" && castlibList[r][3]
2119   
2120    theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" && QUOTE & castlibList[r][3] & QUOTE, RETURN, 0, 1)
2121   
2122    if count(theresult) < 1 then
2123      theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" && QUOTE & castlibList[r][3] & QUOTE && "2>&1", RETURN, 0, 1)
2124      if count(theresult) < 1 then
2125        theError = theresult[1]
2126      else
2127        theError = "svn did not respond at all."
2128      end if
2129      alert "Can't proceed svn error while trying to update:" && theError
2130      if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2131      return 0 
2132    end if
2133    ---------------------------------------
2134   
2135   
2136   
2137    theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "status" && QUOTE & castlibList[r][3] & QUOTE, RETURN, 0, 1)
2138   
2139    cnt = count(theresult)
2140    if cnt > 0 then
2141      isChanged = 1
2142      --      alert "Apparently there are no changes to the most recent version in the svn repository: svn status is empty"
2143      --      return 0
2144    end if
2145   
2146  end repeat
2147 
2148  if isChanged = 0 then
2149    alert "Apparently there are no changes to the most recent version in the svn repository: svn status is empty"
2150    if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2151    return 0 
2152  end if
2153 
2154 
2155  pathStr = ""
2156  castlibListCnt = count(castlibList)
2157  repeat with r = 1 to castlibListCnt
2158    put " " & QUOTE & castlibList[r][3] & QUOTE after pathStr
2159  end repeat
2160 
2161 
2162  mDisplayWaitStatusText me, "SVN commit for:" && pathStr
2163 
2164  theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "ci --message" && QUOTE & msg & QUOTE & pathStr, RETURN, 0, 1)
2165 
2166 
2167  ---------------------------------------
2168  if count(theresult) > 0 then
2169    theResult = theresult[1]
2170   
2171    put theResult
2172    if dontShowAlert <> 1 then alert "Done, see the results of the svn operation in the message window."
2173   
2174  else
2175    if dontShowAlert <> 1 then alert "svn application did not respond, something seems to have failed. :-("
2176  end if
2177  ---------------------------------------
2178 
2179  setPref("svn_wCopies_paths_Binary.txt", string(workingCopies))
2180 
2181  if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2182 
2183  return 1
2184 
2185end
2186
2187-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2188
2189on mSVN_Commit_CurrentMovie_Binaries me, chooseNewPath, commitMsg, dontSave, dontShowAlert
2190 
2191  workingCopies = value(getPref("svn_wCopies_paths_Binary.txt"))
2192  if ilk(workingCopies) <> #proplist then workingCopies = [:]
2193 
2194  svnBinary = mGetSVNBinaryPath(me, workingCopies)
2195  if length(svnBinary) < 1 then return 0
2196 
2197  workingFolder = mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies binaries (director files). Please select a working copy of the director files.")
2198  if length(workingFolder) < 1 then return 0
2199 
2200 
2201  ---------------------------------------
2202  msg = string(commitMsg)
2203  if length(msg) < 1 then
2204    msg = baPrompt("Commit message", "Enter commit message", "Commitmessage", 0, -2, -2)
2205   
2206    if length(msg) < 1 then
2207      alert "You must enter a message for the commit action."
2208      return 0
2209    end if
2210  end if
2211  ---------------------------------------
2212 
2213 
2214  ---------------------------------------
2215  if dontSave <> 1 then
2216    -- this flag is only for the case, we come here from the combined commit call "mSVN_Commit_CurrentMovie_Binaries_AND_Scripttext"
2217    -- as the movie was already saved in "mSVN_Commit_CurrentScripts_ScriptText"
2218   
2219    if workingCopies.getaprop(#dontWarnWhenSaving) <> 1 then
2220      answer = baMsgBoxEx("The movie will be saved before committing.", "Save movie?", "Save", "Cancel", "Always save", "Question", 1, "left", "Arial", 14, 4, -2, -2)
2221      if answer = "Cancel" then return 0
2222      if answer = "Always save" then workingCopies.setaprop(#dontWarnWhenSaving, 1)
2223    end if
2224   
2225    statusSwitched = mSwitchToStatusMode(me, 1)
2226   
2227    mDisplayWaitStatusText me, "Saving movie..."
2228   
2229   
2230    -------------------- get version number:
2231    if the platform contains "mac" then
2232      svnBin = mConvertHFS2Unix(me, svnBinary)
2233      workFolder = mConvertHFS2Unix(me, workingFolder)
2234    else
2235      workFolder = workingFolder
2236      if the last char of workFolder = the last char of the applicationpath then delete the last char of workFolder
2237    end if
2238    versionNumber = mGetCurrentRevision(me, svnBin & "version", workFolder)
2239   
2240    if integerP(versionNumber) then
2241     
2242      versionNumber = versionNumber + 2 -- the version will raise
2243     
2244      VersionCheckUrl = string(mGetVersionCheckUrl(me, the moviepath & the moviename, workingCopies, "Select an URL to use for version checking."))
2245      if length(VersionCheckUrl) > 0 then
2246        mscript = member("aleXtrasMovieScript")
2247        ident = ""
2248        if mGetMemType(me, mscript) = #script then ident = string(xscr().mGetThisMovieName())
2249        if length(ident) < 1 then ident = the moviename
2250       
2251        thePassword = ""
2252        placeholder = "%%password:"
2253        offs = offset(placeholder, VersionCheckUrl)
2254        if offs > 0 then
2255          thePassword = VersionCheckUrl.char[offs+length(placeholder) .. length(VersionCheckUrl)]
2256          thePassword = word 1 to thePassword.word.count of thePassword
2257          delete char offs to length(VersionCheckUrl) of VersionCheckUrl
2258        end if
2259       
2260        VersionCheckUrl = word 1 to VersionCheckUrl.word.count of VersionCheckUrl & "?movieName=" & ident
2261      end if
2262      updateurl = 0
2263      repeat with cl = the number of castlibs down to 1
2264        versmem = member("subversion_version_field", cl)
2265        if [#field, #text].getPos(mGetMemType(me, versmem)) > 0 then
2266          if updateurl = 0 then updateurl = 1
2267          curr = versmem.text
2268          if char 1 of curr = "r" then delete char 1 of curr
2269          curr = integer(curr)
2270          if not(integerP(curr)) then curr = 0
2271          if curr < versionNumber then
2272            versmem.text = "r" & versionNumber
2273            if length(VersionCheckUrl) > 0 then
2274              versmem.comments = VersionCheckUrl
2275            end if
2276          else
2277            updateurl = 2
2278          end if
2279        end if
2280      end repeat
2281     
2282      if length(VersionCheckUrl) > 0 then
2283        if updateurl = 1 then
2284          if length(thePassword) then
2285            id = getnettext(VersionCheckUrl & "&version=" & thePassword & versionNumber)
2286          end if
2287        end if
2288      end if
2289     
2290    end if
2291    --------------------- // version number
2292   
2293   
2294    saveMovie()
2295   
2296  else
2297   
2298    statusSwitched = mSwitchToStatusMode(me, 1)
2299   
2300  end if
2301  ----------------------------------------
2302 
2303 
2304 
2305  ---------------------------------------
2306  if workingFolder <> the moviepath then
2307    erg = baCopyFileProgress(the moviepath & the moviename, workingFolder & the moviename, "Always", "Copying movie to working folder", "", 33)
2308    if erg <> 0 then
2309      alert "An error occurred during copying the movie:" && erg
2310      if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2311      return 0
2312    end if
2313    clnum = the number of castlibs
2314    mp = the moviepath
2315    mplen = length(mp)
2316    olddelim = the itemdelimiter
2317    the itemdelimiter = mp
2318    repeat with n = 2 to clnum
2319      fname = castlib(n).filename
2320      if length(fname) > 0 then
2321       
2322        if the moviepath & the moviename <> fname then
2323          offs = offset(mp, fname)
2324          if offs <> 1 then
2325            alert "Castlib" && castlib(n) && "is not within your current moviepath. This is not supported."
2326            if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2327            return 0
2328          end if
2329          relpath = fname
2330          delete char 1 to mplen of relpath
2331         
2332          newpath = workingFolder & relpath
2333          newpathDir = newpath
2334          delete the last item of newpathDir
2335          if baFolderExists(newpathDir) <> 1 then baCreateFolder(newpathDir)
2336          baCopyFileProgress(fname, newpath, "Always", "Copying castlib " & n & " to working folder", "", 33)
2337         
2338        end if
2339       
2340      end if
2341    end repeat
2342    the itemdelimiter = olddelim
2343  end if
2344  ---------------------------------------
2345 
2346  ---------------------------------------
2347  if the platform contains "mac" then
2348    svnBinary = mConvertHFS2Unix(me, svnBinary)
2349    workingFolder = mConvertHFS2Unix(me, workingFolder)
2350  else
2351    if the last char of workingFolder = the last char of the applicationpath then delete the last char of workingFolder
2352  end if
2353  ---------------------------------------
2354 
2355 
2356  ---------------------------------------
2357  mDisplayWaitStatusText me, "SVN update for:" && workingFolder
2358 
2359  theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" && QUOTE & workingFolder & QUOTE, RETURN, 0, 1)
2360 
2361  if count(theresult) < 1 then
2362    theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" && QUOTE & workingFolder & QUOTE && "2>&1", RETURN, 0, 1)
2363    if count(theresult) < 1 then
2364      theError = theresult[1]
2365    else
2366      theError = "svn did not respond at all."
2367    end if
2368    alert "Can't proceed svn error while trying to update:" && theError
2369    if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2370    return 0 
2371  end if
2372  ---------------------------------------
2373 
2374 
2375  ------- NOW, basically there are two options, one is only commiting the files, which we have copied (director movie and castlibs)
2376  ------- OR commit the whole folder (-> everything, which is changed or added to <workingFolder>)
2377  ------- The problem regarding option #1, is that it would be a new revision for each file -> ugly
2378  ------- #2 however "messes" with files, which the user may not expect...
2379  ------- I for one prefer #2 anyway, therefore I didn't even implement #1
2380  ------- in order to implement #1 you can use a repeat loop just like the above repeat, which goes thorugh each castlib
2381 
2382  theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "status" && QUOTE & workingFolder & QUOTE, RETURN, 0, 1)
2383 
2384  cnt = count(theresult)
2385  if cnt < 1 then
2386    alert "Apparently there are no changes to the most recent version in the svn repository: svn status is empty"
2387    if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2388    return 0
2389  end if
2390 
2391  repeat with n = 1 to cnt
2392    answ = theresult[n]
2393    meth = word 1 of answ
2394    delete word 1 of answ
2395   
2396    case meth of
2397      "!": -- deleted file (missing here, but in the repository present)
2398        -- I don't think, it is a good idea to delete the file in the repository in this case
2399        -- as it may also be the case, that we only have a subset of the castlibs/scripts
2400        -- therefore I just skip these files and leave it to the user what to do with them in his svn client application
2401        -- we only put a message, so the user is made aware of this fact
2402        put "Missing file!" && answ && "is missing here, but present in the repository"
2403        mDisplayWaitStatusText me, "Missing file!" && answ && "is missing here, but present in the repository"
2404       
2405      "?": -- newly added file
2406        mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "add" && QUOTE & answ & QUOTE, RETURN, 0, 1)
2407       
2408        put "Added file" && answ && "to the repository"
2409        mDisplayWaitStatusText me, "Added file" && answ && "to the repository"
2410       
2411      "m":
2412        -- just log the changes:
2413        put "Update file:" && answ
2414        mDisplayWaitStatusText me, "Update file:" && answ
2415       
2416    end case
2417   
2418  end repeat
2419 
2420  mDisplayWaitStatusText me, "SVN commit of:" && workingFolder
2421 
2422  theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "ci --message" && QUOTE & msg & QUOTE && QUOTE & workingFolder & QUOTE, RETURN, 0, 1)
2423 
2424 
2425  ---------------------------------------
2426  if count(theresult) > 0 then
2427    theResult = theresult[1]
2428   
2429    put theResult
2430    if dontShowAlert <> 1 then alert "Done, see the results of the svn operation in the message window."
2431   
2432  else
2433    if dontShowAlert <> 1 then alert "svn application did not respond, something seems to have failed. :-("
2434  end if
2435  ---------------------------------------
2436 
2437  setPref("svn_wCopies_paths_Binary.txt", string(workingCopies))
2438 
2439  if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2440 
2441  return 1
2442end
2443
2444-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2445
2446on mSVN_Update_AllCastlibs_and_source me, chooseNewPath, onlyUpdate_SVN_WorkingFolder, selectionList, revisionNumber, dontShowAlert
2447  mSVN_Update_Working_Copy_ScriptText me, revisionNumber, void, #all, 1
2448  mSVN_Update_SelectedCastlib me, chooseNewPath, onlyUpdate_SVN_WorkingFolder, #all, revisionNumber, dontShowAlert
2449end
2450
2451-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2452
2453on mSVN_Update_SelectedCastlib_and_source me, chooseNewPath, onlyUpdate_SVN_WorkingFolder, selectionList, revisionNumber, dontShowAlert
2454  mSVN_Update_Working_Copy_ScriptText me, revisionNumber, void, selectionList, 1
2455  mSVN_Update_SelectedCastlib me, chooseNewPath, onlyUpdate_SVN_WorkingFolder, selectionList, revisionNumber, dontShowAlert
2456end
2457
2458
2459-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2460
2461on mSVN_Update_SelectedCastlib me, chooseNewPath, onlyUpdate_SVN_WorkingFolder, selectionList, revisionNumber, dontShowAlert
2462 
2463  castlibList = getCastlibList(me, selectionList, the activecastlib)
2464 
2465  if count(castlibList) < 1 then
2466    alert "No castlib selected. The parameter didn't yield a valid list. Make sure, that you provide a linear list with integers, specifying a number of a castlib each."
2467    return 0
2468  end if
2469  put "Updating castlibs:" && castlibList
2470 
2471 
2472  workingCopies = value(getPref("svn_wCopies_paths_Binary.txt"))
2473  if ilk(workingCopies) <> #proplist then workingCopies = [:]
2474 
2475  svnBinary = mGetSVNBinaryPath(me, workingCopies)
2476  if length(svnBinary) < 1 then exit
2477 
2478  workingFolder = mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies binaries (director files). Please select a working copy of the director files.")
2479  if length(workingFolder) < 1 then exit
2480 
2481 
2482 
2483  oldmoviepath = the moviepath
2484  oldmovie = oldmoviepath & the moviename
2485 
2486 
2487  isMac = (the platform contains "mac")
2488  castlibPathList = []
2489 
2490  ---------------------------------------
2491  if workingFolder <> oldmoviepath then
2492   
2493    mp = oldmoviepath
2494    mplen = length(mp)
2495    olddelim = the itemdelimiter
2496    the itemdelimiter = mp
2497   
2498   
2499    repeat with actCL in castlibList
2500      fname = castlib(actCL).filename
2501      if length(fname) > 0 then
2502       
2503        offs = offset(mp, fname)
2504        if offs <> 1 then
2505          alert "Castlib" && castlib(actCL) && "is not within your current moviepath. This is not supported."
2506          return 0
2507        end if
2508       
2509        relpath = fname
2510        delete char 1 to mplen of relpath
2511       
2512        newpath = workingFolder & relpath
2513        --        newpathDir = newpath
2514        --        delete the last item of newpathDir
2515       
2516        -- if baFolderExists(newpathDir) <> 1 then baCreateFolder(newpathDir)
2517        -- baCopyFileProgress(fname, newpath, "Always", "Copying castlib " & actCL & " to working folder", "", 33)
2518       
2519        if isMac then
2520          castlibPathList.add([#newpath:newpath, #newpathUnix: mConvertHFS2Unix(me, newpath), #fname:fname])
2521        else
2522          castlibPathList.add([#newpath:newpath, #newpathUnix: newpath, #fname:fname])
2523        end if
2524       
2525      else
2526       
2527        -- musty something REALLY wrong, as the filename should ALWAYS be of any length (internal castlibs )
2528        return 0
2529       
2530      end if
2531     
2532    end repeat
2533   
2534    the itemdelimiter = olddelim
2535   
2536  else
2537   
2538    repeat with actCL in castlibList
2539      fname = castlib(actCL).filename
2540      newpath = fname
2541      if isMac then
2542        castlibPathList.add([#newpath:newpath, #newpathUnix: mConvertHFS2Unix(me, newpath), #fname:fname])
2543      else
2544        castlibPathList.add([#newpath:newpath, #newpathUnix: newpath, #fname:fname])
2545      end if
2546    end repeat
2547   
2548  end if
2549  ---------------------------------------
2550 
2551 
2552  statusSwitched = mSwitchToStatusMode(me, 1)
2553 
2554 
2555  doReturnToOldMovie = 0
2556 
2557  if (onlyUpdate_SVN_WorkingFolder <> 1) or (oldmoviepath contains workingFolder) then
2558   
2559    mDisplayWaitStatusText me, "Temporary switch to new movie in order to replace files"
2560   
2561    ------------------------------
2562    -- close this movie by issuing a "new movie..." command
2563    -- in order to replace the current movie, with the updated movie
2564    dispatchcommand(4097)
2565    ------------------------------
2566   
2567    doReturnToOldMovie = 1
2568   
2569  end if
2570 
2571 
2572 
2573  if the platform contains "mac" then
2574    svnBinary = mConvertHFS2Unix(me, svnBinary)
2575    workingFolderUnix = mConvertHFS2Unix(me, workingFolder)
2576    -- newpathUnix = baUnixName(newpath)
2577  else
2578    -- newpathUnix = newpath
2579    workingFolderUnix = workingFolder
2580    if the last char of workingFolderUnix = the last char of the applicationpath then delete the last char of workingFolderUnix
2581  end if
2582 
2583 
2584  mDisplayWaitStatusText me, "SVN update..." -- && newpathUnix
2585 
2586 
2587  revisionNumber = getValidRevNumber(me, revisionNumber)
2588 
2589  repeat with castlibPaths in castlibPathList
2590   
2591    theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" && "-r" && revisionNumber && QUOTE & castlibPaths[#newpathUnix] & QUOTE, RETURN, 0, 1)
2592   
2593    if count(theresult) < 1 then
2594      if doReturnToOldMovie = 1 then go to movie oldmovie
2595      if dontShowAlert <> 1 then alert "svn application did not respond, something seems to have failed. :-("
2596      setPref("svn_wCopies_paths_Binary.txt", string(workingCopies))
2597      if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2598      exit
2599    else
2600      put theresult[1]
2601    end if
2602  end repeat
2603 
2604 
2605 
2606  -------- reload the refreshed movie:
2607  if oldmoviepath contains workingFolder then
2608   
2609    -- go to movie the moviepath & the moviename
2610   
2611  else
2612   
2613    if onlyUpdate_SVN_WorkingFolder <> 1 then
2614     
2615      -------------------------- now get the updated movies over here:
2616      if the last char of workingFolder <> the last char of the applicationpath then put the last char of the applicationpath after workingFolder
2617     
2618      put "Copy file from " & workingFolder & " to " & oldmoviepath
2619     
2620     
2621      repeat with castlibPaths in castlibPathList
2622       
2623        erg = baCopyFileProgress(castlibPaths[#newpath], castlibPaths[#fname], "Always", "Replacing castlib with the version of the working folder", "", 33)
2624        if erg <> 0 then
2625          alert "An error occurred during copying the file (" & castlibPaths[#newpath] & "). Error:" && erg
2626        else
2627          put "Replaced file:" && castlibPaths[#newpath]
2628        end if
2629       
2630      end repeat
2631      ----------------------------------
2632     
2633    end if
2634   
2635  end if
2636 
2637 
2638 
2639  if doReturnToOldMovie = 1 then go to movie oldmovie
2640 
2641  if dontShowAlert <> 1 then alert "Done, see the results of the svn operation in the message window."
2642 
2643 
2644 
2645  setPref("svn_wCopies_paths_Binary.txt", string(workingCopies))
2646 
2647  if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2648 
2649end
2650
2651-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2652
2653on mSVN_Update_CurrentMovie_Binaries me, chooseNewPath, onlyUpdate_SVN_WorkingFolder, revisionNumber, dontShowAlert
2654 
2655  workingCopies = value(getPref("svn_wCopies_paths_Binary.txt"))
2656  if ilk(workingCopies) <> #proplist then workingCopies = [:]
2657 
2658  svnBinary = mGetSVNBinaryPath(me, workingCopies)
2659  if length(svnBinary) < 1 then exit
2660 
2661  workingFolder = mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies binaries (director files). Please select a working copy of the director files.")
2662  if length(workingFolder) < 1 then exit
2663 
2664 
2665  statusSwitched = mSwitchToStatusMode(me, 1)
2666 
2667 
2668  oldmoviepath = the moviepath
2669  oldmovie = oldmoviepath & the moviename
2670 
2671 
2672  if the platform contains "mac" then
2673   
2674    if the platform contains "mac" then
2675      if not(interface(xtra "budapi") contains "baUnixName") then
2676        alert "Please update your copy of the buddyApi xtra to the latest version, baUnixName() is missing."
2677        exit
2678      end if
2679    end if
2680   
2681   
2682    svnBinary = mConvertHFS2Unix(me, svnBinary)
2683    workingFolderUnix = mConvertHFS2Unix(me, workingFolder)
2684    targetPath = mConvertHFS2Unix(me, oldmoviepath)
2685   
2686    theDelim = "/"
2687    if the last char of targetPath = theDelim then delete the last char of targetPath
2688    if the last char of workingFolderUnix = theDelim then delete the last char of workingFolderUnix
2689   
2690  else
2691    workingFolderUnix = workingFolder
2692    targetPath = oldmoviepath
2693    theDelim = the last char of the applicationpath
2694    if the last char of workingFolderUnix = theDelim then delete the last char of workingFolderUnix
2695    if the last char of targetPath = theDelim then delete the last char of targetPath
2696  end if
2697 
2698 
2699 
2700  doReturnToOldMovie = 0
2701 
2702  if (onlyUpdate_SVN_WorkingFolder <> 1) or (oldmoviepath contains workingFolder) then
2703   
2704   
2705    mDisplayWaitStatusText me, "Temporary switch to new movie in order to replace files"
2706   
2707    ------------------------------
2708    -- close this movie by issuing a "new movie..." command
2709    -- in order to replace the current movie, with the updated movie
2710    dispatchcommand(4097)
2711    ------------------------------
2712   
2713    doReturnToOldMovie = 1
2714   
2715  end if
2716 
2717  mDisplayWaitStatusText me, "SVN update:" && workingFolderUnix
2718 
2719  revisionNumber = getValidRevNumber(me, revisionNumber)
2720 
2721  theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" && "-r" && revisionNumber && QUOTE & workingFolderUnix & QUOTE, RETURN, 0, 1)
2722 
2723  if count(theresult) > 0 then
2724   
2725    -------- reload the refreshed movie:
2726    if oldmoviepath contains workingFolder then
2727     
2728      -- go to movie the moviepath & the moviename
2729     
2730    else
2731     
2732      if onlyUpdate_SVN_WorkingFolder <> 1 then
2733       
2734        -------------------------- now get the updated movies over here:
2735        if the last char of workingFolder <> the last char of the applicationpath then put the last char of the applicationpath after workingFolder
2736       
2737        put "Copy files from " & workingFolder & " to " & oldmoviepath
2738       
2739        --        mCopyAllFiles(me, workingFolder, oldmoviepath, theresult)
2740       
2741        mCopyAllFiles(me, workingFolder, oldmoviepath, theresult, workingFolderUnix, targetPath)
2742       
2743        ----------------------------------
2744       
2745      end if
2746     
2747    end if
2748   
2749    put theresult[1]
2750   
2751    if doReturnToOldMovie = 1 then
2752      --  put RETURN & "go to movie" && oldmovie & RETURN
2753      go to movie oldmovie
2754    end if
2755   
2756    if dontShowAlert <> 1 then alert "Done, see the results of the svn operation in the message window."
2757   
2758  else
2759   
2760    if doReturnToOldMovie = 1 then go to movie oldmovie
2761   
2762    if dontShowAlert <> 1 then alert "svn application did not respond, something seems to have failed. :-("
2763  end if
2764 
2765 
2766  setPref("svn_wCopies_paths_Binary.txt", string(workingCopies))
2767 
2768 
2769  if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2770 
2771end
2772
2773-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2774
2775on mCopyAllFiles me, fromFolder, toFolder, listOfChangedFiles, fromFolderUnix, toFolderUnix
2776 
2777  if the platform contains "mac" then
2778    if not(interface(xtra "budapi") contains "baReturnUnixNames") then
2779      alert "Please update your copy of the buddyApi xtra to the latest version, baReturnUnixNames() is missing."
2780      listOfChangedFiles = 0
2781    end if
2782  end if
2783 
2784  if listP(listOfChangedFiles) then -- we have a list with status messages from svn for each file
2785   
2786    resetUNames = 0
2787    if the platform contains "mac" then
2788      if not(baSysFolder("prefs") starts "/") then
2789        baReturnUnixNames(1)
2790        resetUNames = 1
2791      end if
2792    end if
2793   
2794    repeat with thisFile in listOfChangedFiles
2795      if char 2 of thisFile = " " then
2796        action = char 1 of thisFile
2797        delete char 1 of thisFile
2798        repeat while char 1 of thisFile = " "
2799          delete char 1 of thisFile
2800          if length(thisFile) < 1 then exit repeat
2801        end repeat
2802        if length(thisFile) > 0 then
2803          offs = offset(fromFolderUnix, thisFile)
2804          if offs = 1 then
2805            case action of
2806              "D": -- deleted
2807                erg = baDeleteFile(toFolderUnix & thisFile)
2808               
2809                if erg <> 1 then
2810                  alert "An error occurred during deleting the file (" & toFolderUnix & thisFile & "). Error:" && erg
2811                else
2812                  put "Delted file:" && toFolderUnix & thisFile
2813                end if
2814               
2815              "U", "A": -- updated, added
2816                delete char 1 to length(fromFolderUnix) of thisFile
2817                erg = baCopyFileProgress(fromFolderUnix & thisFile, toFolderUnix & thisFile, "Always", "Replacing file " & thisFile & " with the version of the working folder", "", 33)
2818               
2819                if erg <> 0 then
2820                  alert "An error occurred during copying the file (" & thisFile & "). Error:" && erg
2821                else
2822                  put "Replaced file:" && thisFile
2823                end if
2824               
2825            end case
2826          else
2827            put "Couldn't copy file" && thisFile && "as it doesn't seem to be in the current path:" && fromFolderUnix
2828          end if
2829         
2830        end if
2831      end if
2832    end repeat
2833   
2834    if resetUNames = 1 then baReturnUnixNames(0)
2835   
2836  else -- no list? we just copy over all .dir and .cst and .ls files
2837   
2838    flist = baFolderList(fromFolder)
2839    flistCnt = count(flist)
2840    repeat with n = flistCnt down to 1
2841      thisFolder = flist[n]
2842      if thisFolder starts ".svn" then next repeat
2843      if not(baFolderExists(toFolder & thisFolder)) then
2844        put "Attempting to create folder:" && toFolder & thisFolder
2845        erg = baCreateFolder(toFolder & thisFolder)
2846       
2847        if erg = 0 then put "successfully created folder"
2848        else put "Unable to create folder."
2849       
2850      else
2851        erg = 1
2852      end if
2853     
2854      if erg = 1 then
2855        mCopyAllFiles me, fromFolder & thisFolder & the last char of toFolder, toFolder & thisFolder & the last char of toFolder
2856      else
2857        alert "Unable to create folder (" & thisFolder & "). Error:" && erg
2858      end if
2859     
2860    end repeat
2861   
2862    flist = baFileList(fromFolder, "*.*")
2863    flistCnt = count(flist)
2864    repeat with n = 1 to flistCnt
2865      thisFile = flist[n]
2866      if thisFile starts ".svn" then next repeat
2867      -- we get ourselves only dir and cast files:
2868      len = length(thisFile)
2869      ext = thisFile.char[len-3 .. len]
2870      if ext = ".dir" or ext = ".cst" or ext = ".ls" then
2871        erg = baCopyFileProgress(fromFolder & thisFile, toFolder & thisFile, "Always", "Replacing movie with the version of the working folder", "", 33)
2872        if erg <> 0 then
2873          alert "An error occurred during copying the file (" & thisFile & "). Error:" && erg
2874        else
2875          put "Replaced file:" && thisFile
2876        end if
2877      end if
2878    end repeat
2879   
2880  end if
2881end
2882
2883
2884-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2885
2886on mSVN_Commit_CurrentScripts_ScriptText me, selected_Members_Only, chooseNewPath, commitMsg, dontShowAlert, selectionList, versionIncrease
2887 
2888  workingCopies = value(getPref("svn_workingCopies_paths.txt"))
2889  if ilk(workingCopies) <> #proplist then workingCopies = [:]
2890 
2891  svnBinary = mGetSVNBinaryPath(me, workingCopies)
2892  if length(svnBinary) < 1 then return 0
2893 
2894  workingFolder = mGetWorkingCopyPath(me, the moviepath & the moviename, chooseNewPath, workingCopies, "No working copy is specified for this movies scripttext. Please select a working copy for the scripttext now.")
2895  if length(workingFolder) < 1 then return 0
2896 
2897  msg = string(commitMsg)
2898 
2899 
2900  if length(msg) < 1 then
2901   
2902    msg = baPrompt("Commit message", "Enter commit message", "Commitmessage", 0, -2, -2)
2903   
2904    if length(msg) < 1 then
2905      alert "You must enter a message for the commit action."
2906      return 0
2907    end if
2908   
2909  end if
2910 
2911 
2912  if workingCopies.getaprop(#dontWarnWhenSaving) <> 1 then
2913    answer = baMsgBoxEx("The movie will be saved before committing.", "Save movie?", "Save", "Cancel", "Always save", "Question", 1, "left", "Arial", 14, 4, -2, -2)
2914    if answer = "Cancel" then return 0
2915    if answer = "Always save" then workingCopies.setaprop(#dontWarnWhenSaving, 1)
2916  end if
2917 
2918 
2919 
2920  statusSwitched = mSwitchToStatusMode(me, 1)
2921 
2922  clibfolder = ""
2923 
2924  castlibList = 0
2925 
2926 
2927 
2928 
2929  -------------------- get version number:
2930  VersionCheckUrl = ""
2931 
2932  if the platform contains "mac" then
2933    svnBin = mConvertHFS2Unix(me, svnBinary)
2934    workFolder = mConvertHFS2Unix(me, workingFolder)
2935  else
2936    workFolder = workingFolder
2937    if the last char of workFolder = the last char of the applicationpath then delete the last char of workFolder
2938  end if
2939  versionNumber = mGetCurrentRevision(me, svnBin & "version", workFolder)
2940 
2941  if integerP(versionNumber) then
2942   
2943    if voidP(versionIncrease) then versionIncrease = 1
2944    versionNumber = versionNumber + versionIncrease + 1 -- the version will raise
2945   
2946    VersionCheckUrl = string(mGetVersionCheckUrl(me, the moviepath & the moviename, workingCopies, "Select an URL to use for version checking."))
2947    if length(VersionCheckUrl) > 0 then
2948      mscript = member("aleXtrasMovieScript")
2949      ident = ""
2950      if mGetMemType(me, mscript) = #script then ident = string(xscr().mGetThisMovieName())
2951      if length(ident) < 1 then ident = the moviename
2952     
2953      thePassword = ""
2954      placeholder = "%%password:"
2955      offs = offset(placeholder, VersionCheckUrl)
2956      if offs > 0 then
2957        thePassword = VersionCheckUrl.char[offs+length(placeholder) .. length(VersionCheckUrl)]
2958        thePassword = word 1 to thePassword.word.count of thePassword
2959        delete char offs to length(VersionCheckUrl) of VersionCheckUrl
2960      end if
2961     
2962      VersionCheckUrl = word 1 to VersionCheckUrl.word.count of VersionCheckUrl & "?movieName=" & ident
2963     
2964    end if
2965   
2966  end if
2967  --------------------- // version number
2968 
2969 
2970 
2971 
2972  -------- if we work on only one castlib:
2973 
2974  if ilk(selected_Members_Only) = #castLib then
2975   
2976    -----------------------------------------------------
2977    processIOnlySelectedMembers = 1
2978    clsellist = string(selectionList)
2979    if length(clsellist) > 0 then
2980      if listP(value(clsellist)) then processIOnlySelectedMembers = 0
2981    end if
2982    castlibList = getCastlibList(me, selectionList, selected_Members_Only.number)
2983   
2984   
2985    mpname = the moviepath & the moviename
2986    isInternal = 0
2987    repeat with cl in castlibList
2988      if castlib(cl).filename = mpname then
2989        isInternal = 1
2990        exit repeat
2991      end if
2992    end repeat
2993   
2994   
2995    if count(castlibList) < 1 then
2996      alert "No castlib selected. The parameter didn't yield a valid list. Make sure, that you provide a linear list with integers, specifying a number of a castlib each."
2997      if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
2998      return 0
2999    end if
3000   
3001    -----------------------------------------------------
3002   
3003    delim = the last char of the applicationpath
3004   
3005    olddelim = the itemdelimiter
3006    the itemdelimiter = delim
3007   
3008    updateurl = 0
3009   
3010    repeat with n = count(castlibList) down to 1
3011     
3012      selected_Members_Only = castlib(castlibList[n])
3013     
3014      -------------------- get version number:
3015     
3016     
3017      versmem = member("subversion_version_field", selected_Members_Only.number)
3018      if [#field, #text].getPos(mGetMemType(me, versmem)) > 0 then
3019        if updateurl = 0 then updateurl = 1
3020        curr = versmem.text
3021        if char 1 of curr = "r" then delete char 1 of curr
3022        curr = integer(curr)
3023        if not(integerP(curr)) then curr = 0
3024        if curr < versionNumber then
3025          versmem.text = "r" & versionNumber
3026          if length(VersionCheckUrl) > 0 then
3027            versmem.comments = VersionCheckUrl
3028          end if
3029        else
3030          updateurl = 2
3031        end if
3032      end if
3033     
3034      --------------------- // version number
3035     
3036     
3037      if the last item of workingFolder = "castlib" & selected_Members_Only.number then
3038        clibfolder = workingFolder
3039      else
3040        if the last char of workingFolder <> delim then put delim after workingFolder
3041        clibfolder = workingFolder & "castlib" & selected_Members_Only.number
3042      end if
3043     
3044      castlibList[n] = [castlibList[n], clibfolder, workingFolder]
3045      --------
3046     
3047     
3048    end repeat
3049   
3050    -------------------- get version number:
3051    if length(VersionCheckUrl) > 0 then
3052      if updateurl = 1 then
3053        if length(thePassword) then
3054          id = getnettext(VersionCheckUrl & "&version=" & thePassword & versionNumber)
3055        end if
3056      end if
3057    end if
3058    --------------------- // version number
3059   
3060    the itemdelimiter = olddelim
3061   
3062   
3063   
3064  else -- treat all:
3065   
3066    processIOnlySelectedMembers = 0
3067   
3068    -------------------- get version number:
3069    updateurl = 0
3070   
3071    repeat with cl = the number of castlibs down to 1
3072      versmem = member("subversion_version_field", cl)
3073      if [#field, #text].getPos(mGetMemType(me, versmem)) > 0 then
3074        if updateurl = 0 then updateurl = 1
3075        curr = versmem.text
3076        if char 1 of curr = "r" then delete char 1 of curr
3077        curr = integer(curr)
3078        if not(integerP(curr)) then curr = 0
3079        if curr < versionNumber then
3080          versmem.text = "r" & versionNumber
3081          if length(VersionCheckUrl) > 0 then
3082            versmem.comments = VersionCheckUrl
3083          end if
3084        else
3085          updateurl = 2
3086        end if
3087      end if
3088    end repeat
3089   
3090    if length(VersionCheckUrl) > 0 then
3091      if updateurl = 1 then
3092        if length(thePassword) then
3093          id = getnettext(VersionCheckUrl & "&version=" & thePassword & versionNumber)
3094        end if
3095      end if
3096    end if
3097    --------------------- // version number
3098   
3099   
3100    castlibList = 0
3101   
3102  end if
3103 
3104 
3105  workingFolderOriginal = workingFolder
3106 
3107  if castlibList = 0 then
3108   
3109    -------- if we work on only one castlib:
3110    if length(clibfolder) > 0 then workingFolder = clibfolder
3111    --------
3112   
3113    if the platform contains "mac" then
3114      svnBinary = mConvertHFS2Unix(me, svnBinary)
3115      workingFolder = mConvertHFS2Unix(me, workingFolder)
3116    else
3117      if the last char of workingFolder = the last char of the applicationpath then delete the last char of workingFolder
3118    end if
3119   
3120   
3121    workingFolder = " " & QUOTE & workingFolder & QUOTE
3122   
3123  else
3124   
3125    if the platform contains "mac" then svnBinary = mConvertHFS2Unix(me, svnBinary)
3126    cnt = count(castlibList)
3127   
3128    workingFolder = ""
3129   
3130    repeat with n = 1 to cnt
3131     
3132      if the platform contains "mac" then
3133        castlibList[n][3] = mConvertHFS2Unix(me, castlibList[n][3])
3134      else
3135        str = castlibList[n][3]
3136        if the last char of str = the last char of the applicationpath then
3137          delete the last char of str
3138          castlibList[n][3] = str
3139        end if
3140      end if
3141     
3142      put " " & QUOTE & castlibList[n][3] & QUOTE after workingFolder
3143     
3144    end repeat
3145   
3146  end if
3147 
3148 
3149  mDisplayWaitStatusText me, "SVN update of:" && workingFolder
3150 
3151 
3152  theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" & workingFolder, RETURN, 0, 1)
3153 
3154 
3155  if count(theresult) < 1 then
3156    theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "update" & workingFolder && "2>&1", RETURN, 0, 1)
3157    if count(theresult) < 1 then
3158      theError = theresult[1]
3159    else
3160      theError = "svn did not respond at all."
3161    end if
3162    alert "Can't proceed svn error while trying to update:" && theError
3163    if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
3164    return 0 
3165  end if
3166 
3167 
3168 
3169  -------- if we work on only one castlib:
3170 
3171  if ilk(selected_Members_Only) = #castLib then
3172   
3173    mDisplayWaitStatusText me, "Commiting scripttext for castlibs:" && castlibList
3174    put "Commiting scripttext for castlibs:" && castlibList
3175    repeat with n = count(castlibList) down to 1
3176     
3177      selected_Members_Only = castlib(castlibList[n][1])
3178      if processIOnlySelectedMembers = 0 then processEntireCastlib = selected_Members_Only
3179      else processEntireCastlib = 1
3180      mDisplayWaitStatusText me, "Saving castlib:" && selected_Members_Only
3181      selected_Members_Only.save()
3182      mExportAllScriptsToDiskWithFolder me, 1, processEntireCastlib, 1, mConvertUnix2Hfs(me, castlibList[n][3])
3183     
3184    end repeat
3185   
3186  else -- treat all:
3187   
3188    mDisplayWaitStatusText me, "Saving movie..."
3189    saveMovie()
3190    mExportAllScriptsToDiskWithFolder me, 1, processIOnlySelectedMembers, 1, workingFolderOriginal
3191   
3192  end if
3193 
3194 
3195  theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "status" & workingFolder, RETURN, 0, 1)
3196 
3197  cnt = count(theresult)
3198  if cnt < 1 then
3199    alert "Apparently there are no changes to the scripts of the most recent version in the svn repository: svn status is empty"
3200    if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
3201    return 1
3202  end if
3203 
3204  repeat with n = 1 to cnt
3205    answ = theresult[n]
3206    meth = word 1 of answ
3207    delete word 1 of answ
3208   
3209    case meth of
3210      "!": -- deleted file (missing here, but in the repository present)
3211       
3212        if processIOnlySelectedMembers = 1 then
3213          -- I don't think, it is a good idea to delete the file in the repository in this case
3214          -- as it may also be the case, that we only have a subset of the castlibs/scripts
3215          -- therefore I just skip these files and leave it to the user what to do with them in his svn client application
3216          -- we only put a message, so the user is made aware of this fact
3217          put "Missing file!" && answ && "is missing here, but present in the repository"
3218         
3219          mDisplayWaitStatusText me, "Missing file!" && answ && "is missing here, but present in the repository"
3220         
3221        else
3222         
3223          mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "rm" && QUOTE & answ & QUOTE, RETURN, 0, 1)
3224         
3225          put "Deleted file" && answ && "in the repository"
3226         
3227          mDisplayWaitStatusText me, "Deleted file" && answ && "in the repository"
3228         
3229        end if
3230       
3231       
3232      "?": -- newly added file
3233        mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "add" && QUOTE & answ & QUOTE, RETURN, 0, 1)
3234       
3235        put "Added file" && answ && "to the repository"
3236       
3237        mDisplayWaitStatusText me, "Added file" && answ && "to the repository"
3238       
3239      "m":
3240        -- just log the changes:
3241        put "Update file:" && answ
3242       
3243        mDisplayWaitStatusText me, "Update file:" && answ
3244       
3245    end case
3246   
3247  end repeat
3248 
3249  mDisplayWaitStatusText me, "SVN commit:" && workingFolder
3250 
3251  theresult = mDoShellCmd(me, QUOTE & svnBinary & QUOTE && "ci --message" && QUOTE & msg & QUOTE & workingFolder, RETURN, 0, 1)
3252 
3253 
3254  if count(theresult) > 0 then
3255    theResult = theresult[1]
3256   
3257    put theResult
3258   
3259   
3260    if dontShowAlert <> 1 then
3261      alert "Done, see the results of the svn operation in the message window."
3262    end if
3263   
3264  else
3265    alert "svn application did not respond, something seems to have failed, while commiting the scripttext. :-("
3266  end if
3267 
3268 
3269  setPref("svn_workingCopies_paths.txt", string(workingCopies))
3270 
3271 
3272  if statusSwitched = 1 then statusSwitched = mSwitchToStatusMode(me, 0)
3273 
3274  return 1
3275 
3276end
3277
3278
3279
3280-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3281---------- svn helper handlers
3282
3283on mGetSVNBinaryPath me, workingCopies
3284 
3285  if (mCheckForXtra(me, "budapi") + (mCheckForXtra(me, "Shell") + mCheckForXtra(me, "ff_shell"))) < 2 then
3286    alert "You need the shell xtra and the buddyApi xtra in order to proceed"
3287    return ""
3288  end if
3289 
3290  savePrefs = 0
3291  if ilk(workingCopies) <> #proplist then
3292    workingCopies = value(getPref("svn_workingCopies_paths.txt"))
3293    if ilk(workingCopies) <> #proplist then workingCopies = [:]
3294    savePrefs = 1
3295  end if
3296 
3297 
3298  if the platform contains "mac" then
3299    svnBinary = baHFSName(string(workingCopies.getaprop(#svnBinary)))
3300  else
3301    svnBinary = string(workingCopies.getaprop(#svnBinary))
3302  end if
3303 
3304  if the platform contains "mac" then -- dunno how to check on windows, if svn is installed, anyone ?
3305   
3306    if baFileExists(svnBinary) <> 1 then svnBinary = ""
3307   
3308   
3309    if length(svnBinary) < 1 then
3310     
3311      svnBinary = []
3312     
3313      svnBinary = mDoShellCmd(me, "for thisBinPath in /usr/bin /bin /usr/sbin /sbin /usr/local/sbin /usr/local/bin /opt/sbin /opt/bin /opt/local/sbin /opt/local/bin /sw/bin /sw/sbin ; do find $thisBinPath -name svn ; done", RETURN, 0, 1)
3314      -- end if
3315     
3316      if count(svnBinary) < 1 then
3317        alert "svn binary not found in your binaries folder. Where is the svn binary?"
3318        svnBinary = mGetFilePathFromUser(me)
3319        if length(svnBinary) < 1 then return ""
3320       
3321      else
3322        svnBinary = baHFSName(svnBinary[1])
3323       
3324      end if
3325     
3326     
3327    end if
3328   
3329    if baFileExists(svnBinary) <> 1 then
3330      alert "The path to the svn binary seems to have changed. Please try again in order to search the path."
3331      svnBinary = ""
3332    end if
3333   
3334   
3335  else
3336    -- dunno how to check on windows, if svn is installed, anyone ?
3337    svnBinary = "svn"
3338  end if
3339 
3340 
3341  workingCopies.setaprop(#svnBinary, svnBinary)
3342 
3343  if savePrefs = 1 then setPref("svn_workingCopies_paths.txt", string(workingCopies))
3344 
3345  return svnBinary
3346 
3347end
3348
3349
3350-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3351
3352on mGetVersionCheckUrl me, movieIdentifier, workingCopies, selectMsg
3353 
3354  movieIdentifier = string(movieIdentifier)
3355  if length(movieIdentifier) < 1 then
3356    movieIdentifier = the moviepath & the moviename
3357  end if
3358 
3359  savePrefs = 0
3360  if ilk(workingCopies) <> #proplist then
3361    workingCopies = value(getPref("svn_workingCopies_paths.txt"))
3362    if ilk(workingCopies) <> #proplist then workingCopies = [:]
3363    savePrefs = 1
3364  end if
3365 
3366  versionCheckUrlList = workingCopies.getaprop(#versionCheckUrls)
3367  if not(objectP(versionCheckUrlList)) then
3368    versionCheckUrlList = [:] 
3369    workingCopies.setaprop(#versionCheckUrls, versionCheckUrlList)
3370  end if
3371 
3372  versionCheckUrl = string(versionCheckUrlList.getaprop(movieIdentifier))
3373 
3374  if length(versionCheckUrl) > 0 then return versionCheckUrl
3375 
3376 
3377  repeat with n = the number of castlibs down to 1
3378    versmem = member("subversion_version_field", n)
3379    if [#field, #text].getPos(mGetMemType(me, versmem)) > 0 then
3380      versionCheckUrl = string(versmem.comments)
3381      if length(versionCheckUrl) then exit repeat
3382    end if
3383  end repeat
3384 
3385  if length(versionCheckUrl) > 0 then
3386   
3387    selectMsg = string(selectMsg)
3388    if length(selectMsg) < 1 then selectMsg = "No update check URL is specified for this movie. Please enter an URL."
3389   
3390    --    if mCheckForXtra(me, "BudApi") = 1 then
3391    --      versionCheckUrl = baPrompt("Select URL", selectMsg, "http://www.farbflash.de/cgi-bin/versionCheck.pl %%password: secretpassword", 0, -2, -2)
3392    --    else
3393    muiobj = new(xtra "Mui")
3394    --     versionCheckUrl = muiobj.GetUrl("http://www.farbflash.de/cgi-bin/versionChecker.pl %%password: secretpassword", 1)
3395    versionCheckUrl = muiobj.GetUrl(versionCheckUrl && "%%password: secretpassword", 1)
3396    muiobj = 0
3397    --    end if
3398   
3399    if length(versionCheckUrl) < 1 then return ""
3400   
3401    versionCheckUrlList.setaprop(movieIdentifier, versionCheckUrl)
3402   
3403    if savePrefs = 1 then setPref("svn_workingCopies_paths.txt", string(workingCopies))
3404   
3405  end if
3406 
3407  return versionCheckUrl
3408 
3409end
3410
3411-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3412
3413on mGetWorkingCopyPath me, movieIdentifier, chooseNewPath, workingCopies, selectMsg
3414 
3415  movieIdentifier = string(movieIdentifier)
3416  if length(movieIdentifier) < 1 then
3417    movieIdentifier = the moviepath & the moviename
3418  end if
3419 
3420  savePrefs = 0
3421  if ilk(workingCopies) <> #proplist then
3422    workingCopies = value(getPref("svn_workingCopies_paths.txt"))
3423    if ilk(workingCopies) <> #proplist then workingCopies = [:]
3424    savePrefs = 1
3425  end if
3426 
3427  workingFolder = string(workingCopies.getaprop(movieIdentifier))
3428 
3429  if length(workingFolder) > 0 then
3430    if baFolderExists(workingFolder) <> 1 then
3431      workingFolder = ""
3432    end if
3433  end if
3434 
3435 
3436  if chooseNewPath = 1 then
3437    workingFolder = mGetFolderPathFromUser(me, the moviepath, "Please select a working copy for SVN update", 3, "Select working copy", -2, -2)
3438  end if
3439 
3440  if workingFolder = "" then
3441   
3442    selectMsg = string(selectMsg)
3443    if length(selectMsg) < 1 then selectMsg = "No working copy is specified for this movie. Please select a working copy now."
3444   
3445    alert selectMsg
3446   
3447    workingFolder = mGetFolderPathFromUser(me, the moviepath, "Please select a working copy for SVN update", 3, "Select working copy", -2, -2)
3448  end if
3449 
3450  if length(workingFolder) < 1 then return ""
3451 
3452  if checkIfPathIsSVNWorkingCopy(me, workingFolder) <> 1 then
3453    alert workingFolder && "does not appear to be a svn working copy."
3454    workingCopies.deleteprop(movieIdentifier)
3455    return ""
3456  end if
3457 
3458  workingCopies.setaprop(movieIdentifier, workingFolder)
3459 
3460  if savePrefs = 1 then setPref("svn_workingCopies_paths.txt", string(workingCopies))
3461 
3462  return workingFolder
3463 
3464end
3465
3466-- starting with version 1.7 now subversion keeps its metadata in only the root of a working copy
3467-- instead like how it was before in every folder, like it has been in git from the beginning
3468-- good move! But we now must check all the path upwoards to find the .svn folder in order to check
3469-- whether we have a working directory
3470
3471on checkIfPathIsSVNWorkingCopy me, aPath
3472    if length(aPath) < 1 then return 0
3473 
3474  delim = the last char of the applicationpath
3475  if the last char of aPath <> delim then put delim after aPath
3476 
3477  if baFolderExists(aPath & ".svn") <> 1 then
3478    olddelim = the itemdelimiter
3479    the itemdelimiter = delim
3480    delete the last item of aPath
3481    delete the last item of aPath
3482    the itemdelimiter = olddelim
3483    return checkIfPathIsSVNWorkingCopy(me, aPath)
3484  end if
3485 
3486  return 1
3487end
Note: See TracBrowser for help on using the repository browser.