source: trunk/spip/esqueleto-redcta/plugins/svn_update/inc/svn_update.php @ 84

Last change on this file since 84 was 84, checked in by guille, 15 years ago

ahora anda... sacando algunos if

File size: 1.6 KB
Line 
1<?php
2
3        define('_SVN_COMMAND', 'svn');
4
5        // la fonction qui fait le travail
6        function update_svn($l) {
7                $l = trim($l);
8
9                if (!$l OR substr($l,0,1) == '#') return NULL; // commentaires
10
11                @list($src, $dest, $rev, $user) = explode(' ',$l);
12
13                if (!preg_match(',^(https?|svn)://,', $src))
14                        return $src; // erreur
15
16                if (!is_dir($dest))
17                        mkdir($dest, 0777, 'recursive');
18
19                if (!is_dir($dest)
20                OR !is_writable($dest))
21                        return "Impossible d'ecrire dans ".$dest; // erreur
22
23                // Checkout ?
24                if (!file_exists($entries = "$dest/.svn/entries")) {
25                        $command = "checkout $src/ $dest/";
26                }
27
28                else {
29                /*      $entries = join("\n", file($entries));
30                        echo $entries;
31                        if (!preg_match(',\surl="([^"]+)",', $entries, $r))
32                                return "fichier .svn/entries non conforme ou illisible";
33                        $old_src = $r[1];
34               
35                        // Switch ?
36                        if ($old_src != $src) {
37                                $command = "switch --relocate $old_src/ $src/ $dest/";
38                        }
39                */                     
40                        // Update
41              //        else {
42                                if ($rev)
43                                        $command = "update --revision $rev $dest/";
44                                else
45                                        $command = "update $dest/";
46        //              }
47                }
48
49                if ($command) {
50                        $command = _SVN_COMMAND." $user ".$command;
51                        $out = array();
52                        exec($command,$out);
53                        array_unshift($out, $command);
54                        return $out;
55                }
56
57        }
58
59        function traiter_config_svn($config = array()) {
60                foreach($config as $l) {
61                        echo "<hr /><b>", htmlspecialchars($l), "</b>";
62                        $res = update_svn($l);
63                        if (is_string($res))
64                                echo "<br /><b>Erreur: ",
65                                        htmlspecialchars($res),
66                                        "</b>";
67                        if (is_array($res))
68                                echo "<br />".nl2br(htmlspecialchars(join("\n", $res)));
69                        echo "<br />\n";
70                }
71        }
72
73?>
Note: See TracBrowser for help on using the repository browser.