Search code examples
svn

How to prevent losing commit history in Subversion after merges?


Setup simple SVN project layout:

svnadmin create proj-repo
svn co file://$PWD/proj-repo proj
cd proj
mkdir branches trunk tags features
svn add *
svn ci -m 'Basic SVN project setup.'

Start project:

cd trunk
svn add README
svn ci -m 'Add README'

Implement features:

svn cp . ^/features/linux-port
cd ../../
svn co file://$PWD/proj-repo/features/linux-port proj-linux-port
cd proj-linux-port
svn ci -m "Implement feature 1."
svn ci -m "Implement feature 2."
svn ci -m 'Add last feature.'

Do job in main dev branch:

svn switch ^/trunk
svn ci -m "Fix."

Ready for new features:

svn merge --reintegrate ^/features/linux-port
svn ci -m 'Integrate features.'

But now:

svn log .

------------------------------------------------------------------------
r9 | user | 2013-07-30 18:38:01 +0300 (Tue, 30 Jul 2013) | 1 line

Integrate features.
------------------------------------------------------------------------
r8 | user | 2013-07-30 18:36:53 +0300 (Tue, 30 Jul 2013) | 1 line

Fix.

and:

svn diff -r9

Index: README
===================================================================
--- README      (revision 8)
+++ README      (revision 9)
@@ -1,2 +1,5 @@
 hello fix

+feature 1
+
+feature 2
+
+final feature

Property changes on: .
___________________________________________________________________
Added: svn:mergeinfo
   Merged /features/linux-port:r2-8

So I lose subsequent commits for each individual features from /features/linux-port:r2-8. Is it possible to preserve them without switching to HG/Git/Bzr/Fossil?

UPDATE We usually write good commit messages where explain coding decision and put links to BTS. SVN erase these info and we're very sad.

So we need use old school Changelog?


Solution

  • Oh, I just carefully read:

    svn help log
    
      -g [--use-merge-history] : use/display additional information from merge
    

    So full history available with usual SVN tools.

    To see actual diff use hat path syntax:

    svn diff -c 4 ^/
    

    Also I found apropriate section in official docs:

    http://svnbook.red-bean.com/en/1.7/svn.branchmerge.advanced.html

    The svn blame command also takes the --use-merge-history (-g) option.
    If this option is neglected, somebody looking at a line-by-line annotation
    of file may get the mistaken impression that you were responsible for the lines
    that fixed a certain error