svn-all-fast-export:匹配文件名 [英] svn-all-fast-export: Match file names

查看:62
本文介绍了svn-all-fast-export:匹配文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

svn-all-fast-export的匹配规则必须以结尾/结束,但递归规则除外.我有一个svn存储库,需要在分支上递归,并对分支下的目录和文件执行不同的操作.子目录应该放在一个git分支中,而svn分支下的文件应该放在另一个git分支中.例如,在svn中:

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和subdir2应该转到git中的分支A,file1和file2应该转到git中的分支B.

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

由于svn导出日期的方式,只有/branches/20被提及是创建它的提交的更改,因此我必须具有svn-all-fast-export匹配/branches/20并递归查看文件和子目录.

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.

由于svn-all-fast-export需要在匹配模式上使用斜杠,因此在这种情况下如何匹配文件名?我可以很好地匹配子目录,但是当前svn-all-fast-export会忽略文件,因为它无法在文件上递归,而且我不知道如何编写规则来匹配普通文件.

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.

推荐答案

在将复杂的多项目Subversion存储库转换为git时,我还需要匹配文件(将某些文件类型移至其他存储库).在研究了svn2git(svn-all-fast-export)源代码后,我得出的结论是,匹配模式实际上不需要尾部斜杠-尾部斜杠导致模式仅匹配目录. 我得到了以下规则:

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

使用--debug-rules运行svn-all-fast-export来查看发生的情况.

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

这篇关于svn-all-fast-export:匹配文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆