Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

CorrectingSplitSubversionKeywords

Categories: Tips
<< | Page list | >>

How to block and correct subversion keywords split across lines in .lyx files

A slightly more verbose explanation of this fix can be found at http://dione.no-ip.org/AlexisWiki/CorrectingSvnKeywordsInLyxDocuments.

  1. To prevent accidentally committing .lyx files with split SVN keywords, create a subversion pre-commit hook containing:
    #!/usr/bin/env perl
    $repos = $ARGV[0];
    $txn = $ARGV[1];
    $rc = 0; #  assume success till proven otherwise
    foreach $ch (`svnlook changed -t "$txn" "$repos"`) {
        chomp($ch);
        next if ($ch !~ /^[AU]\S*\s+(\S.*)$/);
        $fn = $1;
        next if ($fn !~ /\.lyx$/);
        $cntnt = scalar(`svnlook cat -t "$txn" "$repos" "$fn"`);
        foreach $kw (qw/LastChangedDate LastChangedRevision LastChangedBy HeadURL Id/) {
            next if ($cntnt !~ /\$$kw:\s*\S+\s*\n\s*\$/);
            print STDERR "$0: ERROR: split '$kw' keyword\n";
            $rc = 1;
        }
    }
    exit($rc); 
  2. When you try to commit and the hook complains about split lines then correct the problem by running:
    perl -0777 -pi.bak -e 's/\$(LastChangedDate|LastChangedRevision|LastChangedBy|HeadURL|Id):\s*(\S+)\s*\n\s*\$/\$$1: $2 \$/msg' *.lyx
    
    
    Tips
Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2008-09-27 10:32 UTC