started classes to interpreted svn commands

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@88 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
vsnijders 2007-02-26 23:04:58 +00:00
parent 0a4411699c
commit f62ba9ec2d
7 changed files with 639 additions and 0 deletions

View File

@ -0,0 +1,199 @@
unit svnclasses;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
DOM, XMLRead;
type
TEntryKind = (ekUnknown, ekFile, ekDirectory);
{ TCommit }
TCommit = class
private
FAuthor: string;
FDate: string;
FRevision: integer;
public
procedure Clear;
property Author: string read FAuthor write FAuthor;
property Date: string read FDate write FDate;
property Revision: integer read FRevision write FRevision;
end;
{ TRepository }
TRepository = class
private
FUrl: string;
FUUID: string;
public
procedure Clear;
property URL: string read FUrl write FUrl;
property UUID: string read FUUID write FUUID;
end;
{ TEntry }
TEntry = class
private
FCommit: TCommit;
FKind: TEntryKind;
FPath: string;
FRepository: TRepository;
FRevision: integer;
FUrl: string;
procedure LoadFromNode(ANode: TDomNode);
public
constructor Create;
destructor Destroy; override;
procedure Clear;
property Commit: TCommit read FCommit;
property Kind: TEntryKind read FKind write FKind;
property Path: string read FPath write FPath;
property URL: string read FUrl write FUrl;
property Repository: TRepository read FRepository;
property Revision: integer read FRevision write FRevision;
end;
{ TSvnInfo }
TSvnInfo = class
private
FEntry: TEntry;
procedure LoadFromXml(ADoc: TXMLDocument);
public
constructor Create;
destructor Destroy; override;
procedure Clear;
procedure LoadFromStream(s: TStream);
procedure LoadFromFile(FileName: string);
property Entry: TEntry read FEntry;
end;
implementation
{ TSvnInfo }
procedure TSvnInfo.LoadFromXml(ADoc: TXMLDocument);
begin
Clear;
Entry.LoadFromNode(ADoc.DocumentElement.FindNode('entry'));
end;
constructor TSvnInfo.Create;
begin
inherited Create;
FEntry := TEntry.Create;
end;
destructor TSvnInfo.Destroy;
begin
FEntry.Free;
inherited Destroy;
end;
procedure TSvnInfo.Clear;
begin
FEntry.Clear;
end;
procedure TSvnInfo.LoadFromStream(s: TStream);
var
ADoc: TXMLDocument;
begin
ReadXMLFile(ADoc, s);
try
LoadFromXml(ADoc);
finally
ADoc.Free;
end;
end;
procedure TSvnInfo.LoadFromFile(FileName: string);
var
ADoc: TXMLDocument;
begin
ReadXMLFile(ADoc, FileName);
try
LoadFromXml(ADoc);
finally
ADoc.Free;
end;
end;
{ TEntry }
procedure TEntry.LoadFromNode(ANode: TDomNode);
var
EntryNode: TDomElement;
KindString: string;
UrlNode: TDomNode;
begin
if ANode=nil then exit;
if ANode.NodeType = ELEMENT_NODE then begin
EntryNode := TDomElement(ANode);
FRevision := StrToIntDef(EntryNode.GetAttribute('revision'),0);
FPath := EntryNode.GetAttribute('path');
KindString := EntryNode.GetAttribute('kind');
if KindString = 'file' then
FKind := ekFile
else if KindString = 'dir' then
FKind := ekDirectory
else
FKind := ekUnknown;
UrlNode := EntryNode.FindNode('url');
if assigned(UrlNode) then
FUrl := UrlNode.TextContent;
end;
end;
constructor TEntry.Create;
begin
inherited Create;
FCommit := TCommit.Create;
FRepository := TRepository.Create;
end;
destructor TEntry.Destroy;
begin
FCommit.Free;
FRepository.Free;
inherited Destroy;
end;
procedure TEntry.Clear;
begin
FPath := '';
FKind := ekUnknown;
FUrl := '';
FRevision := 0;
FCommit.Clear;
FRepository.Clear;
end;
{ TRepository }
procedure TRepository.Clear;
begin
FUrl := '';
FUUID := '';
end;
{ TCommit }
procedure TCommit.Clear;
begin
FAuthor := '';
FDate := '';
FRevision := 0;
end;
end.

40
components/svn/svnpkg.lpk Normal file
View File

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<CONFIG>
<Package Version="2">
<PathDelim Value="\"/>
<Name Value="svnpkg"/>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)\"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Files Count="1">
<Item1>
<Filename Value="svnclasses.pas"/>
<UnitName Value="svnclasses"/>
</Item1>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="1">
<Item1>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item1>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
</PublishOptions>
</Package>
</CONFIG>

20
components/svn/svnpkg.pas Normal file
View File

@ -0,0 +1,20 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit svnpkg;
interface
uses
svnclasses, LazarusPackageIntf;
implementation
procedure Register;
begin
end;
initialization
RegisterPackage('svnpkg', @Register);
end.

View File

@ -0,0 +1,289 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="5"/>
<General>
<MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
<ActiveEditorIndexAtStart Value="2"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
<Language Value=""/>
<CharSet Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="4">
<Item1>
<PackageName Value="svnpkg"/>
</Item1>
<Item2>
<PackageName Value="FPCUnitTestRunner"/>
</Item2>
<Item3>
<PackageName Value="LCL"/>
</Item3>
<Item4>
<PackageName Value="FCL"/>
</Item4>
</RequiredPackages>
<Units Count="12">
<Unit0>
<Filename Value="fpcunitsvnpkg.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="fpcunitsvnpkg"/>
<UsageCount Value="20"/>
</Unit0>
<Unit1>
<Filename Value="testsvnclasses.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="TestSvnClasses"/>
<CursorPos X="83" Y="36"/>
<TopLine Value="17"/>
<EditorIndex Value="0"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\..\..\..\lazarus\components\fpcunit\guitestrunner.pas"/>
<UnitName Value="GuiTestRunner"/>
<CursorPos X="1" Y="48"/>
<TopLine Value="29"/>
<EditorIndex Value="1"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="..\..\..\..\fpc\2.1\fcl\inc\fpcunit.pp"/>
<UnitName Value="fpcunit"/>
<CursorPos X="1" Y="446"/>
<TopLine Value="427"/>
<EditorIndex Value="9"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\svnclasses.pas"/>
<UnitName Value="svnclasses"/>
<CursorPos X="16" Y="173"/>
<TopLine Value="154"/>
<EditorIndex Value="2"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="info.xml"/>
<CursorPos X="64" Y="4"/>
<TopLine Value="1"/>
<EditorIndex Value="3"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
<SyntaxHighlighter Value="XML"/>
</Unit5>
<Unit6>
<Filename Value="..\..\..\..\fpc\2.1\fcl\xml\dom.pp"/>
<UnitName Value="DOM"/>
<CursorPos X="3" Y="1168"/>
<TopLine Value="1165"/>
<EditorIndex Value="4"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="..\..\..\..\fpcbuild\2.0.4\fpcsrc\packages\extra\gtk2\gtk+\gtk\gtksocket.inc"/>
<CursorPos X="74" Y="77"/>
<TopLine Value="58"/>
<EditorIndex Value="5"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="..\..\..\..\lazarus\lcl\interfaces\gtk2\gtk2extrah.inc"/>
<CursorPos X="47" Y="44"/>
<TopLine Value="25"/>
<EditorIndex Value="6"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
<Filename Value="..\..\..\..\fpcbuild\2.0.4\fpcsrc\packages\extra\gtk2\gtk+\gdk\gdkdrawable.inc"/>
<CursorPos X="94" Y="12"/>
<TopLine Value="1"/>
<EditorIndex Value="7"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="..\..\..\..\lazarus\lcl\interfaces\win32\win32winapi.inc"/>
<CursorPos X="33" Y="3164"/>
<TopLine Value="3145"/>
<EditorIndex Value="8"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit10>
<Unit11>
<Filename Value="..\..\..\..\fpc\2.1\rtl\win\wininc\ascdef.inc"/>
<CursorPos X="10" Y="268"/>
<TopLine Value="249"/>
<UsageCount Value="10"/>
</Unit11>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="80" Column="3" TopLine="58"/>
</Position1>
<Position2>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="82" Column="21" TopLine="46"/>
</Position2>
<Position3>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="43" Column="3" TopLine="41"/>
</Position3>
<Position4>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="124" Column="42" TopLine="106"/>
</Position4>
<Position5>
<Filename Value="..\..\..\..\fpc\2.1\fcl\xml\dom.pp"/>
<Caret Line="224" Column="37" TopLine="189"/>
</Position5>
<Position6>
<Filename Value="..\..\..\..\fpc\2.1\fcl\xml\dom.pp"/>
<Caret Line="94" Column="15" TopLine="75"/>
</Position6>
<Position7>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="124" Column="30" TopLine="102"/>
</Position7>
<Position8>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="130" Column="13" TopLine="111"/>
</Position8>
<Position9>
<Filename Value="..\..\..\..\fpc\2.1\fcl\xml\dom.pp"/>
<Caret Line="217" Column="40" TopLine="198"/>
</Position9>
<Position10>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="134" Column="30" TopLine="111"/>
</Position10>
<Position11>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="131" Column="48" TopLine="112"/>
</Position11>
<Position12>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="130" Column="1" TopLine="112"/>
</Position12>
<Position13>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="83" Column="46" TopLine="72"/>
</Position13>
<Position14>
<Filename Value="..\..\..\..\fpcbuild\2.0.4\fpcsrc\packages\extra\gtk2\gtk+\gtk\gtksocket.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position14>
<Position15>
<Filename Value="..\..\..\..\lazarus\lcl\interfaces\gtk2\gtk2extrah.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position15>
<Position16>
<Filename Value="..\..\..\..\fpcbuild\2.0.4\fpcsrc\packages\extra\gtk2\gtk+\gdk\gdkdrawable.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position16>
<Position17>
<Filename Value="..\..\..\..\lazarus\lcl\interfaces\win32\win32winapi.inc"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position17>
<Position18>
<Filename Value="..\..\..\..\lazarus\lcl\interfaces\win32\win32winapi.inc"/>
<Caret Line="3164" Column="33" TopLine="3145"/>
</Position18>
<Position19>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="89" Column="8" TopLine="72"/>
</Position19>
<Position20>
<Filename Value="..\..\..\..\lazarus\components\fpcunit\guitestrunner.pas"/>
<Caret Line="45" Column="36" TopLine="26"/>
</Position20>
<Position21>
<Filename Value="..\..\..\..\lazarus\components\fpcunit\guitestrunner.pas"/>
<Caret Line="47" Column="63" TopLine="28"/>
</Position21>
<Position22>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="55" Column="22" TopLine="36"/>
</Position22>
<Position23>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="103" Column="5" TopLine="60"/>
</Position23>
<Position24>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="33" Column="3" TopLine="31"/>
</Position24>
<Position25>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="17" Column="3" TopLine="15"/>
</Position25>
<Position26>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="185" Column="17" TopLine="25"/>
</Position26>
<Position27>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="174" Column="5" TopLine="131"/>
</Position27>
<Position28>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="182" Column="29" TopLine="156"/>
</Position28>
<Position29>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="60" Column="21" TopLine="36"/>
</Position29>
<Position30>
<Filename Value="..\svnclasses.pas"/>
<Caret Line="173" Column="11" TopLine="154"/>
</Position30>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="ECodetoolError"/>
</Item1>
<Item2>
<Name Value="EFOpenError"/>
</Item2>
<Item3>
<Name Value="EAssertionFailedError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,13 @@
program fpcunitsvnpkg;
{$mode objfpc}{$H+}
uses
Interfaces, Forms, GuiTestRunner, TestSvnClasses, svnpkg;
begin
Application.Initialize;
Application.CreateForm(TGuiTestRunner, TestRunner);
Application.Run;
end.

View File

@ -0,0 +1,18 @@
<?xml version="1.0" ?>
<info>
<entry kind="dir" path="." revision="10685">
<url>svn+ssh://www.freepascal.org/FPC/svn/lazarus/trunk</url>
<repository>
<root>svn+ssh://www.freepascal.org/FPC/svn/lazarus</root>
<uuid>4005530d-fff6-0310-9dd1-cebe43e6787f</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
</wc-info>
<commit revision="10685">
<author>jesus</author>
<date>2007-02-25T22:55:08.029980Z</date>
</commit>
</entry>
</info>

View File

@ -0,0 +1,60 @@
unit TestSvnClasses;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, fpcunit, testutils, testregistry,
svnclasses;
type
{ TTestSvnClasses }
TTestSvnClasses= class(TTestCase)
private
function GetInfoFileName: string;
published
procedure TestHookUp;
procedure TestLoadInfo;
end;
implementation
function TTestSvnClasses.GetInfoFileName: string;
begin
Result := ExtractFilePath(ParamStr(0)) + 'info.xml';
end;
procedure TTestSvnClasses.TestHookUp;
var
InfoFileName: string;
begin
InfoFileName := GetInfoFileName;
AssertTrue(InfoFileName + ' does not exist', FileExists(InfoFileName));
end;
procedure TTestSvnClasses.TestLoadInfo;
var
SvnInfo: TSvnInfo;
begin
SvnInfo := TSvnInfo.Create;
try
SvnInfo.LoadFromFile(GetInfoFileName);
AssertEquals('Wrong revision', 10685, SvnInfo.Entry.Revision);
AssertEquals('Wrong path', '.', SvnInfo.Entry.Path);
AssertEquals('Wrong kind', ord(ekDirectory), ord(SvnInfo.Entry.Kind));
AssertEquals('Wrong URL',
'svn+ssh://www.freepascal.org/FPC/svn/lazarus/trunk',
SvnInfo.Entry.URL);
finally
SvnInfo.Free;
end;
end;
initialization
RegisterTest(TTestSvnClasses);
end.