Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An AppleScript to ease Finder/CVS integration System
I wanted CVS integrated into the finder. I still do. This was a first step for me as I am just learning AppleScript. I created a folder action that will color code the files based on thier CVS status.

I don't know if this is good AppleScript code. I just know it seems to run and work on my machine. If there are any recomendations on, A) better coding practices or, B) a better means for doing CVS work from the Finder, all comments are welcome.

Read the rest of the hint for the script...

[robg adds: I haven't tested this one myself...]


-- set the amount of time before dialogs auto-answer:
property dialog_timeout : 30 
property cvs_folder : "CVS"
property added_label : 7 -- Grey
property modified_label : 4 -- Blue
property updates_label : 6 -- green
property conflict_label : 2 --Red
property noncvs_label : 1 -- orange
property no_label : 0
property grey_label : 7 -- Grey
property yellow_label : 3 -- Yellow
property purple_label : 5 -- Purple

on opening folder thisFolder
  tell application "Finder"
    activate
    try
      if (exists folder cvs_folder of thisFolder) then
        set folderUrl to the URL of thisFolder
        set localOffset to offset of "localhost" in folderUrl
        set folderPath to text (localOffset + 9) thru end of folderUrl
        set cvsResponse to do shell script "cd " & folderPath & ¬
         ";/usr/bin/cvs -nq update -l"
        set thisFileList to list folder thisFolder with invisibles
        repeat with thisFile in thisFileList
          set fileItem to ((thisFolder as string) & thisFile) as alias
          set the label index of the fileItem to no_label
        end repeat
        set my text item delimiters to return
        repeat with cvsLine in text items of cvsResponse
          if length of cvsLine is 0 then
            exit repeat
          end if
          set cvsStatus to text 1 thru 1 of cvsLine
          set cvsFile to text 3 thru end of cvsLine
          if cvsFile is in thisFileList then
            set fileItem to ((thisFolder as string) & cvsFile) as alias
            if cvsStatus is equal to "C" then
              set the label index of the fileItem to conflict_label
            else
              if cvsStatus is equal to "?" then
                set the label index of the fileItem to noncvs_label
              else
                if cvsStatus is equal to "P" or cvsStatus is equal to ¬
                 "U" then
                  set the label index of the fileItem to updates_label
                else
                  if cvsStatus is equal to "M" then
                    set the label index of the fileItem to modified_label
                  else
                    if cvsStatus is equal to "A" then
                      set the label index of the fileItem to added_label
                    end if
                  end if
                end if
              end if
            end if
          end if
        end repeat
      end if
    on error e
      display dialog e
    end try
  end tell
end opening folder
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[5,330 views]  

An AppleScript to ease Finder/CVS integration | 5 comments | Create New Account
Click here to return to the 'An AppleScript to ease Finder/CVS integration' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
An AppleScript to ease Finder/CVS integration
Authored by: prk on Mar 17, '04 11:11:15AM

Now this is an excellent idea! I'm not an Apple Scripter so I'm not sure about the code, but I would love to have CVS integration into Finder. I was also thinking about going to SubVersion. I wonder if that could be done as well?



[ Reply to This | # ]
How does this work?
Authored by: 5chm31din6 on Mar 17, '04 01:01:36PM

So, how does this work? Do you attach it to a folder as a Folder Action Script? If so, is it recursive, or do I need to attach the script to every folder? Could I possibly be more inquisitive? Do you think? Hmmm?

---
Signature, schmignature.



[ Reply to This | # ]
How does this work?
Authored by: carll on Mar 17, '04 01:11:14PM

You attach it to the each folder that you want view cvs status in. It's not recursive. That would be nice but I'd be conserned with the delay in waiting for a full recursive cvs response.

Suggestions for improvement are welcome. Especially from people, unlike myself, who actually know AppleScript



[ Reply to This | # ]
CVSFinder
Authored by: webmac on Mar 17, '04 03:35:05PM
I found this on Sourceforge: http://cvsfinder.sourceforge.net/. Anyone who tested it?

[ Reply to This | # ]
CVSFinder
Authored by: avarame on Mar 17, '04 05:51:24PM

The readme says it's only been tested with 10.2 and "might" work with 10.3... Caveat user.



[ Reply to This | # ]