Pergunta

Please consider the following scenario:
1. User A creates and commits a file (lets say file1.txt).
2. User B deletes this file from the repository.
3. User A has the file in his local working copy and would like to restore it. The user finds that out after an Update() was done.

What is the proper way to achieve this?

So far I've tried:
- Client.Revert() followed by Update but I see no change.
- Client.Merge(local_working_copy, SvnUriTarget_of_repository, revision_range_between_the_previous_and_new) - still no change.
- Client.DiffMerge(), where the target path is the local path of the file, the merge_from is the path in the repository with the previous revision number, and the merge_to is the local path with the new revision. - I get an exception saying that the file is not under version control. It can't be added since it doesn't exist locally anymore. When I replaced the target path to be the repository path I get an exception saying this is not a working copy.

Please help,
Noa

Foi útil?

Solução 2

For anyone else who might need this and has no previous experience with SVN:

When running update, use this useful answer to subscribe to the Update() event. This way you can save all the names of the files that were deleted (or whatever other action interests you).

Then, after Update() is done, you can use Copy() as follows:
Copy(new SvnUriTarget(path/to/file/in/repository, new SvnRevision(the_old_revision_which_had_the_files)), local/path/to/file);

Now all that's left is to Commit() the file(s) back to the repository and you're done :)

Noa

Outras dicas

You should reverse the revision properties, because you're reversing the merge. This means you have to create an SvnRevisionRange like:

new SvnRevisionRange(newRevision, oldRevision);

When you use from old to new, you're trying to apply the same change again (which is a no-op because it has already happened).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top