3

Match rules for svn-all-fast-export must end with a trailing /, except for recurse rules. I have an svn repository that needs to recurse on a branch and do different things with directories and files under the branch. Subdirectories should get placed in one git branch and files directly under the svn branch should be placed in a different git branch. For example, in svn:

/branches/20/subdir1
/branches/20/subdir2
/branches/20/file1
/branches/20/file2

subir1 and subdir2 should go to branch A in git and file1 and file2 should go to branch B in git.

Because of the way svn exports its date, only /branches/20 gets mentioned as changed for the commit that created it so I must have svn-all-fast-export match /branches/20 and recurse to see the files and subdirectories.

Because svn-all-fast-export requires a trailing slash on a match pattern, how can I match file names in this situation? I can match the subdirs just fine but currently svn-all-fast-export ignores the files because it can't recurse on a file and I don't know how to write a rule to match an ordinary file.

David Greene
  • 394
  • 2
  • 12
  • Not sure why this got downvoted. I've read just about every article on the 'net about svn-all-fast-export that I could find... – David Greene Aug 24 '14 at 04:47

1 Answers1

4

While working on a conversion of a complex multi-project subversion repository to git I also needed to match files (move some file types to a different repository). After studying the svn2git (svn-all-fast-export) source code I came to the conclusion that the match pattern doesn't actually require a trailing slash - the trailing slash causes the pattern to only match directories. I ended up with the following rule:

    # binary blobs
    match /(.*\.)(zip|tar\.gz|tgz|tar\.bz|tbz|jar|deb)$
      repository blobs.git
      branch master
      prefix \1\2
    end match

and it works just fine. Therefore I would try the following in your case:

    # folders
    match /branches/([^/]+)/([^/]+)/
      repository repo.git
      branch \1-A
      prefix \2
    end match

    # files
    match /branches/([^/]+)/([^/]+)$
      repository repo.git
      branch \1-B
      prefix \2
    end match

    # recurse
    match /branches/([^/]+)
      action recurse
    end match

Run svn-all-fast-export with --debug-rules to see what's happening.

piit79
  • 1,256
  • 1
  • 8
  • 13
  • Note that the `prefix` statement is required for a pattern to match files, even when you want to ignore the files and not put them into a repository. See also here under `Important Details`: https://techbase.kde.org/Projects/MoveToGit/UsingSvn2Git No reason given tho ... – Marty Jun 25 '18 at 12:12