我可以在svndumpfilter include语句中使用正则表达式吗? [英] Can I use Regular expression in svndumpfilter include statement?

查看:130
本文介绍了我可以在svndumpfilter include语句中使用正则表达式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从svn(Windows上的服务器)导出数据,但是我不想包含根目录. 示例:

I need to export data from svn (server on Windows), but i don't want to include root directory. Example:

svn
-project1
--trunk
--branches
-project2
--trunk
--branches
--onemorefolder

我要包括到project1.dump文件夹中:主干和分支(不是project1) 我使用:

I want to include to project1.dump folders: trunk and branches (not project1) I use:

 svnadmin dump /svn/ | svndumpfilter include --drop-empty-revs --renumber-revs /project1/trunk /project1/branches | sed "s/Node-path:[ ]project1\//Node-path: /g" -b | sed "s/Node-copyfrom-path:[ ]project1\//Node-copyfrom-path: /g" -b > project1.dump

但是我想使这个过程自动化并创建bat文件:

But I want to automate this process and created bat file:

call svnadmin dump /svn/iss/ -r %2:%3 | svndumpfilter include --drop-empty-revs --renumber-revs /%1/trunk /%1/branches | sed "s/Node-path:[ ]%1\//Node-path: /g" -b | sed "s/Node-copyfrom-path:[ ]%1\//Node-copyfrom-path: /g" -b > %4

但是它仅适用于主干文件夹和分支文件夹所在的结构. 如何包含根文件夹中的所有文件夹并排除该根文件夹? 我可以在include语句中使用正则表达式吗? 谢谢.

But it works only with structure where are trunk and branches folders. How can i include all folders from my root folder and exclude this root folder? Can I use regex in include statement? Thanks.

推荐答案

首先,您可以同时使用两个sed命令:

First you could do both the sed commands as one:

代替

sed "s/Node-path:[ ]%1\//Node-path: /g" -b | \
sed "s/Node-copyfrom-path:[ ]%1\//Node-copyfrom-path: /g" -b

你可以做

sed "s/Node-\(copyfrom-\|\)path:[ ]%1\//Node-\1path: /g" -b

使用模式中的后向引用\1来匹配Node-pathNode-copyfrom-path.

which uses the backreference \1 in the pattern to match Node-path or Node-copyfrom-path.

对于root的所有子文件夹(不包括根文件夹本身),也许您可​​以尝试使用find <ROOTFOLDER> -type d -mindepth 1 -maxdepth 1查找所有不包含根目录本身的子目录.

For all subfolders of root, excluding the root folder itself, maybe you can try using find <ROOTFOLDER> -type d -mindepth 1 -maxdepth 1 which finds all subdirectories not including the root itself.

也许是(未经测试的)之类的东西

Perhaps something like (untested):

call svnadmin dump /svn/iss/ -r %2:%3  | \                   # keep same
svndumpfilter include --drop-empty-revs --renumber-revs \
    `find %1 -type d -maxdepth 1 -mindepth 1` | \             # used find
sed "s/Node-\(copyfrom-|\)path:[ ]%1\//Node-\1path: /g" -b \ # combined line
> %4

这篇关于我可以在svndumpfilter include语句中使用正则表达式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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