You've already forked lazarus-ccr
fpsvnsync: fixed adding new directories (or files) with properties
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@154 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -186,6 +186,9 @@ var
|
|||||||
var
|
var
|
||||||
SourcePropInfo: TSvnPropInfo;
|
SourcePropInfo: TSvnPropInfo;
|
||||||
DestPropInfo: TSvnPropInfo;
|
DestPropInfo: TSvnPropInfo;
|
||||||
|
BaseFileName: string;
|
||||||
|
DestFileName: string;
|
||||||
|
DestFileProp: TSvnFileProp;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
|
||||||
function CreatePropInfo(const BaseDir: string): TSvnPropInfo;
|
function CreatePropInfo(const BaseDir: string): TSvnPropInfo;
|
||||||
@ -238,9 +241,13 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
for i := 0 to SourcePropInfo.FileCount-1 do begin
|
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: ',
|
writeln('FileName mismatch: ',
|
||||||
SourcePropInfo[i].FileName, '<>', DestPropInfo[i].FileName);
|
SourcePropInfo[i].FileName, '<>', DestFileProp.FileName);
|
||||||
halt(3);
|
halt(3);
|
||||||
end;
|
end;
|
||||||
CopyFileProp(SourcePropInfo[i], DestPropInfo[i]);
|
CopyFileProp(SourcePropInfo[i], DestPropInfo[i]);
|
||||||
@ -274,14 +281,18 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
SourceHead := GetRevision('-rHEAD '+FSourceWC);
|
try
|
||||||
writeln(FSourceWC, ' HEAD at revision ', SourceHead);
|
SourceHead := GetRevision('-rHEAD '+FSourceWC);
|
||||||
|
writeln(FSourceWC, ' HEAD at revision ', SourceHead);
|
||||||
|
|
||||||
Revision := GetRevision('-rHEAD '+FDestWC);
|
Revision := GetRevision('-rHEAD '+FDestWC);
|
||||||
writeln(FDestWC, ' HEAD at revision ', Revision);
|
writeln(FDestWC, ' HEAD at revision ', Revision);
|
||||||
|
|
||||||
DestRoot := GetRepositoryRoot(FDestWC);
|
DestRoot := GetRepositoryRoot(FDestWC);
|
||||||
writeln('------');
|
writeln('------');
|
||||||
|
except
|
||||||
|
halt(9);
|
||||||
|
end;
|
||||||
XmlOutput := TMemoryStream.Create;
|
XmlOutput := TMemoryStream.Create;
|
||||||
|
|
||||||
SvnLog := TSvnLog.Create;
|
SvnLog := TSvnLog.Create;
|
||||||
|
@ -189,6 +189,7 @@ type
|
|||||||
FProperties: TStrings;
|
FProperties: TStrings;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
|
constructor Create(const AFileName: string);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
property FileName: string read FFileName;
|
property FileName: string read FFileName;
|
||||||
property Properties: TStrings read FProperties;
|
property Properties: TStrings read FProperties;
|
||||||
@ -198,15 +199,17 @@ type
|
|||||||
|
|
||||||
TSvnPropInfo = class
|
TSvnPropInfo = class
|
||||||
private
|
private
|
||||||
FFiles: TFPObjectList;
|
FFiles: TFPHashObjectList;
|
||||||
function GetFile(index: integer): TSvnFileProp;
|
function GetFile(index: integer): TSvnFileProp;
|
||||||
function GetFileCount: integer;
|
function GetFileCount: integer;
|
||||||
|
function ContainsFile(const AFileName: string) : boolean;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
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);
|
procedure LoadForFiles(FileNames: TStrings);
|
||||||
|
function GetFileItem(const s: string): TSvnFileProp;
|
||||||
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;
|
||||||
@ -561,6 +564,12 @@ begin
|
|||||||
FProperties := TStringList.Create;
|
FProperties := TStringList.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
constructor TSvnFileProp.Create(const AFileName: string);
|
||||||
|
begin
|
||||||
|
Create;
|
||||||
|
FFileName := AFileName;
|
||||||
|
end;
|
||||||
|
|
||||||
destructor TSvnFileProp.Destroy;
|
destructor TSvnFileProp.Destroy;
|
||||||
begin
|
begin
|
||||||
FProperties.Free;
|
FProperties.Free;
|
||||||
@ -579,9 +588,14 @@ begin
|
|||||||
Result := FFiles.Count;
|
Result := FFiles.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSvnPropInfo.ContainsFile(const AFileName: string): boolean;
|
||||||
|
begin
|
||||||
|
Result := true;
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TSvnPropInfo.Create;
|
constructor TSvnPropInfo.Create;
|
||||||
begin
|
begin
|
||||||
FFiles := TFPObjectList.Create(true);
|
FFiles := TFPHashObjectList.Create(true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TSvnPropInfo.Destroy;
|
destructor TSvnPropInfo.Destroy;
|
||||||
@ -609,11 +623,10 @@ begin
|
|||||||
while (i<Lines.Count) do begin
|
while (i<Lines.Count) do begin
|
||||||
Line := Lines[i];
|
Line := Lines[i];
|
||||||
if copy(Line, 1, length(PropertiesOn))=PropertiesOn then begin
|
if copy(Line, 1, length(PropertiesOn))=PropertiesOn then begin
|
||||||
FileProp := TSvnFileProp.Create;
|
|
||||||
QuotePos := PosEx('''', Line, Length(PropertiesOn)+2);
|
QuotePos := PosEx('''', Line, Length(PropertiesOn)+2);
|
||||||
FileProp.FFileName :=
|
FileProp := TSvnFileProp.Create(
|
||||||
Copy(Line, Length(PropertiesOn)+2, QuotePos - Length(PropertiesOn)-2);
|
Copy(Line, Length(PropertiesOn)+2, QuotePos - Length(PropertiesOn)-2));
|
||||||
FFiles.Add(FileProp);
|
FFiles.Add(FileProp.FileName, FileProp);
|
||||||
inc(i);
|
inc(i);
|
||||||
while (i<Lines.Count) do begin
|
while (i<Lines.Count) do begin
|
||||||
|
|
||||||
@ -664,10 +677,20 @@ begin
|
|||||||
ExecuteSvnCommand('proplist -v' + Files, Output);
|
ExecuteSvnCommand('proplist -v' + Files, Output);
|
||||||
Output.Position := 0;
|
Output.Position := 0;
|
||||||
LoadFromStream(Output);
|
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
|
finally
|
||||||
Output.Free;
|
Output.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSvnPropInfo.GetFileItem(const s: string): TSvnFileProp;
|
||||||
|
begin
|
||||||
|
Result := TSvnFileProp(FFiles.Find(s));
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -272,16 +272,20 @@ procedure TTestSvnClasses.TestPropListLoadForFiles;
|
|||||||
var
|
var
|
||||||
SvnPropInfo: TSvnPropInfo;
|
SvnPropInfo: TSvnPropInfo;
|
||||||
FileNames: TStrings;
|
FileNames: TStrings;
|
||||||
|
i : integer;
|
||||||
begin
|
begin
|
||||||
FileNames:= TStringList.Create;
|
FileNames:= TStringList.Create;
|
||||||
FileNames.Add('testsvnclasses.pas');
|
FileNames.Add('testsvnclasses.pas');
|
||||||
|
FileNames.Add(ExtractFileDir(ParamStr(0)));
|
||||||
FileNames.Add('fpcunitsvnpkg.lpi');
|
FileNames.Add('fpcunitsvnpkg.lpi');
|
||||||
SvnPropInfo := TSvnPropInfo.Create;
|
SvnPropInfo := TSvnPropInfo.Create;
|
||||||
try
|
try
|
||||||
SvnPropInfo.LoadForFiles(FileNames);
|
SvnPropInfo.LoadForFiles(FileNames);
|
||||||
AssertEquals('Wrong number of files', 2, SvnPropInfo.FileCount);
|
AssertEquals('Wrong number of files', FileNames.Count, SvnPropInfo.FileCount);
|
||||||
AssertEquals('Wrong file name', FileNames[0], SvnPropInfo[0].FileName);
|
for i := 0 to FileNames.Count-1 do begin
|
||||||
AssertEquals('Wrong file name', FileNames[1], SvnPropInfo[1].FileName);
|
AssertNotNull('File name missing: '+ FileNames[i],
|
||||||
|
SvnPropInfo.GetFileItem(FileNames[i]));
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
FileNames.Free;
|
FileNames.Free;
|
||||||
SvnPropInfo.Free;
|
SvnPropInfo.Free;
|
||||||
|
@ -29,7 +29,7 @@ begin
|
|||||||
XmlOutput:= TMemoryStream.Create;
|
XmlOutput:= TMemoryStream.Create;
|
||||||
SvnExitCode := ExecuteSvnCommand('log --xml -rHEAD', XmlOutput);
|
SvnExitCode := ExecuteSvnCommand('log --xml -rHEAD', XmlOutput);
|
||||||
AssertEquals('Unexpected exit code', 0, SvnExitCode);
|
AssertEquals('Unexpected exit code', 0, SvnExitCode);
|
||||||
AssertTrue('No XmlOuput', XmlOutput.Size>0)
|
AssertTrue('No XmlOutput', XmlOutput.Size>0)
|
||||||
finally
|
finally
|
||||||
XmlOutput.Free;
|
XmlOutput.Free;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user