Changeset 9


Ignore:
Timestamp:
May 18, 2015, 11:49:39 PM (9 years ago)
Author:
chronos
Message:
  • Added: Simple Bazaar backend.\n* Added: Support for backends dynamic registration.\n* Added: Backend selection in checkout form.
Location:
trunk
Files:
5 added
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormCheckout.lfm

    r8 r9  
    11object FormCheckout: TFormCheckout
    22  Left = 833
    3   Height = 377
     3  Height = 417
    44  Top = 345
    5   Width = 826
     5  Width = 834
    66  Caption = 'Checkout'
    7   ClientHeight = 377
    8   ClientWidth = 826
     7  ClientHeight = 417
     8  ClientWidth = 834
     9  OnShow = FormShow
    910  LCLVersion = '1.5'
    1011  object GroupBox1: TGroupBox
    1112    Left = 8
    12     Height = 184
     13    Height = 232
    1314    Top = 8
    14     Width = 810
     15    Width = 818
    1516    Align = alTop
    1617    BorderSpacing.Around = 8
    1718    Caption = 'Repository'
    18     ClientHeight = 157
    19     ClientWidth = 806
     19    ClientHeight = 205
     20    ClientWidth = 814
    2021    TabOrder = 0
    2122    object Label1: TLabel
    2223      Left = 8
    2324      Height = 25
    24       Top = 16
     25      Top = 64
    2526      Width = 166
    2627      Caption = 'URL of repository:'
     
    3031      Left = 8
    3132      Height = 35
    32       Top = 48
    33       Width = 787
     33      Top = 96
     34      Width = 795
    3435      Anchors = [akTop, akLeft, akRight]
    3536      TabOrder = 0
     
    3839      Left = 8
    3940      Height = 25
    40       Top = 88
     41      Top = 136
    4142      Width = 181
    4243      Caption = 'Checkout directory:'
     
    4647      Left = 8
    4748      Height = 35
    48       Top = 120
    49       Width = 731
     49      Top = 168
     50      Width = 739
    5051      Anchors = [akTop, akLeft, akRight]
    5152      TabOrder = 1
    5253    end
    5354    object Button1: TButton
    54       Left = 755
     55      Left = 763
    5556      Height = 25
    56       Top = 128
     57      Top = 176
    5758      Width = 40
    5859      Anchors = [akTop, akRight]
     
    6162      TabOrder = 2
    6263    end
     64    object ComboBox1: TComboBox
     65      Left = 152
     66      Height = 35
     67      Top = 16
     68      Width = 352
     69      ItemHeight = 0
     70      Style = csDropDownList
     71      TabOrder = 3
     72    end
     73    object Label3: TLabel
     74      Left = 8
     75      Height = 25
     76      Top = 21
     77      Width = 49
     78      Caption = 'Type:'
     79      ParentColor = False
     80    end
    6381  end
    6482  object GroupBox2: TGroupBox
    6583    Left = 8
    6684    Height = 105
    67     Top = 200
    68     Width = 810
     85    Top = 248
     86    Width = 818
    6987    Align = alTop
    7088    BorderSpacing.Around = 8
     
    7290    TabOrder = 1
    7391  end
    74   object ButtonCancel: TButton
    75     Left = 728
    76     Height = 25
    77     Top = 328
    78     Width = 75
    79     Anchors = [akTop, akRight]
    80     Caption = 'Cancel'
    81     ModalResult = 2
     92  object Panel1: TPanel
     93    Left = 0
     94    Height = 50
     95    Top = 367
     96    Width = 834
     97    Align = alBottom
     98    BevelOuter = bvNone
     99    ClientHeight = 50
     100    ClientWidth = 834
    82101    TabOrder = 2
    83   end
    84   object ButtonOk: TButton
    85     Left = 616
    86     Height = 25
    87     Top = 328
    88     Width = 75
    89     Anchors = [akTop, akRight]
    90     Caption = 'Ok'
    91     ModalResult = 1
    92     TabOrder = 3
     102    object ButtonOk: TButton
     103      Left = 624
     104      Height = 25
     105      Top = 16
     106      Width = 75
     107      Anchors = [akTop, akRight]
     108      Caption = 'Ok'
     109      ModalResult = 1
     110      TabOrder = 0
     111    end
     112    object ButtonCancel: TButton
     113      Left = 736
     114      Height = 25
     115      Top = 16
     116      Width = 75
     117      Anchors = [akTop, akRight]
     118      Caption = 'Cancel'
     119      ModalResult = 2
     120      TabOrder = 1
     121    end
    93122  end
    94123end
  • trunk/Forms/UFormCheckout.pas

    r8 r9  
    66
    77uses
    8   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
     8  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
     9  Menus, ExtCtrls;
    910
    1011type
     
    1617    ButtonCancel: TButton;
    1718    ButtonOk: TButton;
     19    ComboBox1: TComboBox;
    1820    EditURL: TEdit;
    1921    EditDir: TEdit;
     
    2224    Label1: TLabel;
    2325    Label2: TLabel;
     26    Label3: TLabel;
     27    Panel1: TPanel;
    2428    procedure Button1Click(Sender: TObject);
     29    procedure FormShow(Sender: TObject);
    2530  private
    2631    { private declarations }
     
    3641{$R *.lfm}
    3742
     43uses
     44  UCore, UBackend;
     45
    3846{ TFormCheckout }
    3947
     
    4654end;
    4755
     56procedure TFormCheckout.FormShow(Sender: TObject);
     57var
     58  I: Integer;
     59begin
     60  ComboBox1.Clear;
     61  for I := 0 to Core.Backends.Count - 1 do
     62    ComboBox1.AddItem(TBackend(Core.Backends[I]).Name, Core.Backends[I]);
     63  if ComboBox1.Items.Count > 0 then
     64    ComboBox1.ItemIndex := 0;
     65end;
     66
    4867end.
    4968
  • trunk/Forms/UFormMain.pas

    r8 r9  
    8585const
    8686  AppName = 'VCSCommander';
     87var
     88  NewCaption: string;
    8789begin
     90  NewCaption := '';
    8891  if Assigned(Core.Project) then
    89     Caption := Core.Project.Directory + ' - ' + AppName
    90     else Caption := AppName;
     92    NewCaption := Core.Project.Directory + ' (' + Core.Project.Backend.Name + ') - ';
     93  NewCaption := NewCaption + AppName;
     94  Caption := NewCaption;
    9195end;
    9296
  • trunk/UCore.pas

    r8 r9  
    77uses
    88  Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, UVCS, UProject,
    9   ULastOpenedList, Forms, Dialogs;
     9  ULastOpenedList, Forms, Dialogs, Contnrs, UBackend;
    1010
    1111type
     
    4747  private
    4848    procedure UpdateInterface;
     49    procedure RegisterBackends;
     50    procedure RegisterBackend(Backend: TBackend);
     51    function DetectBackend(Directory: string): TBackend;
    4952  public
     53    Backends: TObjectList; // TList<TBackend>
    5054    Project: TProject;
    5155    procedure LoadConfig;
     
    6468
    6569uses
    66   UFormMain, UFormBrowse, UFormSettings, UFormCommit, UFormCheckout;
     70  UFormMain, UFormBrowse, UFormSettings, UFormCommit, UFormCheckout,
     71  USubversion, UBazaar;
    6772
    6873{ TCore }
     
    8085procedure TCore.DataModuleCreate(Sender: TObject);
    8186begin
     87  Backends := TObjectList.Create;
    8288  UpdateInterface;
    8389end;
     
    8591procedure TCore.DataModuleDestroy(Sender: TObject);
    8692begin
    87   Project.Free;
     93  FreeAndNil(Project);
     94  FreeAndNil(Backends);
    8895end;
    8996
     
    97104  AProjectClose.Enabled := Assigned(Project);
    98105  FormMain.UpdateInterface;
     106end;
     107
     108procedure TCore.RegisterBackends;
     109begin
     110  RegisterBackend(TBackendSubversion.Create);
     111  RegisterBackend(TBackendBazaar.Create);
     112end;
     113
     114procedure TCore.RegisterBackend(Backend: TBackend);
     115begin
     116  Backends.Add(Backend);
     117end;
     118
     119function TCore.DetectBackend(Directory: string): TBackend;
     120var
     121  I: Integer;
     122begin
     123  I := 0;
     124  while (I < Backends.Count) and (not TBackend(Backends[I]).IsWorkingCopy(Directory)) do Inc(I);
     125  if I < Backends.Count then Result := TBackend(Backends[I])
     126    else Result := nil;
    99127end;
    100128
     
    115143procedure TCore.Init;
    116144begin
     145  RegisterBackends;
    117146  LoadConfig;
    118147  if (LastOpenedList1.Items.Count > 0) and DirectoryExistsUTF8(LastOpenedList1.Items[0]) then
     
    129158  AProjectClose.Execute;
    130159  Project := TProject.Create;
    131   Project.VCSType := vtSubversion;
    132   Project.Directory := Directory;
    133   UpdateInterface;
    134   FormBrowse.Directory := Project.Directory;
    135   FormBrowse.ReloadList;
    136   LastOpenedList1.AddItem(Project.Directory);
     160  Project.Backend := DetectBackend(Directory);
     161  if Assigned(Project.Backend) then begin
     162    Project.Directory := Directory;
     163    UpdateInterface;
     164    FormBrowse.Directory := Project.Directory;
     165    FormBrowse.ReloadList;
     166    LastOpenedList1.AddItem(Project.Directory);
     167  end else ShowMessage('Directory not recognized as working copy of any of supported VCS systems');
    137168end;
    138169
     
    175206    TempProject := TProject.Create;
    176207    try
    177       TempProject.VCSType := vtSubversion;
     208      TempProject.Backend := TBackend(FormCheckout.ComboBox1.Items.Objects[FormCheckout.ComboBox1.ItemIndex]);
    178209      TempProject.Directory := FormCheckout.EditDir.Text;
    179210      TempProject.RepositoryURL := FormCheckout.EditURL.Text;
  • trunk/Units/UProject.pas

    r8 r9  
    66
    77uses
    8   Classes, SysUtils, UVCS;
     8  Classes, SysUtils, UVCS, UBackend;
    99
    1010type
    11 
    12   TVCSType = (vtNone, vtSubversion, vtCVS, vtMercurial, vtBazaar, vzGit);
    1311
    1412{ TProject }
     
    1614  TProject = class
    1715  private
    18     FVCSType: TVCSType;
     16    FBackend: TBackend;
    1917    function GetDirectory: string;
    2018    function GetRepositoryURL: string;
    2119    procedure SetDirectory(AValue: string);
    2220    procedure SetRepositoryURL(AValue: string);
    23     procedure SetVCSType(AValue: TVCSType);
     21    procedure SetBackend(AValue: TBackend);
    2422  public
    2523    WorkingCopy: TWorkingCopy;
     
    2725    constructor Create;
    2826    destructor Destroy; override;
    29     property VCSType: TVCSType read FVCSType write SetVCSType;
     27    property Backend: TBackend read FBackend write SetBackend;
    3028    property Directory: string read GetDirectory write SetDirectory;
    3129    property RepositoryURL: string read GetRepositoryURL write SetRepositoryURL;
     
    4038{ TProject }
    4139
    42 procedure TProject.SetVCSType(AValue: TVCSType);
     40procedure TProject.SetBackend(AValue: TBackend);
    4341begin
    44   if FVCSType = AValue then Exit;
    45   FVCSType := AValue;
     42  if FBackend = AValue then Exit;
     43  FBackend := AValue;
    4644  FreeAndNil(WorkingCopy);
    47   case AValue of
    48     vtSubversion: WorkingCopy := TSubversion.Create;
    49     else WorkingCopy := TWorkingCopy.Create;
    50   end;
     45  WorkingCopy := AValue.WorkingCopyClass.Create;
    5146end;
    5247
  • trunk/Units/UVCS.pas

    r8 r9  
    1919    procedure SetRepositoryURL(AValue: string);
    2020  protected
    21     procedure ExecuteProcess(Command: string; Parameters: TStrings); virtual;
     21    procedure ExecuteProcess(Command: string; Parameters: array of string); virtual;
    2222  public
    2323    procedure Checkout; virtual;
     
    2525    procedure CleanUp; virtual;
    2626    procedure Commit(Message: TStrings); virtual;
    27     procedure Move; virtual;
     27    procedure Move(Source, Dest: string); virtual;
    2828    procedure Merge; virtual;
    2929    procedure Refresh; virtual;
     
    3535    Path: string;
    3636  end;
     37
    3738
    3839
     
    5758end;
    5859
    59 procedure TWorkingCopy.ExecuteProcess(Command: string; Parameters: TStrings);
     60procedure TWorkingCopy.ExecuteProcess(Command: string; Parameters: array of string);
    6061begin
    6162  FormConsole.Executable := Command;
    62   FormConsole.Parameters.Assign(Parameters);
     63  FormConsole.Parameters.Clear;
     64  FormConsole.Parameters.AddStrings(Parameters);
    6365  if DirectoryExistsUTF8(Path) then FormConsole.WorkingDir := Path
    6466    else FormConsole.WorkingDir := '';
     
    8688end;
    8789
    88 procedure TWorkingCopy.Move;
     90procedure TWorkingCopy.Move(Source, Dest: string);
    8991begin
    9092
  • trunk/VCSCommander.lpi

    r8 r9  
    8383      </Item4>
    8484    </RequiredPackages>
    85     <Units Count="12">
     85    <Units Count="14">
    8686      <Unit0>
    8787        <Filename Value="VCSCommander.lpr"/>
     
    128128      </Unit6>
    129129      <Unit7>
    130         <Filename Value="Units/USubversion.pas"/>
     130        <Filename Value="Backends/Subversion/USubversion.pas"/>
    131131        <IsPartOfProject Value="True"/>
    132132      </Unit7>
     
    156156        <ResourceBaseClass Value="Form"/>
    157157      </Unit11>
     158      <Unit12>
     159        <Filename Value="Backends/Bazaar/UBazaar.pas"/>
     160        <IsPartOfProject Value="True"/>
     161      </Unit12>
     162      <Unit13>
     163        <Filename Value="Units/UBackend.pas"/>
     164        <IsPartOfProject Value="True"/>
     165      </Unit13>
    158166    </Units>
    159167  </ProjectOptions>
     
    165173    <SearchPaths>
    166174      <IncludeFiles Value="$(ProjOutDir)"/>
    167       <OtherUnitFiles Value="Forms;Units"/>
     175      <OtherUnitFiles Value="Forms;Units;Backends/Bazaar;Backends/Subversion"/>
    168176      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
    169177    </SearchPaths>
  • trunk/VCSCommander.lpr

    r8 r9  
    1010  Forms, UFormMain, UCore, Common, TemplateGenerics, UFormBrowse, UVCS,
    1111  UFormFavorites, UFormSettings, UFormConsole, USubversion, UProject, SysUtils,
    12   UFormCommit, UFormCheckout
     12  UFormCommit, UFormCheckout, UBazaar, UBackend
    1313  { you can add units after this };
    1414
Note: See TracChangeset for help on using the changeset viewer.