dongqiaozhe5070 2012-08-15 18:34
浏览 66
已采纳

PHP,Subversion和克隆然后提交目录结构

I have an interesting problem that I am hoping somebody might be able to help me solve. I have a subversion repository which I use to store the source code for a very large PHP site. Here are some details about my setup that are important:

  • The dev version ot the site lives on the server at /var/www/sitename-dev, and was created by doing an svn checkout from the repository.
  • A live version of the site lives at /var/www/sitename, and was also created with svn checkout.
  • There is a post-commit hook set up on the repository that will run an svn update on the dev site after every commit, and an svn update on the live site if the commit log entry contains a special deployment keyword.
  • All of the above works wonderfully and has improved the productivity of my team considerably.

The purpose of the site is to provide a set of core functionality that many companies need, and let each company who purchases our product have their own specially branded site that provides our functionality. This is accomplished using the Smarty templating engine (which is excellent). Each branded site shares the same core files (therefore fixing a bug in a core file fixes it for every site), and has a directory structure for templates located in /resources/site. Each file in /resources/site is needed, but the contents will vary from site to site.

What I want to be able to do is create a form in the administrator section of the site that will create a new branded site as a clone of the /resources/site directory of an existing default site (in the local copy in /var/www), and add it to the subversion repository (add/commit). This will allow us to start redoing the template immediately after our next svn update.

Here is what I have so far:

public function addNewSiteHandle($handleName){
    try{
        $resourceRoot = "/var/www/site";
        echo "Resource Root = ".$resourceRoot."<br />";
        $resourceRoot .= "/resources";
        echo "Resource Root = ".$resourceRoot."<br />";
        $this->recursiveCopy($resourceRoot."/rtx", $resourceRoot."/".$handleName);
        $files = array();
        foreach(scandir($resourceRoot."/".$handleName) as $file){
            if($file != "." && $file != ".." && $file != ".svn"){
                echo "Processing \"$file\"<br />";
                svn_add($resourceRoot."/".$handleName."/".$file, true, true);
                array_push($files, $resourceRoot."/".$handleName."/".$file);
            }
        }
        svn_commit("Handle \"$handleName\" added through the Website.", $files);
    }
    catch(Exception $e){
        error_log($e->getMessage());
    }
}

This complains with the error:

[Wed Aug 15 14:31:01 2012] [error] [client 192.168.1.x] PHP Warning: svn_add(): svn error(s) occured 155007 (Path is not a working copy directory) '/var/www/site/resources/testtt43' is not a working copy in /var/www/site/Subversion.class.php on line 76, referer: http://b1.festivadev.com/cloneTest.html

I know the site is a working copy directory, so I'm not sure what the problem is. Any ideas?

  • 写回答

1条回答 默认 最新

  • douvcpx6526 2012-08-15 18:57
    关注

    Your script copies the entire site directory including .svn subdirectories. You should not copy these .svn directories or recursively delete them from copied directories after copying. After that SVN add & commit should work properly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站