This file is indexed.

/usr/share/doc/php5-svn/examples/hook_copycommit.php is in php5-svn 1.0.2-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
<?php

/* 
  example copy on commit hook script
  usage:
  php ..path..to..this..file.. hook_copycommit.php "$REPOS" "$REV" "/target/location" >> /tmp/svnlog 

*/
dl('svn.so');

class Subversion_CopyCommit {
    var $repos;
    var $rev;
    var $target; // where the copy goes
    
    
    function start($args) {
        print_r($args);
        list( $cmd , $this->repos, $this->rev , $this->target ) = $args; 
        if (empty($this->target)) {
            echo "NO TARGET !";exit;
        }
        if ($this->repos{0} == '/') {
            $this->repos = 'file://'. $this->repos;
        }
        $this->rev = (int) $this->rev;
        $ar = svn_log($this->repos, $this->rev,  $this->rev-1, 0, SVN_DISCOVER_CHANGED_PATHS);
        
        
        //print_R($ar);
        foreach($ar[0]['paths'] as $action) {
            $this->processAction($action);
        }
    }
    
    function processAction($action) 
    {
        $this->debug("Action: {$action['action']} on {$action['path']}");
        switch($action['action']) {
            case 'M': // modified
            case 'A': // added.
               
               /* how to handle moves?? */
               
                // is it a file or directory?
                if ($this->isDir($action['path'])) {
                    if (!file_exists($this->target . $action['path'])) {
                        require_once 'System.php';
                        System::mkdir(array('-p',$this->target . $action['path']));
                    }
                    return;
                }
                
                $this->writeFile($this->target.$action['path'], 
                    svn_cat($this->repos . $action['path'],$this->rev))    ;
                return;
                
            case 'D': // deleted.
                if (file_exists($this->target . $action['path'])) {
                    require_once 'System.php';
                    System::rm($this->target . $action['path']);
                }
                return;
                
            case 'R': // replaced????
                return;
        }
    }
    var $dircache = array();
     
    function isDir($path) 
    {
        if (!isset($this->dircache[dirname($path)])) {
		echo "SVN:LS ".$this->repos.dirname($path) ."\n";
		$p = strlen(dirname($path)) > 1  ? dirname($path) : '';
            $this->dircache[dirname($path)]= svn_ls($this->repos.$p,$this->rev);
        }
        $ar= $this->dircache[dirname($path)];
        //print_r($ar);
        $match = basename($path);
        foreach($ar as $info) {
            if ($info['name'] != $match) {
                continue;
            }
            return $info['type'] == 'dir';
        }
        return false;
    }
    function writeFile($target,$data) 
    {
        if (!file_exists(dirname($target))) {
            require_once 'System.php';
            System::mkdir(array('-p', dirname($target)));
        }
        $fh = fopen($target,'w');
        fwrite($fh, $data);
        fclose($fh);
    }
    
    function debug($str) 
    {
        echo $str."\n";
    }
    
}
ini_set('memory_limit','64M');
$x = new Subversion_CopyCommit;
$x->start($_SERVER['argv']);