1: <?php
2: /**
3: * Subversion patchset class.
4: *
5: * @author Anil Madhavapeddy <anil@recoil.org>
6: * @author Michael Slusarz <slusarz@horde.org>
7: * @package Vcs
8: */
9: class Horde_Vcs_Patchset_Svn extends Horde_Vcs_Patchset_Base
10: {
11: /**
12: * Constructor
13: *
14: * @param Horde_Vcs $rep A Horde_Vcs repository object.
15: * @param string $file The filename to create patchsets for.
16: */
17: public function __construct($rep, $opts = array())
18: {
19: // TODO: Allow access via 'range'
20: $fileOb = $rep->getFile($opts['file']);
21:
22: foreach ($fileOb->getLog() as $rev => $log) {
23: $this->_patchsets[$rev] = array_merge(
24: $log->toHash(),
25: array('members' => array())
26: );
27:
28: foreach ($log->getFiles() as $file => $info) {
29: $to = $rev;
30: $status = Horde_Vcs_Patchset::MODIFIED;
31: if ($info['status'] == 'A') {
32: $from = null;
33: $status = Horde_Vcs_Patchset::ADDED;
34: } elseif ($info['status'] == 'D') {
35: $from = $to;
36: $to = null;
37: $status = Horde_Vcs_Patchset::DELETED;
38: } else {
39: // This technically isn't the previous revision,
40: // but it works for diffing purposes.
41: $from = $to - 1;
42: }
43:
44: $this->_patchsets[$rev]['members'][] = array('file' => $file,
45: 'from' => $from,
46: 'to' => $to,
47: 'status' => $status);
48: }
49: }
50: }
51: }
52: