Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retroactive copy/merge

Tags:

merge

svn

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.

like image 814
Jason Kresowaty Avatar asked May 29 '12 17:05

Jason Kresowaty


1 Answers

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>

like image 58
Attila Avatar answered Oct 01 '22 23:10

Attila