Changeset 3 for trunk/SVNZero.lpr
- Timestamp:
- Mar 2, 2022, 1:22:13 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SVNZero.lpr
r1 r3 7 7 cthreads, 8 8 {$ENDIF} 9 Classes, SysUtils, CustApp, USubversion 9 Classes, SysUtils, CustApp, USubversion, UTest, USvnZero 10 10 { you can add units after this }; 11 11 12 12 type 13 13 14 { TSvnZero }14 { TSvnZeroApp } 15 15 16 TSvnZero = class(TCustomApplication)16 TSvnZeroApp = class(TCustomApplication) 17 17 protected 18 18 procedure DoRun; override; 19 function CheckErrorOutput(Text: string): Boolean; 19 private 20 procedure NormalRun; 20 21 public 21 S ubversion: TSubversion;22 SvnZero: TSvnZero; 22 23 constructor Create(TheOwner: TComponent); override; 23 24 destructor Destroy; override; … … 27 28 { TSvnZero } 28 29 29 procedure TSvnZero.DoRun; 30 var 31 StandardOutput: string; 32 Params: array of string; 33 I: Integer; 30 procedure TSvnZeroApp.DoRun; 34 31 begin 35 StandardOutput := ''; 36 SetLength(Params, ParamCount); 37 for I := 0 to ParamCount - 1 do 38 Params[I] := GetParams(I + 1); 39 40 while True do begin 41 Subversion.Execute(Params); 42 StandardOutput := StandardOutput + Subversion.StandardOutput; 43 if CheckErrorOutput(Subversion.ErrorOutput) then begin 44 end else Break; 32 if HasOption('t', 'test') then begin 33 with TTest.Create do 34 try 35 Run; 36 finally 37 Free; 38 end; 39 end else begin 40 NormalRun; 45 41 end; 46 if StandardOutput <>'' then Write(StandardOutput);47 if Subversion.ErrorOutput <>'' then Write(Subversion.ErrorOutput);48 Subversion.ZeroPristine;49 42 50 43 (* // quick check parameters … … 62 55 Exit; 63 56 end; 64 65 { add your program here }66 57 *) 67 58 … … 70 61 end; 71 62 72 function TSvnZero.CheckErrorOutput(Text: string): Boolean;63 procedure TSvnZeroApp.NormalRun; 73 64 var 74 FileName: string;65 Params: TStringArray; 75 66 I: Integer; 76 67 begin 77 Result := False; 78 if Pos(': Checksum mismatch', Text) > 0 then begin 79 I := Pos('''', Text); 80 if I > 0 then begin 81 FileName := Copy(Text, I + 1, MaxInt); 82 I := Pos('''', FileName); 83 if I > 0 then 84 Delete(FileName, I, MaxInt); 68 Params := Default(TStringArray); 69 SetLength(Params, ParamCount); 70 for I := 0 to ParamCount - 1 do 71 Params[I] := GetParams(I + 1); 85 72 86 Subversion.Execute(['-r', '0', 'update', FileName]); 87 Subversion.Execute(['cleanup']); 88 Result := True; 89 end; 90 end; 73 SVNZero.ExecuteOutput(Params); 91 74 end; 92 75 93 constructor TSvnZero .Create(TheOwner: TComponent);76 constructor TSvnZeroApp.Create(TheOwner: TComponent); 94 77 begin 95 78 inherited; 96 79 StopOnException := True; 97 S ubversion := TSubversion.Create;80 SvnZero := TSvnZero.Create; 98 81 end; 99 82 100 destructor TSvnZero .Destroy;83 destructor TSvnZeroApp.Destroy; 101 84 begin 102 FreeAndNil(S ubversion);85 FreeAndNil(SvnZero); 103 86 inherited; 104 87 end; 105 88 106 procedure TSvnZero .WriteHelp;89 procedure TSvnZeroApp.WriteHelp; 107 90 begin 108 91 { add your help code here } 109 writeln('Usage: ', ExeName, ' -h');92 WriteLn('Usage: ', ExeName, ' -h'); 110 93 end; 111 94 … … 116 99 117 100 var 118 Application: TSvnZero ;101 Application: TSvnZeroApp; 119 102 begin 120 103 {$if declared(UseHeapTrace)} … … 123 106 {$ENDIF} 124 107 125 Application := TSvnZero .Create(nil);108 Application := TSvnZeroApp.Create(nil); 126 109 Application.Title := 'SVN Zero'; 127 110 Application.Run;
Note:
See TracChangeset
for help on using the changeset viewer.