2
votes

I'm trying to do an import using subgit. Just a one-time migration. My SVN structure contains:

  • branches
    • branch1
    • features
      • branch2
  • hotfixes
    • branch3

I'd like to convert all three to branches in git. I've tried:

proj=myproject; subgit import --svn-url <correctPath>/$proj --authors-file
  ~/authors --branches branches --branches branches/features
  --branches hotfixes --tags tags  $i

This seems to just use "hotfixes" as the only place to import from. (I'm using SubGit version 2.0.2 ('Patrick') build #2731.) I also tried using:

--branches "branches;branches/features;hotfixes"

But that completely failed (it was probably looking for a directory with semi-colons in it).

Any suggestion for the one-time import?

(Note, I saw this related question.)

1
Hmmm... my svn structure wasn't so clear branches - branch1 - features - branch2 - hotfixes - branch3user3550496
'import' command is a short form of 'configure' + 'install' + 'uninstall' commands, so you can use these 3 commands instead of one 'import' command and immediately after 'configure' command modify SubGit config file to specify "branches=" several times.Dmitry Pavlenko
OK, I can't figure out how to make a multiline post of the branch structure. Let's say that I have a branches dir, with a subdir of features. Both branches and features have actual branches I need to migrate. Plus, there is a folder hotfixes at the same level as branches.user3550496

1 Answers

3
votes

You can use a combination of 'configure' + 'install' + 'uninstall' commands. I suppose, your repository has the following structure:

$ svn ls --depth infinity <SVN_URL>                                                                                                                                                     
branches/                                                                                                                                                                                                                         
branches/branch1/                                                                                                                                                                                                                 
branches/branch2/                                                                                                                                                                                                                 
branches/features/                                                                                                                                                                                                                
branches/features/feature1/                                                                                                                                                                                                       
branches/features/feature2/                                                                                                                                                                                                       
hotfixes/                                                                                                                                                                                                                         
hotfixes/hotfix1/
hotfixes/hotfix2/
tags/
tags/tag1/
tags/tag2/
trunk/

Then do the following. Run 'configure' command:

$ subgit configure --svn-url <SVN_URL> repo

Edit repo/subgit/config file to this repository structure (or you can invent your own refs/heads/ namespaces, the only requirement is: the shouldn't be the same for different kinds of branches; if you need one-time import and everything under refs/heads/*, you can rename them later with a script):

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

Run 'install' command:

$ subgit install repo

Then if you run "git branch -a" from "repo" directory, you'll see something like that:

$ git branch -a
  branch1
  branch2
  features/feature1
  features/feature2
  hotfixes/hotfix1
  hotfixes/hotfix2
* master

Optionally you can run 'uninstall' command to disable synchronization temporary or forever (--purge option)

$ subgit uninstall [--purge] repo