Login | Register
My pages Projects Community openCollabNet

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

svnutils
Discussion topic

Back to topic list

CVS update: /svnutils/trunk/, /svnutils/trunk/src/

Author sunny256
Full name Øyvind A. Holm
Date 2008-09-20 22:59:15 PDT
Message User: sunny256 Date: 2008-09-20 22:59:15-0700 Added: svnutils/trunk/src/findrev Modified: svnutils/trunk/CONTENTS Log: r211 | sunny256 | 2008-09-21 05:28:35 +0000 (Sun, 21 Sep 2008) | 89 lines Added the findrev script. * /trunk/src/findrev Welcome. Moved from my private repository at http://svn.sunbase.org/repos/utils/trunk/findrev r2470. Log history in (sorry) Norwegian: # ------------------------------------------------------------------------ # r2460 | sunny | 2008-09-20 04:09:56 +0000 (Sat, 20 Sep 2008) | 7 lines # # * /trunk/findrev # Dette er et script som jeg begynte på med på carmbb. Fildatoen er # 2007-04-07 03:29:22Z, og jeg har ikke testa det enda. Skal bruke # binærsøk for å finne fram til revisjoner ved å kjøre tester. # # f84a829c-86c9-11dd-83e4-000475e441b9 # ------------------------------------------------------------------------ # r2461 | sunny | 2008-09-20 04:18:50 +0000 (Sat, 20 Sep 2008) | 5 lines # # * /trunk/findrev # Merga Lib/std/perl r2096:2339 med mergesvn. # # 383a6790-86cb-11dd-8c72-000475e441b9 # ------------------------------------------------------------------------ # r2462 | sunny | 2008-09-20 09:11:24 +0000 (Sat, 20 Sep 2008) | 8 lines # # * /trunk/findrev # Nå kommer den seg. Har bytta ut terminologien, man måtte tenke omvendt # før. Nå er det bare snakk om å leite gjennom revisjonene til testen # passerer, det vil si returnerer 0 eller noe man har spesifisert. # Oppdaterte hjelpeskjermen også. # # 141cdfa4-86f4-11dd-983c-000475e441b9 # ------------------------------------------------------------------------ # r2463 | sunny | 2008-09-20 15:32:01 +0000 (Sat, 20 Sep 2008) | 8 lines # # * /trunk/findrev # Har ordna litt på hjelpeskjermen og forandra på statusmeldinga # underveis, nå ser den sånn ut: # # ==== Checking revision 1738 (1736:1739, 4 left)...svn update...run test: # # 4113ed60-8729-11dd-9522-000475e441b9 # ------------------------------------------------------------------------ # r2464 | sunny | 2008-09-20 15:40:10 +0000 (Sat, 20 Sep 2008) | 6 lines # # * /trunk/findrev # Sletta noe ruskepod som lå midt i, pluss den svære poden på enden av # fila. Blir ikke å bruke den. # # 66373f10-872a-11dd-a75a-000475e441b9 # ------------------------------------------------------------------------ # r2465 | sunny | 2008-09-20 16:09:35 +0000 (Sat, 20 Sep 2008) | 7 lines # # * /trunk/findrev # Dropper det "-f/--file"-valget og gjør det mulig å spesifisere # elementet som det skal opereres på direkte på kommandolinja. Det er # mer naturlig. # # 831fc300-872e-11dd-bb59-000475e441b9 # ------------------------------------------------------------------------ # r2469 | sunny | 2008-09-21 03:58:30 +0000 (Sun, 21 Sep 2008) | 12 lines # # findrev: Bytter ut "-c/--cleanup" med "-b/--before" og "-a/--after". Mer # fleksibelt. # # * /trunk/findrev # (find_revision): cleanup-parameteret er byttet ut med to for before og # after. # (test_ok): Samme her, i tillegg ble before- og after-kommandoen lagt # inn rundt testen. # (usage): Den måtte jo også oppdateres. # # 8669fe82-8791-11dd-8ae9-000475e441b9 # ------------------------------------------------------------------------ # r2470 | sunny | 2008-09-21 05:10:03 +0000 (Sun, 21 Sep 2008) | 6 lines # # * /trunk/findrev # (usage): Glemte en forandring i r2469 da "-c/--cleanup" gikk ut # vinduet. I tillegg var det ikke forklaring på "-w/--want". # # 898d5370-879b-11dd-a3ab-000475e441b9 # ------------------------------------------------------------------------ * /trunk/CONTENTS Added findrev description. 1150d848-879e-11dd-ab0d-000475e441b9 39a13636-87a2-11dd-a652-000475e441b9 File Changes: Directory: /svnutils/trunk/ =========================== File [changed]: CONTENTS Url: http://svnutils.tigris.org/source/browse/svnutils/trunk/CONTENTS?r1=1.12&r2=1.13 Delta lines: +5 -1 ------------------- --- CONTENTS 2007-02-19 04:03:28-0700 1.12 +++ CONTENTS 2008-09-20 22:59:12-0700 1.13 @@ -18,6 +18,10 @@ Strips the dollars and keyword name directly from text files. Designed for use when releasing files and the keywords should not be changed by other programs. + - findrev + Searches for a specific revision by running a test command or + script. Start and end revision can be specified, and the program + uses binary search to locate the revision. Can be fully automated. - mergesvn Merge changes between files or directories and store the point of the last merge in a special "mergesvn" property. A master location @@ -73,5 +77,5 @@ backup program, but let’s first see if there are any other wheels around that’s already invented. -$Id: CONTENTS 171 2007-02-14 20:16:00Z sunny $ +$Id: CONTENTS 211 2008-09-21 05:28:35Z sunny256 $ vim: set tw=72 ts=2 sw=2 sts=2 et fo+=w fenc=UTF-8 : Directory: /svnutils/trunk/src/ =============================== File [added]: findrev Url: http://svnutils.tigris.org/source/browse/svnutils/trunk/src/findrev?rev=1.1&content-type=text/vnd.viewcvs-markup Added lines: 351 ---------------- #!/usr/bin/perl -w #======================================================================= # $Id: findrev 211 2008-09-21 05:28:35Z sunny256 $ # Locate a Subversion revision based on used defined criteras. # # Character set: UTF-8 # ©opyleft 2007– Øyvind A. Holm # License: GNU General Public License version 2 or later, see end of # file for legal stuff. #======================================================================= BEGIN { our @version_array; } use strict; use Getopt::Long; $| = 1; our $Debug = 0; our %Opt = ( 'after' => "", 'before' => "", 'exec' => "", 'debug' => 0, 'help' => 0, 'ignore-externals' => 0, 'revision' => "", 'verbose' => 0, 'version' => 0, 'want' => 0, ); our $progname = $0; $progname =~ s/^.*\/(.*?)$/$1/; my $rcs_id = '$Id: findrev 211 2008-09-21 05:28:35Z sunny256 $'; my $id_date = $rcs_id; $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d\d:\d\d:\d\d\S+).*/$1/; my $CMD_SVN = "svn"; push(@main::version_array, $rcs_id); Getopt::Long::Configure("bundling"); GetOptions( "after|A=s" => \$Opt{'after'}, "before|B=s" => \$Opt{'before'}, "exec|e=s" => \$Opt{'exec'}, "debug" => \$Opt{'debug'}, "help|h" => \$Opt{'help'}, "ignore-externals" => \$Opt{'ignore-externals'}, "revision|r=s" => \$Opt{'revision'}, "verbose|v+" => \$Opt{'verbose'}, "version" => \$Opt{'version'}, "want|w=s" => \$Opt{'want'}, ) || die("$progname: Option error. Use -h for help.\n"); $Opt{'debug'} && ($Debug = 1); $Opt{'help'} && usage(0); $Opt{'version'} && print_version(); my ($Start, $End) = (1, "HEAD"); if (length($Opt{'revision'})) { if ($Opt{'revision'} =~ /^(\d*):(\d*|head)$/i) { D("regexp good"); length($1) && ($Start = $1); length($2) && ($End = $2); } else { die("$progname: Invalid revision range in --revision (-r) parameter\n"); } } D("Start = '$Start', End = '$End'"); if (!length($Opt{'exec'})) { die("$progname: No --exec (-e) parameter specified. You might want to consult '$progname --help'.\n"); } my $File; if ($#ARGV == -1) { $File = "."; } elsif ($#ARGV == 0) { $File = $ARGV[0]; } else { die("$progname: Only one file or directory name allowed\n"); } find_revision($Opt{'want'}, $File, $Start, $End, $Opt{'exec'}, $Opt{'before'}, $Opt{'after'}); my $Found = 0; sub find_revision { # Scan a specific revision range for the first merge conflict and # return the revision number # {{{ my ($Want, $File, $Start, $End, $Exec, $Before, $After) = @_; D("find_revision('$Want', '$File', '$Start', '$End', '$Exec', '$Before', '$After')"); print("$progname: $File: Scanning revision range r$Start:$End " . "for return value $Want\n"); my @Array = revisions($File, $Start, $End); if (!scalar(@Array)) { print("No revisions found.\n"); return undef; } my $rev_count = scalar(@Array); printf("$rev_count revision%s to check\n", $rev_count == 1 ? "" : "s"); print("(" . join(", ", @Array) . ")\n"); my $min_block = 0; my ($min_pos, $max_pos) = (0, $rev_count); my $last_mid = 0; my $first_fail = 0; my $last_good = 0; my $has_checked = 0; while (1) { my $mid_pos = int(($min_pos + $max_pos) / 2); last if ($has_checked && ($mid_pos == $last_mid)); my $Rev = $Array[$mid_pos]; D("max_pos = '$max_pos', scalar("); printf("==== Checking revision %lu (%lu:%lu, %lu left)...", $Rev, $Array[$min_pos], $Array[$max_pos-1], $max_pos - $min_pos); my $exit_code = test_ok($Want, $File, $Rev, $Exec, $Before, $After); if ($exit_code != $Opt{'want'}) { print("NOT FOUND (code $exit_code), going up\n"); $min_pos = $mid_pos; D("min_pos set to '$mid_pos'"); if (!$last_good || ($Rev > $last_good)) { $last_good = $Rev; } } else { print("FOUND (code $exit_code), going down\n"); $max_pos = $mid_pos; D("max_pos set to '$mid_pos'"); if (!$first_fail || ($Rev < $first_fail)) { $first_fail = $Rev; } } $has_checked = 1; $last_mid = $mid_pos; } print($first_fail ? "Found at r$first_fail. " : "Condition not found. " ); print($last_good ? "Last revision where the test fails at r$last_good.\n" : "Condition found in all revisions.\n" ); # }}} } # find_revision() sub revisions { # Return an array of revision numbers from a specific revision range # for a version controlled element # {{{ my ($File, $Start, $End) = @_; D("revisions('$File', '$Start', '$End')"); my $safe_file = escape_filename($File); my $Data = ""; my @Revs = (); my $pipe_cmd = "$CMD_SVN log --xml -r$Start:$End $safe_file\@$End |"; D("opening pipe '$pipe_cmd'"); if (open(PipeFP, $pipe_cmd)) { $Data = join("", ); close(PipeFP); $Data =~ s//push(@Revs, "$1")/egs; } if ($Revs[0] eq $Start) { # splice(@Revs, 0, 1); } return(@Revs); # }}} } # revisions() sub mysyst { # Customised system() {{{ my @Args = @_; my $system_txt = sprintf("system(\"%s\");", join("\", \"", @Args)); D("$system_txt"); deb_wait(); msg(1, "@_\n"); system(@_); # }}} } # mysyst() sub escape_filename { # Kludge for handling file names with spaces and characters that # trigger shell functions # {{{ my $Name = shift; # $Name =~ s/\\/\\\\/g; # $Name =~ s/([ \t;\|!&"'`#\$\(\)<>\*\?])/\\$1/g; $Name =~ s/'/\\'/g; $Name = "'$Name'"; return($Name); # }}} } # escape_filename() sub deb_wait { # Wait until Enter is pressed if $Debug and verbose >= 2 {{{ $Debug || return; if ($Opt{'verbose'} >= 2) { print("debug: Press ENTER..."); ; } # }}} } # deb_wait() sub test_ok { # {{{ my ($Want, $File, $Rev, $Exec, $Before, $After) = @_; my $Retval; D("test_ok(Want='$Want', File='$File', Rev='$Rev', Exec='$Exec', Before='$Before', After='$After')"); print("svn update..."); if ($Opt{'ignore-externals'}) { mysyst($CMD_SVN, "update", "--ignore-externals", "-q", "-r$Rev", $File); } else { mysyst($CMD_SVN, "update", "-q", "-r$Rev", $File); } if (length($Before)) { print("execute before:\n"); mysyst($Before); } print("run test:\n"); $Retval = mysyst($Exec); if (length($After)) { print("execute after:\n"); mysyst($After); } D("test_ok() returns '$Retval'"); return($Retval); # }}} } # test_ok() sub print_version { # Print program version {{{ for (@main::version_array) { print("$_\n"); } exit(0); # }}} } # print_version() sub usage { # Send the help message to stdout {{{ my $Retval = shift; print(<= $verbose_level) { print(STDERR "$progname: $Txt\n"); } # }}} } # msg() sub D { # Print a debugging message {{{ $Debug || return; my @call_info = caller; chomp(my $Txt = shift); my $File = $call_info[1]; $File =~ s#\\#/#g; $File =~ s#^.*/(.*?)$#$1#; print(STDERR "$File:$call_info[2] $$ $Txt\n"); return(""); # }}} } # D() __END__ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w fo+=2 : # End of file $Id: findrev 211 2008-09-21 05:28:35Z sunny256 $

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

Messages

Show all messages in topic

CVS update: /svnutils/trunk/, /svnutils/trunk/src/ sunny256 Øyvind A. Holm 2008-09-20 22:59:15 PDT
Messages per page: