Changeset 612


Ignore:
Timestamp:
Nov 20, 2008, 8:22:22 PM (11 years ago)
Author:
Bruno Cornec
Message:

Adds Mercurial support in CMS.pm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/lib/ProjectBuilder/CMS.pm

    r600 r612  
    8383pb_cms_compliant(undef,'PBDIR',"$ENV{'PBPROJDIR'}/$tmp",$pburl->{$ENV{'PBPROJ'}},$pbinit);
    8484
    85 if ($scheme =~ /^svn/) {
     85if ($scheme =~ /^hg/) {
    8686    # svnversion more precise than svn info
     87    $tmp = `(cd "$ENV{'PBDIR'}" ; hg identify )`;
     88    chomp($tmp);
     89    $tmp =~ s/^.* //;
     90    $ENV{'PBREVISION'}=$tmp;
     91    $ENV{'PBCMSLOGFILE'}="hg.log";
     92} elsif (($scheme eq "file") || ($scheme eq "ftp") || ($scheme eq "http")) {
     93    $ENV{'PBREVISION'}="flat";
     94    $ENV{'PBCMSLOGFILE'}="flat.log";
     95} elsif ($scheme =~ /^svn/) {
    8796    $tmp = `(cd "$ENV{'PBDIR'}" ; svnversion .)`;
    8897    chomp($tmp);
    8998    $ENV{'PBREVISION'}=$tmp;
    9099    $ENV{'PBCMSLOGFILE'}="svn.log";
    91 } elsif (($scheme eq "file") || ($scheme eq "ftp") || ($scheme eq "http")) {
    92     $ENV{'PBREVISION'}="flat";
    93     $ENV{'PBCMSLOGFILE'}="flat.log";
    94100} elsif ($scheme =~ /^cvs/) {
    95101    # Way too slow
     
    194200        copy($path,$destdir);
    195201    }
     202} elsif ($scheme =~ /^hg/) {
     203    if (defined $source) {
     204        if (-d $source) {
     205            $tmp = $destdir;
     206        } else {
     207            $tmp = "$destdir/".basename($source);
     208        }
     209        $source = pb_cms_mod_hg_http($source);
     210        pb_system("hg export $source $tmp","Exporting $source from Mercurial to $tmp ");
     211    } else {
     212        $uri = pb_cms_mod_hg_http($uri);
     213        pb_system("hg export $uri $destdir","Exporting $uri from Mercurial to $destdir ");
     214    }
    196215} elsif ($scheme =~ /^cvs/) {
    197216    # CVS needs a relative path !
     
    245264    $res =~ s/^\s*//;
    246265    close(PIPE);
     266    chomp($res);
     267} elsif ($scheme =~ /^hg/) {
     268    open(HGRC,".hg/hgrc/") || return("");
     269    while (<HGRC>) {
     270        ($void,$res) = split(/^default.*=/) if (/^default.*=/);
     271    }
     272    close(HGRC);
    247273    chomp($res);
    248274} elsif ($scheme =~ /^cvs/) {
     
    284310The third parameter is the URL of the destination CMS content.
    285311
    286 Only coded for SVN now.
     312Only coded for SVN now as used for pbconf itself not the project
    287313
    288314=cut
     
    321347    $url = pb_cms_mod_svn_http($url);
    322348    pb_system("svn co $url $destination","Checking out $url to $destination ");
     349} elsif ($scheme =~ /^hg/) {
     350    $url = pb_cms_mod_hg_http($url);
     351    pb_system("hg clone $url $destination","Checking out $url to $destination ");
    323352} elsif (($scheme eq "ftp") || ($scheme eq "http")) {
    324353    return;
     
    361390    pb_system("svn up $dir","Updating $dir ");
    362391} elsif ($scheme eq "flat") {
     392} elsif ($scheme =~ /^hg/) {
     393    pb_system("cd $dir ; hg up","Updating $dir ");
    363394} elsif ($scheme =~ /^cvs/) {
    364395    pb_system("cvs up $dir","Updating $dir ");
     
    389420    pb_system("svn ci -m \"$msg\" $dir","Checking in $dir ");
    390421} elsif ($scheme eq "flat") {
     422} elsif ($scheme =~ /^hg/) {
     423    pb_system("hg ci -m \"$msg\" $dir","Checking in $dir ");
    391424} elsif ($scheme =~ /^cvs/) {
    392425    pb_system("cvs ci -m \"$msg\" $dir","Checking in $dir ");
     
    412445    pb_system("svn add $f","Adding $f to SVN ");
    413446} elsif ($scheme eq "flat") {
     447} elsif ($scheme =~ /^hg/) {
     448    pb_system("hg add $f","Adding $f to Mercurial ");
    414449} elsif ($scheme =~ /^cvs/) {
    415450    pb_system("cvs add $f","Adding $f to CVS ");
     
    434469if ($scheme =~ /^svn/) {
    435470    open(PIPE,"svn diff $dir |") || die "Unable to get svn diff from $dir";
     471    my $l = 0;
     472    while (<PIPE>) {
     473        $l++;
     474    }
     475    return($l);
     476} elsif ($scheme =~ /^hg/) {
     477    open(PIPE,"hg diff $dir |") || die "Unable to get hg diff from $dir";
    436478    my $l = 0;
    437479    while (<PIPE>) {
     
    570612        pb_cms_checkout($scheme,$uri,$ENV{$envar});
    571613    }
    572 } elsif (($scheme !~ /^cvs/) || ($scheme !~ /^svn/)) {
     614} elsif (($scheme !~ /^cvs/) || ($scheme !~ /^svn/)  || ($scheme !~ /^hg/)) {
    573615    # Do not compare if it's not a real cms
    574616    return;
     
    690732        }
    691733    }
     734} elsif ($scheme =~ /^hg/) {
     735    if (! -f "$dest/ChangeLog") {
     736        # In case we have no network, just create an empty one before to allow correct build
     737        open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog";
     738        close(CL);
     739        pb_system("hg log -v $pkgdir > $dest/$ENV{'PBCMSLOGFILE'}","Extracting log info from SVN");
     740        }
     741    }
    692742} elsif (($scheme eq "file") || ($scheme eq "dir") || ($scheme eq "http") || ($scheme eq "ftp")) {
    693743    if (! -f "$dest/ChangeLog") {
     
    721771}
    722772
     773sub pb_cms_mod_hg_http {
     774
     775my $url = shift;
     776
     777$url =~ s/^hg\+(http[s]*):/$1:/;
     778return($url);
     779}
     780
    723781=back
    724782
Note: See TracChangeset for help on using the changeset viewer.