Page tree

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Branches mapping overview.

Branches mapping is a set of rules that establish a correspondence between SVN and Git branches and tags. These rules are defined by branches mapping configuration options in SubGit configuration file.

Branches and Tags in Subversion.

There are few key Subversion concepts, that matter in the context of SubGit mapping process:

  • repository – a central store, root directory, that holds all data in the form of a filesystem tree. A repository contains one or more projects.
  • project – a data part in a repository, that can be logically distinguished from the rest, like a distinct software product or a library. Most projects have their own recognizable "main lines" and "divergent copies" of development.
  • branch - a distinct line of development that exists independently of all others, yet still shares a common history. A branch is a directory within repository or project, which contains all files of that particular line of development.
  • tag – a named snapshot of a development line in time. A tag is also a directory within repository or project. The main difference between branch and tag is that tags are supposed to be unchanged with time.
  • trunk – a branch, that represents the main line of development. It's a directory within repository or project, which contains the main line of development.
  • revision – a certain state of the filesystem tree, that has an assigned number and commentary.
  • layout – a way how repository or project filesystem tree is organized.
  • standard layout – a repository layout, that Subversion development team recommends to follow. According to that layout, each project resides in its own subdirectory within a repository and has three subdirectories for trunk, branches, and tags.

A SVN repository can be organized in any way and SubGit can deal with any possible SVN repository layout.

A graphical representation of the explained SVN concepts:

Branches and Tags in Git

Unlike SVN, which stores data in the form of a filesystem tree, Git represents its data as a set of snapshots of a filesystem, that is being stored in Git's objects database. Due to this difference, most of Git concepts differ from their SVN counterparts albeit have the same names:

  • repository – a directory, that contains Git database and metadata.
  • commit – a Git object, that contains a pointer to a data snapshot in Git database. Essentially, the commit is a hash-named file in Git database, that contains a reference to a tree object, representing a data snapshot in time.
  • branch – a reference to certain commit; a file in a Git database that contains a hash of a certain commit, thus referencing that particular commit.
  • master branch – a default branch called master that's being created along with new repository. By agreement, it represents the main line of development, but technically it's just another branch.
  • tag – like a branch, a reference to a commit - a file in a Git database that contains a hash of that particular commit. Git supports two kinds of *tags*: *lightweight* and *annotated*; SubGit supports only *lightweight tags*.

A graphical representation of the explained Git concepts:

Mapping Configuration Options

All the mapping configuration assembled in SubGit configuration file. The configuration file is being created at the SVN-to-Git translation beginning by SubGit's configure subcommand. The file is situated in subgit subdirectory inside a newly created Git repository:

SubGit confiuration file
/GIT_REPOS_PATH
    …
    /subgit
       …
       config

Here is an example of how the [svn] of the configuration file may look like:

[svn] section
[svn]
    url = http://svn.example.com/svn/repository_1/project_1
    trunk = trunk:refs/heads/master
    branches = branches/*:refs/heads/project_1/*
    branches = features_*:refs/heads/features/*
    tags = tags/*:refs/tags/*
    shelves = shelves/*:refs/shelves/*
    excludeBranches = features/feat_4510
    excludePath = *.exe


All the mapping settings reside in [svn] configurations section. There are three main settings groups:

  • SVN project location:
    • url - a URL leading to the SVN project.
       
  • Branches and tags mapping rules:
    • trunk - a path, relative to the URL, that leads to project's trunk.
    • branches - a relative path to a directory, containing branches, or a path to a particular branch.
    • tags - a relative path to a directory, containing tags, or a path to a particular tag.
    • shelves - a relative path to a directory, where *shelves* will be kept.
       
  • Refining mapping rules:
    • excludeBranches - a relative path or path pattern with one wildcard, that point to branches or tags, that should be excluded from translation.
    • excludeTags - same as excludeBranches.
    • excludePath - an expression, representing files to be excluded from the translation.
    • includePath - an expression, representing files to be included in the translation.

svn.url

This option sets a URL to the SVN project, that is being translated into Git repository. SubGit translates a SVN project into a Git repository: not whole SVN repository to Git repository:

Thus, the `svn.url` setting is supposed to point to your SVN project root, not to SVN repository root; i.e., if you want to mirror, say, 'project1' to Git, then the svn.url must be set as follows:

svn.url
[svn]
    url = http://example.com/svn/repository/project1

Most of the mapping settings rely on this path and their values are being set relative to this project root.

SubGit support all protocols SVN supports, so the svn.url can be set using the following protocol prefixes:

  • file:///
  • svn://
  • svn+ssh://
  • http://
  • https://

Mapping settings

The next four options – trunk, branches, tags, shelves – actually tell SubGit how SVN to Git entities match to each other. Generic mapping syntax is:

     <Mapping-option> = <Subversion-Path-Pattern>:<Git-Reference-Pattern>

where

  • Mapping-option - essentially, a mapping option: trunk, branches, tags or shelves.
  • Subversion-Path-Pattern – a SVN directory path relative to `svn.url`.
  • Git-Reference-Pattern – a path inside Git repository where references will be stored.

svn.trunk

This setting establishes a correspondence between SVN *trunk* and Git branch that represents the main line of development. Assuming, that SVN "main line of development" is being kept in a directory named trunk and Git master branch represents the "main line" in Git, the mapping may look like this:

trunk = trunk:refs/heads/master

where

  • the first trunk is a mapping option name, determining which entity is being mapped.
  • the second trunk is a path to SVN directory, which plays a role of trunk. This path is relative to specified svn.url i.e. the full path to that directory consists of the URL and this path. Thus, suppose the URL is set like follows:
          url = http://example.com/svn/repository/project1

In this case, the full path to the SVN trunk is equal to:

          http://example.com/svn/repository/Project1/trunk
  • refs/heads/master – a path in Git repository, where the branch reference is kept. In this case, SVN trunk is being translated into Git master branch.

There are few rules that apply to the svn.trunk option:

Trunk mapping rules

    • trunk must be mapped; the only exclusion is the configuration with no defined mapping - no trunk, branches, tags and shelves options at all - that may be used to import SVN projects with no branches.
    • there must be only one trunk mapping.
    • trunk cannot contain wildcards.






  • No labels