source: svkversion @ 51f45d1

barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 51f45d1 was 51f45d1, checked in by Nelson Elhage <nelhage@mit.edu>, 17 years ago
Make `svkversion' handle exported trees better
  • Property mode set to 100755
File size: 827 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6if (-e ".svn") {
7    exec("svnversion",@ARGV);
8}
9
10use Getopt::Long;
11my $no_newline = 0;
12GetOptions("no-newline|n!" => \$no_newline);
13my $newline = $no_newline ? "" : "\n";
14my $p = shift @ARGV;
15$p ||= ".";
16
17my @lines = `svk info $p 2>&1`;
18if($! || $lines[0] =~ "not a checkout path") {
19    print "exported$newline";
20    exit;
21}
22my @merged = grep {/^Merged From: /} @lines;
23
24unless (@merged) {
25    @merged = grep {/^Revision: /} @lines;
26    my ($version) = $merged[0] =~ /^Revision: (\d+)/;
27    print "$version$newline";
28    exit;
29}
30
31my ($path, $rev) = $merged[0] =~ /^Merged From: (\S+), Rev. (\d+)/;
32
33my @log = `svk log -l1 -r$rev /$path`;
34@log = grep {/\(orig r\d+\)/} @log;
35
36if (@log and $log[0] =~ /\(orig r(\d+)\)/) {
37    print "$1$newline";
38} else {
39    print "$rev$newline";
40}
Note: See TracBrowser for help on using the repository browser.