Changeset 11


Ignore:
Timestamp:
May 19, 2015, 11:33:02 PM (9 years ago)
Author:
chronos
Message:
  • Added: Log form to show history of object. Implemented for Subversion partialy.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Backends/Subversion/USubversion.pas

    r10 r11  
    3131    procedure Merge; override;
    3232    procedure Add(FileName: string); override;
     33    procedure GetLog(FileName: string; Log: TLogList); override;
    3334  end;
    3435
     
    9192end;
    9293
     94procedure TSubversion.GetLog(FileName: string; Log: TLogList);
     95var
     96  NewItem: TLogItem;
     97  I: Integer;
     98  Line: string;
     99  ChangedFiles: Boolean;
     100  Action: string;
     101begin
     102  NewItem := nil;
     103  Log.Clear;
     104  Execute(['log', FileName, '-v']);
     105  for I := 0 to ExecutionOutput.Count - 1 do begin
     106    Line := Trim(ExecutionOutput[I]);
     107    if Line = '------------------------------------------------------------------------' then begin
     108      if Assigned(NewItem) then Log.Add(NewItem);
     109      NewItem := TLogItem.Create;
     110    end else
     111    if Pos('|', Line) > 0 then begin
     112      NewItem.Revision := Trim(GetNext(Line, '|'));
     113      NewItem.Author := Trim(GetNext(Line, '|'));
     114      GetNext(Line, '|');
     115      //NewItem.Time := StrToDateTime(Trim(GetNext(Line, '|')));
     116    end else
     117    if Line = 'Changed paths:' then begin
     118      ChangedFiles := True;
     119    end else
     120    if ChangedFiles then begin
     121      if (Line <> '') and (Copy(ExecutionOutput[I], 1, 3) = '   ') then begin
     122        Action := GetNext(Line, ' ');
     123        NewItem.Actions := NewItem.Actions + Action;
     124        NewItem.ChangedFiles.Add(Line);
     125      end else
     126      if Line = '' then begin
     127        ChangedFiles := False;
     128      end;
     129    end else
     130      NewItem.Messages.Add(Line);
     131  end;
     132  if Assigned(NewItem) then Log.Add(NewItem);
     133end;
     134
    93135end.
    94136
  • trunk/Forms/UFormBrowse.lfm

    r10 r11  
    99  OnCreate = FormCreate
    1010  OnDestroy = FormDestroy
     11  OnShow = FormShow
    1112  LCLVersion = '1.5'
    1213  object TreeView1: TTreeView
     
    6162    OnData = ListView1Data
    6263    OnDblClick = AOpenExecute
     64    OnSelectItem = ListView1SelectItem
    6365  end
    6466  object PopupMenu1: TPopupMenu
     
    8385    object MenuItem6: TMenuItem
    8486      Action = AOpen
     87    end
     88    object MenuItem7: TMenuItem
     89      Action = ALogShow
    8590    end
    8691  end
     
    111116      OnExecute = AOpenExecute
    112117    end
     118    object ALogShow: TAction
     119      Caption = 'Show log'
     120      OnExecute = ALogShowExecute
     121    end
    113122  end
    114123end
  • trunk/Forms/UFormBrowse.pas

    r10 r11  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   ExtCtrls, Menus, ActnList, UFindFile;
     9  ExtCtrls, Menus, ActnList, UFindFile, UVCS;
    1010
    1111type
     
    1515  TFormBrowse = class(TForm)
    1616    AAdd: TAction;
     17    ALogShow: TAction;
    1718    AOpen: TAction;
    1819    AProperties: TAction;
     
    2829    MenuItem5: TMenuItem;
    2930    MenuItem6: TMenuItem;
     31    MenuItem7: TMenuItem;
    3032    PopupMenu1: TPopupMenu;
    3133    Splitter1: TSplitter;
     
    3335    procedure AAddExecute(Sender: TObject);
    3436    procedure ADeleteExecute(Sender: TObject);
     37    procedure ALogShowExecute(Sender: TObject);
    3538    procedure AOpenExecute(Sender: TObject);
    3639    procedure ARenameExecute(Sender: TObject);
    3740    procedure FormCreate(Sender: TObject);
    3841    procedure FormDestroy(Sender: TObject);
     42    procedure FormShow(Sender: TObject);
    3943    procedure ListView1Data(Sender: TObject; Item: TListItem);
    4044    procedure ListView1DblClick(Sender: TObject);
     45    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
     46      Selected: Boolean);
    4147  private
    4248    FileList: TStringList;
     
    5359
    5460uses
    55   UCore;
     61  UCore, UFormLog;
    5662
    5763{$R *.lfm}
     
    7177end;
    7278
     79procedure TFormBrowse.ListView1SelectItem(Sender: TObject; Item: TListItem;
     80  Selected: Boolean);
     81begin
     82  UpdateInterface;
     83end;
     84
    7385procedure TFormBrowse.ADeleteExecute(Sender: TObject);
    7486begin
    7587
     88end;
     89
     90procedure TFormBrowse.ALogShowExecute(Sender: TObject);
     91begin
     92  FormLog.FileName := Directory + DirectorySeparator + ListView1.Selected.Caption;
     93  FormLog.ShowModal;
    7694end;
    7795
     
    114132end;
    115133
     134procedure TFormBrowse.FormShow(Sender: TObject);
     135begin
     136  UpdateInterface;
     137end;
     138
    116139procedure TFormBrowse.ReloadList;
    117140var
     
    145168  ARename.Enabled := Assigned(ListView1.Selected);
    146169  AProperties.Enabled := Assigned(ListView1.Selected);
     170  AOpen.Enabled := Assigned(ListView1.Selected);
     171  ALogShow.Enabled := Assigned(ListView1.Selected);
    147172end;
    148173
  • trunk/UCore.lfm

    r8 r11  
    44  OldCreateOrder = False
    55  Height = 435
    6   HorizontalOffset = 539
    7   VerticalOffset = 195
     6  HorizontalOffset = 695
     7  VerticalOffset = 306
    88  Width = 693
    99  object ActionList1: TActionList
  • trunk/Units/UVCS.pas

    r10 r11  
    66
    77uses
    8   Classes, SysUtils, FileUtil;
     8  Classes, SysUtils, FileUtil, Contnrs;
    99
    1010type
     11
     12  { TLogItem }
     13
     14  TLogItem = class
     15    Author: string;
     16    Actions: string;
     17    Time: TDateTime;
     18    Revision: string;
     19    Messages: TStringList;
     20    ChangedFiles: TStringList;
     21    constructor Create;
     22    destructor Destroy; override;
     23  end;
     24
     25  TLogList = class(TObjectList)
     26
     27  end;
    1128
    1229  { TWorkingCopy }
     
    2037  protected
    2138    procedure ExecuteProcess(Command: string; Parameters: array of string); virtual;
     39    function GetNext(var Text: string; Separator: string): string;
    2240  public
     41    ExecutionOutput: TStringList;
    2342    procedure Checkout; virtual;
    2443    procedure Update; virtual;
     
    2948    procedure Refresh; virtual;
    3049    procedure Add(FileName: string); virtual;
     50    procedure GetLog(FileName: string; Log: TLogList); virtual;
     51    constructor Create;
     52    destructor Destroy; override;
    3153    property RepositoryURL: string read FRepositoryURL write SetRepositoryURL;
    3254    property Path: string read FPath write SetPath;
     
    4365uses
    4466  UFormConsole;
     67
     68{ TLogItem }
     69
     70constructor TLogItem.Create;
     71begin
     72  Messages := TStringList.Create;
     73  ChangedFiles := TStringList.Create;
     74end;
     75
     76destructor TLogItem.Destroy;
     77begin
     78  Messages.Free;
     79  ChangedFiles.Free;
     80  inherited Destroy;
     81end;
    4582
    4683{ TWorkingCopy }
     
    67104    else FormConsole.WorkingDir := '';
    68105  FormConsole.ShowModal;
     106  ExecutionOutput.Assign(FormConsole.Log);
     107end;
     108
     109function TWorkingCopy.GetNext(var Text: string; Separator: string): string;
     110begin
     111  if Pos(Separator, Text) > 0 then begin
     112    Result := Copy(Text, 1, Pos(Separator, Text) - 1);
     113    Delete(Text, 1, Pos(Separator, Text) + Length(Separator));
     114  end else begin
     115    Result := Text;
     116    Text := '';
     117  end;
    69118end;
    70119
     
    109158end;
    110159
     160procedure TWorkingCopy.GetLog(FileName: string; Log: TLogList);
     161begin
     162  Log.Clear;
     163end;
     164
     165constructor TWorkingCopy.Create;
     166begin
     167  ExecutionOutput := TStringList.Create;
     168  FPath := '';
     169  FRepositoryURL := '';
     170end;
     171
     172destructor TWorkingCopy.Destroy;
     173begin
     174  FreeAndNil(ExecutionOutput);
     175  inherited Destroy;
     176end;
     177
    111178end.
    112179
  • trunk/VCSCommander.lpi

    r10 r11  
    8484      </Item4>
    8585    </RequiredPackages>
    86     <Units Count="15">
     86    <Units Count="16">
    8787      <Unit0>
    8888        <Filename Value="VCSCommander.lpr"/>
     
    169169        <IsPartOfProject Value="True"/>
    170170      </Unit14>
     171      <Unit15>
     172        <Filename Value="Forms/UFormLog.pas"/>
     173        <IsPartOfProject Value="True"/>
     174        <ComponentName Value="FormLog"/>
     175        <HasResources Value="True"/>
     176        <ResourceBaseClass Value="Form"/>
     177      </Unit15>
    171178    </Units>
    172179  </ProjectOptions>
  • trunk/VCSCommander.lpr

    r9 r11  
    1010  Forms, UFormMain, UCore, Common, TemplateGenerics, UFormBrowse, UVCS,
    1111  UFormFavorites, UFormSettings, UFormConsole, USubversion, UProject, SysUtils,
    12   UFormCommit, UFormCheckout, UBazaar, UBackend
     12  UFormCommit, UFormCheckout, UBazaar, UBackend, UFormLog
    1313  { you can add units after this };
    1414
     
    3838  Application.CreateForm(TFormCommit, FormCommit);
    3939  Application.CreateForm(TFormCheckout, FormCheckout);
     40  Application.CreateForm(TFormLog, FormLog);
    4041  Application.Run;
    4142end.
Note: See TracChangeset for help on using the changeset viewer.