[p4] Can p4 get along with Win2K + Cygwin B21?

Heather Van Steenburgh hvansteenburgh at nimble.com
Tue Sep 19 11:46:26 PDT 2000


Here are some details on how to get the p4 command line to deal with local
syntax under the Cygwin bash shell.  Basically, you need to redefine PWD to
be a form understandable by perforce.  

Please note: I've only tested this with bash 2.02 (cygwin b20) and 2.04
(cygwin 1.1).  Other versions of bash may need different PWD translation.
Also, my pwd2.sh script would probably be better off rewritten as an exe but
I think it's okay as it is for starters.

The 4 steps shown below take care of most of the problems, but there is
still a problem if you try to use an absolute local path (like
c:\myproject\myfile.ext).  I haven't found a way around that one yet and
have reported it to Perforce.  Let me know if you'd like more information on
that particular problem.

So, here are the steps:

1) Use cygwin port of 'p4.exe'

2) Create a cygwin-pwd to dos-pwd converter.  Example:
	#!/bin/sh

	# Try cygwin 1.1 conversion first.  The cygwin 1.1 format is 
	# /cygdrive/driveletter/dirname...
	#
	PWD2=$(echo $PWD | sed -e 's,^/cygdrive/\([a-z]\)\(.*\),\1:\2,')

	# If no change, we're not cygwin 1.1.  Try cygwin b20 format next.
	# The cygwin b20 format is: if c drive, simply /dirname...; if other

	# drive, //DRIVELETTER/dirname...  Translate the driver letter to
	# lowercase for consistency (so when people upgrade from b20 to 1.1
	# they won't need to change the case of the drive letter in all
	# their clientspecs.
	#
	if [ "$PWD" = "$PWD2" ]; then
		PWD2=$(echo $PWD | sed -e 's,^//\(.\)/\(.*\),\1:/\2,' -e
's,^/,c:/,' -e 'y,[A-Z]:,[a-z]:,')
	fi

	if [ "$PWD2" = "" ]; then
		echo ERROR!  PWD translation to DOS format failed.  
		echo PWD2 is NULL!
		exit 1
	elif [ ! -d "$PWD2" ]; then
		echo ERROR!  PWD translation to DOS format failed.  
		echo The resulting filespec \"$PWD2\" is not a directory!
		exit 1 
	else
		# Success - echo the result.
		echo $PWD2
	fi

3) In your .bashrc, 
	a) prepend the directory(ies) that contains cygwin p4 and pwd2 to
your path.  
	b) define your desired P4PORT, P4USER, P4CLIENT defaults (the
registry 
		is not read for these)
	c) alias p4 to reassign PWD (the alias below assumes you've put your

		pwd2 converter in the same directory as your cygwin p4.exe)
		example:
			alias p4='PWD=`sh $P4DIR/pwd2.sh` $P4DIR/p4'

4) Define your client roots with forward slashes (e.g., c:/projects/mydir).
P4Win doesn't mind (at least not on my Win2K machine) but the cygwin p4.exe
does.

Cheers,
Heather

-----Original Message-----
From: Eric Promislow [mailto:ericp at activestate.com]
Sent: Tuesday, September 19, 2000 11:31 AM
To: perforce-user at perforce.com
Subject: [p4] Can p4 get along with Win2K + Cygwin B21?


Hello,

Yesterday I upgraded my cygwin toolset from B20 to B21, and
can no longer use the perforce client.

B21 tries harder to simulate a Unix environment.  It partitions
your disk into the drives

/usr/...  -- cygwin files, and /usr/home/... for user "accounts"

/cygdrive/c/... -- other c: files
/cygdrive/d/... -- drive d: files

- etc.


The problem is that bash perforce is confused sometimes.  I can sync:

% p4 sync
...
//depot/main/Apps/src/thing.bat#2 - updating
c:/home\ericp\main\Apps\thing.bat

but if I do

% p4 have ./...
Path '/cygdrive/c/home/ericp/main/Apps/src\...' is not under client's root
c':/'.

Anyone figure out how to make this work?  Or should I go back to cygwin b20?

- Eric Promislow
EricP at ActiveState.com
_______________________________________________
perforce-user mailing list  -  perforce-user at perforce.com
http://maillist.perforce.com/mailman/listinfo/perforce-user



More information about the perforce-user mailing list