Saturday, January 30, 2010

Some quotes

Algorithms with Perl has some very fun quotes in the beginning of each chapter:

"What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?" - Larry Wall

"Computer science is no more about computers than astronomy is about telescopes" - E.W. Dijkstra

"I wonder what happens if I connect this to this?" - the last words of too many people

Tuesday, January 26, 2010

Perforce and Cygwin

There are multiple posts (saw one with a complex Python script) on how to make perforce windows command line client (p4.exe) behave with cygwin.

The main issue is paths - p4.exe expects paths like "c:\depot\project1code", whereas cygwin would provide it paths like "/cygdrive/c/depot/project1code". So how do you deal with that?

The simplest solution, at least to me, is to write a wrapper script that invokes cygpath -aw to get windows path from cygwin path, and then use it on p4.exe.


p4 edit `cygpath -aw myfile.c`


Of course that becomes tedious in no time. Hence the script.


#!/usr/bin/perl
use warnings;

$path = $ARGV[1];
$adjpath = `cygpath -aw $path`;
$command = "p4 $ARGV[0] $adjpath";
$command =~ s/\\/\\\\/g;
$output = `$command`;
print $output;



The other problem with using P4 and Cygwin is the p4config file. By setting P4CONFIG=.p4config in the environment, and then having a .p4config file at the root of each clientspec home directory, you can get perforce to automatically change clientspec when you change into that directory (no need for an explicit call to p4 set p4client).

Well this doesn't quite work with cygwin.

There is a cygwin client given by Perforce, that works well with this. But that does not work well with P4V/P4Win for Windows, so you need to have separate clients for cygwin and windows. Haven't found a solution to make .p4config work on cygwin with Windows-native p4.exe.