Changeset 4 for trunk


Ignore:
Timestamp:
Mar 2, 2022, 11:00:51 PM (3 years ago)
Author:
chronos
Message:
  • Modified: Generalized svn info parsing.
  • Added: Language files for translation of text strings.
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore set to
      lib
      svnzero
      svnzero.dbg
      SVNZero.lps
      heaptrclog.trc
  • trunk/Install/deb/build.sh

    r2 r4  
    44#ARCH=x86_64-linux
    55
    6 BUILD_ROOT=/tmp/build-root/2048
     6BUILD_ROOT=/tmp/build-root/SVNZero
    77mkdir -p $BUILD_ROOT
    88cp -r -f ../.. $BUILD_ROOT
  • trunk/SVNZero.lpi

    r3 r4  
    1414      <ResourceType Value="res"/>
    1515    </General>
     16    <i18n>
     17      <EnableI18N Value="True"/>
     18      <OutDir Value="Languages"/>
     19    </i18n>
    1620    <BuildModes>
    1721      <Item Name="Debug" Default="True"/>
  • trunk/USubversion.pas

    r3 r4  
    1010
    1111type
     12  TSubversionInfo = record
     13    Checksum: string;
     14    Revision: string;
     15    URL: string;
     16    Path: string;
     17  end;
    1218
    1319  { TExecute }
     
    2127    procedure Execute(Parameters: array of string); virtual;
    2228    procedure ExecuteOutput(Parameters: array of string);
     29    function GetInfo(Text: string): TSubversionInfo;
    2330  end;
    2431
     
    97104end;
    98105
     106function TExecute.GetInfo(Text: string): TSubversionInfo;
     107var
     108  Index: Integer;
     109  Lines: TStringList;
     110  I: Integer;
     111  Line: string;
     112  Name: string;
     113  Value: string;
     114begin
     115  Lines := TStringList.Create;
     116  try
     117    Lines.Text := Text;
     118    for I := 0 to Lines.Count - 1 do begin
     119      Line := Trim(Lines[I]);
     120      Index := Pos(':', Line);
     121      if Index > 0 then begin
     122        Name := Trim(Copy(Line, 1, Index - 1));
     123        Value := Trim(Copy(Line, Index + 1, MaxInt));
     124        if Name = 'Checksum' then Result.Checksum := Value
     125        else if Name = 'Revision' then Result.Revision := Value
     126        else if Name = 'Path' then Result.Path := Value
     127        else if Name = 'URL' then Result.URL := Value;
     128      end;
     129    end;
     130  finally
     131    Lines.Free;
     132  end;
     133end;
     134
    99135{ TSubversionAdmin }
    100136
  • trunk/USvnZero.pas

    r3 r4  
    2121    procedure ZeroPristine;
    2222    procedure RestorePristine;
    23     function GetFileChecksum(Text: string): string;
    24     function GetFileRevision(Text: string): string;
    25     function GetFileURL(Text: string): string;
    2623    function GetWorkingCopyRootPathFromText(Text: string): string;
    2724    function GetSvnDir(FileName: string): string;
     
    8178procedure TSvnZero.RestorePristine;
    8279begin
    83 
    84 end;
    85 
    86 function TSvnZero.GetFileChecksum(Text: string): string;
    87 var
    88   Index: Integer;
    89 const
    90   StartText = 'Checksum: ';
    91 begin
    92   Index := Pos(StartText, Text);
    93   if Index > 0 then begin
    94     Result := Copy(Text, Index + Length(StartText), MaxInt);
    95     Index := Pos(LineEnding, Result);
    96     if Index > 0 then begin
    97       Delete(Result, Index, MaxInt);
    98     end;
    99   end;
    100 end;
    101 
    102 function TSvnZero.GetFileRevision(Text: string): string;
    103 var
    104   Index: Integer;
    105 const
    106   StartText = 'Revision: ';
    107 begin
    108   Index := Pos(StartText, Text);
    109   if Index > 0 then begin
    110     Result := Copy(Text, Index + Length(StartText), MaxInt);
    111     Index := Pos(LineEnding, Result);
    112     if Index > 0 then begin
    113       Delete(Result, Index, MaxInt);
    114     end;
    115   end;
    116 end;
    117 
    118 function TSvnZero.GetFileURL(Text: string): string;
    119 var
    120   Index: Integer;
    121 const
    122   StartText = 'URL: ';
    123 begin
    124   Index := Pos(StartText, Text);
    125   if Index > 0 then begin
    126     Result := Copy(Text, Index + Length(StartText), MaxInt);
    127     Index := Pos(LineEnding, Result);
    128     if Index > 0 then begin
    129       Delete(Result, Index, MaxInt);
    130     end;
    131   end;
    13280end;
    13381
     
    226174var
    227175  FileName: string;
    228   FileChecksum: string;
    229176  I: Integer;
    230177  ExportedFileName: string;
    231178  PristineFileName: string;
    232   FileURL: string;
    233   Revision: string;
     179  Info: TSubversionInfo;
    234180begin
    235181  Result := False;
     
    243189
    244190      Subversion.Execute(['info', FileName]);
    245       FileChecksum := GetFileChecksum(Subversion.StandardOutput);
    246       Revision := GetFileRevision(Subversion.StandardOutput);
    247       FileURL := GetFileURL(Subversion.StandardOutput);
     191      Info := GetInfo(Subversion.StandardOutput);
    248192      ExportedFileName := GetSvnDir(FileName) + DirectorySeparator + 'tmp' +
    249193        DirectorySeparator + 'ExportedFile.bin';
    250       PristineFileName := GetPristineDir(FileName) + DirectorySeparator + Copy(FileChecksum, 1, 2) +
    251         DirectorySeparator + FileChecksum + '.svn-base';
    252       Subversion.Execute(['export', '-r', Revision, '--force', FileURL, ExportedFileName]);
     194      PristineFileName := GetPristineDir(FileName) + DirectorySeparator + Copy(Info.Checksum, 1, 2) +
     195        DirectorySeparator + Info.Checksum + '.svn-base';
     196      Subversion.Execute(['export', '-r', Info.Revision, '--force', Info.URL, ExportedFileName]);
    253197      MakeFileWriteable(PristineFileName);
    254198      CopyFile(ExportedFileName, PristineFileName);
Note: See TracChangeset for help on using the changeset viewer.