Fix branch determination in CVS driver
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Jun 2009 17:46:58 +0000 (11:46 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Jun 2009 17:46:58 +0000 (11:46 -0600)
framework/Vcs/lib/Horde/Vcs.php
framework/Vcs/lib/Horde/Vcs/Cvs.php

index 7a1feec..5a4d713 100644 (file)
@@ -598,7 +598,7 @@ class Horde_Vcs
      */
     public function getDefaultBranch()
     {
-        return 'master';
+        return 'HEAD';
     }
 
 }
@@ -841,7 +841,7 @@ abstract class Horde_Vcs_File
     /**
      * TODO
      */
-    protected $_branch;
+    protected $_branch = null;
 
     /**
      * Create a repository file object, and give it information about
index 1711fac..cfdb295 100644 (file)
@@ -457,29 +457,27 @@ class Horde_Vcs_File_Cvs extends Horde_Vcs_File
                     $log = $rep->getLogObject($this, null);
                     $rev = $log->queryRevision();
                     $onbranch = false;
-                    $onhead = (substr_count($rev, '.') > 1);
+                    $onhead = (substr_count($rev, '.') == 1);
 
                     // Determine branch information.
-                    if (!empty($branches)) {
-                        if ($onhead) {
-                            foreach ($branches as $key => $val) {
-                                if (strpos($rev, $val) === 0) {
-                                    $onbranch = true;
-                                    $log->setBranch($key);
-                                    if (!isset($this->_branches[$key])) {
-                                        $this->_branches[$key] = $rev;
-                                        $this->_revlist[$key] = $rep->getRevisionRange($this, '1.1', $rev);
-                                    }
-                                    break;
+                    if ($onhead) {
+                        $onbranch = (empty($this->_branch) || $this->_branch == 'HEAD') ||
+                            ($rep->cmp($branches[$this->_branch], $rev) === 1);
+                    } elseif ($this->_branch != 'HEAD') {
+                        foreach ($branches as $key => $val) {
+                            if (strpos($rev, $val) === 0) {
+                                $onbranch = true;
+                                $log->setBranch($key);
+                                if (!isset($this->_branches[$key])) {
+                                    $this->_branches[$key] = $rev;
+                                    $this->_revlist[$key] = $rep->getRevisionRange($this, '1.1', $rev);
                                 }
+                                break;
                             }
-                        } else {
-                            $onbranch = $this->_branch &&
-                                ($rep->cmp($branches[$this->_branch], $rev) === 1);
                         }
                     }
 
-                    if (!$this->_branch || $onbranch) {
+                    if ($onbranch) {
                         $this->_revs[] = $rev;
                         $this->_logs[$rev] = $log;
                     }