Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo a Repair Move in TortoiseSVN

Suppose I have renamed File A to File B with windows explorer and created a new File C.

In Tortoise SVN, I accidently use the "Repair Move" on File A and C, instead of A and B. Is there an easy way to undo the repair (and redo it with the right files)? Changes are not committed at that point.

The only way I'm currently aware of is reverting the delete and add, which will restore File A, then manually delete the file again and redo the associations correctly. With multiple files involved, this somewhat involves the risk of accidently reverting local changes, so I'm interested if there is a better way.

Note: even though TortoiseSVN is used to produce the problem, an answer with svn console is also acceptable.


Here is the example with Files A.txt, B.txt and C.txt step by step:

After A is renamed to B and C is added locally

>svn st
!       A.txt
?       B.txt
?       C.txt

After Tortoise SVN "Repair move" is incorrectly applied A -> C

>svn st
D       A.txt
        > moved to C.txt
?       B.txt
A  +    C.txt
        > moved from A.txt

My workflow to fix the situation, which I'm not really happy with:

>ren C.txt C.txt.bak
>svn revert C.txt A.txt
>ren C.txt.bak C.txt
>del A.txt

Resulting in the starting situation from where I can redo the repair with correct files

>svn st
!       A.txt
?       B.txt
?       C.txt

What I would love but which doesn't appear to exist

svn mv --force --ignore-files A.txt B.txt
svn add --force C.txt

in a way that it ignores that A is already marked deleted and allow a history transfer from A to B, reinterpreting C as clean add instead of transfering history from A.

like image 631
grek40 Avatar asked Feb 20 '17 14:02

grek40


People also ask

How do I revert changes in SVN?

Right click on the selected revision(s), then select Context Menu → Revert changes from this revision. Or if you want to make an earlier revision the new HEAD revision, right click on the selected revision, then select Context Menu → Revert to this revision. This will discard all changes after the selected revision.

What is Revert changes from this revision?

If you want your entire local source code to revert back to the way things were at some previous revision, choose "Revert to this revision." If instead you want to keep your local source up-to-date, but undo some change that was made several revisions ago, then you don't want your entire local source to go back, you ...

How do I recover a deleted SVN repository?

Getting a deleted file or folder back If you have not committed a delete operation to the repository, then use TortoiseSVN -> Revert to retrieve the file. If you have already committed the deletion: Use the log dialogue box to find out the revision of your file.


1 Answers

There is way involving 2 commands on A.txt only instead of the 4 commands in your current workflow (affecting C.txt too). After TortoiseSVN "repair move" is incorrectly applied, execute:

svn revert A.txt
del A.txt

svn stat will be:

!       A.txt
?       B.txt
A  +    C.txt

From Tortoise SVN you can now "repair move" between A.txt and B.txt, resulting in the correct state:

D       A.txt
        > moved to B.txt
A  +    B.txt
        > moved from A.txt
A  +    C.txt

Same technique can be used in TortoiseSVN UI (revert A.txt, then delete A.txt from the explorer). The reason why this works, is that the move state is coupled to the missing file, not to the non-versioned file. The only modification on C.txt is, that it was added by using the repair move command (which you wanted to add probably anyway).

The "Repair move" command only works if exactly two files are selected, one having the "missing" and the other the "non-versioned" status. Only that way TortoiseSVN can find out which file got renamed to which file.

https://tortoisesvn.net/repairmoves.html

After reverting & deletion of A.txt you end up with a missing file (A.txt) and a non-versioned file (B.txt) again, as before the incorrect applied repair move. So you can apply repair move again between these two files.

like image 132
Constantin Avatar answered Sep 23 '22 21:09

Constantin