Changeset 11
- Timestamp:
- Nov 2, 2022, 12:00:09 AM (2 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 svnzero.dbg 4 4 SVNZero.lps 5 SVNZero.res 5 6 heaptrclog.trc 6 7 Languages/*.mo
-
- Property svn:ignore
-
trunk/Install/deb/debian/control
r9 r11 9 9 Package: svnzero 10 10 Architecture: any 11 Depends: ${shlibs:Depends}, ${misc:Depends}, libsqlite3 11 Depends: ${shlibs:Depends}, ${misc:Depends}, libsqlite3-0 12 12 Description: Subversion zero pristine wrapper. 13 13 HomePage: https://app.zdechov.net/svnzero -
trunk/SVNZero.lpr
r10 r11 43 43 AddNew('Delete update', TTestCaseDeleteUpdate); 44 44 AddNew('Delete update duplicate files', TTestCaseDeleteUpdateDuplicateFiles); 45 45 46 for I := 0 to Count - 1 do 46 47 if Items[I] is TTestCaseSvn then begin -
trunk/USvnZero.pas
r9 r11 4 4 5 5 uses 6 Classes, SysUtils, FileUtil, USubversion ;6 Classes, SysUtils, FileUtil, USubversion, UCommon; 7 7 8 8 type … … 18 18 function CheckErrorOutput(Text: string): Boolean; 19 19 function GetFileInfoByMd5(Md5Hash: string): TSubversionInfo; 20 function GetFileInfoBySha1(Sha1Hash: string): TSubversionInfo; 20 21 procedure ZeroPristine; 21 22 procedure RestorePristine; … … 48 49 Files: TStrings; 49 50 I: Integer; 50 Empty: TStringList;51 51 Dir: string; 52 52 FileName: string; … … 54 54 begin 55 55 ZeroedFilesCount := 0; 56 Empty := TStringList.Create; 56 Dir := GetPristineDir('.'); 57 if DirectoryExists(Dir) then 57 58 try 58 Dir := GetPristineDir('.'); 59 if DirectoryExists(Dir) then 60 try 61 Files := FindAllFiles(Dir, '*' + SvnBaseExt); 62 for I := 0 to Files.Count - 1 do begin 63 FileName := Files[I]; 64 if FileSize(FileName) > 0 then 65 begin 66 MakeFileWriteable(FileName); 67 Empty.SaveToFile(FileName); 68 Inc(ZeroedFilesCount); 69 end; 70 end; 71 finally 72 Files.Free; 59 Files := FindAllFiles(Dir, '*' + SvnBaseExt); 60 for I := 0 to Files.Count - 1 do begin 61 FileName := Files[I]; 62 DeleteFile(FileName); 63 MakeFileWriteable(FileName); 64 Inc(ZeroedFilesCount); 73 65 end; 74 66 finally 75 Empty.Free;67 Files.Free; 76 68 end; 77 69 //StandardOutput := StandardOutput + Format(SZeroedFilesCount, [ZeroedFilesCount]) + LineEnding; … … 183 175 Info: TSubversionInfo; 184 176 Md5Hash: string; 177 Sha1Hash: string; 185 178 const 186 179 StartText = 'expected:'; 180 StartText2 = 'svn: E000002: Can''t open file '''; 187 181 begin 188 182 Result := False; 189 if Pos(': Checksum mismatch', Text) > 0 then begin 183 I := Pos(StartText2, Text); 184 if I > 0 then begin 185 Sha1Hash := Copy(Text, I + Length(StartText2), MaxInt); 186 I := Pos('.svn-base', Sha1Hash); 187 if I > 0 then 188 Delete(Sha1Hash, I, MaxInt); 189 I := LastPos(DirectorySeparator, Sha1Hash); 190 if I > 0 then 191 Delete(Sha1Hash, 1, I); 192 193 Info := GetFileInfoBySha1(Sha1Hash); 194 ExportedFileName := GetSvnDir('.') + DirectorySeparator + 'tmp' + 195 DirectorySeparator + 'ExportedFile.bin'; 196 PristineFileName := GetPristineDir('.') + DirectorySeparator + Copy(Info.Checksum, 1, 2) + 197 DirectorySeparator + Info.Checksum + '.svn-base'; 198 Subversion.Execute(['export', '-r', Info.Revision, '--force', Info.URL, ExportedFileName]); 199 MakeFileWriteable(PristineFileName); 200 CopyFile(ExportedFileName, PristineFileName); 201 Subversion.Execute(['cleanup']); 202 Result := True; 203 end; 204 205 (* if Pos(': Checksum mismatch', Text) > 0 then begin 190 206 I := Pos(StartText, Text); 191 207 if I > 0 then begin … … 206 222 Result := True; 207 223 end; 208 209 224 { I := Pos('''', Text); 210 225 if I > 0 then begin … … 228 243 } 229 244 end; 245 *) 230 246 end; 231 247 … … 273 289 end; 274 290 291 function TSvnZero.GetFileInfoBySha1(Sha1Hash: string): TSubversionInfo; 292 var 293 Database: TSQLite3Database; 294 Statement: TSQLite3Statement; 295 begin 296 Database := TSQLite3Database.Create; 297 try 298 Database.Open(GetSvnDir('.') + DirectorySeparator + 'wc.db'); 299 Result.Checksum := Sha1Hash; 300 301 Statement := Database.Prepare('SELECT repos_path,changed_revision FROM NODES WHERE checksum="$sha1$' + Result.Checksum + '" LIMIT 1'); 302 try 303 while Statement.Step = SQLITE_ROW do begin 304 Result.Path := Statement.ColumnText(0); 305 Result.Revision := Statement.ColumnText(1); 306 end; 307 finally 308 Statement.Free; 309 end; 310 311 Statement := Database.Prepare('SELECT root FROM REPOSITORY LIMIT 1'); 312 try 313 while Statement.Step = SQLITE_ROW do begin 314 Result.URL := Statement.ColumnText(0) + '/' + Result.Path; 315 end; 316 finally 317 Statement.Free; 318 end; 319 320 if Result.Checksum.StartsWith('$sha1$') then 321 Result.Checksum := Copy(Result.Checksum, 7); 322 finally 323 Database.Free; 324 end; 325 end; 326 275 327 end. 276 328
Note:
See TracChangeset
for help on using the changeset viewer.