[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-19 11:10:30 CET

Marcin Kasperski wrote:

>>(Pros of SVN tags: the creation of a tag is a versioned event;...
> (b) maybe more subversion way - whenever I svn copy something,
> add log entry to the copy source (best if special so it can be
> easily distinguished with svn log switches). It will also help
> keep track of branching or just find out what have been copied
> and where.

A perl program which lists copies within a subtree of the repositories
is attached. It should do what you require:

$ ./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

-- 
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');
}

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 Fri Mar 19 11:11:00 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.