How to correctly retrieve SVN-Info from relative URI in SVN-external using SharpSvn
Asked Answered
I

0

12

I have a Powershell Cmdlet, which creates SVN-Branches from the trunk via SharpSvn. The repository contains externals with and without revision/pegRevision explicitly set. In the branch, all externals with no revision set should be to their HEAD revision at creation time of the branch, s.t. future changes don't affect the branch.

Therefore, I extract the external-info into SharpSvn.SvnExternalItem and query the repository for the current HEAD revision of each external found using SharpSvn.SvnClient.GetInfo(SvnTarget externalTarget, out SvnInfoEventArgs info)

Hence, I need a robust way to get from the ExternalInfo to the SvnTarget (or directly to the revision info). I don't want to restrict the format of the external URIs, i.e. all the possibilities shown here should work. Is there a clean solution in SharpSvn to resolve all those kinds of URIs to an absolute URI or an alternative way to retrieve its latest revision?

E.g. something like this would be great (I know my external uri and the absolute URI of the directory defining the external, which is surely needed for relative URIs):

public SvnTarget ResolveExternalUri(SvnUriTarget aOwningDirectory, string aExternalReferenceUri) {
  // yeah, I know this does not exist (yet?)
  return SvnUri.Combine(aOwningDirectory.Uri, aExternalRefferenceUri);
}

Currently, I am just parsing the external URI-string myself, check if it's relative or absolute and treat those '^' and '//' prefixes, but I am not sure if I support all variants and I thought this should be a quite common task, which could already be solved by some hidden gem in the SvnClient-lib.

Inarticulate answered 29/8, 2012 at 15:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.