Paulkl
Paulkl

Reputation: 1

SVN - Merge history while recreating repository structure

in preparation to change the VCS from SVN to Git on legacy projects, I stumbled about the necessity to arrange the projects in a certain way to make proper use of svn2git , that is

  1. Project_1
  1. Project_2 ...

I know that directories, including their history can be moved to new folders using svn mv --parents SRC DST. Yet I face the particular challenge of such structure:

  1. trunk
  1. branches
  1. tags

Is there a way to merge the history of trunk/Project_1, branches/branch_1/Project_1 etc into one new folder Project_1 with corresponding subdirectories as svn2git expect ?

My current solution is:

svn mv --parents trunk/Project_1 ./Project_1/trunk
svn mv --parents branches/branch_1/Project_1 ./Project_1/branches/branch_1

, but obviously the history of the new dir "Project_1" is empty

Upvotes: 0

Views: 68

Answers (2)

Lazy Badger
Lazy Badger

Reputation: 97385

Just don't use svn2git, because

  • even mentioned git-svn allow more flexibility in initial SVN-tree
  • if core git-svn will not be able to handle your tree correctly (but I don't think so) your can use SubGit, which cover (with properly configured options) even extremely exotic cases

Upvotes: 1

ulidtko
ulidtko

Reputation: 15642

with corresponding subdirectories as svn2git expect

I don't know about svn2git (never used it even once), but git-svn itself is very flexible and accepts many sorts of weird nonstandard svn directory structures.

With git-svn, you don't have to svn mv anything. You just have to call git svn init with properly configured options:

-T<trunk_subdir>
--trunk=<trunk_subdir>
-t<tags_subdir>
--tags=<tags_subdir>
-b<branches_subdir>
--branches=<branches_subdir>
-s
--stdlayout 

After git svn init and before git svn fetch, you may review and fixup the trunk/branches/tags matching patterns in .git/config. There, you can remap svn paths using glob patterns, and you can also ignore svn paths by glob patterns.

So if I understand correctly what you're trying to do, you'll have 2 git repos, Project_1 and Project_2. To obtain Project_1, you'd do steps roughly along the lines:

SVNBASEURL=svn+ssh://user@subversion-server.example/top

mkdir Project_1; cd Project_1
git init
git svn init \
  --trunk=trunk/Project_1 \
  --branches='branches/*/Project_1' \
  --tags='tags/*/Project_1' \
  "$SVNBASEURL"/

# review/edit/fix/tune .git/config into shape

git svn fetch

And similarly for Project_2. Good luck!

Upvotes: 0

Related Questions