Ignore:
Timestamp:
Jul 13, 2015, 11:44:23 AM (9 years ago)
Author:
chronos
Message:
  • Added: Support for reading file status from working copy.
File:
1 edited

Legend:

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

    r14 r15  
    66
    77uses
    8   Classes, SysUtils, UVCS, UBackend;
     8  Classes, SysUtils, UVCS, UBackend, XMLRead, DOM, UXMLUtils;
    99
    1010type
     
    3333    procedure Remove(FileName: string); override;
    3434    procedure GetLog(FileName: string; Log: TLogList); override;
     35    procedure GetStatus(FileName: string; Status: TFileStatusList); override;
    3536  end;
    3637
     
    172173end;
    173174
     175procedure TSubversion.GetStatus(FileName: string; Status: TFileStatusList);
     176var
     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;
     187begin
     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;
     228end;
     229
    174230end.
    175231
Note: See TracChangeset for help on using the changeset viewer.