sub reven()

in lib/metafile.pl [158:199]


sub reven($$) {
    my $dirname = shift;
    my $basename = shift;
    my $rev = $revs{"$dirname$basename"};

    unless ($rev) {
        my $curpath = docpath("$dirname$basename.xml");

        sysopen(FILE, $curpath, O_RDONLY)
            or die "could not open file '$curpath' ($!), stopped";

        {
            local $_;
            while (<FILE>) {
                $rev = $1, last if /<!-- \044LastChangedRevision:\s*(\S+)\s*\$ -->/;
            }
        }

        close(FILE)
            or die "could not close file '$curpath' ($!), stopped";

        $revs{"$dirname$basename"} = $rev;
    }
    unless ($rev || $no_git) {
        # LastChangedRevision is not available with git-svn or a git checkout
        # from git.apache.org. Try to get the revision from the log.
        my $curpath = docpath("$dirname$basename.xml");
        # XXX: This does not work if there has been a local commit
        my $log = qx{git log -1 $curpath 2> /dev/null};
        if ($? == 0) {
            if ( $log =~ /git-svn-id:[^\@]+\@(\d+)\s/ ) {
                $revs{"$dirname$basename"} = $rev = $1;
            }
        }
        else {
            # no git repo
            $no_git = 1;
        }
    }

    return $rev;
}