您好,欢迎访问一九零五行业门户网

使用PHP编写的SVN类_PHP教程

复制代码 代码如下:
entry [0]->attributes () as $key => $value ) {
            if ( $key == 'revision' ) {
                return $value;
            }
        }
    }
    /**
     * 获取最新版本号
     * @param $path string
     */
    public static function getheadrevision($path) {
        $command = cd $path && sudo svn up;
        $output = self::runcmd ( $command );
        $output = implode ( '
', $output );
        preg_match_all ( /[0-9]+/, $output, $ret );
        if (! $ret [0] [0]) {
            return
. $command .
. $output;
        }
        return $ret [0] [0];
    }
    /**
     * 获取某文件最早版本号
     *
     * @param $filepath string
     *
     */
    public static function getfilefirstversion($filepath){
        $command = sudo svn log {$filepath};
        $output = self::runcmd ( $command , |grep -i ^r[0-9]* |awk  '{print $1}');
        if(empty($output)){
            return false;
        }
        return str_replace(r, '', $output[count($output)-1]);
    }
    /**
     * 获取两个版本间修改的文件信息列表
     *
     * @param $fromversion int
     * @param $headrevision int
     * @param $$path string
     *
     * @return array
     */
    public static function getchangedfiles($path, $fromversion, $headrevision ){
        $files = array();
        $pipe = |grep -i ^index:|awk -f : '{print $2}';
        $command = svn diff -r {$fromversion}:{$headrevision} $path;
        $output = self::runcmd ( $command ,$pipe);
        $files = array_merge($files, $output);
        $command = svn diff -r {$headrevision}:{$fromversion} $path; //文件删除可用逆向对比
        $output = self::runcmd ( $command ,$pipe);
        $files = array_merge($files, $output);
        return array_unique($files);
    }
    /**
     * 获取两个版本间某文件修改 的内容
     *
     * @param $filepath string
     * @param $fromversion int
     * @param $headrevision int
     *
     * @return array
     */
    public static function getchangedinfo( $filepath, $fromversion, $headrevision ){
        $command = sudo svn diff -r {$fromversion}:{$headrevision} $filepath;
        $output = self::runcmd ( $command );
        return $output;
    }
    /**
     * 查看文件内容
     *
     * @param $filepath string
     * @param $version int
     *
     * @return array
     */
    public static function getfilecontent($filepath, $version){
        $command = sudo svn cat -r {$version} $filepath;
        $output = self::runcmd ( $command );
        return $output;
    }
    /**
     * run a cmd and return result
     * @param $command string
     * @param $pipe string (可以增加管道对返回数据进行预筛选)
     * @return array
     */
    protected static function runcmd($command , $pipe =) {
        $authcommand = ' --username ' . self::svn_username . ' --password ' . self::svn_password . ' --no-auth-cache --non-interactive --config-dir ' . self::svn_config_dir . '.subversion';
        exec ( $command . $authcommand . 2>&1 . $pipe, $output );
        return $output;
    }
}
http://www.bkjia.com/phpjc/328034.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/328034.htmltecharticle复制代码 代码如下: ?php /** * svn 外部命令 类 * * @author rubekid * * @todo comment need addslashes for svn commit * */ class svnutils { /** * * svn 账号 */ const sv...
其它类似信息

推荐信息