forked from lix-project/hydra
Fix Mercurial diff
It only showed the log messages of $rev1 and $rev2. Now it shows the range $rev1::$rev2, excluding $rev1.
This commit is contained in:
parent
585d3274e3
commit
433b94ee68
|
@ -13,6 +13,7 @@ use DateTime;
|
||||||
use Digest::SHA qw(sha256_hex);
|
use Digest::SHA qw(sha256_hex);
|
||||||
use Text::Diff;
|
use Text::Diff;
|
||||||
use File::Slurp;
|
use File::Slurp;
|
||||||
|
use IPC::Run qw(run);
|
||||||
|
|
||||||
|
|
||||||
sub api : Chained('/') PathPart('api') CaptureArgs(0) {
|
sub api : Chained('/') PathPart('api') CaptureArgs(0) {
|
||||||
|
@ -175,7 +176,6 @@ sub scmdiff : Chained('api') PathPart('scmdiff') Args(0) {
|
||||||
my $type = $c->request->params->{type};
|
my $type = $c->request->params->{type};
|
||||||
my $rev1 = $c->request->params->{rev1};
|
my $rev1 = $c->request->params->{rev1};
|
||||||
my $rev2 = $c->request->params->{rev2};
|
my $rev2 = $c->request->params->{rev2};
|
||||||
my $branch;
|
|
||||||
|
|
||||||
die("invalid revisions: [$rev1] [$rev2]") if $rev1 !~ m/^[a-zA-Z0-9_.]+$/ || $rev2 !~ m/^[a-zA-Z0-9_.]+$/;
|
die("invalid revisions: [$rev1] [$rev2]") if $rev1 !~ m/^[a-zA-Z0-9_.]+$/ || $rev2 !~ m/^[a-zA-Z0-9_.]+$/;
|
||||||
|
|
||||||
|
@ -184,10 +184,14 @@ sub scmdiff : Chained('api') PathPart('scmdiff') Args(0) {
|
||||||
my $diff = "";
|
my $diff = "";
|
||||||
if ($type eq "hg") {
|
if ($type eq "hg") {
|
||||||
my $clonePath = getSCMCacheDir . "/hg/" . sha256_hex($uri);
|
my $clonePath = getSCMCacheDir . "/hg/" . sha256_hex($uri);
|
||||||
die if ! -d $clonePath;
|
die "repository '$uri' is not in the SCM cache\n" if ! -d $clonePath;
|
||||||
$branch = `(cd $clonePath; hg log --template '{branch}' -r $rev2)`;
|
my $out;
|
||||||
$diff .= `(cd $clonePath; hg log -r $rev1 -r $rev2 -b $branch)`;
|
run(["hg", "log", "-R", $clonePath, "-r", "reverse($rev1::$rev2) and not($rev1)"], \undef, \$out)
|
||||||
$diff .= `(cd $clonePath; hg diff -r $rev1:$rev2)`;
|
or die "hg log failed";
|
||||||
|
$diff .= $out;
|
||||||
|
run(["hg", "diff", "-R", $clonePath, "-r", "$rev1::$rev2"], \undef, \$out)
|
||||||
|
or die "hg diff failed";
|
||||||
|
$diff .= $out;
|
||||||
} elsif ($type eq "git") {
|
} elsif ($type eq "git") {
|
||||||
my $clonePath = getSCMCacheDir . "/git/" . sha256_hex($uri);
|
my $clonePath = getSCMCacheDir . "/git/" . sha256_hex($uri);
|
||||||
die if ! -d $clonePath;
|
die if ! -d $clonePath;
|
||||||
|
|
Loading…
Reference in a new issue