Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /svnutils/trunk/src/

svnutils
Discussion topic

Back to topic list

CVS update: /svnutils/trunk/src/

Author sunny256
Full name Øyvind A. Holm
Date 2004-08-20 18:21:06 PDT
Message User: sunny256
Date: 04/08/20 18:21:06

Added:
 /svnutils/trunk/src/
  svnbranchroot

Log:
 r42 | pmorch | 2004-08-21 03:19:31 +0200 | 11 lines
 
 New script: Find the root of a branch. Takes one parameter - the branch,
 and finds the root revision of the branch - the revision from which it
 was made. Especially good for investigating tags. What revision of the
 parent branch was this tag made from?
 
 Made by Peter Valdemar Mørch <peter at morch dot com>, commit by sunny256 using
 his tigris.org name.
 
 * /trunk/src/svnbranchroot
   New file. Also set svn:eol-style to "native".

File Changes:

Directory: /svnutils/trunk/src/
===============================

File [added]: svnbranchroot
Url: http://svnutils.tigr​is.org/source/browse​/svnutils/trunk/src/​svnbranchroot?rev=1.​1&content-type=t​ext/vnd.viewcvs-mark​up
Added lines: 92
---------------
#!/usr/bin/perl -w
use strict;
use XML::Parser;
use FileHandle;

=head1 Usage

svnbranchroot <branch>

e.g.

 svnbranchroot .
   or
 svnbranchroot http://server/repos/​branches/branch1

Find the root of a branch. Takes one parameter - the branch, and finds
the root revision of the branch - the revision from which it was
made. Especially good for investigating tags. What revision of the
parent branch was this tag made from?

See the tip under "Merging a Whole Branch to Another"

http://svnbook.red-b​ean.com/svnbook/book​.html#svn-ch-4-sect-​4.1

for the procedure.

Here it is automated.

 Copyright 2004 Peter Morch
 Released under the GPL

=cut

my $branch = $ARGV[0]
  or die "Please supply a branch as in:\n$0 <branch>";

my $parser = new XML::Parser(Style => 'Tree');

# We only care about markup...
$parser->setHand​lers("Char",0);

my $fh = new FileHandle;
open I, "svn log -v --xml --stop-on-copy $branch |"
  or die "Couldn't open svn log $branch";
my $t = $parser->parse(*I);
close I;

my $lastRev = pop @{$$t[1]};
my ($lrHash, %lrContents) = @$lastRev;

# use lib '/opt/capmon/inc'; use Dbug ; dbugDump(\%lrContents);
# prints something like:
# DEBUG: $VAR1 = {
# 'msg' => [
# {}
# ],
# 'date' => [
# {}
# ],
# 'author' => [
# {}
# ],
# 'paths' => [
# {},
# 'path',
# [
# {
# 'copyfrom-path' => '/branches/complete/CAPMON_4',
# 'action' => 'A',
# 'copyfrom-rev' => '4372'
# }
# ]
# ]
# };

my $paths = $lrContents{paths};
shift @$paths;
my $copyfromRev;
while (@$paths && ! defined $copyfromRev) {
  (shift @$paths eq 'path')
    or die "Huh? paths contains something other than a 'path'";
  my $pathContents = shift @$paths;
  $copyfromRev = $pathContents->[​0]->{'copyfrom-re​v'}
    if ($pathContents->​[0]->{'copyfrom-r​ev'});
}

# Print a newline if its a tty...
if (-t STDOUT) {
  print $copyfromRev . "\n";
} else {
  print $copyfromRev;
}




--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@svnu​tils.tigris.org
For additional commands, e-mail: cvs-help at svnutils dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /svnutils/trunk/src/ sunny256 Øyvind A. Holm 2004-08-20 18:21:06 PDT
Messages per page: