gitsvnmigrationkde-plasmasvn2git

KDE svn2git rules - defining multiple folders


I have an SVN structure of the following:

- Project A
  - Folder 1
    - Folder a
    - Folder b
      - Folder 1
        - trunk
        - tags
          ...
      - Folder n
        - trunk
        - tags
  - Folder 2
  - Folder 3
- Project B

In terms of writing KDE matching rules for svn2git, is the following correct:

create repository repo
end repository

match Project A/Folder 1/Folder b/([^/]+)/trunk/([^/]+)/
  repository repo/Project A/Folder b/([^/]+)
  branch master
end match

# Add a prefix to all tag branches so we can fix them later.
match Project A/Folder 1/Folder b/([^/]+)/tags/([^/]+)/
  repository repo/Project A/Folder b/([^/]+)
  branch tag--\1
end match

# Ignore all other directories.
match /
end match

Also, do I have to create all the folders in my Git repo beforehand, or will svn2git do it for me?


Solution

  • svn2git will create the directories for you, but you have to define the repositories explicitly in the rules file. If you reference a repository that is note defined (e. g. because the match regex matched something you didn't create, then the migration will stop with an error message.

    Your rules are not correct though, I think it should be more like

    create repository repo
    end repository
    
    match /(Project A/Folder 1/Folder b/[^/]+/)trunk/
      repository repo
      prefix \1
      branch master
    end match
    
    match /(Project A/Folder 1/Folder b/[^/]+/)tags/([^/]+)/
      repository repo
      prefix \1
      branch refs/tags/\2
    end match
    
    # Ignore all other directories.
    match /
    end match