From eea630f3bb0fb10f453cae423069c87c92a802b6 Mon Sep 17 00:00:00 2001 From: juha Date: Sat, 30 Jun 2012 12:17:14 +0000 Subject: [PATCH] svn2revisioninc: add support for HG mirror repos cloned from SVN. Issue #22330, patch from Ludo Brands git-svn-id: trunk@37823 - --- tools/svn2revisioninc.pas | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/svn2revisioninc.pas b/tools/svn2revisioninc.pas index 6bf21347b4..254fc249cf 100644 --- a/tools/svn2revisioninc.pas +++ b/tools/svn2revisioninc.pas @@ -50,9 +50,7 @@ it tries to execute hg to get the revision id. Not checking for the .hg subdirectory allows getting the hg revision id even in subdirectories. - No support yet for svn repos converted to hg (e.g. with hgsubversion), - so you get a Mercurial commit identifier (a hex number) instead of svn. - To minimize confusion, the text hg: is prepended to the string. + Support for svn repos converted to hg with hgsubversion. } program Svn2RevisionInc; @@ -191,7 +189,8 @@ var try with HgVersionProcess do begin // Get global revision ID (no need to worry about branches) - CommandLine := 'hg id --id "' + SourceDirectory + '"'; + CurrentDirectory:=SourceDirectory; + CommandLine := 'hg parents --template="{svnrev}:{node|short}"'; Options := [poUsePipes, poWaitOnExit]; try Execute; @@ -204,8 +203,11 @@ var System.Delete(ScrapeResult, 1, Pos(#13, ScrapeResult)); System.Delete(ScrapeResult, 1, Pos(#10, ScrapeResult)); System.Delete(ScrapeResult, Pos(' ', ScrapeResult), Length(ScrapeResult)); - //Indicate we're dealing with Mercurial to avoid confusing the user: - ScrapeResult:='hg:'+ScrapeResult; + if ScrapeResult[1]=':' then //no svn version found. + //Indicate we're dealing with Mercurial to avoid confusing the user: + ScrapeResult:='hg'+ScrapeResult + else + ScrapeResult:=copy(ScrapeResult,2,pos(':',ScrapeResult)-2); except // ignore error, default result is false end;