|
|
@@ -79,22 +79,34 @@ p4_import_changelist() {
|
|
|
}
|
|
|
|
|
|
p4finish() {
|
|
|
- local cwd="${PWD}"
|
|
|
- local rmdir=0
|
|
|
- if [[ ${1} == "-d" ]]; then rmdir=1; shift; fi
|
|
|
- local tar="${1}"
|
|
|
+ local rmdir=0 force=0 good=1
|
|
|
+ if [[ ${1} == "-d" ]]; then rmdir=1; shift; fi
|
|
|
+ if [[ ${1} == "-f" ]]; then force=1; shift; fi
|
|
|
+
|
|
|
+ local tar="${1}" cwd="${PWD}"
|
|
|
if [[ -z ${tar} ]] || [[ ! -d ${tar} ]]; then
|
|
|
echo "Directory does not exist: '${tar}'"
|
|
|
return 1
|
|
|
fi
|
|
|
+
|
|
|
cd "${tar}"
|
|
|
- if [[ $(p4 opened 2>/dev/null) == "" ]]; then
|
|
|
+ if [[ $(p4 client -o | grep ^Root | sed 's/Root:\s*//g') != "${PWD}" ]]; then
|
|
|
+ echo "This directory is not a perforce client"
|
|
|
+ elif [[ $(p4 opened 2>/dev/null) == "" ]]; then
|
|
|
+ p4 sync ...#0
|
|
|
+ elif [[ ${force} -eq 1 ]]; then
|
|
|
+ echo "Perforce client has open files, but forcing the issue"
|
|
|
+ p4 revert ...
|
|
|
p4 sync ...#0
|
|
|
- cd "${cwd}"
|
|
|
- [[ ${rmdir} -eq 1 ]] && rm -rf "${tar}"
|
|
|
else
|
|
|
echo "Perforce client has open files"
|
|
|
- cd "${cwd}"
|
|
|
+ good=0
|
|
|
+ fi
|
|
|
+
|
|
|
+ cd "${cwd}"
|
|
|
+ if [[ ${good} -eq 1 ]]; then
|
|
|
+ [[ ${rmdir} -eq 1 ]] && rm -rf "${tar}"
|
|
|
+ else
|
|
|
return 1
|
|
|
fi
|
|
|
}
|