Subversion Repositories DevTools

Rev

Rev 1328 | Rev 1343 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1328 Rev 1341
Line 819... Line 819...
819
#
819
#
820
# Description     : Determine a list of packages within the repo
820
# Description     : Determine a list of packages within the repo
821
#                   This turns out to be a very slow process
821
#                   This turns out to be a very slow process
822
#                   so don't use it unless you really really need to
822
#                   so don't use it unless you really really need to
823
#
823
#
-
 
824
# Inputs          : $self       - Instance data
824
# Inputs          : $repo       - Name of the repository
825
#                   $repo       - Name of the repository
-
 
826
#                   Last argument may be a hash of options.
-
 
827
#                           Progress    - True: Show progress
-
 
828
#                           Show        - >1 : display matched Tags and stats
-
 
829
#                                         >2 : display Packages
-
 
830
#                           Tag         - Enable Tag Matching
-
 
831
#                                         Value is the tag to match
825
#
832
#
826
# Returns         : 
833
# Returns         : Ref to an array of all packages
-
 
834
#                   Ref to an array of all packahes with matched tag
827
#
835
#
828
sub SvnListPackages
836
sub SvnListPackages
829
{
837
{
-
 
838
    #
-
 
839
    #   Extract arguments and options
-
 
840
    #   If last argument is a hesh, then its a hash of options
-
 
841
    #
-
 
842
    my $opt;
830
    my ($repo) = @_;
843
    $opt = pop @_
-
 
844
        if (@_ > 0 and UNIVERSAL::isa($_[-1],'HASH'));
831
 
845
 
-
 
846
    my ($self, $repo) = @_;
-
 
847
 
832
    my @path_list = $repo;
848
    my @path_list = '';
833
    my @list;
849
    my @list;
-
 
850
    my @mlist;
834
    my $scanned = 0;
851
    my $scanned = 0;
835
    Debug ("SvnListPackages");
852
    Debug ("SvnListPackages");
836
    while ( @path_list )
853
    while ( @path_list )
837
    {
854
    {
838
        my $path = shift @path_list;
855
        my $path = shift @path_list;
-
 
856
        if ( $opt->{Progress} )
-
 
857
        {
-
 
858
            Message ("Reading: " . ( $path || 'RepoRoot') );
-
 
859
        }
839
        $scanned++;
860
        $scanned++;
840
print "Reading: $path\n";
-
 
841
        my ( $ref_files, $ref_dirs, $ref_svn, $found ) = SvnScanPath ( 'Listing Packages', $path );
861
        my ( $ref_files, $ref_dirs, $ref_svn, $found ) = $self->SvnScanPath ( 'Listing Packages', join( '/', $repo, $path) );
842
 
862
 
843
        #
863
        #
844
        #   If there are Subversion dirs (ttb) in this directory
864
        #   If there are Subversion dirs (ttb) in this directory
845
        #   then this is a package. Add to list
865
        #   then this is a package. Add to list
846
        #
866
        #
Line 849... Line 869...
849
        #
869
        #
850
        #   Add subdirs to the list of paths to explore
870
        #   Add subdirs to the list of paths to explore
851
        #
871
        #
852
        foreach  ( @$ref_dirs )
872
        foreach  ( @$ref_dirs )
853
        {
873
        {
854
            chop;                                 # Remove trailing '/'
874
            chop;                                   # Remove trailing '/'
855
            push @path_list, $path . '/' . $_;    # Extend the path
875
            push @path_list, $path ? join('/', $path , $_) : $_; # Extend the path
-
 
876
        }
-
 
877
    }
-
 
878
 
-
 
879
    if ( $opt->{Tag} )
-
 
880
    {
-
 
881
        my $tag = $opt->{Tag};
-
 
882
        foreach my $path ( sort @list )
-
 
883
        {
-
 
884
            Message ("Testing: $path") if ( $opt->{Progress} );
-
 
885
            if ( $self->SvnTestPath ( 'Listing Packages', join('/', $repo, $path, 'tags', $tag) ) )
-
 
886
            {
-
 
887
                push @mlist, $path;
-
 
888
            }
856
        }
889
        }
857
    }
890
    }
858
 
891
 
-
 
892
    if ( $opt->{Show} )
-
 
893
    {
859
    Message ("Found:", @list );
894
        Message ("Found Tags:", @mlist );
-
 
895
        Message ("Found Packages:", @list ) if  $opt->{Show} > 2;
-
 
896
        Message ("Tags Found: " . scalar @mlist );
-
 
897
        Message ("Packages Found: " . scalar @list );
860
    Message ("Dirs Scanned: $scanned");
898
        Message ("Dirs Scanned: $scanned");
-
 
899
    }
-
 
900
 
861
    Message ("Packages Found: $#list");
901
    return \@list, \@mlist;
862
}
902
}
863
 
903
 
864
#-------------------------------------------------------------------------------
904
#-------------------------------------------------------------------------------
865
# Function        : ListLabels
905
# Function        : ListLabels
866
#
906
#
Line 1400... Line 1440...
1400
    #   as provided by configuration information within the environment
1440
    #   as provided by configuration information within the environment
1401
    #
1441
    #
1402
    $rpath =~ m~(.+?)/(.*)~;
1442
    $rpath =~ m~(.+?)/(.*)~;
1403
    my $fe = $1 || $rpath;
1443
    my $fe = $1 || $rpath;
1404
    my $rest = $2 || '';
1444
    my $rest = $2 || '';
1405
 
-
 
1406
    if ( $SVN_URLS{$fe} )
1445
    if ( $SVN_URLS{$fe} )
1407
    {
1446
    {
1408
        $url = $SVN_URLS{$fe};
1447
        $url = $SVN_URLS{$fe};
1409
        $pkgroot = $rest;
1448
        $pkgroot = $rest;
1410
        $processed = 1;
1449
        $processed = 1;
Line 1635... Line 1674...
1635
#                   This may well fail unless the Repo is setup to allow such
1674
#                   This may well fail unless the Repo is setup to allow such
1636
#                   chnages and the user is allowed to make such changes
1675
#                   chnages and the user is allowed to make such changes
1637
#
1676
#
1638
# Inputs          : $name
1677
# Inputs          : $name
1639
#                   $value
1678
#                   $value
-
 
1679
#                   $allowError     - Support for bad repositories
1640
#
1680
#
-
 
1681
# Returns         : 0 - Change made
1641
# Returns         : Will not return on error
1682
#                   Will not return on error
1642
#
1683
#
1643
sub setRepoProperty
1684
sub setRepoProperty
1644
{
1685
{
1645
    my ($self, $name, $value ) = @_;
1686
    my ($self, $name, $value, $allowError ) = @_;
-
 
1687
    my $retval = 0;
-
 
1688
 
1646
    Debug ( "setRepoProperty", $name, $value );
1689
    Debug ( "setRepoProperty", $name, $value );
1647
    #
1690
    #
1648
    #   Ensure that the Repo version is known
1691
    #   Ensure that the Repo version is known
1649
    #   This should be set by a previous operation
1692
    #   This should be set by a previous operation
1650
    #
1693
    #
Line 1664... Line 1707...
1664
                       ) )
1707
                       ) )
1665
    {
1708
    {
1666
        #
1709
        #
1667
        #   Property NOT set
1710
        #   Property NOT set
1668
        #
1711
        #
-
 
1712
        if ( $allowError )
-
 
1713
        {
-
 
1714
            Warning ("setRepoProperty: $name - FAILED");
-
 
1715
            $retval = 1;
-
 
1716
        }
-
 
1717
        else
-
 
1718
        {
1669
        Error ("setRepoProperty: $name - FAILED");
1719
            Error ("setRepoProperty: $name - FAILED");
-
 
1720
        }
-
 
1721
    }
-
 
1722
 
-
 
1723
    return $retval;
-
 
1724
}
-
 
1725
 
-
 
1726
 
-
 
1727
#-------------------------------------------------------------------------------
-
 
1728
# Function        : backTrackSvnLabel
-
 
1729
#
-
 
1730
# Description     : Examine a Svn Tag and backtrack until we find the branch
-
 
1731
#                   that was used to create the label
-
 
1732
#
-
 
1733
# Inputs          : $self                   - Instance Data
-
 
1734
#                   $src_label              - Label to process
-
 
1735
#                                             Label within the current instance
-
 
1736
#
-
 
1737
# Returns         : Branch from which the label was taken
-
 
1738
#                   or the label prefixed with 'tags'.
-
 
1739
#
-
 
1740
sub backTrackSvnLabel
-
 
1741
{
-
 
1742
    my ($self, $src_label) = @_;
-
 
1743
 
-
 
1744
    #
-
 
1745
    #   Init stored data
-
 
1746
    #
-
 
1747
    $self->{btData} = ();
-
 
1748
 
-
 
1749
    #
-
 
1750
    #   extract data
-
 
1751
    #
-
 
1752
#    DebugDumpData("SVN", $svn );
-
 
1753
#$self->{PRINTDATA} = 1;
-
 
1754
    $src_label =~ s~^tags/~~;
-
 
1755
    $self->SvnCmd ( 'log', '-v', '--xml', '-q', '--stop-on-copy', $self->Full() . '/tags/' . $src_label
-
 
1756
                    , { 'credentials' => 1,
-
 
1757
                        'process' => \&ProcessBackTrack,
-
 
1758
                         }
-
 
1759
                        );
-
 
1760
 
-
 
1761
    #
-
 
1762
    #   Process data
-
 
1763
    #       $self->{btData}{entry}      - temp stuff
-
 
1764
    #       @{$self->{btData}{data}}    - Array of entries
-
 
1765
    #
-
 
1766
    #
-
 
1767
#    DebugDumpData("btData", $self->{btData} );
-
 
1768
 
-
 
1769
    my $peglessLabel = $src_label;
-
 
1770
       $peglessLabel =~ s~@\d+$~~;
-
 
1771
    my $branch;
-
 
1772
    foreach my $entry ( @{$self->{btData}{data}} )
-
 
1773
    {
-
 
1774
        my $name;
-
 
1775
        my $isaBranch;
-
 
1776
        my $target = $entry->{target};
-
 
1777
 
-
 
1778
        if ( $target =~ m~/tags/$peglessLabel$~ )
-
 
1779
        {
-
 
1780
            my $parent = $entry->{fromPath};
-
 
1781
            if ( $parent =~ m~(.+)/((tags|branches|trunk)(/|$).*)~ )
-
 
1782
            {
-
 
1783
                $branch = $2 . '@' . $entry->{fromRev};
-
 
1784
                last;
-
 
1785
            }
-
 
1786
        }
-
 
1787
    }
-
 
1788
    delete $self->{btData};
-
 
1789
 
-
 
1790
    #
-
 
1791
    #   Return nice value or original value
-
 
1792
    #
-
 
1793
    unless ( $branch )
-
 
1794
    {
-
 
1795
        $branch = 'tags/' . $src_label;
-
 
1796
    }
-
 
1797
 
-
 
1798
    Verbose( "backTrackSvnLabel: $src_label -> $branch");
-
 
1799
    return $branch;
-
 
1800
}
-
 
1801
 
-
 
1802
#-------------------------------------------------------------------------------
-
 
1803
# Function        : ProcessBackTrack
-
 
1804
#
-
 
1805
# Description     :
-
 
1806
#                   Parse
-
 
1807
#                       <logentry
-
 
1808
#                          revision="24272">
-
 
1809
#                       <author>bivey</author>
-
 
1810
#                       <date>2005-07-25T15:45:35.000000Z</date>
-
 
1811
#                       <paths>
-
 
1812
#                       <path
-
 
1813
#                          prop-mods="false"
-
 
1814
#                          text-mods="false"
-
 
1815
#                          kind="dir"
-
 
1816
#                          copyfrom-path="/enqdef/branches/Stockholm"
-
 
1817
#                          copyfrom-rev="24271"
-
 
1818
#                          action="A">/enqdef/tags/enqdef_24.0.1.sls</path>
-
 
1819
#                       </paths>
-
 
1820
#                       <msg>COTS/enqdef: Tagged by Jats Svn Import</msg>
-
 
1821
#                       </logentry>
-
 
1822
#
-
 
1823
#
-
 
1824
#                   Uses:   $self->{btData}     - Scratch Data
-
 
1825
#
-
 
1826
# Inputs          : $self           - Class Data
-
 
1827
#                   $line           - Input data to parse
-
 
1828
#
-
 
1829
# Returns         : 0 - Do not terminate input command
-
 
1830
#
-
 
1831
sub  ProcessBackTrack
-
 
1832
{
-
 
1833
    my ($self, $line ) = @_;
-
 
1834
    Message ( $line ) if $self->{PRINTDATA};
-
 
1835
 
-
 
1836
    if ( $line =~ m~^<logentry~ ) {
-
 
1837
        $self->{btData}{entry} = ();
-
 
1838
 
-
 
1839
    } elsif ( $line =~ m~^\s+revision="(\d+)"~ ) {
-
 
1840
        $self->{btData}{entry}{Rev} = $1;
-
 
1841
 
-
 
1842
    } elsif ( $line =~ m~^\s+copyfrom-path="(.*)"~ ) {
-
 
1843
        $self->{btData}{entry}{fromPath} = $1;
-
 
1844
 
-
 
1845
    } elsif ( $line =~ m~^\s+copyfrom-rev="(\d+)"~ ) {
-
 
1846
        $self->{btData}{entry}{fromRev} = $1;
-
 
1847
        
-
 
1848
    } elsif ( $line =~ m~\s+action=.*?>(.*)</path~ ) {
-
 
1849
        $self->{btData}{entry}{target} = $1;
-
 
1850
 
-
 
1851
    } elsif ( $line =~ m~</logentry~ ) {
-
 
1852
        if ( exists $self->{btData}{entry}{fromPath} )
-
 
1853
        {
-
 
1854
#            DebugDumpData("Data", $self->{btData}{entry};
-
 
1855
            push @{$self->{btData}{data}}, $self->{btData}{entry};
-
 
1856
        }
1670
    }
1857
    }
-
 
1858
 
-
 
1859
    #
-
 
1860
    #   Return 0 to keep on going
-
 
1861
    return 0;
1671
}
1862
}
1672
 
1863
 
-
 
1864
 
-
 
1865
 
1673
#------------------------------------------------------------------------------
1866
#------------------------------------------------------------------------------
1674
1;
1867
1;