## Learn all about client aliases at ## https://www.perforce.com/perforce/doc.current/manuals/cmdref/chapter.introduction.html#introduction.aliases # Command mapping to other source control systems (e.g. git, svn, etc.) checkout = sync commit = submit commit-am $(description) = reconcile && submit -d $(description) purge = clean stash = shelve stash-list = changes -s shelved blame = annotate -u pull = fetch -r origin # Aliases can refer to other aliases co = checkout ci = commit # Short commands desc = describe di = diff itg = integrate pop = populate rc = reconcile st = status me = set -q P4USER # Fix my typos clinet = client snyc = sync sumbit = submit recnocile = reconcile ## Well-known variables P4USER, P4CLIENT, P4PORT, P4LANGUAGE, CWD, and OS ## can be substituted using the syntax '$(variable)'. # Set different command defaults. annotate = annotate -u changes = changes -u $(P4USER) describe = describe -s grep = grep -i ## Create personalized commands, which may contain multiple chained commands ## separated by the special token '&&'. ## ## Alias definitions can be split across multiple lines by splitting it ## immediately after any '&&' token, or by splitting it at any word and ## ending the line with '\'. # status command that also shows files that need syncing. my-status = status && sync -n # Simplify system administration: # Display active users, Shut down the server: active-users = changes -m 3 && monitor show && lockstat halt = admin shutdown ## Aliases can define variables, and have several operators available: ## ## Variables defined as an alias argument can be used later in the ## command chain. ## ## Variables can also be created by the output redirection operator, '>', ## and can then be passed via the input redirection operator, '<', ## to commands later in the chain. ## ## Comparison operators can be used in their text form, '$(GT)', '$(LT)' ## and '$(EQ)'. ## ## The 'p4subst' operator performs string substitution, and is roughly ## analogous to using sed 's/regular expression/literal/g'. # Clean up empty shelved changelists kill-shelf $(cl) = shelve -d -c $(cl) && change -d $(cl) ## 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) ## Note how the newGroup and addUserToGroup aliases use the ability ## to add a line using += syntax, '+$(EQ)' here, to an existing field ## in the spec object using the --field flag. 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) # New changelist using a string substitution and I/O redirection 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) # What changelists 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) # new commands purge = clean -I pending = changes -s pending -u $(P4USER) -c $(P4CLIENT) shelved = changes -s shelved -u $(P4USER) -c $(P4CLIENT) desc-changes = -F "%change%" -ztag changes -m1 -s submitted ... > $(chg) && describe -s $(chg) nuke-shelf $(change) = shelve -dc $(change) && revert -c $(change) //... && change -d $(change) # one shot move! mv $(from) $(to) = edit $(from) && move $(from) $(to) # Alias '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) && reconcile -c $(chg) && shelve -c $(chg) -r # Cherry picking 1. This alias turns this command # p4 cherry-pick-change 1015978 p15.2 main # into this: # p4 integrate //depot/p15.2/...@1015978,1015978 //depot/main/... cherry-pick-change $(cl) $(s) $(t) = \ integrate //depot/$(s)/...@$(cl),$(cl) //depot/$(t)/... # Cherry picking 2. This alias also resolves and submits the result: cherry-pick $(cl) $(s) $(t) $(msg) = \ integrate //depot/$(s)/...@$(cl),$(cl) //depot/$(t)/... && resolve -am -Ac //depot/$(t)/... && submit -d $(msg) # Replace my entire client nuke-it-from-orbit = -F %clientRoot% -ztag info > $(root) && revert //... && clean $(root)/... && sync ###### DVCS: Aliases to communicate with multiple servers. ###### ## Change the order of arguments so the following command does what you want: ## clone perforce:1666 //depot/main/p4... ~/local-repos/main clone $(p4port) $(path) $(dir) = \ -d $(dir) -u $(P4USER) clone -p $(p4port) -f $(path) ## Use aliases like the following when copying spec objects from the ## shared server to your personal server. copy-user $(p4port) $(u) = -p $(p4port) user -o $(u) > $(spec) && -u $(u) 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) # Fetch and merge changes from my remote server mergedown $(b) = fetch && switch $(b) && merge && resolve -am && submit -d "Merged down from main" # Merge and push changes to my remote server copyup $(src) $(tgt) = switch $(tgt) && merge --from $(src) && resolve -as && submit -d "Copied up from $(src)" && push # 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 ###### Aliases for Streams ###### # Create new stream depot newStreamsDepot $(dpt) = depot -o -t stream $(dpt) > $(depotSpec) && depot -i < $(depotSpec) ## Making a new task stream and switching to it to do your work becomes ## as simple as: p4 newTaskStream job084103 bp-dev 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 ## One shot branch deletion nuke-stream $(branch) = stream -d //stream/$(branch) && obliterate -y //stream/$(branch)/... ## Get updates of this file refresh-aliases = -u guest -p workshop.perforce.com:1666 print -o /home/mylogin/.p4aliases -q //guest/perforce_software/p4alias-examples/main/SampleP4Alias.txt