In subversive activities, someone deleted a file and added it with changes in one commit, how can I fix this?

Someone made one subversion transaction, which would delete the file, and added a new file with the same name, which consists of the source files along with ~ 155 new lines.

(I have no idea how they did it.)

Now 'svn log' shows only the history returning to this commit, and I have to jump over the hoops if I want to change the versions of this file before and after the moment they did it. (For example, 'svn diff url @oldrev url @newrev' instead of 'svn diff -rn: m')

After that, several commits were made to this file. (About 3).

How can i fix this?

I use the client string 'svn' client on Linux.

+4
source share
3 answers

Mightymuke is actually right:

Here are the instructions:

  • pay attention to all changes to the newly created file (I call them R1 .. in Rn)
  • mark revision when source file was deleted (I call it Rd)
  • check working copy with at least this file
  • delete the new file and commit the changes and indicate in the commit message that the file was added incorrectly in commit R1 (specify the version and make sure everyone can understand why this was wrong)
  • update your working copy ('svn update')
  • if you use tortoiseSVN, use the show log and find Rd in the history, click on it and right-click on the remote file and select "Revert changes from this version". Do not use this in the entire revision, because then you will also undo other changes. Other OSs use reverse merging for this ("-c-Rd" means, for example, "-c-50" if 50 was a revision of your remote file):

    svn merge -c-Rd

  • copy the current contents of the file from the deleted file to the restored one and commit (specify the discard of the changes R2..Rn in the commit message). Alternative: you can recreate each of the old versions and transfer them separately (specify the original version of R2 ... Rn in each commit message)

+2
source

Here are the commands:

$ svn log affected # Find the last rev that is good, and write it down. $ svn rm affected $ svn ci -m'Reverting to save.' affected $ svn cat -rGOOD_REV affected > affected $ svn up # important $ svn add affected $ svn ci -m'Readding damaged file.' affected $ svn up # important # Get revisions after bad import $ svn diff -rBAD_REV:BAD_REV_PLUS_ONE > diff1.txt $ patch -p0 < diff1.txt $ svn ci -m'Rescued -rBAD_REV_PLUS_ONE.' affected $ svn diff -rBAD_REV_PLUS_ONE:BAD_REV_PLUS_TWO > diff2.txt $ svn ci -m'Rescued -rBAD_REV_PLUS_TWO.' affected 
0
source

I understand that this is an old question, but so far it has no simple answer.

The problem described above is simple. In one commit, you delete the file. In a later commit, you re-add the file. This breaks the svn history between two files with the same name.

The fix is ​​simple. You will need to make svn rm most recent file, svn cp correct preliminary version of the file, then manually update the file with the latest updates and check it back.

For example, suppose myFile.h was removed in revision 1234:

 $ cp myFile.h myFile.h.latest # save copy of latest edits. $ svn rm myFile.h # remove file from svn $ svn cp myFile.h@1233 myFile.h # restore the pre-deleted revision (along with history) $ cp myFile.h.latest myFile.h # overwrite local copy with latest edits $ svn ci myFile.h # save to SVN 
0
source

Source: https://habr.com/ru/post/1447046/


All Articles