Saturday, March 11, 2017

Undo a Repair Move in TortoiseSVN

Leave a Comment

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.

1 Answers

Answers 1

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.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment