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
|
||||
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,6 +281,7 @@ var
|
||||
end;
|
||||
|
||||
begin
|
||||
try
|
||||
SourceHead := GetRevision('-rHEAD '+FSourceWC);
|
||||
writeln(FSourceWC, ' HEAD at revision ', SourceHead);
|
||||
|
||||
@ -282,6 +290,9 @@ begin
|
||||
|
||||
DestRoot := GetRepositoryRoot(FDestWC);
|
||||
writeln('------');
|
||||
except
|
||||
halt(9);
|
||||
end;
|
||||
XmlOutput := TMemoryStream.Create;
|
||||
|
||||
SvnLog := TSvnLog.Create;
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user