Search code examples
gitsvnsubgit

Subgit importing a root directory without standard layout


I have the following SVN repository structure. This is not by design, someone did something odd before I became involved.

https://server/svn/repo
https://server/svn/repo/rootfolder1
https://server/svn/repo/rootfolder2
https://server/svn/repo/trunk
https://server/svn/repo/trunk/trunkfolder1
https://server/svn/repo/trunk/trunkfolder2

I am attempting to import the two folders rootfolder1 and rootfolder2 into a Git repository (I will then split them off to separate repositories using git-filter-branch).

Running subgit import --svn-url https://server/svn/repo repo-root, I'm left with a Git repository with trunkfolder1 and trunkfolder2. Passing --trunk repo gives me an empty Git repository. Running as subgit import --svn-url --trunk repo https://server/svn repo-root gives me the following error:

IMPORT FAILED

error: svn: E175002: PROPFIND of '/': 405 Method Not Allowed (https://server)

I also tried subgit --import --trunk . --svn-url https://server/svn/repo repo-root however subgit complains about the --trunk parameter.

Any suggestions on a solution to this problem?


Solution

  • If you eventually intend to have those 'rootfolders' into separate repositories, then it's reasonable to import them into different Git repositories on the import stage, I think. It could be done by the following two commands:

    subgit import --trunk rootfolder1 --username <svn user name> --password <svn user password> --non-interactive --trust-server-cert --svn-url https://server/svn/repo <GIT_REPO>
    
    subgit import --trunk rootfolder2 --username <svn user name> --password <svn user password> --non-interactive --trust-server-cert --svn-url https://server/svn/repo <GIT_REPO_2>
    

    In this case, 'rootfolder1' will be imported into GIT_REPO and 'rootfolder2' into GIT_REPO_2, so you won't need to split them.

    In addition, I'd recommend providing an authors file during import so that SVN users are translated to suitable Git users, find more details here:

    https://subgit.com/documentation/import-book.html#authors_file

    Importing both 'rootfolders' into a single Git repository is also possible, but it requires extra steps to get rid of 'trunk':

    • prepare a new Git repo for the import:

      subgit configure https://server/svn/repo GIT_REPO

    • open SubGit configuration file in a text editor:

      GIT_REPO/subgit/config

    • change mapping configuration in the following way:

      [svn]
      
          trunk:refs/heads/master
          excludePath = /trunk
      

      save and close the file.

    • run the import:

      subgit import GIT_REPO

    In this case, GIT_REPO will only contain 'rootfolders' as 'trunk' is excluded by 'excludePath' directive.