1 | program SVNZero;
|
---|
2 |
|
---|
3 | uses
|
---|
4 | {$IFDEF UNIX}cthreads,{$ENDIF}
|
---|
5 | Interfaces, // this includes the LCL widgetset
|
---|
6 | Classes, SysUtils, CustApp, USubversion, USvnZero, UTestCases, UExecute,
|
---|
7 | UTestCase;
|
---|
8 |
|
---|
9 | type
|
---|
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 |
|
---|
27 | procedure TSvnZeroApp.DoRun;
|
---|
28 | var
|
---|
29 | I: Integer;
|
---|
30 | begin
|
---|
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;
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TSvnZeroApp.NormalRun;
|
---|
80 | var
|
---|
81 | Params: TStringArray;
|
---|
82 | I: Integer;
|
---|
83 | J: Integer;
|
---|
84 | begin
|
---|
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);
|
---|
97 | end;
|
---|
98 |
|
---|
99 | constructor TSvnZeroApp.Create(TheOwner: TComponent);
|
---|
100 | begin
|
---|
101 | inherited;
|
---|
102 | StopOnException := True;
|
---|
103 | SvnZero := TSvnZero.Create;
|
---|
104 | end;
|
---|
105 |
|
---|
106 | destructor TSvnZeroApp.Destroy;
|
---|
107 | begin
|
---|
108 | FreeAndNil(SvnZero);
|
---|
109 | inherited;
|
---|
110 | end;
|
---|
111 |
|
---|
112 | procedure TSvnZeroApp.WriteHelp;
|
---|
113 | begin
|
---|
114 | { add your help code here }
|
---|
115 | WriteLn('Usage: ', ExeName, ' -h');
|
---|
116 | end;
|
---|
117 |
|
---|
118 | {$if declared(UseHeapTrace)}
|
---|
119 | const
|
---|
120 | HeapTraceLog = 'heaptrclog.trc';
|
---|
121 | {$ENDIF}
|
---|
122 |
|
---|
123 | var
|
---|
124 | Application: TSvnZeroApp;
|
---|
125 |
|
---|
126 | {$R *.res}
|
---|
127 |
|
---|
128 | begin
|
---|
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;
|
---|
138 | end.
|
---|
139 |
|
---|