1 | unit UCVS;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, UVCS, UBackend;
|
---|
9 |
|
---|
10 | type
|
---|
11 |
|
---|
12 | { TBackendSubversion }
|
---|
13 |
|
---|
14 | TBackendCVS = class(TBackend)
|
---|
15 | constructor Create;
|
---|
16 | function IsWorkingCopy(Directory: string): Boolean; override;
|
---|
17 | end;
|
---|
18 |
|
---|
19 |
|
---|
20 | { TCVS }
|
---|
21 |
|
---|
22 | TCVS = class(TWorkingCopy)
|
---|
23 | protected
|
---|
24 | procedure Execute(Parameters: array of string);
|
---|
25 | public
|
---|
26 | procedure Checkout; override;
|
---|
27 | procedure Update; override;
|
---|
28 | procedure CleanUp; override;
|
---|
29 | procedure Commit(Message: TStrings); override;
|
---|
30 | procedure Move(Source, Dest: string); override;
|
---|
31 | procedure Merge; override;
|
---|
32 | procedure Add(FileName: string); override;
|
---|
33 | procedure Remove(FileName: string); override;
|
---|
34 | procedure GetStatus(FileName: string; Status: TFileStatusList); override;
|
---|
35 | end;
|
---|
36 |
|
---|
37 | { TRepositoryCVS }
|
---|
38 |
|
---|
39 | TRepositoryCVS = class(TRepository)
|
---|
40 | protected
|
---|
41 | procedure Execute(Parameters: array of string);
|
---|
42 | public
|
---|
43 | procedure Init; override;
|
---|
44 | end;
|
---|
45 |
|
---|
46 |
|
---|
47 | implementation
|
---|
48 |
|
---|
49 | { TRepositoryCVS }
|
---|
50 |
|
---|
51 | procedure TRepositoryCVS.Execute(Parameters: array of string);
|
---|
52 | begin
|
---|
53 | ExecuteProcess('/usr/bin/cvs', Parameters);
|
---|
54 | end;
|
---|
55 |
|
---|
56 | procedure TRepositoryCVS.Init;
|
---|
57 | begin
|
---|
58 | Execute(['-d ' + GetCurrentDir + DirectorySeparator + Path, 'init']);
|
---|
59 | end;
|
---|
60 |
|
---|
61 | { TBackendCVS }
|
---|
62 |
|
---|
63 | constructor TBackendCVS.Create;
|
---|
64 | begin
|
---|
65 | Name := 'CVS';
|
---|
66 | HomePage := 'http://www.nongnu.org/cvs/';
|
---|
67 | WorkingCopyClass := TCVS;
|
---|
68 | RepositoryClass := TRepositoryCVS;
|
---|
69 | end;
|
---|
70 |
|
---|
71 | function TBackendCVS.IsWorkingCopy(Directory: string): Boolean;
|
---|
72 | begin
|
---|
73 | Result := DirectoryExists(Directory + DirectorySeparator + 'CVS');
|
---|
74 | end;
|
---|
75 |
|
---|
76 | { TCVS }
|
---|
77 |
|
---|
78 | procedure TCVS.Execute(Parameters: array of string);
|
---|
79 | begin
|
---|
80 | EnvVars.Values['CVSROOT'] := GetCurrentDir + DirectorySeparator + Path;
|
---|
81 | ExecuteProcess('/usr/bin/cvs', Parameters);
|
---|
82 | end;
|
---|
83 |
|
---|
84 | procedure TCVS.Checkout;
|
---|
85 | begin
|
---|
86 | Execute(['checkout', RepositoryURL, Path]);
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TCVS.Update;
|
---|
90 | begin
|
---|
91 | Execute(['update']);
|
---|
92 | end;
|
---|
93 |
|
---|
94 | procedure TCVS.CleanUp;
|
---|
95 | begin
|
---|
96 | Execute(['cleanup']);
|
---|
97 | end;
|
---|
98 |
|
---|
99 | procedure TCVS.Commit(Message: TStrings);
|
---|
100 | begin
|
---|
101 | Execute(['commit', '-m "' + Message.Text + '"']);
|
---|
102 | end;
|
---|
103 |
|
---|
104 | procedure TCVS.Move(Source, Dest: string);
|
---|
105 | begin
|
---|
106 | // CVS doesn't support moving files and directories
|
---|
107 | RenameFile(Source, Dest);
|
---|
108 | Execute(['rm', Source]);
|
---|
109 | Execute(['add', Dest]);
|
---|
110 | end;
|
---|
111 |
|
---|
112 | procedure TCVS.Merge;
|
---|
113 | begin
|
---|
114 | Execute(['merge']);
|
---|
115 | end;
|
---|
116 |
|
---|
117 | procedure TCVS.Add(FileName: string);
|
---|
118 | begin
|
---|
119 | Execute(['add', FileName]);
|
---|
120 | end;
|
---|
121 |
|
---|
122 | procedure TCVS.Remove(FileName: string);
|
---|
123 | begin
|
---|
124 | DeleteFile(FileName);
|
---|
125 | Execute(['rm', FileName]);
|
---|
126 | end;
|
---|
127 |
|
---|
128 | procedure TCVS.GetStatus(FileName: string; Status: TFileStatusList);
|
---|
129 | begin
|
---|
130 | Status.Clear;
|
---|
131 | Execute(['status']);
|
---|
132 |
|
---|
133 | end;
|
---|
134 |
|
---|
135 | end.
|
---|
136 |
|
---|