diff --git a/Context.sublime-menu b/Context.sublime-menu index 0832e41..6366185 100644 --- a/Context.sublime-menu +++ b/Context.sublime-menu @@ -50,7 +50,22 @@ "caption": "Select Diff Application" } ] - }, + }, + { + "command": "perforce_visual", + "args": {"cmd": "history"}, + "caption": "History" + }, + { + "command": "perforce_visual", + "args": {"cmd": "annotate"}, + "caption": "Time Lapse" + }, + { + "command": "perforce_visual", + "args": {"cmd": "tree"}, + "caption": "Revision Graph" + }, { "command": "perforce_list_checked_out_files", "caption": "List Checked Out Files" diff --git a/Default.sublime-commands b/Default.sublime-commands index a66090f..04f5f70 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -27,6 +27,21 @@ "caption": "Perforce: Diff", "command": "perforce_diff" }, + { + "caption": "Perforce: History", + "command": "perforce_visual", + "args": {"cmd": "history"} + }, + { + "caption": "Perforce: Time Lapse", + "command": "perforce_visual", + "args": {"cmd": "annotate"} + }, + { + "caption": "Perforce: Revision Graph", + "command": "perforce_visual", + "args": {"cmd": "tree"} + }, { "caption": "Perforce: Graphical Diff with Depot", "command": "perforce_graphical_diff_with_depot" diff --git a/Main.sublime-menu b/Main.sublime-menu index a2db347..d21eebe 100644 --- a/Main.sublime-menu +++ b/Main.sublime-menu @@ -53,6 +53,21 @@ } ] }, + { + "command": "perforce_visual", + "args": {"cmd": "history"}, + "caption": "History" + }, + { + "command": "perforce_visual", + "args": {"cmd": "annotate"}, + "caption": "Time Lapse" + }, + { + "command": "perforce_visual", + "args": {"cmd": "tree"}, + "caption": "Revision Graph" + }, { "command": "perforce_list_checked_out_files", "caption": "List Checked Out Files" diff --git a/Perforce.py b/Perforce.py index fece15c..d4b0738 100644 --- a/Perforce.py +++ b/Perforce.py @@ -19,6 +19,7 @@ # Eric Martel - Better handling of P4CONFIG files # Andrew Butt & Eric Martel - threading of the diff task and selector for the graphical diff application # Eric Martel - Added the possibility to Submit the default changelist +# Matt York - p4v commands to load history, time lapse view, and revision graph import sublime import sublime_plugin @@ -53,12 +54,35 @@ def on_activated(self, view): def ConstructCommand(in_command): command = '' if(sublime.platform() == "osx"): - command = 'source ~/.bash_profile && ' + + # We need P4 path variables from bash_profile or bash_login + if os.path.exists(os.path.expanduser('~/.bash_profile')): + config_file = ('~/.bash_profile') + elif os.path.exists(os.path.expanduser('~/.bash_login')): + config_file = '~/.bash_login' + elif os.path.exists(os.path.expanduser('~/.profile')): + config_file = '~/.profile' + else: + WarnUser("Could not find .bash_profile, .bash_login or .profile") + return + command = 'source ' + os.path.expanduser(config_file) + ' && ' # Revert change until threading is fixed # command = getPerforceConfigFromPreferences(command) command += in_command return command +def GetPerforceInfo(): + command = ConstructCommand('p4 info') + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True) + result, err = p.communicate() + + if(err): + WarnUser("usererr " + err.strip()) + return err + + settings = dict([entry.split(': ',1) for entry in result.splitlines()]) + return settings + def getPerforceConfigFromPreferences(command): perforce_settings = sublime.load_settings('Perforce.sublime-settings') @@ -1036,3 +1060,36 @@ def MakeChangelistsList(self): resultchangelists.insert(0, "Changelist " + changelistlinesplit[1] + " - " + ' '.join(changelistlinesplit[7:])) return resultchangelists + +class PerforceVisualCommandThread(threading.Thread): + def __init__(self, command, filename): + self.command = command + self.filename = filename + threading.Thread.__init__(self) + + def run(self): + p = GetPerforceInfo() + command = ConstructCommand('p4v -p %s -u %s -c %s -cmd "%s %s"' % + (p['Server license-ip'], p['User name'], p['Client name'], + self.command, self.filename)) + p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=global_folder, shell=True) + result, err = p.communicate() + +def PerforceVisualCommandOnFile(command, full_path): + if(full_path): + folder_name, filename = os.path.split(full_path) + if(IsFileInDepot(folder_name, filename)): + PerforceVisualCommandThread(command, full_path).start() + LogResults(1, "Launching thread for Visual Command") + else: + LogResults(0, "File is not under the client root.") + else: + WarnUser("View does not contain a file") + +class PerforceVisualCommand(sublime_plugin.TextCommand): + def run(self, edit, cmd): + if(cmd): + PerforceVisualCommandOnFile(cmd, self.view.file_name()) + else: + sublime.error_message("no cmd type given for p4v") + diff --git a/messages/1.0.14.txt b/messages/1.0.14.txt index e7d9b64..4c968c1 100644 --- a/messages/1.0.14.txt +++ b/messages/1.0.14.txt @@ -1,4 +1,8 @@ Perforce integration 1.0.14 Changelog: Change -- Added the possibility to submit the Default changelist \ No newline at end of file +- Added the possibility to submit the Default changelist +Add +- Added function to extract all info in `p4 info` into a dictionary +- Added a command to launch any p4v window. Window specified in args. Launches in separate thread. +- Added context, main, and command menu items for p4v History, Time Lapse, and Revision Graph windows diff --git a/package-metadata.json b/package-metadata.json index 51613bd..f417ac1 100644 --- a/package-metadata.json +++ b/package-metadata.json @@ -1 +1 @@ -{"url": "https://github.com/ericmartel/Sublime-Text-2-Perforce-Plugin", "version": "2012.01.12.01.58.03", "description": "Supports auto add and checkout with commands to add, diff, checkout, revert, diff using p4diff and lists all checked out files with quick access to them"} \ No newline at end of file +{"url": "http://www.ericmartel.com/sublime-text-2-perforce-plugin/", "version": "2012.05.08.08.14.02", "description": "Supports auto add and checkout with commands to add, checkout, delete, diff, rename, revert, diff using p4diff and lists all checked out files with quick access to them with simple changelist management"} \ No newline at end of file