diff --git a/applications/fpsvnsync/fpsvnsync.lpr b/applications/fpsvnsync/fpsvnsync.lpr index 6407f0234..969291a2d 100644 --- a/applications/fpsvnsync/fpsvnsync.lpr +++ b/applications/fpsvnsync/fpsvnsync.lpr @@ -186,6 +186,9 @@ var var SourcePropInfo: TSvnPropInfo; DestPropInfo: TSvnPropInfo; + BaseFileName: string; + DestFileName: string; + DestFileProp: TSvnFileProp; i: Integer; function CreatePropInfo(const BaseDir: string): TSvnPropInfo; @@ -238,9 +241,13 @@ var end; for i := 0 to SourcePropInfo.FileCount-1 do begin - if Copy(SourcePropInfo[i].FileName, length(FSourceWC)+1, 4000) <> Copy(DestPropInfo[i].FileName, Length(FDestWC)+1, 4000) then begin + BaseFileName := Copy(SourcePropInfo[i].FileName, length(FSourceWC)+1, 4000); + DestFileName := FDestWC + BaseFileName; + DestFileProp := DestPropInfo.GetFileItem(DestFileName); + + if BaseFileName <> Copy(DestFileProp.FileName, Length(FDestWC)+1, 4000) then begin writeln('FileName mismatch: ', - SourcePropInfo[i].FileName, '<>', DestPropInfo[i].FileName); + SourcePropInfo[i].FileName, '<>', DestFileProp.FileName); halt(3); end; CopyFileProp(SourcePropInfo[i], DestPropInfo[i]); @@ -274,14 +281,18 @@ var end; begin - SourceHead := GetRevision('-rHEAD '+FSourceWC); - writeln(FSourceWC, ' HEAD at revision ', SourceHead); + try + SourceHead := GetRevision('-rHEAD '+FSourceWC); + writeln(FSourceWC, ' HEAD at revision ', SourceHead); - Revision := GetRevision('-rHEAD '+FDestWC); - writeln(FDestWC, ' HEAD at revision ', Revision); + Revision := GetRevision('-rHEAD '+FDestWC); + writeln(FDestWC, ' HEAD at revision ', Revision); - DestRoot := GetRepositoryRoot(FDestWC); - writeln('------'); + DestRoot := GetRepositoryRoot(FDestWC); + writeln('------'); + except + halt(9); + end; XmlOutput := TMemoryStream.Create; SvnLog := TSvnLog.Create; diff --git a/components/svn/svnclasses.pas b/components/svn/svnclasses.pas index 67d00bcab..b0366196c 100644 --- a/components/svn/svnclasses.pas +++ b/components/svn/svnclasses.pas @@ -189,6 +189,7 @@ type FProperties: TStrings; public constructor Create; + constructor Create(const AFileName: string); destructor Destroy; override; property FileName: string read FFileName; property Properties: TStrings read FProperties; @@ -198,15 +199,17 @@ type TSvnPropInfo = class private - FFiles: TFPObjectList; + FFiles: TFPHashObjectList; function GetFile(index: integer): TSvnFileProp; function GetFileCount: integer; + function ContainsFile(const AFileName: string) : boolean; public constructor Create; destructor Destroy; override; procedure LoadFromStream(s: TStream); procedure LoadFromFile(FileName: string); procedure LoadForFiles(FileNames: TStrings); + function GetFileItem(const s: string): TSvnFileProp; property FileItem[index: integer]: TSvnFileProp read GetFile; default; property FileCount: integer read GetFileCount; end; @@ -561,6 +564,12 @@ begin FProperties := TStringList.Create; end; +constructor TSvnFileProp.Create(const AFileName: string); +begin + Create; + FFileName := AFileName; +end; + destructor TSvnFileProp.Destroy; begin FProperties.Free; @@ -579,9 +588,14 @@ begin Result := FFiles.Count; end; +function TSvnPropInfo.ContainsFile(const AFileName: string): boolean; +begin + Result := true; +end; + constructor TSvnPropInfo.Create; begin - FFiles := TFPObjectList.Create(true); + FFiles := TFPHashObjectList.Create(true); end; destructor TSvnPropInfo.Destroy; @@ -609,11 +623,10 @@ begin while (i<Lines.Count) do begin Line := Lines[i]; if copy(Line, 1, length(PropertiesOn))=PropertiesOn then begin - FileProp := TSvnFileProp.Create; QuotePos := PosEx('''', Line, Length(PropertiesOn)+2); - FileProp.FFileName := - Copy(Line, Length(PropertiesOn)+2, QuotePos - Length(PropertiesOn)-2); - FFiles.Add(FileProp); + FileProp := TSvnFileProp.Create( + Copy(Line, Length(PropertiesOn)+2, QuotePos - Length(PropertiesOn)-2)); + FFiles.Add(FileProp.FileName, FileProp); inc(i); while (i<Lines.Count) do begin @@ -664,10 +677,20 @@ begin ExecuteSvnCommand('proplist -v' + Files, Output); Output.Position := 0; LoadFromStream(Output); + for i := 0 to FileNames.Count -1 do begin + if FFiles.FindIndexOf(FileNames[i])<0 then begin + FFiles.Add(FileNames[i], TSvnFileProp.Create(FileNames[i])); + end; + end; finally Output.Free; end; end; +function TSvnPropInfo.GetFileItem(const s: string): TSvnFileProp; +begin + Result := TSvnFileProp(FFiles.Find(s)); +end; + end. diff --git a/components/svn/test/testsvnclasses.pas b/components/svn/test/testsvnclasses.pas index 1cdb597e8..1d68db3ba 100644 --- a/components/svn/test/testsvnclasses.pas +++ b/components/svn/test/testsvnclasses.pas @@ -272,16 +272,20 @@ procedure TTestSvnClasses.TestPropListLoadForFiles; var SvnPropInfo: TSvnPropInfo; FileNames: TStrings; + i : integer; begin FileNames:= TStringList.Create; FileNames.Add('testsvnclasses.pas'); + FileNames.Add(ExtractFileDir(ParamStr(0))); FileNames.Add('fpcunitsvnpkg.lpi'); SvnPropInfo := TSvnPropInfo.Create; try SvnPropInfo.LoadForFiles(FileNames); - AssertEquals('Wrong number of files', 2, SvnPropInfo.FileCount); - AssertEquals('Wrong file name', FileNames[0], SvnPropInfo[0].FileName); - AssertEquals('Wrong file name', FileNames[1], SvnPropInfo[1].FileName); + AssertEquals('Wrong number of files', FileNames.Count, SvnPropInfo.FileCount); + for i := 0 to FileNames.Count-1 do begin + AssertNotNull('File name missing: '+ FileNames[i], + SvnPropInfo.GetFileItem(FileNames[i])); + end; finally FileNames.Free; SvnPropInfo.Free; diff --git a/components/svn/test/testsvncommand.pas b/components/svn/test/testsvncommand.pas index ff5161984..a01d088e9 100644 --- a/components/svn/test/testsvncommand.pas +++ b/components/svn/test/testsvncommand.pas @@ -29,7 +29,7 @@ begin XmlOutput:= TMemoryStream.Create; SvnExitCode := ExecuteSvnCommand('log --xml -rHEAD', XmlOutput); AssertEquals('Unexpected exit code', 0, SvnExitCode); - AssertTrue('No XmlOuput', XmlOutput.Size>0) + AssertTrue('No XmlOutput', XmlOutput.Size>0) finally XmlOutput.Free; end;