Changeset 9 for trunk/USubversion.pas


Ignore:
Timestamp:
Aug 21, 2022, 7:07:10 PM (2 years ago)
Author:
chronos
Message:
  • Modified: Restore pristine files for deleted files with using information from subversion SQLite3 database.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/USubversion.pas

    r5 r9  
    44
    55uses
    6   Classes, SysUtils, Process, FileUtil
     6  Classes, SysUtils, Process, FileUtil, UExecute
    77  {$IFDEF UNIX}, baseunix{$ENDIF};
    88
     
    1515  end;
    1616
    17   { TExecute }
    18 
    19   TExecute = class
    20   protected
    21     function GetExecutable: string; virtual;
    22   public
    23     StandardOutput: string;
    24     ErrorOutput: string;
    25     procedure Execute(Parameters: array of string); virtual;
    26     procedure ExecuteOutput(Parameters: array of string);
    27     function GetInfo(Text: string): TSubversionInfo;
    28   end;
    29 
    3017  { TSubversion }
    3118
     
    3522    function GetExecutable: string; override;
    3623  public
     24    function GetInfo(Text: string): TSubversionInfo;
    3725  end;
    3826
     
    5038implementation
    5139
    52 { TExecute }
    53 
    54 function TExecute.GetExecutable: string;
    55 begin
    56   Result := '';
    57 end;
    58 
    59 procedure TExecute.Execute(Parameters: array of string);
    60 var
    61   Process: TProcess;
    62   I: Integer;
    63   Buffer: string;
    64   Count: Integer;
    65 begin
    66   StandardOutput := '';
    67   ErrorOutput := '';
    68   Buffer := '';
    69   try
    70     Process := TProcess.Create(nil);
    71     Process.Executable := GetExecutable;
    72     for I := 0 to Length(Parameters) - 1 do
    73       Process.Parameters.Add(Parameters[I]);
    74     Process.Options := [poUsePipes, poNoConsole];
    75     Process.Execute;
    76     while Process.Running or (Process.Output.NumBytesAvailable > 0) or
    77     (Process.Stderr.NumBytesAvailable > 0) do
    78     begin
    79       if Process.Output.NumBytesAvailable > 0 then begin
    80         SetLength(Buffer, 1000);
    81         Count := Process.Output.Read(Buffer[1], Length(Buffer));
    82         SetLength(Buffer, Count);
    83         StandardOutput := StandardOutput + Buffer;
    84       end;
    85       if Process.Stderr.NumBytesAvailable > 0 then begin
    86         SetLength(Buffer, 1000);
    87         Count := Process.Stderr.Read(Buffer[1], Length(Buffer));
    88         SetLength(Buffer, Count);
    89         ErrorOutput := ErrorOutput + Buffer;
    90       end;
    91       Sleep(1);
    92     end;
    93   finally
    94     Process.Free;
    95   end;
    96 end;
    97 
    98 procedure TExecute.ExecuteOutput(Parameters: array of string);
    99 begin
    100   Execute(Parameters);
    101   if StandardOutput <> '' then Write(StandardOutput);
    102   if ErrorOutput <> '' then Write(ErrorOutput);
    103 end;
    104 
    105 function TExecute.GetInfo(Text: string): TSubversionInfo;
     40function TSubversion.GetInfo(Text: string): TSubversionInfo;
    10641var
    10742  Index: Integer;
Note: See TracChangeset for help on using the changeset viewer.