我们有一个像这样的svn文件夹结构:
svn-repo
|
+------userA
| |
| +----projAA
| |
| +----projAB
| ...
|
+------userB
| |
... +----projBA
|
+----projBB
...
直接来源于projAA,proj AB,......
我们希望将来能够使用标签和分支机构。因此我们希望有这样的结构:
svn-repo
|
+------userA
| |
| +----projAA
| | |
| | +---tags
| | |
| | +---branches
| | |
| | +---trunk
| |
| +----projAB
| | |
| | +---tags
| | |
| | +---branches
| | |
| | +---trunk
| ...
|
+------userB
| |
... +----projBA
| |
| +---tags
| |
| +---branches
| |
| +---trunk
|
+----projBB
| |
| +---tags
| |
| +---branches
| |
| +---trunk
...
现在我的问题是我如何自动完成这项工作?
到目前为止,我已经编写了这个简单的脚本:
@echo off & setlocal
set MY_BAT_FILE=%~nx0
if [%1]==[] goto missing_param
set MY_SVN_PATH=%1
set MY_TMP_PATH=%MY_SVN_PATH%_TMP
set MY_SVN_TRUNK=%MY_SVN_PATH%/trunk
set MY_SVN_TAGS=%MY_SVN_PATH%/tags
set MY_SVN_BRANCHES=%MY_SVN_PATH%/branches
set MY_SVN_MSG="created/edited by: %MY_BAT_FILE%"
svn mkdir %MY_TMP_PATH% -m %MY_SVN_MSG%
svn move %MY_SVN_PATH%/*.* %MY_TMP_PATH% -m %MY_SVN_MSG%
svn mkdir %MY_SVN_PATH% -m %MY_SVN_MSG%
svn mkdir %MY_SVN_TRUNK% -m %MY_SVN_MSG%
svn mkdir %MY_SVN_TAGS% -m %MY_SVN_MSG%
svn mkdir %MY_SVN_BRANCHES% -m %MY_SVN_MSG%
svn move %MY_TMP_PATH%/*.* %MY_SVN_TRUNK% -m %MY_SVN_MSG%
goto END
:missing_param
echo.failed!
echo.
echo.usage:
echo. %MY_BAT_FILE% ^<SVN_PATH^>
echo.
echo.parameter
echo. SVN_PATH:
echo. path to svn repository/folder (without trailing "/").
goto END
:END
pause
但由于svn move %MY_SVN_PATH%/*.* %MY_TMP_PATH% -m %MY_SVN_MSG%
和svn move %MY_TMP_PATH%/*.* %MY_SVN_TRUNK% -m %MY_SVN_MSG%
,这不起作用
因为不支持通配符。
如果我使用svn move %MY_SVN_PATH% %MY_TMP_PATH% -m %MY_SVN_MSG%
和svn move %MY_TMP_PATH% %MY_SVN_TRUNK% -m %MY_SVN_MSG%
(=没有通配符),那么它不仅会复制文件夹的内容,还会复制孔文件夹。
这导致svn-rep/userA/projAA/trunk/projAA_TMP/projAA/
而不是svn-rep/userA/projAA/trunk/
。
如何将文件夹的内容移动到另一个文件夹?
提前感谢。
答案 0 :(得分:1)
我找到了解决方案。
这是新脚本。如果有人有兴趣的话。
@echo on & setlocal
set MY_BAT_FILE=%~nx0
if [%1]==[] goto missing_param
set MY_SVN_PATH=%1
set MY_TMP_PATH=%MY_SVN_PATH%_TMP
set MY_SVN_TRUNK=%MY_SVN_PATH%/trunk
set MY_SVN_TAGS=%MY_SVN_PATH%/tags
set MY_SVN_BRANCHES=%MY_SVN_PATH%/branches
set MY_SVN_MSG="created/edited by: %MY_BAT_FILE%"
:: svn mkdir %MY_TMP_PATH% -m %MY_SVN_MSG% :: dont create the tmp-directory !
:: just make a copy of the original folder
svn copy %MY_SVN_PATH% %MY_TMP_PATH% -m %MY_SVN_MSG%
:: delete the original folder
svn delete %MY_SVN_PATH% -m %MY_SVN_MSG%
:: re-create the initial folder (it is empty now)
svn mkdir %MY_SVN_PATH% -m %MY_SVN_MSG%
:: create empty branches and tags folders
svn mkdir %MY_SVN_TAGS% -m %MY_SVN_MSG%
svn mkdir %MY_SVN_BRANCHES% -m %MY_SVN_MSG%
:: move (same as rename) the temp folder to trunk
svn move %MY_TMP_PATH% %MY_SVN_TRUNK% -m %MY_SVN_MSG%
goto EOF
:missing_param
echo.failed!
echo.
echo.usage:
echo. %MY_BAT_FILE% ^<SVN_PATH^>
echo.
echo.parameter
echo. SVN_PATH:
echo. path to svn repository/folder (without trailing "/").
goto EOF
:EOF
pause
文件夹正在执行以下步骤:
1: //svn-repo/user/proj
2: //svn-repo/user/proj
//svn-repo/user/proj_TMP
3: //svn-repo/user/proj_TMP
4: //svn-repo/user/proj_TMP
//svn-repo/user/proj << this is new created, empty!
5: //svn-repo/user/proj_TMP
//svn-repo/user/proj/branches
//svn-repo/user/proj/tags
6: //svn-repo/user/proj/branches
//svn-repo/user/proj/tags
//svn-repo/user/proj/trunk << //svn-repo/user/proj_TMP moved (=renamed)