Changeset 13 for trunk/Units/UVCS.pas


Ignore:
Timestamp:
May 30, 2015, 1:02:36 PM (9 years ago)
Author:
chronos
Message:
  • Added: New test form where general functionality of selected backend can be tested.
  • Added: Basic git backend implementation.
  • Added: Project group form and ability to open/save group of projects as configuration to XML file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Units/UVCS.pas

    r11 r13  
    3636    procedure SetRepositoryURL(AValue: string);
    3737  protected
     38    EnvVars: TStringList;
    3839    procedure ExecuteProcess(Command: string; Parameters: array of string); virtual;
    3940    function GetNext(var Text: string; Separator: string): string;
    4041  public
     42    UserName: string;
     43    Password: string;
     44    Email: string;
    4145    ExecutionOutput: TStringList;
    4246    procedure Checkout; virtual;
     
    4852    procedure Refresh; virtual;
    4953    procedure Add(FileName: string); virtual;
     54    procedure Remove(FileName: string); virtual;
    5055    procedure GetLog(FileName: string; Log: TLogList); virtual;
    5156    constructor Create;
     
    5560  end;
    5661
     62  { TRepository }
     63
    5764  TRepository = class
     65  protected
     66    procedure ExecuteProcess(Command: string; Parameters: array of string); virtual;
     67  public
     68    ExecutionOutput: TStringList;
    5869    Path: string;
    59   end;
    60 
    61 
     70    procedure Init; virtual;
     71    constructor Create;
     72    destructor Destroy; override;
     73  end;
     74
     75
     76function URLFromDirectory(DirName: string; Relative: Boolean): string;
    6277
    6378implementation
     
    6681  UFormConsole;
    6782
    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);
     83function URLFromDirectory(DirName: string; Relative: Boolean): string;
     84begin
     85  Result := DirName;
     86  if Relative then Result := GetCurrentDirUTF8 + DirectorySeparator + Result;
     87  Result := 'file:///' + StringReplace(Result, DirectorySeparator, '/', [rfReplaceAll]);
     88end;
     89
     90{ TRepository }
     91
     92procedure TRepository.ExecuteProcess(Command: string;
     93  Parameters: array of string);
    9994begin
    10095  FormConsole.Executable := Command;
     
    107102end;
    108103
     104procedure TRepository.Init;
     105begin
     106
     107end;
     108
     109constructor TRepository.Create;
     110begin
     111  ExecutionOutput := TStringList.Create;
     112  Path := '';
     113end;
     114
     115destructor TRepository.Destroy;
     116begin
     117  FreeAndNil(ExecutionOutput);
     118  inherited Destroy;
     119end;
     120
     121{ TLogItem }
     122
     123constructor TLogItem.Create;
     124begin
     125  Messages := TStringList.Create;
     126  ChangedFiles := TStringList.Create;
     127end;
     128
     129destructor TLogItem.Destroy;
     130begin
     131  Messages.Free;
     132  ChangedFiles.Free;
     133  inherited Destroy;
     134end;
     135
     136{ TWorkingCopy }
     137
     138procedure TWorkingCopy.SetPath(AValue: string);
     139begin
     140  if FPath = AValue then Exit;
     141  FPath := AValue;
     142  Refresh;
     143end;
     144
     145procedure TWorkingCopy.SetRepositoryURL(AValue: string);
     146begin
     147  if FRepositoryURL=AValue then Exit;
     148  FRepositoryURL:=AValue;
     149end;
     150
     151procedure TWorkingCopy.ExecuteProcess(Command: string; Parameters: array of string);
     152begin
     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);
     161end;
     162
    109163function TWorkingCopy.GetNext(var Text: string; Separator: string): string;
    110164begin
     
    158212end;
    159213
     214procedure TWorkingCopy.Remove(FileName: string);
     215begin
     216
     217end;
     218
    160219procedure TWorkingCopy.GetLog(FileName: string; Log: TLogList);
    161220begin
     
    166225begin
    167226  ExecutionOutput := TStringList.Create;
     227  EnvVars := TStringList.Create;
    168228  FPath := '';
    169229  FRepositoryURL := '';
     
    172232destructor TWorkingCopy.Destroy;
    173233begin
     234  FreeAndNil(EnvVars);
    174235  FreeAndNil(ExecutionOutput);
    175236  inherited Destroy;
Note: See TracChangeset for help on using the changeset viewer.