Page tree
Skip to end of metadata
Go to start of metadata

Layout Changed over History

As it was mentioned, SVN project relayout brings a peculiarity to SubGit mirroring process. The peculiarity is that part of the SVN revisions history will be lost during import/mirror to Git. Not all the history, of course, but the history of relocated directories. Let's take a look at the example: say, you created a branch called new_branch right in SVN project's root:

/repository
        /project
            /new_branch
            /branches
            /tags
            /trunk

you made some commit to that branch and then realized that new_branch was improper name so you renamed it to feat_1725:

/repository
        /project
            /feat_1725
            /branches
            /tags
            /trunk

made some commit and finally decided that the branches had to reside in branches directory, so you moved it

/repository
        /project
            /branches
                /feat_1725
            /tags
            /trunk

so SVN log show the following history for that branch:

$ svn log -v branches/feat_1725/
    ------------------------------------------------------------------------
    r158 | user | 2017-06-05 12:38:19 +0500 (Mon, 05 Jun 2017) | 1 line
    Changed paths:
       A /kafka/branches/feat_1725 (from /kafka/feat_1725:157)
       D /kafka/feat_1725

    moved feat_1725 into branches directory
    ------------------------------------------------------------------------
    r157 | user | 2017-06-05 12:37:41 +0500 (Mon, 05 Jun 2017) | 1 line
    Changed paths:
       M /kafka/feat_1725/main.c

    edited main.c in feat_1725 in project's root
    ------------------------------------------------------------------------
    r156 | user | 2017-06-05 12:36:56 +0500 (Mon, 05 Jun 2017) | 1 line
    Changed paths:
       A /kafka/feat_1725 (from /kafka/new_branch:155)
       D /kafka/new_branch

    renamed new_branch to feat_1725
    ------------------------------------------------------------------------
    r155 | user | 2017-06-05 12:36:13 +0500 (Mon, 05 Jun 2017) | 1 line
    Changed paths:
       M /kafka/new_branch/main.c

    changed main.c in new_branch in project's root
    ------------------------------------------------------------------------
    r154 | user | 2017-06-05 12:35:03 +0500 (Mon, 05 Jun 2017) | 1 line
    Changed paths:
       A /kafka/new_branch (from /kafka/trunk:153)

    new_branch created

At this point, if you import/mirror this SVN project to Git using standard mapping configuration:

trunk = trunk:refs/heads/master
    branches = branches/*:refs/heads/*
    tags = tags/*:refs/tags/*
    shelves = shelves/*:refs/shelves/*

you won't see all those changes in Git - the history will start from last moving operation:

$ git log
    commit cec14db7c3e02e30b493456de4e6cf666eefcf3c
    Author: user <user@example.com>
    Date:   Mon Jun 5 07:38:19 2017 +0000

        moved feat_1725 into branches directory

Luckily, there is a way to retrieve whole history: to do this you need to add all the names this branch had into the mapping configuration. Thus, in this case we have to set the mapping configuration like this:

trunk = trunk:refs/heads/master
    branches = branches/*:refs/heads/*
    branches = feat_1725:refs/heads/feat_1725_1
    branches = new_branch:refs/heads/new_branch
    tags = tags/*:refs/tags/*
    shelves = shelves/*:refs/shelves/*

Note, that neither new_branch nor feat_1725 are present in the project's root directory anymore, we add them into mapping configuration only to retrieve whole history. Now, having this mapping scheme we will see everything:

$ git log --pretty=oneline
    224a955c70f8dac47cefc3eaa80e4d31d46a1a1c moved feat_1725 into branches directory
    8dcc92d43b6a6457611f41b6672ff2c9a83c56da edited main.c in feat_1725 in project's root
    219185494a74014984f5e0a5a79dfe23ec7f4095 renamed new_branch to feat_1725
    f7c2fc95c20c675834d209c8b82bf364cb737d34 changed main.c in new_branch in project's root
    a888f553cb7305251a167d547f5c2eafbc9624a9 new_branch created

Note that SubGit tool is smart enough and it's mostly able to determine such cases and create correct mapping scheme when subgit configure is used in conjunction with --layout auto option.

This SubGit peculiarity doesn't affect any other import/mirror aspects, all the rest features work fine, so if you don't need to see whole the history in Git, then you can relayout the SVN project in any way you want. But if otherwise, it's crucial for you to see the history in Git - it's better not to change the layout and mirror the SVN project "as-is".

  • No labels