简体   繁体   中英

reading SVN:externals from working copy

Until recently it was simple to read all the SVN:Externals referenced in a subversion working copy by just reading some text files stored in the .svn subdirectory. With the change to a new on disk structure using mysql tables this is no longer that simple.

I want to update an internally used tool that used to read that list of externals to using the new structure. The Tool is written in Delphi 2007 so I would prefer some code written in Delphi.

There is Version Insight for RAD Studio on sourceforge which might contain some code to do the trick but I wonder if any body else has maybe already gone through the work of extracting the required parts from that project or has an alternative.

You can also do it programmatically, using the Subversion client DLLs. Here is a minimal example written in Delphi XE:

program svnext;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  SvnClient;

procedure Main;
var
  SvnClient: TSvnClient;
  SvnItem: TSvnItem;
begin
  // Subversion client DLL directory; here I simply use the .exe's directory
  // (I copied the DLLs there manually.)
  BaseDllDir := ExtractFilePath(ParamStr(0));

  SvnClient := nil;
  SvnItem := nil;
  try
    SvnClient := TSvnClient.Create;
    SvnClient.Initialize;
    SvnItem := TSvnItem.Create(SvnClient, nil, ParamStr(1));
    Writeln(SvnItem.PropValues['svn:externals']);
  finally
    SvnItem.Free;
    SvnClient.Free;
  end;
end;

begin
  try
    Main;
  except
    on E: Exception do
    begin
      ExitCode := 1;
      Writeln(Format('[%s] %s', [E.ClassName, E.Message]));
    end;
  end;
end.

You might have to tweak the code for Delphi 2007. It seems Version Insight has evolved in the meantime and lost (some of) the backward compatibility.

If you can call the svn executable, it is pretty easy to find all the externals stored in your repository :

svn propget -R svn:externals .

will return :

first/path/to/external - name_of_first_external http://first_repos/that/is/in/external
second/path/to/external - name_of_second_external http://second_repos/that/is/in/external

Like others said, call the SVN executable. You can integrate this with the Delphi Tools menu using this technique: http://delphi.wikia.com/wiki/Adding_TortoiseSVN_to_the_Tools_menu

To add to that article, it's also VERY handy to have an "open folder here" entry that opens Windows Explorer for the folder of the file being edited. Here's the "tool properties" for that:

  • Title: Open Folder Here
  • Program: explorer.exe
  • Parameters: $PATH($EDNAME)

If you have this, then you've got all of TortoiseSVN at your fingertips.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM