# p4 changes, files, or describe; just in p4 print. If P4CLIENT is unset, the
# message will include "Librarian checkout".
test_expect_success 'exit gracefully for p4 server errors' '
- test_when_finished "mv \"$db\"/depot/file1,v,hidden \"$db\"/depot/file1,v" &&
- mv "$db"/depot/file1,v "$db"/depot/file1,v,hidden &&
+ # Note that newer Perforce versions started to store files
+ # compressed in directories. The case statement handles both
+ # old and new layout.
+ case "$(echo "$db"/depot/file1*)" in
+ *,v)
+ test_when_finished "mv \"$db\"/depot/file1,v,hidden \"$db\"/depot/file1,v" &&
+ mv "$db"/depot/file1,v "$db"/depot/file1,v,hidden;;
+ *,d)
+ path="$(echo "$db"/depot/file1,d/*.gz)" &&
+ test_when_finished "mv \"$path\",hidden \"$path\"" &&
+ mv "$path" "$path",hidden;;
+ *)
+ BUG "unhandled p4d layout";;
+ esac &&
test_when_finished cleanup_git &&
test_expect_code 1 git p4 clone --dest="$git" //depot@1 >out 2>err &&
test_grep "Error from p4 print" err
# text
# @@
#
+ # Note that newer Perforce versions started to store files
+ # compressed in directories. The case statement handles both
+ # old and new layout.
cd "$db/depot" &&
- sed "/@target1/{; s/target1/@/; n; d; }" \
- empty-symlink,v >empty-symlink,v.tmp &&
- mv empty-symlink,v.tmp empty-symlink,v
+ case "$(echo empty-symlink*)" in
+ empty-symlink,v)
+ sed "/@target1/{; s/target1/@/; n; d; }" \
+ empty-symlink,v >empty-symlink,v.tmp &&
+ mv empty-symlink,v.tmp empty-symlink,v;;
+ empty-symlink,d)
+ path="empty-symlink,d/$(ls empty-symlink,d/ | tail -n1)" &&
+ rm "$path" &&
+ gzip </dev/null >"$path";;
+ *)
+ BUG "unhandled p4d layout";;
+ esac
) &&
(
# Make sure symlink really is empty. Asking
cd db &&
p4d -jc &&
# P4D automatically adds a BOM. Remove it here to make the file invalid.
- sed -e "\$d" depot/file1,v >depot/file1,v.new &&
- mv depot/file1,v.new depot/file1,v &&
- printf "@$UTF16@" >>depot/file1,v &&
+ #
+ # Note that newer Perforce versions started to store files
+ # compressed in directories. The case statement handles both
+ # old and new layout.
+ case "$(echo depot/file1*)" in
+ depot/file1,v)
+ sed -e "\$d" depot/file1,v >depot/file1,v.new &&
+ mv depot/file1,v.new depot/file1,v &&
+ printf "@$UTF16@" >>depot/file1,v;;
+ depot/file1,d)
+ path="$(echo depot/file1,d/*.gz)" &&
+ gunzip -c "$path" >"$path.unzipped" &&
+ sed -e "\$d" "$path.unzipped" >"$path.new" &&
+ printf "$UTF16" >>"$path.new" &&
+ gzip -c "$path.new" >"$path" &&
+ rm "$path.unzipped" "$path.new";;
+ *)
+ BUG "unhandled p4d layout";;
+ esac &&
p4d -jrF checkpoint.1
)
'