Skip to content

Commit

Permalink
First attempt
Browse files Browse the repository at this point in the history
- Perforce commands now mapped to Command-4    - (Old ones still live at
Control-Shift-F.  I haven't touched those.)  - All commands at Command-4
now work on multiple selected files  - Using shell scripts instead of
awkwardly-invoked Python when possible  - Added Sync with Depot  - If
you try to Save inside a Perforce depot, you will be prompted to
overwrite the locked file.  Do it.  This Perforce bundle will open that
file for editing on your behalf.  TODO:  - Add support for
shelve/unshelve
  • Loading branch information
appsforartists authored and infininight committed Aug 15, 2012
1 parent b83efd5 commit 8e6ff94
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 52 deletions.
50 changes: 33 additions & 17 deletions Commands/Add or Edit.tmCommand
Expand Up @@ -3,32 +3,48 @@
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<string>saveActiveFile</string>
<key>command</key>
<string>the_file=`python -c "import sys,os;print os.path.realpath(sys.argv[1])" $TM_FILEPATH`
<string>#!/bin/bash
result=`"${TM_P4:=p4}" edit "$the_file" 2&gt;&amp;1`
status=$?
p4_info_key="Client root: "
if [[ "$result" =~ "already opened for add" ]]; then
echo "Already opened for add."
exit $status
fi
# Get the key: value pair containing the workspace path from
# p4
workspace_path=`p4 info | grep "$p4_info_key"`
# Remove the key
workspace_path="${workspace_path#$p4_info_key}/"
# If the currently open file contains workspace_path
if [[ $TM_FILEPATH =~ $workspace_path ]]
then
# P4 add or edit the file
the_file=`python -c "import sys,os;print os.path.realpath(sys.argv[1])" $TM_FILEPATH`
if [[ "$result" =~ "not on client" ]]; then
result=`"${TM_P4:=p4}" add "$the_file" 2&gt;&amp;1`
status=$?
fi
result=`"${TM_P4:=p4}" edit "$the_file" 2&gt;&amp;1`
status=$?
echo $result
exit $status
</string>
if [[ "$result" =~ "already opened for add" ]]; then
echo "Already opened for add."
exit $status
fi
if [[ "$result" =~ "not on client" ]]; then
result=`"${TM_P4:=p4}" add "$the_file" 2&gt;&amp;1`
status=$?
fi
echo $result
exit $status
fi</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>^F</string>
<string>@s</string>
<key>name</key>
<string>Open for Add or Edit</string>
<string>Save (add/edit if neccessary)</string>
<key>output</key>
<string>showAsTooltip</string>
<key>uuid</key>
Expand Down
9 changes: 6 additions & 3 deletions Commands/Add to Depot.plist
Expand Up @@ -5,11 +5,14 @@
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>the_file=`python -c "import sys,os;print os.path.realpath(sys.argv[1])" $TM_FILEPATH`
"${TM_P4:=p4}" add "$the_file"
</string>
<string>#!/bin/bash
# eval is needed to parse the 's in $TM_SELECTED_FILES
eval p4 add $TM_SELECTED_FILES</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>@4</string>
<key>name</key>
<string>Add to Depot</string>
<key>output</key>
Expand Down
6 changes: 3 additions & 3 deletions Commands/Annotate.plist
Expand Up @@ -6,14 +6,14 @@
<string>nop</string>
<key>command</key>
<string>the_file=`python -c "import sys,os;print os.path.realpath(sys.argv[1])" $TM_FILEPATH`
"${TM_P4:=p4}" annotate -c -i -q "$the_file"
"${TM_P4:=p4}" -P $P4PASSWD annotate -c -i -q "$the_file"
</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>^F</string>
<string>@4</string>
<key>name</key>
<string>Annotate</string>
<string>Blame</string>
<key>output</key>
<string>openAsNewDocument</string>
<key>uuid</key>
Expand Down
13 changes: 9 additions & 4 deletions Commands/Open for Delete.tmCommand
Expand Up @@ -5,15 +5,20 @@
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>the_file=`python -c "import sys,os;print os.path.realpath(sys.argv[1])" $TM_FILEPATH`
"${TM_P4:=p4}" delete "$the_file"
<string>#!/bin/bash
# eval is needed to parse the 's in $TM_SELECTED_FILES
eval p4 delete $TM_SELECTED_FILES
# force TM to refresh the current file..
rescan_project
</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>^F</string>
<string>@4</string>
<key>name</key>
<string>Mark for Delete</string>
<string>Delete from Depot</string>
<key>output</key>
<string>showAsTooltip</string>
<key>uuid</key>
Expand Down
10 changes: 7 additions & 3 deletions Commands/Open for Editing.plist
Expand Up @@ -5,13 +5,17 @@
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>the_file=`python -c "import sys,os;print os.path.realpath(sys.argv[1])" $TM_FILEPATH`
"${TM_P4:=p4}" edit "$the_file"
<string>#!/bin/bash
# eval is needed to parse the 's in $TM_SELECTED_FILES
eval p4 edit $TM_SELECTED_FILES
</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>@4</string>
<key>name</key>
<string>Open for Editing</string>
<string>Edit in workspace</string>
<key>output</key>
<string>showAsTooltip</string>
<key>uuid</key>
Expand Down
2 changes: 2 additions & 0 deletions Commands/Perforce Command Reference.tmCommand
Expand Up @@ -8,6 +8,8 @@
<string>open "http://perforce.com/perforce/doc.082/manuals/cmdref/index.html"</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>@4</string>
<key>name</key>
<string>Perforce Command Reference</string>
<key>output</key>
Expand Down
12 changes: 6 additions & 6 deletions Commands/Revert to Latest.plist
Expand Up @@ -5,16 +5,16 @@
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>the_file=`python -c "import sys,os;print os.path.realpath(sys.argv[1])" $TM_FILEPATH`
"${TM_P4:=p4}" revert "$the_file"
<string>#!/bin/bash
# force TM to refresh the current file..
rescan_project
</string>
# eval is needed to parse the 's in $TM_SELECTED_FILES
eval p4 revert $TM_SELECTED_FILES</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>@4</string>
<key>name</key>
<string>Revert to Latest</string>
<string>Revert</string>
<key>output</key>
<string>showAsTooltip</string>
<key>uuid</key>
Expand Down
5 changes: 3 additions & 2 deletions Commands/Submit Changelist….plist
Expand Up @@ -14,6 +14,7 @@ require 'p4_forms'
require 'shelltokenize'
p4 = ENV['TM_P4'] || 'p4'
#commit_paths = ENV['CommitPaths']
support = ENV['TM_SUPPORT_PATH']
commit_tool = support + "/bin/CommitWindow.app/Contents/MacOS/CommitWindow"
Expand Down Expand Up @@ -72,9 +73,9 @@ IO.popen(%Q{"#{p4}" submit -i}, "w+" ) {|p| p.puts commit_form.to_s }
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>^F</string>
<string>@4</string>
<key>name</key>
<string>Submit Changelist…</string>
<string>Commit Changelist…</string>
<key>output</key>
<string>openAsNewDocument</string>
<key>uuid</key>
Expand Down
43 changes: 43 additions & 0 deletions Commands/Sync with Depot.tmCommand
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//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>#!/bin/bash
p4_info_key="Client root: "
# Get the key: value pair containing the workspace path from
# p4
workspace_path=`p4 info | grep "$p4_info_key"`
# Remove the key
workspace_path="${workspace_path#$p4_info_key}/"
if [[ $TM_SELECTED_FILE =~ $workspace_path ]]
then
relative_path=${TM_SELECTED_FILE#$workspace_path}
if [[ -d $TM_SELECTED_FILE ]]
then
# p4 requires ... to sync a directory
relative_path="${relative_path}/..."
fi
# eval not needed because $TM_SELECTED_FILE is unquoted
cd $workspace_path
p4 sync $relative_path
fi</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key>
<string>@4</string>
<key>name</key>
<string>Sync with Depot</string>
<key>output</key>
<string>openAsNewDocument</string>
<key>uuid</key>
<string>48C3E848-57FC-4633-814E-724CE05AC124</string>
</dict>
</plist>
28 changes: 14 additions & 14 deletions info.plist
Expand Up @@ -10,17 +10,17 @@
<string>&lt;a href="http://www.perforce.com/perforce/"&gt;Perforce&lt;/a&gt; is a commercial source control management system.</string>
<key>mainMenu</key>
<dict>
<key>excludedItems</key>
<array>
<string>AD9B4CB8-7577-11D9-A32D-000A95A89C98</string>
<string>9982EC7A-7577-11D9-A32D-000A95A89C98</string>
</array>
<key>items</key>
<array>
<string>0D7B4536-7B90-47ED-BB1C-5A24CEEFB078</string>
<string>BE2B6161-2E23-4C08-B438-409BB1E82DA8</string>
<string>48C3E848-57FC-4633-814E-724CE05AC124</string>
<string>------------------------------------</string>
<string>E73FA01C-7625-11D9-B58C-000A95A89C98</string>
<string>BE2B6161-2E23-4C08-B438-409BB1E82DA8</string>
<string>5D487D57-14F6-4E77-BFAE-769CA3DA40EA</string>
<string>------------------------------------</string>
<string>AD9B4CB8-7577-11D9-A32D-000A95A89C98</string>
<string>9982EC7A-7577-11D9-A32D-000A95A89C98</string>
<string>0D7B4536-7B90-47ED-BB1C-5A24CEEFB078</string>
<string>------------------------------------</string>
<string>38C6DE3A-7664-11D9-B58C-000A95A89C98</string>
<string>556314B2-B3BF-11D9-9B1F-000A95A89C98</string>
Expand All @@ -29,13 +29,12 @@
<string>D6F5F368-C476-4882-82EA-D11E22A445BF</string>
<string>3E208CDF-268C-4A23-902B-5628596E4BC8</string>
<string>------------------------------------</string>
<string>5D487D57-14F6-4E77-BFAE-769CA3DA40EA</string>
<string>------------------------------------</string>
<string>81133C73-CC7A-48EF-AA00-745E0ACF7E6B</string>
<string>------------------------------------</string>
<string>D877FFC4-1170-452B-910B-AB4F0EE743C6</string>
<string>80BD96D6-C41C-45F3-8CAE-E6D88B9D7339</string>
<string>C7F04C53-6B13-47DC-AC09-721D311DFD7D</string>
<string>------------------------------------</string>
</array>
<key>submenus</key>
<dict>
Expand All @@ -56,24 +55,25 @@
<string>Perforce</string>
<key>ordering</key>
<array>
<string>BE2B6161-2E23-4C08-B438-409BB1E82DA8</string>
<string>48C3E848-57FC-4633-814E-724CE05AC124</string>
<string>E73FA01C-7625-11D9-B58C-000A95A89C98</string>
<string>5D487D57-14F6-4E77-BFAE-769CA3DA40EA</string>
<string>AD9B4CB8-7577-11D9-A32D-000A95A89C98</string>
<string>9982EC7A-7577-11D9-A32D-000A95A89C98</string>
<string>0D7B4536-7B90-47ED-BB1C-5A24CEEFB078</string>
<string>D6F5F368-C476-4882-82EA-D11E22A445BF</string>
<string>556314B2-B3BF-11D9-9B1F-000A95A89C98</string>
<string>38C6DE3A-7664-11D9-B58C-000A95A89C98</string>
<string>C7F04C53-6B13-47DC-AC09-721D311DFD7D</string>
<string>97E895A4-B5B9-11D9-80D4-000A95A89C98</string>
<string>3E208CDF-268C-4A23-902B-5628596E4BC8</string>
<string>5D487D57-14F6-4E77-BFAE-769CA3DA40EA</string>
<string>E73FA01C-7625-11D9-B58C-000A95A89C98</string>
<string>BE2B6161-2E23-4C08-B438-409BB1E82DA8</string>
<string>1194ED50-336C-45F8-9E73-C777FB3FAF88</string>
<string>092CED4D-9C4C-4ED7-BB6A-5C80D929D9FD</string>
<string>A1DCDF0B-628B-4590-87C0-A551DC1F5F3A</string>
<string>80BD96D6-C41C-45F3-8CAE-E6D88B9D7339</string>
<string>D877FFC4-1170-452B-910B-AB4F0EE743C6</string>
<string>9C843973-4684-4D1F-AC63-748BE92025A6</string>
<string>AD9B4CB8-7577-11D9-A32D-000A95A89C98</string>
<string>9982EC7A-7577-11D9-A32D-000A95A89C98</string>
</array>
<key>uuid</key>
<string>1FCD86C8-7D03-4179-88E1-B67039E8F7C3</string>
Expand Down

0 comments on commit 8e6ff94

Please sign in to comment.