5 messages in com.perforce.perforce-user[p4] What Labels point to a given fil...| From | Sent On | Attachments |
|---|---|---|
| Frank Merrow | 23 May 2001 17:16 | |
| Russell C. Jackson | 23 May 2001 18:17 | |
| barries | 23 May 2001 20:00 | |
| Jeff A. Bowles | 23 May 2001 22:44 | |
| Paul Goffin | 24 May 2001 00:21 |
| Subject: | [p4] What Labels point to a given file . . .![]() |
|---|---|
| From: | barries (barr...@slaysys.com) |
| Date: | 05/23/2001 08:00:44 PM |
| List: | com.perforce.perforce-user |
On Wed, May 23, 2001 at 05:16:49PM -0700, Frank Merrow wrote:
I was wondering if anyone had a script that would print out what Labels point to a given file.
If nobody has one, it looks like a Perl script that did a "p4 labels", then looped through each label looking at the files in the label would be the way to go.
No such luck for a script, but here's some slightly bent Perl code VCP uses, it won't work outside of VCP, but it shows the process. Not sure if it's bugless (ha!) or "best" by any metric...
sub load_p4_labels { my VCP::Source::p4 $self = shift ;
my $labels = '' ; $self->p4( ['labels'], \$labels ) ;
my @labels = map( /^Label\s*(\S*)/ ? $1 : (), split( /^/m, $labels ) ) ;
$self->command_ok_result_codes( 0, 1 ) ;
while ( @labels ) { my $bundle_size = @labels > 25 ? @labels : 25 ; my @bundle_o_labels = splice @labels, 0, $bundle_size ;
my $marker = "//.../NtLkly" ; my @p4_files_args = map { ( $marker, "//...\@$_" ) ; } @bundle_o_labels ; my $files ; $self->p4( [ "-s", "files", @p4_files_args ], \$files ) ;
my $label ; for my $spec ( split /\n/m, $files ) { last if $spec =~ /^exit:/ ; if ( $spec =~ /^error: $marker/o ) { $label = shift @bundle_o_labels ; next ; } next if $spec =~ m{^error: //\.\.\.\@.+ file(\(s\))? not in label.$} ; $spec =~ /^.*?: *\/\/(.*)#(\d+)/ or die "Couldn't parse name & rev from '$spec' in '$files'" ;
debug "vcp: p4 label '$label' => '$1#$2'" if debugging $self ; push @{$self->{P4_LABEL_CACHE}->{$1}->{$2}}, $label ; } } $self->command_ok_result_codes( 0 ) ;
return ; }
The bent bit is the use of the //.../NtLkLy to cause an error, and the call to command_ok_result_codes( 0, 1 ) is to keep VCP from dieing when p4 (correctly) reports a "1" as a result. It's an efficiency hack to keep from respawning lots of p4 commands and the attendant TCP/IP connections.
Any ideas for an easier way that would scale well as there got to be more and more labels?
Nope. I think it would take a new CLI or C++ API interface to do that.
- Barrie




