-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.textmate.org/trunk/Bundles/SVK.tmbundle@6875 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
- Loading branch information
Brian Donovan
committed
Mar 22, 2007
1 parent
c3105ba
commit 2203439
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?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_SVK:=svk}" "If you have installed svk, then you need to either update your <tt>PATH</tt> or set the <tt>TM_SVK</tt> shell variable (e.g. in Preferences / Advanced)" | ||
if [[ -z $TM_SELECTED_FILES ]] | ||
then | ||
TM_SELECTED_FILES="'$TM_FILEPATH'" | ||
fi | ||
"$TM_BUNDLE_SUPPORT/revert_file.rb" $TM_SELECTED_FILES | ||
</string> | ||
<key>input</key> | ||
<string>none</string> | ||
<key>keyEquivalent</key> | ||
<string>^~A</string> | ||
<key>name</key> | ||
<string>Revert</string> | ||
<key>output</key> | ||
<string>showAsTooltip</string> | ||
<key>uuid</key> | ||
<string>8FCB4C8F-23CD-4D2E-A9F2-C4564DFFEB2A</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env ruby -s | ||
|
||
require ENV['TM_SUPPORT_PATH'] + "/lib/dialog" | ||
|
||
abort "Wrong arguments: use -path=«file to revert»" if $path.nil? and ARGV.size == 0 | ||
|
||
svk = ENV['TM_SVK'] || $svk || 'svk' | ||
|
||
# get paths from --path or from naked arguments | ||
paths = if ARGV.size > 0 | ||
ARGV | ||
else | ||
[e_sh($path)] | ||
end | ||
|
||
warn_for_paths = [] | ||
|
||
# Escape paths for shell | ||
paths_for_shell = paths.sort.uniq #.map {|path| e_sh(path)} | ||
|
||
# Ask for status | ||
status = %x{#{svk} status #{paths_for_shell.join(" ")}} | ||
|
||
# Get array of [status, path] tuples | ||
status_for_paths = status.scan(/(.{1,8})\s+(.*)$/) | ||
|
||
status_for_paths.each do|status_entry| | ||
status = status_entry[0] | ||
path = status_entry[1] | ||
|
||
# Reverting added or deleted files will not destroy data | ||
# Unmodified files will be skipped | ||
warn_for_paths << path unless (status =~ /^(A|D|\?)/) | ||
end | ||
|
||
# TextMate::Dialog.alert(:warning, "¿Que pasa?", "It's not dangerous to revert the file “#{paths_for_shell.inspect}”.") | ||
|
||
res = if warn_for_paths.size > 0 then | ||
paths_to_display = warn_for_paths.map {|x| File.basename(x)}.join("”, “") | ||
plural = (warn_for_paths.size == 1) ? '' : 's' | ||
title_files = (warn_for_paths.size == 1) ? "“#{paths_to_display}”" : 'files' | ||
|
||
TextMate::Dialog.alert(:warning, "Revert #{title_files}?", "Do you really want to revert the file#{plural} “#{paths_to_display}” and lose all local changes?", 'Revert', 'Cancel') | ||
else | ||
# Nothing dangerous; be happy | ||
'Revert' | ||
end | ||
|
||
if res =~ /Revert/i then | ||
# ENV['TM_SVK_REVERT'] = path # by using an env. variable we avoid shell escaping | ||
puts `#{svk} revert #{paths_for_shell.join(' ')}` | ||
|
||
# rescan_project | ||
%x{osascript &>/dev/null \ | ||
-e 'tell app "SystemUIServer" to activate' \ | ||
-e 'tell app "TextMate" to activate' &} | ||
else | ||
exit -128 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters