Changeset 9 for trunk/UCore.pas
- Timestamp:
- May 18, 2015, 11:49:39 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r8 r9 7 7 uses 8 8 Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, UVCS, UProject, 9 ULastOpenedList, Forms, Dialogs ;9 ULastOpenedList, Forms, Dialogs, Contnrs, UBackend; 10 10 11 11 type … … 47 47 private 48 48 procedure UpdateInterface; 49 procedure RegisterBackends; 50 procedure RegisterBackend(Backend: TBackend); 51 function DetectBackend(Directory: string): TBackend; 49 52 public 53 Backends: TObjectList; // TList<TBackend> 50 54 Project: TProject; 51 55 procedure LoadConfig; … … 64 68 65 69 uses 66 UFormMain, UFormBrowse, UFormSettings, UFormCommit, UFormCheckout; 70 UFormMain, UFormBrowse, UFormSettings, UFormCommit, UFormCheckout, 71 USubversion, UBazaar; 67 72 68 73 { TCore } … … 80 85 procedure TCore.DataModuleCreate(Sender: TObject); 81 86 begin 87 Backends := TObjectList.Create; 82 88 UpdateInterface; 83 89 end; … … 85 91 procedure TCore.DataModuleDestroy(Sender: TObject); 86 92 begin 87 Project.Free; 93 FreeAndNil(Project); 94 FreeAndNil(Backends); 88 95 end; 89 96 … … 97 104 AProjectClose.Enabled := Assigned(Project); 98 105 FormMain.UpdateInterface; 106 end; 107 108 procedure TCore.RegisterBackends; 109 begin 110 RegisterBackend(TBackendSubversion.Create); 111 RegisterBackend(TBackendBazaar.Create); 112 end; 113 114 procedure TCore.RegisterBackend(Backend: TBackend); 115 begin 116 Backends.Add(Backend); 117 end; 118 119 function TCore.DetectBackend(Directory: string): TBackend; 120 var 121 I: Integer; 122 begin 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; 99 127 end; 100 128 … … 115 143 procedure TCore.Init; 116 144 begin 145 RegisterBackends; 117 146 LoadConfig; 118 147 if (LastOpenedList1.Items.Count > 0) and DirectoryExistsUTF8(LastOpenedList1.Items[0]) then … … 129 158 AProjectClose.Execute; 130 159 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'); 137 168 end; 138 169 … … 175 206 TempProject := TProject.Create; 176 207 try 177 TempProject. VCSType := vtSubversion;208 TempProject.Backend := TBackend(FormCheckout.ComboBox1.Items.Objects[FormCheckout.ComboBox1.ItemIndex]); 178 209 TempProject.Directory := FormCheckout.EditDir.Text; 179 210 TempProject.RepositoryURL := FormCheckout.EditURL.Text;
Note:
See TracChangeset
for help on using the changeset viewer.