source: trunk/USubversion.pas

Last change on this file was 9, checked in by chronos, 21 months ago
  • Modified: Restore pristine files for deleted files with using information from subversion SQLite3 database.
File size: 2.5 KB
Line 
1unit USubversion;
2
3interface
4
5uses
6 Classes, SysUtils, Process, FileUtil, UExecute
7 {$IFDEF UNIX}, baseunix{$ENDIF};
8
9type
10 TSubversionInfo = record
11 Checksum: string;
12 Revision: string;
13 URL: string;
14 Path: string;
15 end;
16
17 { TSubversion }
18
19 TSubversion = class(TExecute)
20 private
21 protected
22 function GetExecutable: string; override;
23 public
24 function GetInfo(Text: string): TSubversionInfo;
25 end;
26
27 { TSubversionAdmin }
28
29 TSubversionAdmin = class(TExecute)
30 protected
31 function GetExecutable: string; override;
32 public
33 end;
34
35procedure MakeFileWriteable(FileName: string);
36
37
38implementation
39
40function TSubversion.GetInfo(Text: string): TSubversionInfo;
41var
42 Index: Integer;
43 Lines: TStringList;
44 I: Integer;
45 Line: string;
46 Name: string;
47 Value: string;
48begin
49 Lines := TStringList.Create;
50 try
51 Lines.Text := Text;
52 for I := 0 to Lines.Count - 1 do begin
53 Line := Trim(Lines[I]);
54 Index := Pos(':', Line);
55 if Index > 0 then begin
56 Name := Trim(Copy(Line, 1, Index - 1));
57 Value := Trim(Copy(Line, Index + 1, MaxInt));
58 if Name = 'Checksum' then Result.Checksum := Value
59 else if Name = 'Revision' then Result.Revision := Value
60 else if Name = 'Path' then Result.Path := Value
61 else if Name = 'URL' then Result.URL := Value;
62 end;
63 end;
64 finally
65 Lines.Free;
66 end;
67end;
68
69{ TSubversionAdmin }
70
71function TSubversionAdmin.GetExecutable: string;
72begin
73 {$IFDEF UNIX}
74 Result := '/usr/bin/svnadmin';
75 {$ENDIF}
76 {$IFDEF WINDOWS}
77 Result := 'c:\Program Files\Subversion\bin\svnadmin.exe';
78 if not FileExists(Result) then
79 Result := 'C:\Program Files\TortoiseSVN\bin\svnadmin.exe';
80 {$ENDIF}
81end;
82
83{ TSubversion }
84
85function TSubversion.GetExecutable: string;
86begin
87 {$IFDEF UNIX}
88 Result := '/usr/bin/svn';
89 {$ENDIF}
90 {$IFDEF WINDOWS}
91 Result := 'c:\Program Files\Subversion\bin\svn.exe';
92 if not FileExists(Result) then
93 Result := 'C:\Program Files\TortoiseSVN\bin\svn.exe';
94 {$ENDIF}
95end;
96
97procedure MakeFileWriteable(FileName: string);
98var
99 {$IFDEF WINDOWS}
100 FileAttributes: Integer;
101 {$ENDIF}
102 {$IFDEF UNIX}
103 FileStat: stat;
104 {$ENDIF}
105begin
106 {$IFDEF WINDOWS}
107 FileAttributes := FileGetAttr(FileName);
108 if (FileAttributes and faReadOnly) > 0 then
109 FileSetAttr(FileName, FileAttributes xor faReadOnly);
110 {$ENDIF}
111 {$IFDEF UNIX}
112 FileStat := default(stat);
113 fpstat(FileName, FileStat);
114 if (FileStat.st_mode and 200) = 0 then
115 fpchmod(FileName, FileStat.st_mode or 200);
116 {$ENDIF}
117end;
118
119end.
120
Note: See TracBrowser for help on using the repository browser.