如何在没有中继的现有svn repo中创建trunk目录,并将所有文件移动到新的trunk?

时间:2010-06-18 04:32:19

标签: svn

我有一个没有主干的svn回购。 我想创建主干和分支目录,并将我的所有文件(当前在根目录中)移动到主干中。

创建主干工作正常:

macbook[601]  # svn mkdir trunk
A         trunk
macbook[602]  # svn commit trunk
Adding         trunk
Committed revision 67.

将所有内容移至主干中失败:

macbook[604] # svn move * trunk
svn: Cannot copy path 'trunk' into its own child 'trunk/trunk'

有没有办法在不单独提供所有文件和目录名称的情况下执行此操作? 有线程描述如何使用TortoiseSVN执行此操作,但我想知道使用svn命令行执行此操作的正确方法。

感谢。


修改

W上。克雷格,谢谢你的快速而有益的回答 我确实遇到了一些并发症;也许有人可以给我一些关于如何解决它们的建议。

我开始使用最新的所有内容,包括一个空的“trunk”目录。我还有几个不受SVN管理的文件:

注意:在尝试此操作之前,我将一些文件移动到“notes”子目录并成功提交了更改。如果有帮助,我可以提供更多细节。

macbook[582] ~/dev/dictionary # svn stat
?       vendor/plugins/redbox_broken
?       config/database.yml
?       lib/dict.rb.original
?       public/javascripts/redbox.js.big
macbook[583] ~/dev/dictionary # ll
total 64
drwxr-xr-x   3 stupakov  stupakov    102 Jun 17 22:05 MISC
-rw-r--r--   1 stupakov  stupakov  10011 Oct 18  2009 README
-rw-r--r--   1 stupakov  stupakov    307 Oct 18  2009 Rakefile
-rw-r--r--   1 stupakov  stupakov   9514 Jun 17 22:05 TO_DO.txt
drwxr-xr-x   7 stupakov  stupakov    238 Mar 11 21:07 app
drwxr-xr-x  11 stupakov  stupakov    374 Jun  5 16:02 config
drwxr-xr-x   7 stupakov  stupakov    238 Jun 17 22:05 db
drwxr-xr-x   4 stupakov  stupakov    136 Oct 18  2009 doc
drwxr-xr-x   6 stupakov  stupakov    204 Oct 18  2009 features
drwxr-xr-x  17 stupakov  stupakov    578 Jun 17 20:51 lib
drwxr-xr-x   4 stupakov  stupakov    136 Apr  4 20:04 log
drwxr-xr-x   6 stupakov  stupakov    204 Oct 18  2009 nbproject
drwxr-xr-x   9 stupakov  stupakov    306 Jun 17 21:55 notes
drwxr-xr-x  11 stupakov  stupakov    374 Oct 18  2009 public
drwxr-xr-x  15 stupakov  stupakov    510 Oct 18  2009 script
drwxr-xr-x  13 stupakov  stupakov    442 Oct 18  2009 spec
drwxr-xr-x   7 stupakov  stupakov    238 Oct 18  2009 stories
drwxr-xr-x   9 stupakov  stupakov    306 Oct 18  2009 test
drwxr-xr-x   7 stupakov  stupakov    238 Feb 17 22:46 tmp
drwxr-xr-x   3 stupakov  stupakov    102 Jun 17 22:05 trunk
drwxr-xr-x   5 stupakov  stupakov    170 Apr  3 20:10 vendor
-rw-r--r--   1 stupakov  stupakov   1151 Sep 26  1998 whale.gif
macbook[584] ~/dev/dictionary # ll trunk

我试图将所有东西“移动”到主干中。

macbook[585] ~/dev/dictionary # echo $(cat ~/flist)
README Rakefile app config db doc features lib log nbproject notes public script spec stories test tmp vendor whale.gif
macbook[586] ~/dev/dictionary # svn move $(cat ~/flist) trunk

SVN的响应是一系列计划添加和删除的文件。

然后我尝试提交时失败了。

macbook[589] ~/dev/dictionary # svn commit -m "moving everything to trunk subdir"
Deleting       README
Deleting       Rakefile
Deleting       app
Deleting       config
Deleting       db
Deleting       doc
Deleting       features
Deleting       lib
Deleting       log
Deleting       nbproject
Deleting       notes
svn: Commit failed (details follow):
svn: Item '/dictionary/notes' is out of date

现在“笔记”目录有冲突

macbook[597] ~/dev/dictionary # svn stat notes
D     C notes
      >   local delete, incoming edit upon update
D       notes/HACKATHON
D       notes/newsgroup_questions.txt
D       notes/svn_rails.sh
D       notes/mysql_notes.txt
D       notes/HOW
D       notes/css_notes.txt

我试图将“备注”更新为旧版本,但冲突不允许:

macbook[606] ~/dev/dictionary # svn up notes -r 68
   C notes
At revision 68.
Summary of conflicts:
  Tree conflicts: 1

然后我试图“解决”冲突:

macbook[612] ~/dev/dictionary # svn resolve --accept=working notes
Resolved conflicted state of 'notes'
macbook[613] ~/dev/dictionary # ll notes
macbook[614] ~/dev/dictionary # svn stat notes -v
D               68       70 stupakov     notes
D               70       70 stupakov     notes/HACKATHON
D               70       70 stupakov     notes/newsgroup_questions.txt
D               70       70 stupakov     notes/svn_rails.sh
D               70       70 stupakov     notes/mysql_notes.txt
D               70       70 stupakov     notes/HOW
D               70       29 stupakov     notes/css_notes.txt

我认为我应该恢复而不是提交预定的移动以防其他事情搞砸了,所以我这样做了:

macbook[630] ~/dev/dictionary # svn revert .

但是,仍然会安排添加和删除。

我很感激有关如何执行以下操作的任何建议:

1)在执行“svn move list_of_dirs trunk”之前,将我的本地副本带到它所处的状态

2)确保“注释”目录是最新的,不会干扰“svn move”

3)成功将所有目标从我的根目录转移到“主干”

非常感谢。

1 个答案:

答案 0 :(得分:4)

你正在使用MacBook,所以让我们假设你的shell为bash:

# Select all the relevant files/directories (less trunk, branches, and tags)
ls * | egrep -v "trunk|branches|tags" > /tmp/files

# Move them within the repository
svn move $(cat /tmp/files) trunk

只要您的文件名中没有空格,这将有效。如果你这样做,那么请改用:

# Select all the relevant files/directories (less trunk, branches, and tags)
ls * | egrep -v "trunk|branches|tags" > /tmp/files

# Move them within the repository
cat /tmp/files | while read file ; do
    svn move "${file}" trunk
done
相关问题