From 5b8fbc22b64a916716a97745d645316f213db374 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Tue, 17 Oct 2006 11:10:36 +0200 Subject: [PATCH] read old revisons from the attic additionally to the changelog infos darcs-hash:20061017091036-7ad00-41df4dbaddb0a20d0f000f7a1bb000aaf2176185.gz --- inc/changelog.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/inc/changelog.php b/inc/changelog.php index 9501ec392..0c6557e46 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -271,7 +271,11 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) { * backwards in chunks untill the requested number of changelog * lines are recieved. * + * Because there may exist revisions not listed in the changelog + * the found revisions are merged with the ones found in the attic + * * @author Ben Coburn <btcoburn@silicodon.net> + * @see getRevisionsFromAttic() */ function getRevisions($id, $first, $num, $chunk_size=8192) { global $cache_revinfo; @@ -354,7 +358,37 @@ function getRevisions($id, $first, $num, $chunk_size=8192) { } } + // merge with attic file info + $revs = array_merge($revs,getRevisionsFromAttic($id,false)); + $revs = array_unique($revs); + rsort($revs); + return $revs; } +/** + * Return a list of available and existing page revisons from the attic + * + * @author Andreas Gohr <andi@splitbrain.org> + * @see getRevisions() + */ +function getRevisionsFromAttic($id,$sorted=true){ + $revd = dirname(wikiFN($id,'foo')); + $revs = array(); + $clid = cleanID($id); + if(strrpos($clid,':')) $clid = substr($clid,strrpos($clid,':')+1); //remove path + $clid = utf8_encodeFN($clid); + + if (is_dir($revd) && $dh = opendir($revd)) { + while (($file = readdir($dh)) !== false) { + if (is_dir($revd.'/'.$file)) continue; + if (preg_match('/^'.$clid.'\.(\d+)\.txt(\.gz)?$/',$file,$match)){ + $revs[]=$match[1]; + } + } + closedir($dh); + } + if($sorted) rsort($revs); + return $revs; +} -- GitLab