Check-in [0fbed40d59]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Populate a list of active branches, and allows updating to them.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0fbed40d59e576e80284745cf8e4615e1df4946e
User & Date: tinus 2015-11-18 21:46:21
Context
2015-11-18
22:04
Save all files before updating to a different revision. check-in: c9e260d5b7 user: tinus tags: trunk
21:46
Populate a list of active branches, and allows updating to them. check-in: 0fbed40d59 user: tinus tags: trunk
20:16
Added toolbar, action and button (with generated image). Does nothing useful for the moment, but it's a first step. check-in: 18217c831e user: tinus tags: trunk
Changes

Changes to src/VCSInfoMenuWzrd.pas.

32
33
34
35
36
37
38



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
337
338
339
340
341
342
343


344
345
346
347
348
349
350
351
352
353
354












355
356
357
358
359
360
361
...
379
380
381
382
383
384
385









































































386
387
388
389
390
391
392
      function GetName: string;
      function GetState: TWizardState;
      procedure Execute;

      { IOTAMenuWizard }
      function GetMenuText: string;




      procedure actIncomingExecute(Sender: TObject);
  end;

procedure Register;

implementation
uses
  System.SysUtils, System.UITypes, System.Classes,
  Vcl.Forms, Vcl.Dialogs,
  Winapi.Windows,
  u_FinalPathName, Vcl.ActnList, Vcl.Graphics;

const
  scMenuIDString = 'net.2of4.VCSInfoWizard';

{ ------------------------------------------------------------------------------------------------ }
procedure Register;
begin
................................................................................

{ ------------------------------------------------------------------------------------------------ }
constructor TVCSInfoWizard.Create;
var
  Services: INTAServices;
  actIncoming: TAction;
  bmpCount: TBitmap;


begin
  Supports(BorlandIDEServices, INTAServices, Services);
  FToolbar := Services.NewToolbar('tlbVCSInfo', 'VCS Info');

  bmpCount := TBitmap.Create;
  bmpCount.SetSize(16, 16);
  bmpCount.Canvas.Brush.Color := clLime; // clBtnFace;
  bmpCount.Canvas.Brush.Style := bsSolid;
  bmpCount.Canvas.FillRect(Rect(0, 0, 16, 16));
  bmpCount.TransparentColor := clFuchsia;













  actIncoming := TAction.Create(FToolbar);
  actIncoming.Caption := '(0)';
  actIncoming.Enabled := True;
  actIncoming.ImageIndex := Services.AddMasked(bmpCount, bmpCount.TransparentColor, 'net.2of4.actIncoming');
  actIncoming.OnExecute := actIncomingExecute;

  FButtonIn := Services.AddToolButton(FToolbar.Name, 'btnIncoming', actIncoming);
................................................................................
  end;
  FToolbar.Free;
  FRepos.Free;
  inherited;
end;

{ ------------------------------------------------------------------------------------------------ }









































































procedure TVCSInfoWizard.actIncomingExecute(Sender: TObject);
begin
  Self.Execute;
end;

{ ------------------------------------------------------------------------------------------------ }
function TVCSInfoWizard.GetMenuText: string;







>
>
>










|







 







>
>

|









>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
      function GetName: string;
      function GetState: TWizardState;
      procedure Execute;

      { IOTAMenuWizard }
      function GetMenuText: string;

      procedure actBranchExecute(Sender: TObject);
      procedure actBranchMenuPopup(Sender: TObject);
      procedure actBranchMenuClick(Sender: TObject);
      procedure actIncomingExecute(Sender: TObject);
  end;

procedure Register;

implementation
uses
  System.SysUtils, System.UITypes, System.Classes,
  Vcl.Forms, Vcl.Dialogs,
  Winapi.Windows,
  u_FinalPathName, Vcl.ActnList, Vcl.Graphics, Vcl.Menus;

const
  scMenuIDString = 'net.2of4.VCSInfoWizard';

{ ------------------------------------------------------------------------------------------------ }
procedure Register;
begin
................................................................................

{ ------------------------------------------------------------------------------------------------ }
constructor TVCSInfoWizard.Create;
var
  Services: INTAServices;
  actIncoming: TAction;
  bmpCount: TBitmap;
  actBranch: TAction;
  btnBranch: TToolButton;
begin
  Supports(ToolsAPI.BorlandIDEServices, INTAServices, Services);
  FToolbar := Services.NewToolbar('tlbVCSInfo', 'VCS Info');

  bmpCount := TBitmap.Create;
  bmpCount.SetSize(16, 16);
  bmpCount.Canvas.Brush.Color := clLime; // clBtnFace;
  bmpCount.Canvas.Brush.Style := bsSolid;
  bmpCount.Canvas.FillRect(Rect(0, 0, 16, 16));
  bmpCount.TransparentColor := clFuchsia;

  actBranch := TAction.Create(FToolbar);
  actBranch.Caption := '(branch name)';
  actBranch.Enabled := True;
  actBranch.ImageIndex := Services.AddMasked(bmpCount, bmpCount.TransparentColor, 'net.2of4.actBranch');
  actBranch.OnExecute := actBranchExecute;

  btnBranch := Services.AddToolButton(FToolbar.Name, 'btnBranch', actBranch) as TToolButton;
  btnBranch.Style := tbsDropDown;
  btnBranch.DropdownMenu := TPopupMenu.Create(btnBranch);
  btnBranch.DropdownMenu.AutoHotkeys := maManual;
  btnBranch.DropdownMenu.OnPopup := actBranchMenuPopup;

  actIncoming := TAction.Create(FToolbar);
  actIncoming.Caption := '(0)';
  actIncoming.Enabled := True;
  actIncoming.ImageIndex := Services.AddMasked(bmpCount, bmpCount.TransparentColor, 'net.2of4.actIncoming');
  actIncoming.OnExecute := actIncomingExecute;

  FButtonIn := Services.AddToolButton(FToolbar.Name, 'btnIncoming', actIncoming);
................................................................................
  end;
  FToolbar.Free;
  FRepos.Free;
  inherited;
end;

{ ------------------------------------------------------------------------------------------------ }
procedure TVCSInfoWizard.actBranchExecute(Sender: TObject);
begin
  Self.Execute;
end;

procedure TVCSInfoWizard.actBranchMenuClick(Sender: TObject);
var
  Item: TMenuItem;
  Project: IOTAProject;
  Info: TRepoInfo;
  Output: string;
  MsgType: TMsgDlgType;
begin
  Item := Sender as TMenuItem;
  Project := ToolsAPI.GetActiveProject;
  if Assigned(Project) then begin
    Info := GetRepoInfo(Project.FileName);
    if Info.IsRepo then begin
      ExecuteCmd('hg -yq status', Output, False, nil, Info.Root);
      if Output.Trim <> '' then begin
        MsgType := mtWarning;
        Output := 'The following files have NOT BEEN COMMITTED:' + sLineBreak + Output.Trim;
      end else begin
        MsgType := mtConfirmation;
      end;
      if TaskMessageDlg('Update repository to branch "' + Item.Caption + '"?', Output, MsgType, mbOKCancel, 0) <> mrOk then
        Exit;
      {$MESSAGE WARN 'HINT: save all files, perhaps even close the project?'}
      if ExecuteCmd('hg -y update "' + Item.Caption + '"', Output, False, nil, Info.Root) <> 0 then begin
        TaskMessageDlg(Info.Root, Output, mtError, [mbOK], 0);
      end else begin
        TaskMessageDlg(Info.Root, Output, mtInformation, [mbOK], 0);
      end;
      {$MESSAGE WARN 'TODO: reopen the project if we closed it, otherwise refresh all files'}
    end;
  end;
end;

procedure TVCSInfoWizard.actBranchMenuPopup(Sender: TObject);
var
  Menu: TPopupMenu;
  Project: IOTAProject;
  Info: TRepoInfo;
  Branches: TStringList;
  ActiveBranch, Branch: string;
  mi: TMenuItem;
begin
  Menu := Sender as TPopupMenu;
  Menu.Items.Clear;
  Project := ToolsAPI.GetActiveProject;
  if Assigned(Project) then begin
    Info := GetRepoInfo(Project.FileName);
    if Info.IsRepo then begin
      ExecuteCmd('hg -yq branch', ActiveBranch, False, nil, Info.Root);
      ActiveBranch := ActiveBranch.Trim;
      Branches := TStringList.Create;
      try
        ExecuteCmd('hg -yq branches', Branches.Append, False, nil, Info.Root);
        Branches.Sort;
        for Branch in Branches do begin
          mi := TMenuItem.Create(Menu);
          mi.Caption := Branch;
          mi.Enabled := Branch <> ActiveBranch;
          mi.OnClick := actBranchMenuClick;
          Menu.Items.Add(mi);
        end;
      finally
        Branches.Free;
      end;
    end;
  end;
end;

procedure TVCSInfoWizard.actIncomingExecute(Sender: TObject);
begin
  Self.Execute;
end;

{ ------------------------------------------------------------------------------------------------ }
function TVCSInfoWizard.GetMenuText: string;

Changes to todo.md.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
=====
* Add always-visible UI element(s), so it's always visible when we should sync
* Modularize VCS repo info (re-use clients from radstudioverins?)
* Add a settings window?

User interface:
--------------
* Figure out how to add a button to the editor window.
* Figure out how to respond to events ([XE7 help](ms-help://embarcadero.rs_xe7/rad/Notifying_a_Wizard_of_IDE_Events.html))
  - `IOTAEditorNotifier`: Modifying or saving a source file, or switching files
    in the editor
  - `IOTAModuleNotifier`: Changing, saving, or renaming a module
  - ⇒ whenever a file changes, check the file cache and then the repo cache,
    and if we've changed repo, we should switch our buttons' displayed info to
    the appropriate repo. If that repo's info is out of date, it should be







|







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
=====
* Add always-visible UI element(s), so it's always visible when we should sync
* Modularize VCS repo info (re-use clients from radstudioverins?)
* Add a settings window?

User interface:
--------------
* <strike>Figure out how to add a button to the editor window.</strike>
* Figure out how to respond to events ([XE7 help](ms-help://embarcadero.rs_xe7/rad/Notifying_a_Wizard_of_IDE_Events.html))
  - `IOTAEditorNotifier`: Modifying or saving a source file, or switching files
    in the editor
  - `IOTAModuleNotifier`: Changing, saving, or renaming a module
  - ⇒ whenever a file changes, check the file cache and then the repo cache,
    and if we've changed repo, we should switch our buttons' displayed info to
    the appropriate repo. If that repo's info is out of date, it should be