##Help me feel more comfortable as a user of another source control system(e.g. git, svn, etc) checkout = sync commit = submit purge = clean stash = shelve stash-list = changes -s shelved blame=annotate pull = fetch -r origin ##short commands co=edit ci=submit st=status itg = integrate pop = populate rc = reconcile di = diff ##Typos clinet = client snyc = sync sumbit = submit recnocile = reconcile ##Help me remember who I am. me = set P4USER ##Create a personalized status command that also shows files that need syncing. my-status = status && sync -n ##Set different defaults. annotate = annotate -u grep = grep -i changes = changes -u $(P4USER) ##Simplify system administration. #Shutting down the server, displaying active users: halt = admin shutdown active-users = changes -m 3 && monitor show && lockstat system-summary = –F “Change: %value%” –ztag\ counter change && -ztag –F “Journal: %value%”\ counter journal ##Remembering to clean up empty changelists kill-shelf $(cl) = shelve -d -c $(cl) && change -d $(cl) ##Change the order of arguments. clone $(p4port) $(path) $(dir) = -d $(dir) -u bruges clone -p $(p4port) -f $(path) #NOTE: Now the following command does what you want: #clone perforce:1666 //depot/main/p4... ~/local-repos/main ##Cherry picking - 1. This alias definition: cherry-pick-change $(cl) $(s) $(t) = integrate //depot/$(s)/...@$(cl),$(cl) //depot/$(t)/... #NOTE:Turns this command: #$ p4 cherry-pick-change 1015978 p15.2 main #Into this: #$ p4 integrate //depot/p15.2/...@1015978,1015978 //depot/main/... ##Cherry picking - 2. Here is another cherry picking example that creates a little merge ##script: cherry-pick $(cl) $(s) $(t) $(msg) = \ integrate //depot/$(s)/...@$(cl),$(cl) //depot/$(t)/... && resolve -am -Ac //depot/$(t)/... && submit -d $(msg) && sync #NOTE: You could then execute a command like the following: #$ p4 cherry-pick 1015978 two one "line a merged into one" #This would run the following commands: #p4 integrate //depot/two/...@1015978,1015978 //depot/one/... #p4 resolve -am -Ac //depot/one/... #p4 submit -d "Cherry-pick change https://swarm.perforce.com/@1015978[1015978] from //depot/two/... to //depot/one/..." #p4 sync ####### Simple pipelining. ###### ##Starting with a simple example: newStreamsDepot $(dpt) = depot -o -t stream $(dpt) > $(depotSpec) && depot -i < $(depotSpec) #Note that when using redirection, the $ variables used in the transformation side of the definition, do not need to correspond to the arguments specified one the left side of the equation. In the example above, depotSpec is a variable created during the execution of the newStreamDepot alias. Here are a couple of aliases for merge down copy up: mergedown $(b) = fetch && switch $(b) && merge && resolve -am && submit -d "Merged down from main" copyup $(b) = switch dev && merge --from $(b) && resolve -as && submit -d "Copied up from $(b)" && push # NOTE the use of the branch name in the submit message of the copyup alias. ## Manipulate spec output # You can use the '--field' feature of the command line to manipulate the data returned by a 'p4 -o' command, where spec is one of our spec types (user, client, branch, group, etc.): new-change $(desc) = --field Description$(EQ)$(desc) change -o > $(form) && change -i < $(form) newServiceUser $(name) = --field Type$(EQ)service user -o $(name) > $(form) && user -f -i < $(form) newOperatorUser $(name) = --field Type$(EQ)operator user -o $(name) > $(form) && user -f -i < $(form) newGroup $(g) = --field Owners+$(EQ)$(P4USER) --field Users+$(EQ)$(P4USER) group -o $(g) \ > $(form) && group -i < $(form) addUserToGroup $(u) $(g) = --field Users+$(EQ)$(u) group -o $(g) > $(form) && group -i < $(form) # NOTE how the newGroup and addUserToGroup aliases use the ability to add a line to an existing field in the spec object with the '+=' syntax for the --field flag. ## String substitutions newChange $(desc) = change -o > $(chg) && p4subst "$(LT)enter.*$(GT)" $(desc) < $(chg) > $(chg2) && change -i < $(chg2) ## Reopen the files in a certain changelist reopenCL $(cl) = -F "%depotFile%" -ztag files @$(EQ)$(cl) > $(files) && -x - edit < $(files) ## Make a new task stream newTaskStream $(task) $(parent) = stream -o -t task -P //stream/$(parent) //stream/$(task) > $(streamSpec) && stream -i < $(streamSpec) && populate -r -S //stream/$(task) && client -s -S //stream/$(task) && sync # NOTE: then switching to a new task stream to do your work becomes as simple as: # p4 newTaskStream job084103 bp-dev ## One shot branch deletion nuke-stream $(branch) = stream -d //stream/$(branch) && obliterate -y //stream/$(branch)/... ## What changeless preceded this one? last-predecessors $(cl) = -F "%depotFile%@$(LT)%change%" -ztag files //...@$(EQ)$(cl) > $(files) && -x - files < $(files) all-predecessors $(cl) = -F "%depotFile%@$(LT)%change%" -ztag files //...@$(EQ)$(cl) > $(files) && -x - files -a < $(files) #NOTE- ###### DVCS: Aliases to communicate with multiple servers. ###### #Use aliases like the following when copying spec objects from the shared server to your personal server. copy-user $(p4port) = -p $(p4port) user -o $(u) > $(spec) && user -i < $(spec) copy-job $(p4port) $(j) = -p $(p4port) job -o $(j) > $(spec) && job -i < $(spec) copy-stream $(p4port) $(s) = -p $(p4port) stream -o $(s) > $(spec) && stream -i < $(spec) ## new commands shelved=changes -s shelved -u $(P4USER) -c $(P4CLIENT) pending=changes -s pending -u $(P4USER) -c $(P4CLIENT) desc=describe -s purge=clean -I blame=annotate -u lc=-F "%change%" -ztag changes -m1 -s submitted ... > $(chg)&& describe -s $(chg) copyup= -F "%baseParent%" -ztag stream -o > $(parent) && -F "%Name%" -ztag stream -o > $(current) && switch $(parent) && merge --from $(current) && resolve -as && submit -d "Pulling crud to main" && switch $(current) nuke-shelf $(change)=shelve -dc $(change) && revert -c $(change) //... && change -d $(change) nc $(desc) = --field Description$(EQ)$(desc) change -o > $(form) && change -i < $(form) newChange $(desc) = change -o > $(chg) && p4subst "$(LT)enter.*$(GT)" $(desc) < $(chg) > $(chg2) && change -i < $(chg2) ## one shot move! mv $(from) $(to) = edit $(from) && move $(from) $(to) ## one shot reconcile and submit a la git commit -am su $(description)=rec && submit -d $(description) ## cp takes a snapshot of WIP and puts it into the active shelf auto_shelved = -ztag -F %change% changes -s shelved -u $(P4USER) -c $(P4CLIENT) ... cp = auto_shelved > $(chg) && rec -c $(chg) && shelve -c $(chg) -r ## what shelves are on my shared server? Single arg and no arg versions. remote-shelves $(remote) = -F %Address% -ztag remote -o $(remote) > $(port) && -p $(port) -u $(P4USER) changes -s shelved -u $(P4USER) remote-shelves = remote-shelves origin nuke-it-from-orbit = -F %clientRoot% -ztag info > $(root) && revert //... && clean $(root)/... && sync refresh-aliases = -u guest -p workshop.perforce.com:1666 print -o /Users/matt/.p4aliases -q //guest/matt_attaway/scripts/.p4aliases