Changeset 15
- Timestamp:
- Jul 13, 2015, 11:44:23 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Backends/CVS/UCVS.pas
r13 r15 32 32 procedure Add(FileName: string); override; 33 33 procedure Remove(FileName: string); override; 34 procedure GetStatus(FileName: string; Status: TFileStatusList); override; 34 35 end; 35 36 … … 125 126 end; 126 127 128 procedure TCVS.GetStatus(FileName: string; Status: TFileStatusList); 129 begin 130 Status.Clear; 131 Execute(['status']); 132 133 end; 134 127 135 end. 128 136 -
trunk/Backends/Subversion/USubversion.pas
r14 r15 6 6 7 7 uses 8 Classes, SysUtils, UVCS, UBackend ;8 Classes, SysUtils, UVCS, UBackend, XMLRead, DOM, UXMLUtils; 9 9 10 10 type … … 33 33 procedure Remove(FileName: string); override; 34 34 procedure GetLog(FileName: string; Log: TLogList); override; 35 procedure GetStatus(FileName: string; Status: TFileStatusList); override; 35 36 end; 36 37 … … 172 173 end; 173 174 175 procedure TSubversion.GetStatus(FileName: string; Status: TFileStatusList); 176 var 177 Doc: TXMLDocument; 178 S: TStringStream; 179 Node: TDOMNode; 180 Node2: TDOMNode; 181 RootNode: TDOMNode; 182 TargetNode: TDOMNode; 183 StatusNode: TDOMNode; 184 StatusItem: TFileStatus; 185 CommitNode: TDOMNode; 186 ItemState: string; 187 begin 188 Status.Clear; 189 Execute(['status', '--xml', '-v']); 190 S := TStringStream.Create(ExecutionOutput.Text); 191 try 192 // Read complete XML document 193 ReadXMLFile(Doc, S); 194 RootNode := Doc.DocumentElement; 195 if RootNode.NodeName = 'status' then begin 196 TargetNode := RootNode.FindNode('target'); 197 if Assigned(TargetNode) then begin 198 Node := TargetNode.FirstChild; 199 while Assigned(Node) do begin 200 if Node.NodeName = 'entry' then begin 201 StatusItem := TFileStatus.Create; 202 StatusItem.FileName := TDOMElement(Node).GetAttribute('path'); 203 StatusNode := Node.FindNode('wc-status'); 204 if Assigned(StatusNode) then begin 205 ItemState := TDOMElement(StatusNode).GetAttribute('item'); 206 if ItemState = 'normal' then StatusItem.State := fssNotModified; 207 if ItemState = 'modified' then StatusItem.State := fssModified; 208 if ItemState = 'deleted' then StatusItem.State := fssRemoved; 209 if ItemState = 'added' then StatusItem.State := fssAdded; 210 211 CommitNode := StatusNode.FindNode('commit'); 212 if Assigned(CommitNode) then begin 213 StatusItem.Version := TDOMElement(CommitNode).GetAttribute('revision'); 214 StatusItem.Author := ReadString(CommitNode, 'author', ''); 215 StatusItem.Time := ReadDateTime(CommitNode, 'date', 0); 216 end; 217 end; 218 Status.Add(StatusItem); 219 end; 220 Node := Node.NextSibling; 221 end; 222 end; 223 end; 224 finally 225 Doc.Free; 226 S.Free; 227 end; 228 end; 229 174 230 end. 175 231 -
trunk/Forms/UFormBrowse.lfm
r13 r15 1 1 object FormBrowse: TFormBrowse 2 Left = 9523 Height = 5 264 Top = 2 875 Width = 7222 Left = 479 3 Height = 538 4 Top = 279 5 Width = 964 6 6 Caption = 'Browse' 7 ClientHeight = 526 8 ClientWidth = 722 7 ClientHeight = 538 8 ClientWidth = 964 9 Menu = MainMenu1 9 10 OnCreate = FormCreate 10 11 OnDestroy = FormDestroy … … 13 14 object TreeView1: TTreeView 14 15 Left = 0 15 Height = 5 2616 Height = 538 16 17 Top = 0 17 18 Width = 241 18 19 Align = alLeft 19 DefaultItemHeight = 2 820 DefaultItemHeight = 24 20 21 TabOrder = 0 21 22 end 22 23 object Splitter1: TSplitter 23 24 Left = 241 24 Height = 5 2625 Height = 538 25 26 Top = 0 26 27 Width = 5 … … 28 29 object ListView1: TListView 29 30 Left = 246 30 Height = 5 2631 Height = 538 31 32 Top = 0 32 Width = 47633 Width = 718 33 34 Align = alClient 34 35 Columns = < … … 121 122 end 122 123 end 124 object MainMenu1: TMainMenu 125 left = 429 126 top = 516 127 end 123 128 end -
trunk/Forms/UFormBrowse.pas
r11 r15 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 ExtCtrls, Menus, ActnList, UFindFile, UVCS ;9 ExtCtrls, Menus, ActnList, UFindFile, UVCS, Contnrs; 10 10 11 11 type … … 23 23 ActionList1: TActionList; 24 24 ListView1: TListView; 25 MainMenu1: TMainMenu; 25 26 MenuItem1: TMenuItem; 26 27 MenuItem2: TMenuItem; … … 46 47 Selected: Boolean); 47 48 private 48 FileList: T StringList;49 FileList: TObjectList; 49 50 public 50 51 Directory: string; … … 67 68 procedure TFormBrowse.ListView1Data(Sender: TObject; Item: TListItem); 68 69 begin 69 if (Item.Index >= 0) and (Item.Index < FileList.Count) then begin 70 Item.Caption := ExtractFileName(FileList[Item.Index]); 70 if (Item.Index >= 0) and (Item.Index < FileList.Count) then 71 with TFileStatus(FileList[Item.Index]) do begin 72 Item.Caption := ExtractFileName(FileName); 73 if State <> fssNonVersioned then begin 74 Item.SubItems.Add(Version); 75 Item.SubItems.Add(DateToStr(Time)); 76 Item.SubItems.Add(Author); 77 Item.SubItems.Add(FileStatusStateText[State]); 78 end; 71 79 end; 72 80 end; … … 124 132 procedure TFormBrowse.FormCreate(Sender: TObject); 125 133 begin 126 FileList := T StringList.Create;134 FileList := TObjectList.Create; 127 135 end; 128 136 … … 142 150 FoundFileList: TStrings; 143 151 I: Integer; 144 begin 152 FileStatusList: TFileStatusList; 153 NewFileItem: TFileStatus; 154 FS: TFileStatus; 155 RelativeName: string; 156 begin 157 FileList.Clear; 158 if Assigned(Core.Project) then begin 159 FileStatusList := TFileStatusList.Create; 160 try 161 Core.Project.WorkingCopy.GetStatus(Directory, FileStatusList); 162 145 163 if DirectoryExistsUTF8(Directory) then begin 146 164 FindFile := TFindFile.Create(nil); … … 150 168 FindFile.InSubFolders := False; 151 169 FoundFileList := FindFile.SearchForFiles; 152 FileList.Assign(FoundFileList); 170 //FoundFileList.Sort; 171 for I := 0 to FoundFileList.Count - 1 do begin 172 NewFileItem := TFileStatus.Create; 173 NewFileItem.FileName := FoundFileList[I]; 174 RelativeName := NewFileItem.FileName; 175 if Copy(RelativeName, 1, Length(Core.Project.WorkingCopy.Path)) = Core.Project.WorkingCopy.Path then 176 Delete(RelativeName, 1, Length(Core.Project.WorkingCopy.Path)); 177 if Copy(RelativeName, 1, 1) = DirectorySeparator then 178 Delete(RelativeName, 1, Length(DirectorySeparator)); 179 FS := FileStatusList.SearchByName(RelativeName); 180 if Assigned(FS) then begin 181 NewFileItem.Assign(FS); 182 end; 183 FileList.Add(NewFileItem); 184 end; 153 185 for I := FileList.Count - 1 downto 0 do 154 if ExtractFileName(FileList[I]) = '.' then FileList.Delete(I); 155 FileList.Sort; 186 if ExtractFileName(TFileStatus(FileList[I]).FileName) = '.' then FileList.Delete(I); 156 187 ListView1.Items.Count := FileList.Count; 157 188 finally … … 159 190 end; 160 191 end else ListView1.Items.Count := 0; 192 finally 193 FileStatusList.Free; 194 end; 195 end; 161 196 ListView1.Refresh; 162 197 end; -
trunk/Packages/Common/UXMLUtils.pas
r6 r15 14 14 procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean); 15 15 procedure WriteString(Node: TDOMNode; Name: string; Value: string); 16 procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime); 16 17 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 17 18 function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean; 18 19 function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string; 20 function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime; 19 21 20 22 … … 72 74 Minute: Integer; 73 75 Second: Integer; 76 SecondFraction: Double; 74 77 Millisecond: Integer; 75 78 begin … … 94 97 if Pos('Z', XMLDateTime) > 0 then 95 98 LeftCutString(XMLDateTime, Part, 'Z'); 96 Millisecond := StrToInt(Part); 99 SecondFraction := StrToFloat('0.' + Part); 100 Millisecond := Trunc(SecondFraction * 1000); 97 101 end else begin 98 102 if Pos('+', XMLDateTime) > 0 then … … 156 160 end; 157 161 162 procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime); 163 var 164 NewNode: TDOMNode; 165 begin 166 NewNode := Node.OwnerDocument.CreateElement(Name); 167 NewNode.TextContent := DateTimeToXMLTime(Value); 168 Node.AppendChild(NewNode); 169 end; 170 158 171 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 159 172 var … … 186 199 end; 187 200 201 function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime 202 ): TDateTime; 203 var 204 NewNode: TDOMNode; 205 begin 206 Result := DefaultValue; 207 NewNode := Node.FindNode(Name); 208 if Assigned(NewNode) then 209 Result := XMLTimeToDateTime(NewNode.TextContent); 210 end; 211 188 212 end. 189 213 -
trunk/UCore.pas
r14 r15 209 209 FormBrowse.ReloadList; 210 210 LastOpenedListProject.AddItem(Project.Directory); 211 end else ShowMessage('Directory not recognized as working copy of any of supported VCS systems');211 end else ShowMessage('Directory ''' + Directory + ''' not recognized as working copy of any of supported VCS systems'); 212 212 end; 213 213 -
trunk/Units/UVCS.pas
r13 r15 25 25 TLogList = class(TObjectList) 26 26 27 end; 28 29 TFileStatusState = (fssNonVersioned, fssAdded, fssRemoved, fssModified, fssNotModified); 30 31 { TFileStatus } 32 33 TFileStatus = class 34 FileName: string; 35 Version: string; 36 Author: string; 37 Time: TDateTime; 38 State: TFileStatusState; 39 procedure Assign(Source: TFileStatus); 40 end; 41 42 { TFileStatusList } 43 44 TFileStatusList = class(TObjectList) 45 function SearchByName(Name: string): TFileStatus; 27 46 end; 28 47 … … 54 73 procedure Remove(FileName: string); virtual; 55 74 procedure GetLog(FileName: string; Log: TLogList); virtual; 75 procedure GetStatus(FileName: string; Status: TFileStatusList); virtual; 56 76 constructor Create; 57 77 destructor Destroy; override; … … 76 96 function URLFromDirectory(DirName: string; Relative: Boolean): string; 77 97 98 const 99 FileStatusStateText: array[TFileStatusState] of string = ('Not versioned', 100 'Added', 'Removed', 'Modified', 'Normal'); 101 78 102 implementation 79 103 … … 86 110 if Relative then Result := GetCurrentDirUTF8 + DirectorySeparator + Result; 87 111 Result := 'file:///' + StringReplace(Result, DirectorySeparator, '/', [rfReplaceAll]); 112 end; 113 114 { TFileStatus } 115 116 procedure TFileStatus.Assign(Source: TFileStatus); 117 begin 118 FileName := Source.FileName; 119 Version := Source.Version; 120 Time := Source.Time; 121 Author := Source.Author; 122 State := Source.State; 123 end; 124 125 { TFileStatusList } 126 127 function TFileStatusList.SearchByName(Name: string): TFileStatus; 128 var 129 I: Integer; 130 begin 131 I := 0; 132 while (I < Count) and (TFileStatus(Items[I]).FileName <> Name) do Inc(I); 133 if I < Count then Result := TFileStatus(Items[I]) 134 else Result := nil; 88 135 end; 89 136 … … 222 269 end; 223 270 271 procedure TWorkingCopy.GetStatus(FileName: string; Status: TFileStatusList); 272 begin 273 Status.Clear; 274 end; 275 224 276 constructor TWorkingCopy.Create; 225 277 begin -
trunk/VCSCommander.lpi
r14 r15 111 111 <HasResources Value="True"/> 112 112 <ResourceBaseClass Value="Form"/> 113 <UnitName Value="UFormBrowse"/> 113 114 </Unit3> 114 115 <Unit4> 115 116 <Filename Value="Units/UVCS.pas"/> 116 117 <IsPartOfProject Value="True"/> 118 <UnitName Value="UVCS"/> 117 119 </Unit4> 118 120 <Unit5> … … 122 124 <HasResources Value="True"/> 123 125 <ResourceBaseClass Value="Form"/> 126 <UnitName Value="UFormFavorites"/> 124 127 </Unit5> 125 128 <Unit6> … … 129 132 <HasResources Value="True"/> 130 133 <ResourceBaseClass Value="Form"/> 134 <UnitName Value="UFormSettings"/> 131 135 </Unit6> 132 136 <Unit7> … … 138 142 <Filename Value="Units/UProject.pas"/> 139 143 <IsPartOfProject Value="True"/> 144 <UnitName Value="UProject"/> 140 145 </Unit8> 141 146 <Unit9> … … 160 165 <HasResources Value="True"/> 161 166 <ResourceBaseClass Value="Form"/> 167 <UnitName Value="UFormCheckout"/> 162 168 </Unit11> 163 169 <Unit12> … … 172 178 <Filename Value="Backends/CVS/UCVS.pas"/> 173 179 <IsPartOfProject Value="True"/> 180 <UnitName Value="UCVS"/> 174 181 </Unit14> 175 182 <Unit15>
Note:
See TracChangeset
for help on using the changeset viewer.