From: Leon Brocard Date: Sat, 20 Dec 2008 08:42:06 +0000 (+0000) Subject: Add a program to switch to a Perforce id X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=734abad9c35353b7df4e009f63d8b7c5c845141c;p=p5sagit%2Fp5-mst-13.2.git Add a program to switch to a Perforce id --- diff --git a/Porting/switch_to_perforce_id.pl b/Porting/switch_to_perforce_id.pl new file mode 100755 index 0000000..cf21a13 --- /dev/null +++ b/Porting/switch_to_perforce_id.pl @@ -0,0 +1,22 @@ +#!perl +use strict; +use warnings; +use English; + +my $perforce_id = shift; +die "Usage: switch_to_perforce_id.pl 34440" unless $perforce_id; + +open my $fh, 'git log -z --pretty=raw|' || die $!; +local $INPUT_RECORD_SEPARATOR = "\0"; + +my $re = qr/p4raw-id:.+\@$perforce_id/; + +while ( my $log = <$fh> ) { + next unless $log =~ /$re/; + my ($commit) = $log =~ /commit ([a-z0-9]+)/; + system "git checkout $commit"; + print "(use git checkout blead to go back)\n"; + exit; +} + +die "No log found for $perforce_id";