Changeset 46236 in webkit


Ignore:
Timestamp:
Jul 22, 2009 1:32:35 PM (15 years ago)
Author:
pkasting@chromium.org
Message:

2009-07-22 Peter Kasting <pkasting@google.com>

Reviewed by David Kilzer.

https://bugs.webkit.org/show_bug.cgi?id=27323
Factor svn-create-patch's "determineSvnRoot()" into a function in
VCSUtils.pm so commit-log-editor can use it too.

  • Scripts/VCSUtils.pm: Add determineSVNRoot().
  • Scripts/commit-log-editor: Use determineSVNRoot() instead of old code (which didn't work as well).
  • Scripts/svn-create-patch: Remove determineSvnRoot() (moved).
Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r46235 r46236  
     12009-07-22  Peter Kasting  <pkasting@google.com>
     2
     3        Reviewed by David Kilzer.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=27323
     6        Factor svn-create-patch's "determineSvnRoot()" into a function in
     7        VCSUtils.pm so commit-log-editor can use it too.
     8
     9        * Scripts/VCSUtils.pm: Add determineSVNRoot().
     10        * Scripts/commit-log-editor: Use determineSVNRoot() instead of old
     11          code (which didn't work as well).
     12        * Scripts/svn-create-patch: Remove determineSvnRoot() (moved).
     13
    1142009-07-22  Jakob Petsovits  <jakob.petsovits@torchmobile.com>
    215
  • trunk/WebKitTools/Scripts/VCSUtils.pm

    r42308 r46236  
    3737   $VERSION     = 1.00;
    3838   @ISA         = qw(Exporter);
    39    @EXPORT      = qw(&isGitDirectory &isGit &isSVNDirectory &isSVN &makeFilePathRelative);
     39   @EXPORT      = qw(&isGitDirectory &isGit &isSVNDirectory &isSVN &determineSVNRoot &makeFilePathRelative);
    4040   %EXPORT_TAGS = ( );
    4141   @EXPORT_OK   = ();
     
    105105}
    106106
     107sub determineSVNRoot()
     108{
     109    my $devNull = File::Spec->devnull();
     110    my $last = '';
     111    my $path = '.';
     112    my $parent = '..';
     113    my $repositoryUUID;
     114    while (1) {
     115        my $thisUUID;
     116        # Ignore error messages in case we've run past the root of the checkout.
     117        open INFO, "svn info '$path' 2> $devNull |" or die;
     118        while (<INFO>) {
     119            if (/^Repository UUID: (.+)/) {
     120                $thisUUID = $1;
     121                { local $/ = undef; <INFO>; }  # Consume the rest of the input.
     122            }
     123        }
     124        close INFO;
     125
     126        # It's possible (e.g. for developers of some ports) to have a WebKit
     127        # checkout in a subdirectory of another checkout.  So abort if the
     128        # repository UUID suddenly changes.
     129        last if !$thisUUID;
     130        if (!$repositoryUUID) {
     131            $repositoryUUID = $thisUUID;
     132        }
     133        last if $thisUUID ne $repositoryUUID;
     134
     135        $last = $path;
     136        $path = File::Spec->catdir($parent, $path);
     137    }
     138
     139    return File::Spec->rel2abs($last);
     140}
     141
    107142sub svnRevisionForDirectory($)
    108143{
  • trunk/WebKitTools/Scripts/commit-log-editor

    r45993 r46236  
    180180        return dirname($gitDir);
    181181    } elsif (isSVN()) {
    182         open(INFO, "-|", qw(svn info)) or die;
    183         my ($root, $url);
    184         while (my $line = <INFO>) {
    185             if ($line =~ /^Repository Root: (.*)$/) {
    186                 $root = $1;
    187             } elsif ($line =~ /^URL: (.*)$/) {
    188                 $url = $1;
    189             }
    190         }
    191         close(INFO);
    192 
    193         my $path = $url;
    194         $path =~ s/^\Q$root\E//;
    195         $path =~ s/^\/?(branches\/[^\/]*|trunk)\/?//;
    196         return File::Spec->rel2abs(File::Spec->catdir(map { ".." } File::Spec->splitdir($path)));
     182        return determineSVNRoot();
    197183    }
    198184}
  • trunk/WebKitTools/Scripts/svn-create-patch

    r46134 r46236  
    4545
    4646use Config;
    47 use Cwd;
     47use Cwd qw();  # "qw()" prevents warnings if we later (indirectly) "use POSIX;".
    4848use File::Basename;
    4949use File::Spec;
    5050use File::stat;
     51use FindBin;
    5152use Getopt::Long;
     53use lib $FindBin::Bin;
    5254use MIME::Base64;
    5355use POSIX qw(:errno_h);
    5456use Time::gmtime;
     57use VCSUtils;
    5558
    5659sub binarycmp($$);
    5760sub canonicalizePath($);
    5861sub chdirAndGetDifference($);
    59 sub determineSvnRoot();
    6062sub findBaseUrl($);
    6163sub findMimeType($;$);
     
    98100}
    99101
    100 my $svnRoot = determineSvnRoot();
     102my $svnRoot = determineSVNRoot();
    101103my $prefix = chdirAndGetDifference($svnRoot);
    102104
     
    468470    return File::Spec->abs2rel($before, $after);
    469471}
    470 
    471 sub determineSvnRoot()
    472 {
    473     my $last = '';
    474     my $path = '.';
    475     my $parent = '..';
    476     my $repositoryUUID;
    477     while (1) {
    478         my $thisUUID;
    479         # Ignore error messages in case we've run past the root of the checkout.
    480         open INFO, "svn info '$path' 2> $devNull |" or die;
    481         while (<INFO>) {
    482             if (/^Repository UUID: (.+)/) {
    483                 $thisUUID = $1;
    484                 { local $/ = undef; <INFO>; }  # Consume the rest of the input.
    485             }
    486         }
    487         close INFO;
    488 
    489         # It's possible (e.g. for developers of some ports) to have a WebKit
    490         # checkout in a subdirectory of another checkout.  So abort if the
    491         # repository UUID suddenly changes.
    492         last if !$thisUUID;
    493         if (!$repositoryUUID) {
    494             $repositoryUUID = $thisUUID;
    495         }
    496         last if $thisUUID ne $repositoryUUID;
    497 
    498         $last = $path;
    499         $path = File::Spec->catdir($parent, $path);
    500     }
    501 
    502     return File::Spec->rel2abs($last);
    503 }
Note: See TracChangeset for help on using the changeset viewer.