require ENV['TM_BUNDLE_SUPPORT'] + '/lib/connect.rb' #Retrieve a p4 object from connect.rb then connect to the server conn = Connect.new p4 = conn.connect if p4 if ENV['TM_SELECTED_FILES'] change_no = '' output = '' #The files selected in project drawer, split select = ENV['TM_SELECTED_FILES'].split(' ') #Get the changelist to edit files for change = conn.get_changelist_choice("Add files to", ['default', 'new']) #If a new changelist is chosen, the change list is created here if change[0] == "new" change_fetch = p4.fetch_change #A blank description to stop p4d complaining change_fetch._description = ' ' change_no = p4.save_change(change_fetch)[0].split(' ')[1] end #For each of the files selected edit it for the requested changelist select.each {|i| path_out = i.rpartition("\'")[0].to_s path_out = path_out[1..path_out.length] begin if change[0] == "pending" change_no = change[1] output = p4.run_edit('-c', change_no, path_out) elsif change[0] == "new" output = p4.run_edit('-c', change_no, path_out) elsif change[0] == "default" change_no = "default" output = p4.run_edit(path_out) else #Something funny has happened :( output = "Oh dear, oh dear, oh dear; please e-mail bbates@perforce.co.uk" end rescue Exception => msg p4.disconnect abort(msg) end } p4.disconnect abort(output.to_s) else abort("Please select files to perform operation on") end else p4.disconnect abort("Failed to connect, please check your settings") end