[p4] Querying the correct file case on a case-sensitive server
David Faison
dfaison at photon.com
Tue May 23 15:15:30 PDT 2006
You could do a script based case-insensitive search from a Windows box.
This technique is sort of brutal - and costly in a directory with a lot
of files, but it works. If performance is an issue, you'll probably have
to resort to real programming using the P4 API.
David Faison
Photon Research Associates
________________________________________________________________________
Rem start of getReal.bat
@echo off
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
set depotpath=%~1
set filename=%~2
set realname=
for /f "delims=#" %%a in ('p4 files "!depotpath!/*"') do (
if /i "%%~nxa"=="!filename!" (
set realname=%%~nxa
goto found
)
)
goto end
:found
echo !realname!
:end
rem end of getReal.bat
________________________________________________________________________
And here's an example of a second script using the one above to retrieve
the case-sensitive name.
________________________________________________________________________
@echo off
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
for /f "delims=#" %%a in ('getReal.bat %~1 %~2') do set realName=%%a
echo realname: [!realnName!]
rem end of sample.bat
________________________________________________________________________
-----Original Message-----
From: From: "David Genest" <david.genest at ubisoft.com>
Sent: Tue, 23 May 2006 13:20:17 -0400
Subject: [p4] Querying the correct file case on a case-sensitive server
Message: 12
Date:
Subject: To: <perforce-user at perforce.com>
Message-ID:
<4ABFB5DF384CA040B8AD71AD64BD6063051E3CBF at UBIMAIL1.ubisoft.org>
Content-Type: text/plain; charset="us-ascii"
Hello,
Our p4 server is running on a case sensitive machine (Linux).
Our clients are in vast majority case preserving, but case-insensitive
machines (win32).
We have automated procedures that open assets for edit, and
fetches information with the fstat command. There are some edge cases
where the file we want to query is not in the correct case.
I was wondering if there was a function that could take as input
a wrongly cased path and get as output the correct path as stored on the
server. I would see this functionality in the p4 where command.
For example (assume the current working directory is in
//depot):
//depot/myGoodCaseFile.txt
Issuing a "p4 where -serverCase mygoodcasefile.txt" would
output:
//depot/myGoodCaseFile.txt //myClient/myGoodCaseFile.txt
d:\workingDir\mygoodcasefile.txt
The actual behavior of the where command just appends the
queried path to the mappings as it would be on the server, so I get:
//depot/mygoodcasefile.txt //myClient/mygoodcasefile.txt
d:\workingDir\mygoodcasefile.txt
I have looked around and read the docs, but I don't think there
is such a behavior. What would be the best way to get the correct case
(as stored on the server) from a wrongly cased file path?
Thanks,
David.
More information about the perforce-user
mailing list