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

Excluding Branches and Tags

Sometimes, not all the SVN entities are worth to be imported or mirrored to Git: branches or tags might lose their importance for a project or might be merged into other development line already, they might be just too old or they might be unneeded for those developers who will use Git repository. Whatever exclusion reason is, the branches and tags might be excluded from import/mirror by using two approaches depending on that whether explicit or wildcard mapping approach is used.

When explicit mapping is used, then particular branches and tags might just be omitted from mapping. For example, if the SVN project doesn't follow any naming and placement conventions - i.e. "all branches in a single directory" layout is used - the only way to import/mirror the project to Git is to create an explicit mapping for all the branches and tags. In such case, to exclude any branch or tag from being imported/mirrored that very branch/tag just must be omitted from the mapping. E.g., for unordered SVN project we have considered earlier in the chapter 5.3:

/repository
        /project_N
            /bug_1224           #branch
            /issue1678          #branch
            /features           #second level directory
                /f4536          #branch
                /feat 4589      #branch
            /main               #"main line" (trunk)
            /v.1.5.6_b3345      #some tag (snapshot)
            /1.5.7 build 7890   #some tag (snapshot)

and if we want to mirror features branches only, then we set mapping for those branches only:

trunk = main:refs/heads/master
    #branches = bug_1224:refs/heads/bug_1224
    #branches = issue1678:refs/heads/issue1678
    branches = features/f4536:refs/heads/f4536
    branches = features/feat 4589:refs/heads/feat 4589
    tags = v.1.5.6_b3345:refs/tags/v.1.5.6_b3345
    tags = 1.5.7 build 7890:refs/tags/1.5.7 build 7890

Commented bug and issue mapping line are left here just to visualize the difference, but actually, these lines can just be removed from the configuration.

Another approach to exclude branches and tags from import/mirror is to use

excludeBranches = SIMPLE_PATTERN
    
    excludeTags = SIMPLE_PATTERN

configuration options. Actually, it's the only way to exclude if wildcard mapping approach is used. Let's consider a SVN project with several places where branches and tags are stored:

/repository
         /project
            /trunk
            /branches
                /july
                /greg
            /bugs
                /bug_1920
                /bug_2310
                /bug_2450
                /bug_2780
                /bug_3310
            /features
                /f3425
                /f3445
                /f3450
            /tags
                /0.9
                /1.0beta
            /major_releases
                /v1.0
                /v1.5
                /v2.0
            /minor_releases
                /v1.0.1
                /v1.0.4                
                /v1.5.1
                /v1.5.3
                /v2.0.2

Whole the project structure can be mirrored to Git using the following mapping scheme:

trunk = trunk:refs/heads/master
    branches = branches/*:refs/heads/*
    branches = features/*:refs/heads/features/*
    branches = bugs/*:refs/bugs/*
    tags = tags/*:refs/tags/*
    tags = major_releases/*:refs/major_releases/*
    tags = minor_releases/*:refs/minor_releases/*
    shelves = shelves/*:refs/shelves/*

If you want to import or mirror branches or tags from all the directories, but exclude certain few, the only way is to use the excludeBranches option. Say, you don't want to import/mirror greg branch and 1.0beta tag. The mapping scheme will be the same we created above, and exclusion can be done by the following options:

excludeBranches = branches/greg
    excludeBranches = tags/1.0beta

Note, having these settings, SubGit will search given SVN directories for these patterns and will exclude all the directories that match them. Or, in other words, SubGit creates full paths using these patterns and exclude all the directories that match these paths. In this particular case SubGit will exclude all the directories found by the following paths:

http://example.com/svn/repository/project/branches/greg
    http://example.com/svn/repository/project/tags/1.0beta

supposing the svn.url is set to http://example.com/svn/repository/project.

These two patterns are explicit and actually point to certain SVN directories. However, if you want to exclude several branches that follow some naming pattern, then you can use one wildcard to created the pattern. Say, in addition to greg and 1.0beta we want to exclude some bugs branches:

excludeBranches = branches/greg
    excludeBranches = tags/1.0beta
    excludeBranches = bugs/bug_2*

Such a configuration will exclude bug2310, bug2450, bug_2780 branches that reside in bug directory.

Both the excludeBranches and excludeTags are equivalent, use can use either of the two to exclude both branches and tags. That is, settings

excludeBranches = branches/greg
    excludeBranches = tags/1.0beta
    excludeBranches = bugs/bug_2*

and

excludeTags = branches/greg
    excludeTags = tags/1.0beta
    excludeTags = bugs/bug_2*

do the exact same job, so you can use any of them.

  • No labels