source: trunk/Backends/CVS/UCVS.pas

Last change on this file was 15, checked in by chronos, 9 years ago
  • Added: Support for reading file status from working copy.
File size: 2.6 KB
Line 
1unit UCVS;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, UVCS, UBackend;
9
10type
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
47implementation
48
49{ TRepositoryCVS }
50
51procedure TRepositoryCVS.Execute(Parameters: array of string);
52begin
53 ExecuteProcess('/usr/bin/cvs', Parameters);
54end;
55
56procedure TRepositoryCVS.Init;
57begin
58 Execute(['-d ' + GetCurrentDir + DirectorySeparator + Path, 'init']);
59end;
60
61{ TBackendCVS }
62
63constructor TBackendCVS.Create;
64begin
65 Name := 'CVS';
66 HomePage := 'http://www.nongnu.org/cvs/';
67 WorkingCopyClass := TCVS;
68 RepositoryClass := TRepositoryCVS;
69end;
70
71function TBackendCVS.IsWorkingCopy(Directory: string): Boolean;
72begin
73 Result := DirectoryExists(Directory + DirectorySeparator + 'CVS');
74end;
75
76{ TCVS }
77
78procedure TCVS.Execute(Parameters: array of string);
79begin
80 EnvVars.Values['CVSROOT'] := GetCurrentDir + DirectorySeparator + Path;
81 ExecuteProcess('/usr/bin/cvs', Parameters);
82end;
83
84procedure TCVS.Checkout;
85begin
86 Execute(['checkout', RepositoryURL, Path]);
87end;
88
89procedure TCVS.Update;
90begin
91 Execute(['update']);
92end;
93
94procedure TCVS.CleanUp;
95begin
96 Execute(['cleanup']);
97end;
98
99procedure TCVS.Commit(Message: TStrings);
100begin
101 Execute(['commit', '-m "' + Message.Text + '"']);
102end;
103
104procedure TCVS.Move(Source, Dest: string);
105begin
106 // CVS doesn't support moving files and directories
107 RenameFile(Source, Dest);
108 Execute(['rm', Source]);
109 Execute(['add', Dest]);
110end;
111
112procedure TCVS.Merge;
113begin
114 Execute(['merge']);
115end;
116
117procedure TCVS.Add(FileName: string);
118begin
119 Execute(['add', FileName]);
120end;
121
122procedure TCVS.Remove(FileName: string);
123begin
124 DeleteFile(FileName);
125 Execute(['rm', FileName]);
126end;
127
128procedure TCVS.GetStatus(FileName: string; Status: TFileStatusList);
129begin
130 Status.Clear;
131 Execute(['status']);
132
133end;
134
135end.
136
Note: See TracBrowser for help on using the repository browser.