Indefero

Indefero Commit Details


Date:2011-06-09 19:23:54 (13 years 10 months ago)
Author:Thomas Keller
Branch:develop, feature.content-md5, feature.diff-whitespace, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, release-1.2, release-1.3
Commit:ac6be0d3c06f924c75cc1e8f10184cf0e0bf8af9
Parents: 7ff6f09f6718eec2038c1eb214b1bb37482f53d1
Message:Implement IDF_Scm::getChanges() for Subversion (closes issue 622)

Changes:

File differences

NEWS.mdtext
88
99
1010
11
1112
1213
1314
- Indefero's issue tracker can now bi-directionally link issues with variable, configurable
terms, such as "is related to", "is blocked by" or "is duplicated by" (issue 638)
- Mercurial source views now show parent revisions (if any) and detailed change information
- Subversion source views now show detailed change information (issue 622)
- File download URLs now contain the file name rather than the upload id; old links still work though (issues 559 and 686)
- Display monotone file and directory attributes in the tree and file view
(needs a monotone with an interface version of 13.1 or newer)
src/IDF/Scm/Svn.php
479479
480480
481481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
482564
483565
484566
        return self::shell_exec('IDF_Scm_Svn::getDiff', $cmd);
    }
    /**
     * @see IDF_Scm::getChanges()
     */
    public function getChanges($commit)
    {
        if ($this->validateRevision($commit) != IDF_Scm::REVISION_VALID) {
            return null;
        }
        $cmd = sprintf(Pluf::f('svn_path', 'svn').' log --xml -v --no-auth-cache -r %s --username=%s --password=%s %s',
                       escapeshellarg($commit),
                       escapeshellarg($this->username),
                       escapeshellarg($this->password),
                       escapeshellarg($this->repo));
        $out = array();
        $cmd = Pluf::f('idf_exec_cmd_prefix', '').$cmd;
        $out = self::shell_exec('IDF_Scm_Svn::getChanges', $cmd);
        $xml = simplexml_load_string($out);
        if (count($xml) == 0) {
            return null;
        }
        $entry = current($xml);
        $return = (object) array(
            'additions'  => array(),
            'deletions'  => array(),
            'patches'    => array(),
            // while SVN has support for attributes, we cannot see their changes
            // in the log's XML unfortunately
            'properties' => array(),
            'copies'     => array(),
            'renames'    => array(),
        );
        foreach ($entry->paths->path as $p) {
            $path = (string) $p;
            foreach ($p->attributes() as $k => $v) {
                $key = (string) $k;
                $val = (string) $v;
                if ($key != 'action')
                    continue;
                if ($val == 'M')
                    $return->patches[] = $path;
                else if ($val == 'A')
                    $return->additions[] = $path;
                else if ($val == 'D')
                    $return->deletions[] = $path;
            }
        }
        // copies are treated as renames if they have an add _and_ a drop;
        // only if they only have an add, but no drop, they're treated as copies
        foreach ($xml->paths as $path) {
            $trg = (string) $path;
            $src = null;
            foreach ($path->attributes() as $k => $v) {
                if ((string) $k == 'copyfrom-path') {
                    $src = (string) $v;
                    break;
                }
            }
            if ($src == null)
                continue;
            $srcidx = array_search($src, $return->deletions);
            $trgidx = array_search($trg, $return->additions);
            if ($srcidx !== false && $trgidx !== false) {
                $return->renames[$src] = $trg;
                unset($return->deletions[$srcidx]);
                unset($return->additions[$trgidx]);
                continue;
            }
            if ($srcidx === false && $trgidx !== false) {
                $return->copies[$src] = $trg;
                unset($return->additions[$trgidx]);
                continue;
            }
            // file sutures (counter-operation to copy) not supported
        }
        return $return;
    }
    /**
     * Get latest changes.

Archive Download the corresponding diff file

Page rendered in 0.15416s using 14 queries.