Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding tentative CVS commit. It currently only handles files descendi…

…ng from the same root folder.

git-svn-id: http://svn.textmate.org/trunk/Bundles/CVS.tmbundle@2812 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
commit 18c25951116f1d0cb1a8a757aefb7b24d2bef86d 1 parent 31c9e71
Brian Donovan authored
View
26 Commands/Commit....plist
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>require_cmd "${TM_CVS:=cvs}" "If you have installed cvs, then you need to either update your &lt;tt&gt;PATH&lt;/tt&gt; or set the &lt;tt&gt;TM_CVS&lt;/tt&gt; shell variable (e.g. in Preferences / Advanced)"
+
+export TM_CVS
+export CommitWindow="$TM_SUPPORT_PATH/bin/CommitWindow.app/Contents/MacOS/CommitWindow"
+
+cd "${TM_PROJECT_DIRECTORY:-$TM_DIRECTORY}"
+"${TM_RUBY:-ruby}" -- "${TM_BUNDLE_SUPPORT}/cvs_commit.rb"</string>
+ <key>input</key>
+ <string>none</string>
+ <key>keyEquivalent</key>
+ <string>^Z</string>
+ <key>name</key>
+ <string>Commit...</string>
+ <key>output</key>
+ <string>showAsHTML</string>
+ <key>uuid</key>
+ <string>BE6728A5-AFC4-4D98-9EC7-C2E951483B71</string>
+</dict>
+</plist>
View
90 Support/Stylesheets/cvs_style.css
@@ -0,0 +1,90 @@
+/* general stuff.. */
+body {
+ font-family: "Lucida Grande", sans-serif;
+ font-size: 13px;
+}
+
+h1 {
+ font-size: 24px;
+ text-shadow: #ddd 2px 3px 3px;
+}
+
+/* make horizontal rules slightly less heavy */
+hr {
+color: #ccc;
+background-color: #ccc;
+height: 1px;
+border: 0px;
+}
+
+/* enable word-wrap for text in <pre> */
+pre {
+word-wrap: break-word;
+}
+
+/* for error formating.. */
+div.error {
+ font-family: "Bitstream Vera Sans Mono", monospace;
+ font-size: 12px;
+ color: #f30;
+ background-color: #fee;
+ border: 2px solid #f52;
+ padding: 4px;
+ margin: 3px;
+}
+
+div.error h2 {
+ font-family: "Lucida Grande", sans-serif;
+ font-size: 17px;
+ margin-top: 0;
+}
+
+div.error a:link, div.error a:visited {
+ background-color: transparent;
+ color: inherit;
+}
+div.error a:hover, div.error a:active {
+ background-color: #f52;
+ text-decoration: none;
+ color: #fee;
+}
+
+
+/* for showing the path or other information about the current operation */
+div.command {
+ color: #03f;
+ background-color: #eef;
+ border: 2px solid #25f;
+ padding: 4px;
+ margin: 3px;
+ font-family: "Bitstream Vera Sans Mono", monospace;
+ font-size: 10px;
+}
+
+div.command h2 {
+ font-family: "Lucida Grande", sans-serif;
+ font-size: 15px;
+ margin-top: 0;
+}
+
+
+/* about links.. */
+a:link, a:visited {
+ background-color: transparent;
+ color: #35a;
+ text-decoration: underline;
+ padding-left: 1px;
+ padding-right: 1px;
+}
+
+a:hover, a:active {
+ background-color: #136;
+ color: #fff;
+ text-decoration: none;
+}
+
+
+/* for everything alternating: */
+.alternate {
+ background-color: #f2f2f2;
+}
View
128 Support/cvs_commit.rb
@@ -0,0 +1,128 @@
+require 'English' # you are angry, english!
+
+cvs = ENV['TM_CVS']
+#commit_paths = ENV['CommitPaths']
+commit_tool = ENV['CommitWindow']
+bundle = ENV['TM_BUNDLE_SUPPORT']
+support = ENV['TM_SUPPORT_PATH']
+ignore_file_pattern = /(\/.*)*(\/\..*|\.(tmproj|o|pyc)|Icon)/
+
+CURRENT_DIR = Dir.pwd + "/"
+
+require (bundle + '/versioned_file.rb')
+require (bundle + '/working_copy.rb')
+require (support + '/bin/shelltokenize.rb')
+require (support + "/bin/Builder.rb")
+
+mup = Builder::XmlMarkup.new(:target => STDOUT)
+
+mup.html {
+ mup.head {
+ mup.title("CVS commit")
+ mup.style( "@import 'file://"+bundle+"/Stylesheets/cvs_style.css';", "type" => "text/css")
+ }
+
+ mup.body {
+ mup.h1("CVS Commit")
+ STDOUT.flush
+ mup.hr
+
+ # Ignore files without changes
+#puts TextMate::selected_paths_for_shell
+ working_copies = TextMate::selected_paths_array.map do |path|
+ File.directory?(path) ?
+ CVS::WorkingCopy.new(path) :
+ CVS::VersionedFile.new(path)
+ end
+
+ #status_command = %Q{"#{cvs}" -nq update #{TextMate::selected_paths_for_shell}}
+#puts status_command
+ #status_output = %x{#{status_command}}
+#puts status_output
+ #paths = status_output.scan(/^(.)....(\s+)(.*)\n/)
+ status = working_copies.inject({}) do |h,wc|
+ case wc
+ when CVS::WorkingCopy then h.update(wc.status)
+ when CVS::VersionedFile then h.update(wc.path => wc.status)
+ end
+ h
+ end
+ paths = status.keys
+
+
+ def paths_for_status(hash, *status)
+ hash.inject([]) { |arr,(k,v)| arr << k if status.include?(v); arr }
+ end
+
+# def status_to_paths()
+# paths = matches.collect { |m| m[2] }
+# paths.collect{|path| path.sub(/^#{CURRENT_DIR}/, "") }
+# end
+
+ def matches_to_status(matches)
+ matches.collect {|m| m[0]}
+ end
+
+ # Ignore files with '?', but report them to the user
+ #unknown_paths = paths.select { |m| m[0] == '?' }
+
+ unknown_paths = paths_for_status(status, :unknown)
+ unknown_to_report_paths = unknown_paths.select { |path| ignore_file_pattern =~ path }
+
+ #unknown_to_report_paths = paths.select{ |m| m[0] == '?' and not ignore_file_pattern =~ m[2]}
+ unless unknown_to_report_paths.empty?
+ mup.div( "class" => "info" ) {
+ mup.text! "These files are not added to the repository, and so will not be committed:"
+ mup.ul{ unknown_to_report_paths.each{ |path| mup.li(path) } }
+ }
+ end
+
+ # Fail if we have conflicts -- cvs commit will fail, so let's
+ # error out before the user gets too involved in the commit
+ conflict_paths = paths_for_status(status, :conflicted)
+
+ unless conflict_paths.empty?
+ mup.div( "class" => "error" ) {
+ mup.text! "Cannot continue; there are merge conflicts in files:"
+ mup.ul{ conflict_paths.keys.each { |path| mup.li(path) } }
+ mup.text! "Canceled."
+ }
+ exit -1
+ end
+
+ # Remove the unknown paths from the commit
+ commit_paths = paths.select { |path| [:modified, :added, :removed].include? status[path] }
+
+ if commit_paths.empty?
+ mup.div( "class" => "info" ) {
+ mup.text! "File(s) not modified; nothing to commit."
+ mup.ul{ unknown_paths.keys.each { |path| mup.li(path) } }
+ }
+ exit 0
+ end
+
+ STDOUT.flush
+
+ commit_status = commit_paths.map { |path| status[path].to_s[0,1].upcase }.join(":")
+
+ commit_path_text = commit_paths.collect { |path| path.quote_filename_for_shell }.join(" ")
+
+ commit_args = %x{"#{commit_tool}" --status #{commit_status} #{commit_path_text}}
+
+ status = $CHILD_STATUS
+ if status != 0
+ mup.div( "class" => "error" ) {
+ mup.text! "Canceled (#{status >> 8})."
+ }
+ exit -1
+ end
+
+ mup.div("class" => "command"){ mup.strong(%Q{#{cvs} commit }); mup.text!(commit_args) }
+
+ mup.pre {
+ STDOUT.flush
+
+ puts working_copies.first.cvs(:commit, commit_args.gsub(working_copies.first.dirname, ''))
+ }
+ }
+}
View
4 Support/versioned_file.rb
@@ -9,7 +9,7 @@ def initialize(path)
end
def dirname
- File.dirname @path
+ (File.dirname(@path) =~ %r{/$}) ? File.dirname(@path) : "#{File.dirname(@path)}/"
end
def basename
@@ -66,7 +66,7 @@ def cvs(command, options={})
class_eval "def self.#{method}(path, *args); new(path).#{method}(*args); end"
end
- private
+ protected
def expand_revision(revision)
case revision
View
8 Support/working_copy.rb
@@ -4,13 +4,17 @@ def initialize(path)
@path = (path =~ %r{/$}) ? path : "#{path}/" # add / if not there
end
+ def dirname
+ @path
+ end
+
def basename
'.'
end
def status
- cvs(:update, :pretend => true, :quiet => true).inject([]) do |files,line|
- files << {$1 => status_for_line line} if line =~ /^\S (.*)$/
+ cvs(:update, :pretend => true, :quiet => true).inject({}) do |files,line|
+ files.update($1 => status_from_line(line)) if line =~ /^\S (.*)$/
files
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.