Changeset 13 for trunk/Units/UVCS.pas
- Timestamp:
- May 30, 2015, 1:02:36 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Units/UVCS.pas
r11 r13 36 36 procedure SetRepositoryURL(AValue: string); 37 37 protected 38 EnvVars: TStringList; 38 39 procedure ExecuteProcess(Command: string; Parameters: array of string); virtual; 39 40 function GetNext(var Text: string; Separator: string): string; 40 41 public 42 UserName: string; 43 Password: string; 44 Email: string; 41 45 ExecutionOutput: TStringList; 42 46 procedure Checkout; virtual; … … 48 52 procedure Refresh; virtual; 49 53 procedure Add(FileName: string); virtual; 54 procedure Remove(FileName: string); virtual; 50 55 procedure GetLog(FileName: string; Log: TLogList); virtual; 51 56 constructor Create; … … 55 60 end; 56 61 62 { TRepository } 63 57 64 TRepository = class 65 protected 66 procedure ExecuteProcess(Command: string; Parameters: array of string); virtual; 67 public 68 ExecutionOutput: TStringList; 58 69 Path: string; 59 end; 60 61 70 procedure Init; virtual; 71 constructor Create; 72 destructor Destroy; override; 73 end; 74 75 76 function URLFromDirectory(DirName: string; Relative: Boolean): string; 62 77 63 78 implementation … … 66 81 UFormConsole; 67 82 68 { TLogItem } 69 70 constructor TLogItem.Create; 71 begin 72 Messages := TStringList.Create; 73 ChangedFiles := TStringList.Create; 74 end; 75 76 destructor TLogItem.Destroy; 77 begin 78 Messages.Free; 79 ChangedFiles.Free; 80 inherited Destroy; 81 end; 82 83 { TWorkingCopy } 84 85 procedure TWorkingCopy.SetPath(AValue: string); 86 begin 87 if FPath = AValue then Exit; 88 FPath := AValue; 89 Refresh; 90 end; 91 92 procedure TWorkingCopy.SetRepositoryURL(AValue: string); 93 begin 94 if FRepositoryURL=AValue then Exit; 95 FRepositoryURL:=AValue; 96 end; 97 98 procedure TWorkingCopy.ExecuteProcess(Command: string; Parameters: array of string); 83 function URLFromDirectory(DirName: string; Relative: Boolean): string; 84 begin 85 Result := DirName; 86 if Relative then Result := GetCurrentDirUTF8 + DirectorySeparator + Result; 87 Result := 'file:///' + StringReplace(Result, DirectorySeparator, '/', [rfReplaceAll]); 88 end; 89 90 { TRepository } 91 92 procedure TRepository.ExecuteProcess(Command: string; 93 Parameters: array of string); 99 94 begin 100 95 FormConsole.Executable := Command; … … 107 102 end; 108 103 104 procedure TRepository.Init; 105 begin 106 107 end; 108 109 constructor TRepository.Create; 110 begin 111 ExecutionOutput := TStringList.Create; 112 Path := ''; 113 end; 114 115 destructor TRepository.Destroy; 116 begin 117 FreeAndNil(ExecutionOutput); 118 inherited Destroy; 119 end; 120 121 { TLogItem } 122 123 constructor TLogItem.Create; 124 begin 125 Messages := TStringList.Create; 126 ChangedFiles := TStringList.Create; 127 end; 128 129 destructor TLogItem.Destroy; 130 begin 131 Messages.Free; 132 ChangedFiles.Free; 133 inherited Destroy; 134 end; 135 136 { TWorkingCopy } 137 138 procedure TWorkingCopy.SetPath(AValue: string); 139 begin 140 if FPath = AValue then Exit; 141 FPath := AValue; 142 Refresh; 143 end; 144 145 procedure TWorkingCopy.SetRepositoryURL(AValue: string); 146 begin 147 if FRepositoryURL=AValue then Exit; 148 FRepositoryURL:=AValue; 149 end; 150 151 procedure TWorkingCopy.ExecuteProcess(Command: string; Parameters: array of string); 152 begin 153 FormConsole.Executable := Command; 154 FormConsole.EnvironmentVariables.Assign(EnvVars); 155 FormConsole.Parameters.Clear; 156 FormConsole.Parameters.AddStrings(Parameters); 157 if DirectoryExistsUTF8(Path) then FormConsole.WorkingDir := Path 158 else FormConsole.WorkingDir := ''; 159 FormConsole.ShowModal; 160 ExecutionOutput.Assign(FormConsole.Log); 161 end; 162 109 163 function TWorkingCopy.GetNext(var Text: string; Separator: string): string; 110 164 begin … … 158 212 end; 159 213 214 procedure TWorkingCopy.Remove(FileName: string); 215 begin 216 217 end; 218 160 219 procedure TWorkingCopy.GetLog(FileName: string; Log: TLogList); 161 220 begin … … 166 225 begin 167 226 ExecutionOutput := TStringList.Create; 227 EnvVars := TStringList.Create; 168 228 FPath := ''; 169 229 FRepositoryURL := ''; … … 172 232 destructor TWorkingCopy.Destroy; 173 233 begin 234 FreeAndNil(EnvVars); 174 235 FreeAndNil(ExecutionOutput); 175 236 inherited Destroy;
Note:
See TracChangeset
for help on using the changeset viewer.