1

How do I check if a file is already in a repository (or NOT in the repository) so I can determine whether I need to 'add' it first before doing the check in? (For the record, I have check-in working, but I get an exception when I try to check in a file that has not yet been added to the repository.)

JasCav
  • 34,458
  • 20
  • 113
  • 170
  • 1
    possible duplicate of [How to check if file is under source control in SharpSvn?](http://stackoverflow.com/questions/868701/how-to-check-if-file-is-under-source-control-in-sharpsvn) – Hans Olsson Oct 20 '11 at 12:42

2 Answers2

1

I believe you can use SvnClient.GetRepositoryIdFromUri to verify that a specific file exists. If that method returns false, then you'll need to Add the file to the repository.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • I took a look at that. However, when I pass the URL as a local string path (C:\Path\To\File.txt), the URI that is created seems incorrect. Maybe I am just formatting the URI incorrectly? – JasCav Mar 31 '10 at 01:58
  • You can use .TryGetRepositoryId(Uri, out Guid) for urls and .TryGetRepositoryId(string, out Guid) for local paths. If you pass a local path to SharpSvn via a Uri, you pass a file:/// style url. – Bert Huijben Apr 01 '10 at 08:35
  • @Bert - Unfortunately, I am still getting back the System.Guid.Empty value as a response, even though the file is already in the repository. – JasCav Apr 03 '10 at 15:34
  • Attempted to use .TryGetRepository(uri, out guid) to check if a bogus file exists on the remote repo and it both returned true and a non-empty guid. Does this method simply check if the patch is there and not the file? I see in the method summary `Gets the Uuid of a Uri, or System.Guid.Empty if path is not versioned` – Knightwisp Jul 14 '16 at 07:58
0

While SvnClient.GetRepositoryIdFromUri may work (I wasn't able to get it working), I did find an answer elsewhere on SO which did work (this didn't come up in my original search, so sorry about the duplicate question).

Community
  • 1
  • 1
JasCav
  • 34,458
  • 20
  • 113
  • 170
  • I've used `GetRepositoryIdFromUri` for quite some time and had no issues so far. But today I realized that it fails if you use it with a previously in SVN deleted file. So deleting a file in SVN and recreating it on the file system will give you false results when using `GetRepositoryIdFromUri`. At least for me that was not the expected result. – Carsten Franke May 03 '18 at 11:10