Search code examples
gitsvngit-svnsvn2git

svn2git migration: Rules


So I have decided to use the svn2git tool after a solid recommendation. In order to migrate the repository, I need authors file and the rules file, along with the repository itself. I composed all these three, and put them under a directory, which I call myRepository_test for the time being. I expect my new git repository to be here after the migration.

Here is the repository structure I currently have:

- myRepository
  -- myRepository.release
  -- myRepository.mapping
  -- myRepository.base
  -- ..

In total I have around 30 projects here.

Hereby I share my files which will be used:

authormap.txt:

egent = Emma Gent <[email protected]>
gstar = Gabriel Star <[email protected]>
.
.

For the time being, I wanted to try only for 2 projects, so:

myRepository.rules:

create repository myRepository
end repository

# main history

match /trunk/myRepository/myRepository.release/
  repository myRepository
  branch master
end match

match /trunk/myRepository/myRepository.mapping/
  repository myRepository
  branch master
end match

# Ignore everything else
match /
end match

which makes the final command:

./svn-all-fast-export --identity-map authormap.txt --rules myRepository.rules --add-metadata http://address/svn/myRepository

which ends as:

Loading rules from: "myRepository.rules" 
Loading rules from "myRepository.rules" 
Could not read the rules file: myRepository.rules
Aborted (core dumped)

I am not very sure about the content of the rules file, would be nice if someone could help me regarding that.

Thanks in advance.


Solution

  • The message you get does not mean the syntax is bogus, the syntax looks fine. It actually cannot find or read the file itself. Do you call svn-all-fast-export from where the directory where your myRepository.rules file is lying. And do you have read rights on the file as the user as which you call svn-all-fast-export?

    Regarding the content of the rules file, I don't think it is fully correct already. You store the contents of myRepository.release and myRepository.mapping into the root of your repository. If that was what you intended, it is fine. If not, you should probably use a prefix rule inside the match block so that the contents get added to separate sub-directories. But you will see this after you were able to successfully run the tool anyway.

    And one more note, the match expressions are regular expressions, so you might want to escape the . and have match /trunk/myRepository/myRepository\.release/. Or if you really want the contents in the same folder even

    match /trunk/myRepository/myRepository\.(release|mapping)/
      repository myRepository
      branch master
    end match
    

    or if you want subdirs

    match /trunk/myRepository/myRepository\.(release|mapping)/
      repository myRepository
      branch master
      prefix \1
    end match
    

    or

    match /trunk/myRepository/(myRepository\.(release|mapping))/
      repository myRepository
      branch master
      prefix \1
    end match
    

    For more info on rules, see https://techbase.kde.org/Projects/MoveToGit/UsingSvn2Git#How_rulesets_work