Added Perforce plugin.
[profile.git] / .vim / perforce / p4Utils.sh
1 # Get the list of unopened files under the given $1/$2 directory.
2 #   It should be possible to implement the logic by using temp files and diff,
3 #   but this was more challenging to me :)
4 # Ex:
5 #   unOpenedFiles=`getUnOpenedFiles "$root" "src"`
6 getUnOpenedFiles() {
7     path=$1
8     dir=$2
9     p4 opened $path/$dir/... \
10         | sed -e 's/.*'$dir'/'$dir'/' -e 's/#.*$//' \
11         | perl -n -e '
12           print;
13           END
14           {
15               # Merge the opened list with all the files under BaseClasses.
16               foreach $f (`find '$path/$dir' -type f | sed -e "s/.*'$dir'/'$dir'/"`)
17               {
18                   print $f;
19               }
20           }' \
21         | sort -f \
22         | uniq -c \
23         | sed -n -e 's/\s*1\s*//p'
24 }