profile-p4 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. export P4EDITOR=/home/user/wreed/bin/vim
  2. export P4DIFF="/home/user/wreed/bin/vim -d"
  3. export P4MERGE="/home/user/wreed/bin/vim -d"
  4. alias p4a="p4 add"
  5. alias p4e="p4 edit"
  6. alias p4r="p4 revert"
  7. alias p4s="p4 sync"
  8. alias p4d="p4 delete"
  9. alias p4o="p4 opened"
  10. alias p4c="p4 client"
  11. alias p4i="p4 integrate"
  12. alias p4grab="p4 diff -se | p4 -x - edit"
  13. alias p4reset="p4 diff -sr | p4 -x - revert"
  14. p4whose() {
  15. if [[ $# -ne 1 ]]; then return 1; fi
  16. local file="${1}"
  17. if [[ ${file:0:2} != "//" ]]; then local file="//depot/online/makefds/mainline/${file}"; fi
  18. # Get only lines with a change source (no integrate/branch)
  19. # Pull the name of each submitter
  20. # Uniqueify without losing order
  21. # Attach a number to them
  22. p4 filelog "${file}" | \
  23. grep -E "^\.\.\. #" | \
  24. awk '{ print $9 }' | cut -d'@' -f1 | \
  25. perl -ne 'if (!defined $x{$_}) { print $_; $x{$_} = 1; }' | \
  26. awk 'BEGIN { idx=1 } { print idx,$0; idx += 1 }'
  27. }
  28. p4backout() {
  29. local changenum="$1"
  30. local target_stage="${2:-fdsparent}"
  31. local lastchange=$((changenum-1))
  32. p4 sync @$lastchange
  33. p4 edit ...
  34. p4 sync @$changenum
  35. p4 resolve -ay
  36. p4 sync @$target_stage
  37. p4 resolve -am
  38. }
  39. p4_import_changelist() {
  40. local changelist="${1}"
  41. local tmpfile=$(mktemp)
  42. trap "rm -f ${tmpfile}" EXIT
  43. p4 client -o > "${tmpfile}"
  44. local client=$(grep -E "^Client:" "${tmpfile}" | awk '{ print $2 }')
  45. local files=($(IFS=$'\n'; p4 describe -s "${changelist}" | grep -E "^\.\.\." | cut -d' ' -f2- | cut -d'#' -f1))
  46. local has_view=$(grep -c -E "^View:" "${tmpfile}")
  47. if [[ $has_view -eq 0 ]]
  48. then
  49. echo "View:" >> "${tmpfile}"
  50. fi
  51. for file in "${files[@]}"
  52. do
  53. local mapping="//${client}/${file##*/}"
  54. echo -e "\t${file} ${mapping}" >> "${tmpfile}"
  55. done
  56. p4 client -i < "${tmpfile}"
  57. }
  58. . ${HOME}/.complete-p4