8

Sometimes a user will copy files using Windows Explorer and commit them when they should have performed an svn repository-level copy or a merge. Thus, SVN does not have proper tracking of these changes. Once I find out about this, the damage is clearly already done and there may have been a lot of subsequent edits to the files in question. It is important not to lose this part of the history as well. Is there anything I can do to retroactively improve things in the repository when I find out these situations have occurred?

Specifically, I have two scenarios, depending on whether the target file already existed or not. In the first sceanrio, (1) the user performed an add that did not record as a copy. In the second scenario, (2) the user performed an update that did not record as a merge.

Furthermore, both the source and the target file have undergone subsequent updates that have also been committed. Sometimes, these subsequent edits have also been made to both sides manually and thus without the proper mergeinfo.

POSSIBILITY: Might manually adding a mergeinfo revprop to the past revision help? If so, how do I do this? Please account for both scenarios.

Jason Kresowaty
  • 16,105
  • 9
  • 57
  • 84
  • Do you mean that the edits to the badly-copied files have been committed to the repository, or are they pending in the local copy? – Attila Jun 15 '12 at 13:53
  • @Atilla, oh yes. By other users. Perhaps months ago. Files might have significant subsequent committed edits too. – Jason Kresowaty Jun 16 '12 at 18:57

3 Answers3

1

Here are the scenarios I can think of and how to resolve them (if possible):

1) the files have been copied and modifications have been committed (to their original URL)

1a) if the branch does not have those files yet:

  • svn-copy the files (or their enclosing directory) to the branch (this will preserve their history)
  • if there were no other changes to those specific files in the trunk, revert the trunk for those files/enclosing directory to the revision right before the copy
  • if there were changes in the trunk to these files, you might still be able to get the changes belonging to the branch out by doing a reverse merge: this should succeed unless some of the changes were overlapping

1b) if the branch does have those files already:

  • svn-merge the trunk's changes to the branch
  • same considerations for the trunk as in 1a)

2) the files have been copied, modifications made but have not been committed (to their original URL as the copy did not change that)

Note: since the modifications have not been committed yet, there is no history to preserve, also nothing to do with the trunk

2a) if the branch does not have those files yet:

  • make a physical copy of the badly-copied files/directory
  • delete the offending folder from the branch's working copy
  • copy/move the previously copied files/directory to the appropriate place in the branch's working copy
  • add the files to the branch

2b) if the branch does have those files already:

  • make a physical copy of the badly-copied files/directory
  • delete the offending folder from the branch's working copy
  • update the working copy of the branch
  • merge(*) the previously copied files/directory with their counterparts in the branch's now up-to-date working copy
  • add the files to the branch

(*) use any regular merging tool for the job, e.g. WinMerge


Update: after your edit I understand your situation better (the above was with the assumption that after the manual copy the URL of the copied folder still pointed to the trunk)

You could try using svn propset --revprop -r <revision> snv:mergeinfo <updated mergeinfo> (unless blocked by a pre-revprop-change hook) on the branch to "fix" the merge info, but I believe you will have to "fix" all subsequent revisions' mergeinfo as well since svn uses this information for fome of its operations (e.g. merges); also, because of the latter, you will have to be very careful about the updated contents.

A better option would be, I think, to just update the log at the revision of the incorrect-commit-to the-branch to include the revision of the trunk the copied files refer to. This way the information is available if needed but no risk of messing up svn's future operations. The big drawback of this approach is that merging the branch back to trunk might have some conflicts that will have to be resolved (as the merge info was not updated). The command to do this opetion is svn propset --revprop -r <revision> svn:log <updated log message>

Attila
  • 28,265
  • 3
  • 46
  • 55
  • if someone just did this and i only have one revision to deal with, i think setting merge info should be enough, does svn merge command do anything special?, it finds out what needs to be merged, copies those files over, when I commit, it stores the delta anyways - my point is, manual winmerge commit + setting merge info should be exactly equal to svn merge + svn commit? – Kalpesh Soni Sep 13 '12 at 18:28
0

Assuming that the file that was copied hasn't been added in the new location, my first thought is to do the following:

  1. Make a backup of the current WC file(s) that were moved
  2. Do a repo move (to preserve history) of the files in #1;
  3. svn up to get the WC in line
  4. Ensure the file(s) were merged correctly and if not use the backups from #1 to get the file(s) in sync.
  5. Commit and move on
AlG
  • 14,697
  • 4
  • 41
  • 54
  • It has been added and committed. Perhaps weeks or months ago. With subsequent edits committed as well to both the original and the mis-"copy" that SVN isn't properly tracking. That's what I meant by "the damage is done". Sorry if I wasn't clear enough. – Jason Kresowaty Jun 16 '12 at 19:00
0

My solution is not technological. Rather I think you have to teach your people they're doing something wrong and show them how to do it right. Nothing to get mad at. Sometimes people (myself included) do something stupid because they haven't realized there is a better way, or because they didn't understand the better way yet.

If this is really recurring, note the mistakes and successes. Tally the results on a board and make it game. Don't pick on people. After some time the issue will wane.

Philippe A.
  • 2,885
  • 2
  • 28
  • 37