[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Proposed New Feature (SVNROOT), '.svnignore', and 'rtag' (Revision Aliases)

From: Martin Tomes <lists_at_tomes.org>
Date: 2004-03-18 15:06:07 CET

Max Bowsher wrote:
> Marcin Kasperski wrote:
>
>>>(Pros of SVN tags: the creation of a tag is a versioned event;
>>
>>In my opinion there is a desperate need for the feature which
>>will enable me to run svn log [some switch] within the working
>>dir of some component and get the list of tags created on this
>>component.
>
> Option (c): Like option (b), but work not by adding extra log entries, but
> by reporting copy sources in the svn log output.

I had a perl program which very nearly does what you are asking so I
hacked it about a bit and it is attached. Put the repository url and
the path within the repository to match and it will list copies.
Example output:

$ ./findcopies.pl http://svn.eurotherm.co.uk:81/svn/randd/itools /itools
  Rev. From->To
     5 /itools/trunk:4->/itools/tags/5.00
     6 /itools/trunk:5->/itools/branches/5.xx
     8 /itools/branches/5.xx:7->/itools/tags/5.50

You should be able to hack this to give the output you require. You
will need to put a valid user/password for your repository into the code.

-- 
Martin Tomes
echo 'Martin x Tomes at controls x eurotherm x co x uk'\
  | sed -e 's/ x /\./g' -e 's/ at /@/'

#!/usr/bin/perl

use strict;
use SVN::Client;

die "usage: findcopies repository path" if ($#ARGV < 1);
my $repo = $ARGV[0];
my $path = $ARGV[1];
$path =~ s/\//\\\//g;
my %copies;

my $ctx = new SVN::Client(
    auth => [SVN::Client::get_simple_provider(),
             SVN::Client::get_simple_prompt_provider(\&simple_prompt, 2),
             SVN::Client::get_username_provider()]
          );

sub simple_prompt {
 my $cred = shift;
 my $realm = shift;
 my $default_username = shift;
 my $may_save = shift;
 my $pool = shift;
 $cred->username('xxx');
 $cred->password('xxx(Lcp)');
}

sub show_log {
 my $changed_paths = shift;
 my $revision = shift;
 my $author = shift;
 my $date = shift;
 my $message = shift;
 my $pool = shift;

 $author = '(no author)' if (!defined($author));
 $date = '(no date)' if (!defined($date));
 $message = '' if (!defined($message));

 foreach my $key (sort keys %$changed_paths) {
   my $frompath = $changed_paths->{$key}->copyfrom_path();
   if ($frompath && ($frompath =~ /^$path/)) {
     $copies{$revision} = [ $date,
                            $author,
                            $key,
                            $frompath,
                            $changed_paths->{$key}->copyfrom_rev(),
                            $message ];
   }
 }
}

sub max {
  my ($a, $b) = @_;
  if ($a < $b) {
    return $b;
  } else {
    return $a;
  }
}

$ctx->log($repo . '/',
          'HEAD',
          1,
          1,
          0,
          \&show_log);

my @sortedkeys = sort keys %copies;
if ($#sortedkeys >= 0) {
  my $fromwidth=4;
  my $towidth=2;
  foreach my $revision (@sortedkeys) {
    my $info = $copies{$revision};
    $fromwidth = max($fromwidth, length($info->[3].':'.$info->[4]));
    $towidth = max($towidth, length($info->[2]));
  }
  my $fmt = '%5s %' . $fromwidth . 's->%-'. $towidth . 's' . "\n";
  printf $fmt, 'Rev.', 'From', 'To';
  foreach my $revision (@sortedkeys) {
    my $info = $copies{$revision};
    printf $fmt, $revision, $info->[3].':'.$info->[4], $info->[2];
  }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Mar 18 15:06:34 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.