private function discoverStreamAncestry(PhabricatorRepositoryGraphStream $stream, $commit, $close_immediately)
 {
     $discover = array($commit);
     $graph = array();
     $seen = array();
     // Find all the reachable, undiscovered commits. Build a graph of the
     // edges.
     while ($discover) {
         $target = array_pop($discover);
         if (empty($graph[$target])) {
             $graph[$target] = array();
         }
         $parents = $stream->getParents($target);
         foreach ($parents as $parent) {
             if ($this->isKnownCommit($parent)) {
                 continue;
             }
             $graph[$target][$parent] = true;
             if (empty($seen[$parent])) {
                 $seen[$parent] = true;
                 $discover[] = $parent;
             }
         }
     }
     // Now, sort them topographically.
     $commits = $this->reduceGraph($graph);
     $refs = array();
     foreach ($commits as $commit) {
         $refs[] = id(new PhabricatorRepositoryCommitRef())->setIdentifier($commit)->setEpoch($stream->getCommitDate($commit))->setCanCloseImmediately($close_immediately)->setParents($stream->getParents($commit));
     }
     return $refs;
 }
 private function discoverStreamAncestry(PhabricatorRepositoryGraphStream $stream, $commit, $close_immediately)
 {
     $discover = array($commit);
     $graph = array();
     $seen = array();
     // Find all the reachable, undiscovered commits. Build a graph of the
     // edges.
     while ($discover) {
         $target = array_pop($discover);
         if (empty($graph[$target])) {
             $graph[$target] = array();
         }
         $parents = $stream->getParents($target);
         foreach ($parents as $parent) {
             if ($this->isKnownCommit($parent)) {
                 continue;
             }
             $graph[$target][$parent] = true;
             if (empty($seen[$parent])) {
                 $seen[$parent] = true;
                 $discover[] = $parent;
             }
         }
     }
     // Now, sort them topographically.
     $commits = $this->reduceGraph($graph);
     $refs = array();
     foreach ($commits as $commit) {
         $epoch = $stream->getCommitDate($commit);
         // If the epoch doesn't fit into a uint32, treat it as though it stores
         // the current time. For discussion, see T11537.
         if ($epoch > 0xffffffff) {
             $epoch = PhabricatorTime::getNow();
         }
         $refs[] = id(new PhabricatorRepositoryCommitRef())->setIdentifier($commit)->setEpoch($epoch)->setCanCloseImmediately($close_immediately)->setParents($stream->getParents($commit));
     }
     return $refs;
 }