Question

I've done some research on why subdirectory merges are bad and recently discovered a subdirectory in our repository that has mergeinfo on it.

I'm trying to remove this merge info manually, and want to see if I'm understanding mergeinfo correctly and doing it properly.

ROOTDIR mergeinfo

/branches/Iteration53:18065-18126

/branches/Iteration54:18150-18204,18210-18231

/branches/Iteration55:18341,18348,18353-18355,18357,18364-18365 <===== This line is different

/branches/gdsRework:17329-17457

/trunk:17869,18085

SUBDIR mergeinfo

/branches/Iteration53/kiwi-web:18065-18126

/branches/Iteration54/kiwi-web:18150-18204,18210-18231

/branches/Iteration55/kiwi-web:18336-18428 <===== This line is different

/branches/gdsRework/kiwi-web:17329-17457

/trunk/kiwi-web:17869,18085

There is only 1 line that is different between the two. I also noticed that the range 18336-18428 in the SUBDIR mergeinfo includes all the revisions of the same line in the ROOTDIR mergeinfo.

So my plan is to just replace that line in ROOTDIR with the line in SUBDIR and delete the SUBDIR mergeinfo all together:

New ROOTDIR merginfo

/branches/Iteration53:18065-18126

/branches/Iteration54:18150-18204,18210-18231

/branches/Iteration55:18336-18428 <===== Now same as SUBDIR mergeinfo

/branches/gdsRework:17329-17457

/trunk:17869,18085

SUBDIR mergeinfo is deleted.

Is this safe? Where would the pitfalls be? Thank you in advance.

Was it helpful?

Solution

It's not recommended to manually edit mergeinfo. Though in past I did something like you described, even with differences between the root and subdir being more complex, such editing is very error-prone and so requires extreme care and accuracy. As I learned later, SVN is powerful enough to fix such situation rather easily; so better don't even get into the habit of manual mergeinfo editing.

The simple case is when the "extra" revisions recorded in the SUBDIR mergeinfo only affect that subdirectory. In this case, all you need is to make a record-only merge of revisions 18336 to 18428 at the ROOTDIR level. The record-only merge will update the mergeinfo for the ROOTDIR without touching any files, and, since the SUBDIR mergeinfo will then be exactly the same as for the ROOTDIR, it will remove that as excessive.

  • If you use SVN commands directly, just add --record-only option to the svn merge command that you'd use for real merge.
  • If you use a GUI client, look for a "record only" or similarly named option in its merge dialog.

Be aware of the difference between a range in mergeinfo (which includes both its ends and everything in between) and a range in -r option (which specifies two revisions to take the diff for); e.g. in the command line you need to specify -r 18335:18428, i.e. the starting revision to take the diff is one less than the first one to be merged.

A more complex case is if these revisions merged into SUBDIR but not ROOTDIR also change files outside of SUBDIR. It's quite likely these changes were not yet merged. If it's safe to ignore these changes, then you may also do a record-only merge. On the contrary, if these changes happened to be missed, you likely will want to do a regular merge for the revisions on the ROOTDIR level, and fix merge conflicts if any.

After the merge (either record only or regular) is done, check that the mergeinfo is properly changed for the directories, and commit the result.

A good article where I learned much about mergeinfo and how it is manipulated by SVN commands (including record-only merge, mergeinfo elision etc.), is here: Subversion 1.5 Mergeinfo - Understanding the Internals. I recommend you to read that before you attempt fixing the mergeinfo in your repository.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top