added TSvnPropInfo.LoadForFiles

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@114 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
vsnijders
2007-03-04 23:27:28 +00:00
parent e1c9c30365
commit 099366f18b
2 changed files with 75 additions and 0 deletions

View File

@ -153,6 +153,7 @@ type
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
function GetFileList: TStrings;
property Author: string read FAuthor write FAuthor; property Author: string read FAuthor write FAuthor;
property CommonPath: string read GetCommonPath; property CommonPath: string read GetCommonPath;
property Date: string read FDate write FDate; property Date: string read FDate write FDate;
@ -203,6 +204,7 @@ type
destructor Destroy; override; destructor Destroy; override;
procedure LoadFromStream(s: TStream); procedure LoadFromStream(s: TStream);
procedure LoadFromFile(FileName: string); procedure LoadFromFile(FileName: string);
procedure LoadForFiles(FileNames: TStrings);
property FileItem[index: integer]: TSvnFileProp read GetFile; default; property FileItem[index: integer]: TSvnFileProp read GetFile; default;
property FileCount: integer read GetFileCount; property FileCount: integer read GetFileCount;
end; end;
@ -458,6 +460,15 @@ begin
end; end;
end; end;
function TLogEntry.GetFileList: TStrings;
var
i: integer;
begin
Result := TStringList.Create;
for i:= 0 to PathCount -1 do
Result.Add(Path[i].Path);
end;
function TLogEntry.GetLogPathCount: integer; function TLogEntry.GetLogPathCount: integer;
begin begin
Result := FLogPaths.Count; Result := FLogPaths.Count;
@ -630,5 +641,24 @@ begin
end; end;
end; end;
procedure TSvnPropInfo.LoadForFiles(FileNames: TStrings);
var
Output: TMemoryStream;
Files: string;
i: integer;
begin
Output := TMemoryStream.Create;
try
Files := '';
for i := 0 to FileNames.Count-1 do
Files := Files + ' ' + FileNames[i];
ExecuteSvnCommand('proplist -v' + Files, Output);
Output.Position := 0;
LoadFromStream(Output);
finally
Output.Free;
end;
end;
end. end.

View File

@ -26,7 +26,9 @@ type
procedure TestLoadComplexLogPaths; procedure TestLoadComplexLogPaths;
procedure TestLoadLogTwice; procedure TestLoadLogTwice;
procedure TestLogCommonPath; procedure TestLogCommonPath;
procedure TestLogFiles;
procedure TestPropList; procedure TestPropList;
procedure TestPropListLoadForFiles;
end; end;
implementation implementation
@ -212,6 +214,29 @@ begin
end; end;
end; end;
procedure TTestSvnClasses.TestLogFiles;
var
SvnLog: TSvnLog;
Files: TStrings;
i: Integer;
begin
SvnLog := TSvnLog.Create;
Files := nil;
try
SvnLog.LoadFromFile(GetLogFileName);
AssertEquals('Wrong number of log entries', 6, SvnLog.LogEntryCount);
for i := 0 to SvnLog.LogEntryCount - 1 do begin
Files := SvnLog.LogEntry[i].GetFileList;
AssertEquals('Wrong number of files',
SvnLog.LogEntry[i].PathCount, Files.Count);
FreeAndNil(Files);
end;
finally
SvnLog.Free;
Files.Free
end;
end;
procedure TTestSvnClasses.TestPropList; procedure TTestSvnClasses.TestPropList;
var var
SvnPropInfo: TSvnPropInfo; SvnPropInfo: TSvnPropInfo;
@ -239,6 +264,26 @@ begin
end; end;
end; end;
procedure TTestSvnClasses.TestPropListLoadForFiles;
var
SvnPropInfo: TSvnPropInfo;
FileNames: TStrings;
begin
FileNames:= TStringList.Create;
FileNames.Add('testsvnclasses.pas');
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);
finally
FileNames.Free;
SvnPropInfo.Free;
end;
end;
initialization initialization
RegisterTest(TTestSvnClasses); RegisterTest(TTestSvnClasses);