1 | unit USubversion;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Process, FileUtil, UExecute
|
---|
7 | {$IFDEF UNIX}, baseunix{$ENDIF};
|
---|
8 |
|
---|
9 | type
|
---|
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 |
|
---|
35 | procedure MakeFileWriteable(FileName: string);
|
---|
36 |
|
---|
37 |
|
---|
38 | implementation
|
---|
39 |
|
---|
40 | function TSubversion.GetInfo(Text: string): TSubversionInfo;
|
---|
41 | var
|
---|
42 | Index: Integer;
|
---|
43 | Lines: TStringList;
|
---|
44 | I: Integer;
|
---|
45 | Line: string;
|
---|
46 | Name: string;
|
---|
47 | Value: string;
|
---|
48 | begin
|
---|
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;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | { TSubversionAdmin }
|
---|
70 |
|
---|
71 | function TSubversionAdmin.GetExecutable: string;
|
---|
72 | begin
|
---|
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}
|
---|
81 | end;
|
---|
82 |
|
---|
83 | { TSubversion }
|
---|
84 |
|
---|
85 | function TSubversion.GetExecutable: string;
|
---|
86 | begin
|
---|
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}
|
---|
95 | end;
|
---|
96 |
|
---|
97 | procedure MakeFileWriteable(FileName: string);
|
---|
98 | var
|
---|
99 | {$IFDEF WINDOWS}
|
---|
100 | FileAttributes: Integer;
|
---|
101 | {$ENDIF}
|
---|
102 | {$IFDEF UNIX}
|
---|
103 | FileStat: stat;
|
---|
104 | {$ENDIF}
|
---|
105 | begin
|
---|
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}
|
---|
117 | end;
|
---|
118 |
|
---|
119 | end.
|
---|
120 |
|
---|