source: trunk/SVNZero.lpr

Last change on this file was 11, checked in by chronos, 19 months ago
  • Modified: Remove pristine files instead of zero their content.
File size: 2.9 KB
Line 
1program SVNZero;
2
3uses
4 {$IFDEF UNIX}cthreads,{$ENDIF}
5 Interfaces, // this includes the LCL widgetset
6 Classes, SysUtils, CustApp, USubversion, USvnZero, UTestCases, UExecute,
7 UTestCase;
8
9type
10
11 { TSvnZeroApp }
12
13 TSvnZeroApp = class(TCustomApplication)
14 protected
15 procedure DoRun; override;
16 private
17 procedure NormalRun;
18 public
19 SvnZero: TSvnZero;
20 constructor Create(TheOwner: TComponent); override;
21 destructor Destroy; override;
22 procedure WriteHelp; virtual;
23 end;
24
25{ TSvnZeroApp }
26
27procedure TSvnZeroApp.DoRun;
28var
29 I: Integer;
30begin
31 if HasOption('print') then begin
32 SvnZero.PrintOutput := True;
33 end;
34 if HasOption('t', 'test') then begin
35 with TTestCases.Create do
36 try
37 AddNew('Add', TTestCaseAdd);
38 AddNew('Update', TTestCaseUpdate);
39 AddNew('Modify', TTestCaseModify);
40 AddNew('Delete', TTestCaseDelete);
41 AddNew('Merge', TTestCaseMerge);
42 AddNew('Update multiple', TTestCaseUpdateMultiple);
43 AddNew('Delete update', TTestCaseDeleteUpdate);
44 AddNew('Delete update duplicate files', TTestCaseDeleteUpdateDuplicateFiles);
45
46 for I := 0 to Count - 1 do
47 if Items[I] is TTestCaseSvn then begin
48 TTestCaseSvn(Items[I]).Subversion.PrintOutput := SvnZero.PrintOutput;
49 TTestCaseSvn(Items[I]).Subversion.PrintCommand := SvnZero.PrintOutput;
50 end;
51 Run;
52 finally
53 Free;
54 end;
55 end else begin
56 NormalRun;
57 end;
58
59(* // quick check parameters
60 ErrorMsg := CheckOptions('h', 'help');
61 if ErrorMsg <> '' then begin
62 ShowException(Exception.Create(ErrorMsg));
63 Terminate;
64 Exit;
65 end;
66
67 // parse parameters
68 if HasOption('h', 'help') then begin
69 WriteHelp;
70 Terminate;
71 Exit;
72 end;
73 *)
74
75 // stop program loop
76 Terminate;
77end;
78
79procedure TSvnZeroApp.NormalRun;
80var
81 Params: TStringArray;
82 I: Integer;
83 J: Integer;
84begin
85 Params := Default(TStringArray);
86 SetLength(Params, ParamCount);
87 J := 0;
88 for I := 0 to ParamCount - 1 do begin
89 if GetParams(I + 1) <> '--print' then begin
90 Params[J] := GetParams(I + 1);
91 Inc(J);
92 end;
93 end;
94 SetLength(Params, J);
95
96 SVNZero.ExecuteOutput(Params);
97end;
98
99constructor TSvnZeroApp.Create(TheOwner: TComponent);
100begin
101 inherited;
102 StopOnException := True;
103 SvnZero := TSvnZero.Create;
104end;
105
106destructor TSvnZeroApp.Destroy;
107begin
108 FreeAndNil(SvnZero);
109 inherited;
110end;
111
112procedure TSvnZeroApp.WriteHelp;
113begin
114 { add your help code here }
115 WriteLn('Usage: ', ExeName, ' -h');
116end;
117
118{$if declared(UseHeapTrace)}
119const
120 HeapTraceLog = 'heaptrclog.trc';
121{$ENDIF}
122
123var
124 Application: TSvnZeroApp;
125
126{$R *.res}
127
128begin
129 {$if declared(UseHeapTrace)}
130 DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
131 SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
132 {$ENDIF}
133
134 Application := TSvnZeroApp.Create(nil);
135 Application.Title := 'SVN Zero';
136 Application.Run;
137 Application.Free;
138end.
139
Note: See TracBrowser for help on using the repository browser.