%%
%% This is file `svn-multi.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% svn-multi.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2006-2009 by Martin Scharrer <martin@scharrer-online.de>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Martin Scharrer.
%% 
%% This work consists of the files svn-multi.dtx, svn-multi-pl.dtx, svn-multi.ins
%% and the derived files svn-multi.sty, svnkw.sty and svn-multi.pl.
%% 
\makeatletter
\def\svnmulti@version{v2.4c}
\RequirePackage{svn-prov}[2010/04/14]
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackageSVN
  {$Id: svn-multi.dtx 2431 2011-04-01 23:00:26Z martin $}
  [\svnmulti@version\space SVN Keywords for multi-file LaTeX documents]

\RequirePackage{kvoptions}

\SetupKeyvalOptions{%
  family = svn-multi,
  prefix = @svnmulti@
}
\newif\if@svnmulti@anygraphic
\newif\if@svnmulti@autoload
\newif\if@svnmulti@autokw
\newif\if@svnmulti@autokwall

\DeclareVoidOption{old}{%
  \@svnmulti@verbatimtrue
  \@svnmulti@groupsfalse
  \@svnmulti@externalfalse
  \@svnmulti@graphicsfalse
  \@svnmulti@pgfimagesfalse
  \@svnmulti@autoloadfalse
  \@svnmulti@tablefalse
  \@svnmulti@filehooksfalse
  \@svnmulti@subgroupsfalse
}
\DeclareVoidOption{all}{%
  \@svnmulti@verbatimtrue
  \@svnmulti@groupstrue
  \@svnmulti@externaltrue
  \@svnmulti@graphicstrue
  \@svnmulti@pgfimagestrue
  \@svnmulti@autoloadtrue
  \@svnmulti@tabletrue
  \@svnmulti@filehookstrue
  \@svnmulti@subgroupstrue
}
\DeclareBoolOption[true]{verbatim}
\DeclareBoolOption[false]{groups}
\DeclareBoolOption[false]{external}
\DeclareBoolOption[false]{subgroups}
\DeclareBoolOption[false]{graphics}
\DeclareBoolOption[false]{pgfimages}
\DeclareStringOption{autoload}[true]
\DeclareBoolOption[false]{table}
\DeclareBoolOption[false]{filehooks}
\DeclareStringOption[false]{autokw}[all]

\ExecuteOptions{old}
\ProcessKeyvalOptions{svn-multi}
\def\svn@depoption#1{%
  \csname if@svnmulti@#1\endcsname\else
  \message{svn-multi: Required option '#1' enabled.}%
  \csname @svnmulti@#1true\endcsname
  \fi
}

\if@svnmulti@groups
  \svn@depoption{filehooks}
\fi
\if@svnmulti@external
  \svn@depoption{filehooks}
\fi
\if@svnmulti@subgroups
  \svn@depoption{groups}
  \svn@depoption{filehooks}
\fi
\if@svnmulti@graphics
  \svn@depoption{external}
  \svn@depoption{autoload}
  \svn@depoption{filehooks}
\fi
\if@svnmulti@pgfimages
  \svn@depoption{external}
  \svn@depoption{autoload}
  \svn@depoption{filehooks}
\fi
\if@svnmulti@autoload
  \svn@depoption{external}
  \svn@depoption{filehooks}
\fi
\if@svnmulti@table
  \svn@depoption{groups}
  \svn@depoption{filehooks}
\fi
\ifx\@svnmulti@autoload\@undefined
\else
\ifx\@svnmulti@autoload\empty
\else
\def\svn@temp{true}
\ifx\@svnmulti@autoload\svn@temp
  \@svnmulti@autoloadtrue
  \svn@depoption{external}
  \svn@depoption{filehooks}
\else
\def\svn@temp{false}
\ifx\@svnmulti@autoload\svn@temp
  \if@svnmulti@autoload
  \PackageWarning{svn-multi}{Option 'autoload' disabled.}
  \fi
  \@svnmulti@autoloadfalse
\else
  \PackageError{svn-multi}%
    {Invalid value for 'autoload' option: '\@svnmulti@autoload'^^J%
     ! Only 'true','false' or empty (='true') are allowed!}{}%
\fi\fi\fi\fi

\def\svn@temp{true}
\ifx\@svnmulti@autokw\svn@temp
  \@svnmulti@autokwtrue
  \@svnmulti@autokwalltrue
  \svn@depoption{filehooks}
\fi
\def\svn@temp{all}
\ifx\@svnmulti@autokw\svn@temp
  \@svnmulti@autokwtrue
  \@svnmulti@autokwalltrue
  \svn@depoption{filehooks}
\fi
\def\svn@temp{ext}
\ifx\@svnmulti@autokw\svn@temp
  \@svnmulti@autokwtrue
  \@svnmulti@autokwallfalse
\fi
\def\svn@temp{false}
\ifx\@svnmulti@autokw\svn@temp
  \@svnmulti@autokwfalse
  \@svnmulti@autokwallfalse
\fi

\if@svnmulti@graphics
  \@svnmulti@anygraphictrue
\fi
\if@svnmulti@pgfimages
  \@svnmulti@anygraphictrue
\fi

\def\svn@ifempty#1{%
  \begingroup
  \edef\svn@temp{#1}%
  \ifx\svn@temp\empty
    \endgroup
    \expandafter
    \@firstoftwo
  \else
    \endgroup
    \expandafter
    \@secondoftwo
  \fi
}

\def\svn@ifequal#1#2{%
  \begingroup
  \edef\svn@stringa{#1}%
  \edef\svn@stringb{#2}%
  \ifx\svn@stringa\svn@stringb
    \endgroup
    \expandafter
    \@firstoftwo
  \else
    \endgroup
    \expandafter
    \@secondoftwo
  \fi
}

\def\svn@ifvalidrev#1{%
  \begingroup
  \@ifundefined{#1}%
    {\let\svn@temp\svn@revinit}%
    {\expandafter\edef
     \expandafter\svn@temp\expandafter{\csname #1\endcsname}}%
  \ifnum\svn@temp=\svn@revinit\relax
    \endgroup
    \expandafter
    \@secondoftwo
  \else
    \endgroup
    \expandafter
    \@firstoftwo
  \fi
}

\def\svn@ifeof#1{%
  \ifeof#1%
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}

\def\svn@ifonlyone#1{%
  \expandafter\expandafter\expandafter
  \svn@@ifonlyone\csname @svng@#1@files\endcsname,\relax
}

\def\svn@@ifonlyone#1,#2\relax{%
  \svn@ifempty{#2}
}

\def\svn@input#1{%
  \begingroup
    \let\svn@rg\svn@g
    \IfFileExists{#1}{\@@input #1\relax}{}%
    \global\let\svn@g\svn@rg
  \endgroup
}

\def\svn@inputsvx#1{%
  \svn@pushfilestack
  \begingroup
  \svn@normalcatcodes
  \svn@input{#1.svx}%
  \endgroup
  \svn@popfilestack
}

\def\svn@normalcatcodes{%
  \catcode`\\=0\relax
  \catcode`\{=1\relax
  \catcode`\}=2\relax
  \catcode`\$=3\relax
  \catcode`\&=4\relax
  \catcode`\^^M=5\relax
  \catcode`\#=6\relax
  \catcode`\^=7\relax
  \catcode`\_=8\relax
  \catcode`\ =10\relax
  \catcode`\@=12\relax
  \catcode`\~=13\relax
  \catcode`\%=14\relax
}

\def\svn@revinit{-2}
\let\svnrev\svn@revinit     \let\@svn@rev\svn@revinit
\let\ifsvnmodified\@secondoftwo
\def\@svn@modified{@secondoftwo}%
\def\svndate{}              \def\@svn@date{}
\def\svnauthor{}            \def\@svn@author{}
\def\svnyear{0000}          \def\@svn@year{0000}
\def\svnmonth{00}           \def\@svn@month{00}
\def\svnday{00}             \def\@svn@day{00}
\def\svnhour{00}            \def\@svn@hour{00}
\def\svnminute{00}          \def\@svn@minute{00}
\def\svnsecond{00}          \def\@svn@second{00}
\def\svntimezonehour{+00}   \def\@svn@timezonehour{+00}
\def\svntimezoneminute{00}  \def\@svn@timezoneminute{00}
\def\svnmainurl{NOT SET}    \def\svnmainfilename{NOT SET}
\def\svnurl{} \def\svnfname{}
\def\svn@temp{}

\def\svn@pg{} \def\svn@g{} \def\svn@cg{\svn@g} \def\svn@rg{\svn@pg}
\let\@svng@@files\empty

\def\svn@initfile{%
  \global\let\svnfilerev\svn@revinit
  \global\let\ifsvnfilemodified\@secondoftwo
  \gdef\svnfiledate{}%
  \gdef\svnfileauthor{}%
  \gdef\svnfileyear{0000}%
  \gdef\svnfilemonth{00}%
  \gdef\svnfileday{00}%
  \gdef\svnfilehour{00}%
  \gdef\svnfileminute{00}%
  \gdef\svnfilesecond{00}%
  \gdef\svnfiletimezonehour{+00}%
  \gdef\svnfiletimezoneminute{00}%
  \gdef\svnfileurl{}%
  \gdef\svnfilefname{}%
  \gdef\svnfiledir{}%
}
\svn@initfile

\newif\ifsvn@modified


\begingroup
\@makeother\^^L
\if@svnmulti@autokw
\gdef\svne@ff{^^L}
\fi
\endgroup

\if@svnmulti@autokw
\newread\svne@read

\newcommand*{\svne@catcodes}{%
  \let\do\@makeother
  \endlinechar=-1%
  \dospecials
  \do0\do1\do2\do3\do4%
  \do5\do6\do7\do8\do9%
  \do\:\do\^^L%
  \do\<\do\>\do\*\do\.\do\-%
  \do\/\do\[\do\]\do\`\do\'\do\"%
  \def\do##1{\catcode`##1=11\relax}%
  \do\A\do\B\do\C\do\D\do\E\do\F
  \do\G\do\H\do\I\do\J\do\K\do\L
  \do\M\do\N\do\O\do\P\do\Q\do\R
  \do\S\do\T\do\U\do\V\do\X\do\Y\do\Z
  \do\a\do\b\do\c\do\d\do\e\do\f
  \do\g\do\h\do\i\do\j\do\k\do\l
  \do\m\do\n\do\o\do\p\do\q\do\r
  \do\s\do\t\do\u\do\v\do\x\do\y\do\z
}

\def\svne@readline#1{%
  \ifeof\svne@read
    \def#1{}%
  \else
    \read\svne@read to #1\relax
  \fi
}

\def\svne@gobblerest{%
  \ifeof\svne@read
    \let\next\relax
  \else
    \read\svne@read to \svn@temp
    \ifx\svn@temp\svne@ff
      \let\next\relax
    \else
      \let\next\svne@gobblerest
    \fi
  \fi
  \next
}

\def\svne@endread{%
  \closein\svne@read
}

\newcommand*{\svne@parseentriesfile}[1]{%
  \begingroup
    \let\next\relax
    \def\svne@version{8}%
    \openin\svne@read=#1format\relax
    \ifeof\svne@read\else
      \svne@readline\svne@version
      \closein\svne@read
    \fi
      \ifnum\svne@version>7\relax
        \openin\svne@read=#1entries\relax
        \ifeof\svne@read\else
          \svne@readline\svne@version
          \ifnum\svne@version>7\relax
            \def\next{\svne@parsedirentry
                      \svne@parseentries}%
          \else
            \closein\svne@read
          \fi
        \fi
      \fi
    \next
  \endgroup
}

\newcommand*{\svne@parsedirentry}{%
  \svne@readline\svne@name
  \svne@readline\svne@kind
  \svn@ifempty{\svne@name}%
    {\svn@ifequal{\svne@kind}{dir}%
      {%
        {\svne@readline\svn@temp}%
        \svne@readline\svne@baseurl
        \svne@gobblerest
      }{}%
    }{}%
}

\begingroup

\@makeother\-
\@makeother\:
\@makeother\.

\gdef\svne@scandate#1{%
  \expandafter\svne@scandate@#1\empty
  0000-00-00T00:00:00.00000Z\empty\empty
}

\gdef\svne@scandate@#1-#2-#3T#4:#5:#6.#7\empty#8\empty{%
  \xdef\svnfileyear{#1}%
  \gdef\svnfilemonth{#2}%
  \gdef\svnfileday{#3}%
  \gdef\svnfilehour{#4}%
  \gdef\svnfileminute{#5}%
  \gdef\svnfilesecond{#6}%
  \gdef\svnfiletimezonehour{+00}%
  \gdef\svnfiletimezoneminute{00}%
  \gdef\svnfiledate{#1-#2-#3 #4:#5:#6Z}%
  \def\svne@date{#1-#2-#3 #4:#5:#6Z}%
}

\endgroup

\newcommand*{\svne@parseentries}{%
  \svn@ifeof{\svne@read}%
  {}%
  {%
    \svne@readline\svne@name
    \@onelevel@sanitize\svne@name
    \svn@ifeof{\svne@read}%
    {}%
    {%
    \svne@readline\svne@kind
    \svn@ifequal{\svne@kind}{file}%
      {%
      \svne@readline\svn@temp
      \svne@readline\svn@temp
      \svne@readline\svn@temp
      \svne@readline\svn@temp
      \svne@readline\svn@temp
      \svne@readline\svn@temp
      \svne@readline\svne@date
      \svne@readline\svne@rev
      \svne@readline\svne@author
      %\@onelevel@sanitize\svne@date
      \svne@scandate{\svne@date}%
      \edef\svne@url{\svne@baseurl/\svne@name}%
      \svne@handleentry
      }{}%
    \svne@gobblerest
    \svne@parseentries
    }%
  }%
}

\def\svne@handleentry{%
  \ifx\svne@rev\empty
    \let\svne@rev\svn@revinit
  \fi
  \svn@ifequal{\svne@name}{\svnfilefname}%
    {%
      \message{^^J%
        Read from '.svn/entries' file:^^J%
        Filename:  \svne@name^^J%
        Date:      \svne@date^^J%
        Revision:  \svne@rev^^J%
        Author:    \svne@author^^J%
        HeadURL:   \svne@url^^J%
        ^^J%
      }%
      \svnkwdef{Filename}{\svne@name}%
      \svnkwdef{Date}{\svne@date}%
      \svnkwdef{Revision}{\svne@rev}%
      \svnkwdef{Author}{\svne@author}%
      \svnkwdef{HeadURL}{\svne@url}%
      \@svn@updateid{\svne@rev}{\svne@date}{\svne@author}{\svne@url}%
      \svne@endread
    }{}%
}%

\def\svnegetfile#1{%
  \begingroup
    \svn@getfilename{#1}%
    \edef\svnfilefname{\svnfilefname}%
    \@onelevel@sanitize\svnfilefname
    \svne@catcodes
    \svne@parseentriesfile{\svnfiledir .svn/}%
    \svne@parseentriesfile{\svnfiledir _svn/}%
  \endgroup
}

\if@svnmulti@autokwall
\AtBeginDocument{%
    \svnegetfile{\jobname.\currfile@mainext}%
}
\fi

\fi

\def\svntimezone{\svntimezonehour\svntimezoneminute\svn@gobblezeros}
\def\svnfiletimezone{\svnfiletimezonehour\svnfiletimezoneminute\svn@gobblezeros}
\def\svncgtimezone{\svncgtimezonehour\svncgtimezoneminute}

\def\svn@gobblezeros{%
  \futurelet\svn@nextchar\svn@gobblezeros@
}
\def\svn@gobblezeros@{%
  \let\@tempa=\relax
  \def\@tempb{0}%
  \ifx0\svn@nextchar
    \let\@tempa=\@gobbletwo
  \fi
  \@tempa
}

\def\svntime{\svnhour:\svnminute:\svnsecond}
\def\svnfiletime{\svnfilehour:\svnfileminute:\svnfilesecond}
\def\svncgtime{\svncghour:\svncgminute:\svncgsecond}

\newcommand*{\svntoday}{%
  \begingroup
    \year\svnyear \month\svnmonth \day\svnday
    \relax \today
  \endgroup
}
\newcommand*{\svnfiletoday}{%
  \begingroup
    \year\svnfileyear \month\svnfilemonth \day\svnfileday
    \relax \today
  \endgroup
}
\newcommand*{\svncgtoday}{%
  \@ifundefined{svng@\svn@cg @year}{??}{%
    \begingroup
      \year\svncgyear \month\svncgmonth \day\svncgday
      \relax \today
    \endgroup
  }%
}%

\newcommand*{\svnid}{%
  \@svnidswtrue
  \svnkwsave
}
\newif\if@svnidsw
\@svnidswfalse

\def\svn@scanId#1 #2\relax{%
  \begingroup
  \def\@tempa{#2}%
  \def\@tempb{-1}%
  \ifx\@tempa\@tempb
    \endgroup
    \svn@scanId@#1 -1 0000-00-00 00:00:00Z (uncommited)\relax
  \else
    \endgroup
    \svn@scanId@#1 #2\relax
  \fi
}

\def\svn@scanId@#1 #2 #3 #4 #5\relax{%
  \@svn@scandate{#3 #4}%
  \svnkwdef{Filename}{#1}%
  \svnkwdef{Date}{#3 #4}%
  \svnkwdef{Revision}{#2}%
  \svnkwdef{Author}{#5}%
  \@svn@updateid{\svnkw{Revision}}{\svnkw{Date}}{\svnkw{Author}}{\svnkw{URL}}%
}

\def\@svn@updateid#1#2#3#4{%
  \begingroup
  \let\protect\@unexpandable@protect
  \xdef\svnfilerev{#1}%
  \ifsvn@modified
    \global\let\ifsvnfilemodified\@firstoftwo
  \else
    \global\let\ifsvnfilemodified\@secondoftwo
  \fi
  \xdef\svnfiledate{#2}%
  \xdef\svnfileauthor{#3}%
  \xdef\svnfileurl{#4}%
  \svn@getfilename\svnfileurl%
  \ifx\svnfilerev\empty\else
    \ifnum\@svn@rev<\svnfilerev
      \xdef\@svn@rev{\svnfilerev}%
      \xdef\@svn@modified{\ifsvnfilemodified{@firstoftwo}{@secondoftwo}}%
      \xdef\@svn@date{\svnfiledate}%
      \xdef\@svn@author{\svnfileauthor}%
      \xdef\@svn@year{\svnfileyear}%
      \xdef\@svn@month{\svnfilemonth}%
      \xdef\@svn@day{\svnfileday}%
      \xdef\@svn@hour{\svnfilehour}%
      \xdef\@svn@minute{\svnfileminute}%
      \xdef\@svn@second{\svnfilesecond}%
      \xdef\@svn@timezonehour{\svnfiletimezonehour}%
      \xdef\@svn@timezoneminute{\svnfiletimezoneminute}%
      \xdef\@svn@url{\svnfileurl}%
      \xdef\@svn@fname{\svnfilefname}%
    \fi

    \if@svnmulti@groups
      \ifx\svn@g\empty\else
        \svn@updategroup{\svn@g}%
      \fi
      \if@svnmulti@subgroups
        \ifsvnsubgroups
          \svn@updategroup{\currfiledir\currfilebase}%
        \fi
      \fi
    \fi
  \fi
  \endgroup
}

\def\@svncg@save#1#2{%
  \expandafter\xdef\csname @svng@\svn@g @#1\endcsname{#2}%
}


\newcommand{\svnidlong}{%
  \svnkwdef{URL}{}%
  \svnkwdef{Date}{}%
  \svnkwdef{Revision}{0}%
  \svnkwdef{Author}{}%
  \if@svnmulti@verbatim
    \expandafter\svnidlong@readverb
  \else
    \expandafter\svnidlong@readargs
  \fi
}
\def\svnidlong@readverb{%
  \@ifnextchar\bgroup
    {\svnidlong@readverb@\svnidlong@readverb@a}%
    {\PackageError{svn-multi}{Wrong syntax for \string\svnidlong}{}}%
}
\def\svnidlong@readverb@#1{%
  \begingroup
  \svn@catcodes
  \catcode`\{=1\relax
  \catcode`\}=2\relax
  #1%
}
\def\svnidlong@readverb@a#1{%
  \endgroup
  \svnkwsave@read #1\relax
  \@ifnextchar\bgroup
    {\svnidlong@readverb@\svnidlong@readverb@b}%
    {\PackageError{svn-multi}{Wrong syntax for \string\svnidlong}{}}%
}
\def\svnidlong@readverb@b#1{%
  \endgroup
  \svnkwsave@read #1\relax
  \@ifnextchar\bgroup
    {\svnidlong@readverb@\svnidlong@readverb@c}%
    {\PackageError{svn-multi}{Wrong syntax for \string\svnidlong}{}}%
}
\def\svnidlong@readverb@c#1{%
  \endgroup
  \svnkwsave@read #1\relax
  \@ifnextchar\bgroup
    {\svnidlong@readverb@\svnidlong@readverb@d}%
    {\PackageError{svn-multi}{Wrong syntax for \string\svnidlong}{}}%
}
\def\svnidlong@readverb@d#1{%
  \endgroup
  \svnkwsave@read #1\relax
  \ifx\svnkwDate\empty\else
    \@svn@scanlongdate{\svnkwDate}%
  \fi
  \@svn@updateid{\svnkw{Revision}}{\svnkw{Date}}%
  {\svnkw{Author}}{\svnkw{URL}}%
  \ignorespaces
}

\if@svnmulti@verbatim
\def\svn@catcodes{%
  \let\do\@makeother
  \dospecials
  \catcode`\^^M9
  \catcode`\ 10
  \catcode`\{1
  \catcode`\}2
}
\else
  \def\svn@catcodes{}
\fi
\def\svnidlong@readargs#1#2#3#4{%
    \svnkwsave@read #1\relax
    \svnkwsave@read #2\relax
    \svnkwsave@read #3\relax
    \svnkwsave@read #4\relax
  \endgroup
  \ifx\svnkwDate\empty\else
    \@svn@scanlongdate{\svnkwDate}%
  \fi
  \@svn@updateid{\svnkw{Revision}}{\svnkw{Date}}%
  {\svnkw{Author}}{\svnkw{URL}}%
  \ignorespaces
}%

\def\svnkwsave{%
  \begingroup
    \svn@catcodes
    \svnkwsave@readargs
}

\gdef\svnkwsave@readargs#1{%
    \svnkwsave@read#1\relax
  \endgroup
  \if@svnidsw
    \ifx\svnkwId\empty\else
      \expandafter
      \svn@scanId\svnkwId\relax
      \@svnidswfalse
    \fi
  \fi
  \ignorespaces
}

\begingroup
\if@svnmulti@verbatim
\catcode`\$=12
\fi
\gdef\svnkwsave@read $#1$\relax{%
  \svn@checkcolon#1:\relax
}
\endgroup

\begingroup
\catcode`\$=11
\gdef\svnkwsave@parse$#1:#2${%
  \expandafter\xdef\csname svnkw#1\endcsname{#2}%
}%
\endgroup

\newcommand{\svnkwdef}[2]{%
  \@ifundefined{svnkwdef@#1}%
    {\svnkwdef@{#1}{#2}}%
    {\csname svnkwdef@#1\endcsname{#2}}%
}

\newcommand{\svnkwdef@}[2]{%
  \begingroup
  \let\protect\@unexpandable@protect
  \expandafter\xdef\csname svnkw#1\endcsname{#2}%
  \endgroup
}

\def\svnkwdef@Rev#1{%
  \svn@ifempty{#1}%
    {\svnkwdef@{Rev}{0}}%
    {%
     \afterassignment\svnkwdef@Rev@
     \@tempcnta=#1\relax
    }%
}
\def\svnkwdef@Rev@#1\relax{%
  \svnkwdef@{Rev}{\the\@tempcnta}%
  \def\svn@temp{#1}%
  \if M\svn@temp\relax
    \global\svn@modifiedtrue
  \else
    \if *\svn@temp\relax
      \global\svn@modifiedtrue
    \else
      \global\svn@modifiedfalse
    \fi
  \fi
}
\def\svnkwdef@Author#1{\svnkwdef@{Author}{#1}}
\def\svnkwdef@Date#1{\svnkwdef@{Date}{#1}}
\def\svnkwdef@URL#1{\svnkwdef@{HeadURL}{#1}}
\let\svnkwdef@Revision=\svnkwdef@Rev
\let\svnkwdef@LastChangedRevision=\svnkwdef@Rev
\let\svnkwdef@LastChangedBy=\svnkwdef@Author
\let\svnkwdef@LastChangedDate=\svnkwdef@Date
\def\svnkwRevision{\svnkwRev}
\def\svnkwLastChangedRevision{\svnkwRev}
\def\svnkwLastChangedBy{\svnkwAuthor}
\def\svnkwLastChangedDate{\svnkwDate}
\def\svnkwURL{\svnkwHeadURL}

\svnkwdef{Rev}{0}
\svnkwdef{Date}{}
\svnkwdef{Author}{}
\svnkwdef{Filename}{}
\svnkwdef{HeadURL}{}

\newcommand{\svnkw}[1]{%
  \@ifundefined{svnkw#1}%
    {\PackageWarning{svn-multi}{SVN keyword '#1' not defined (typo?)}}%
    {\csname svnkw#1\endcsname}%
}%

\def\svn@checkcolon#1:#2\relax{%
  \svn@ifempty{#2}%
    {\svnkwdef{#1}{}}%
    {\svn@stripcolon#2\relax\svnkwdef{#1}{\svn@value}}%
}

\def\svn@stripcolon#1:\relax{%
  \svn@ifempty{#1}%
    {\gdef\svn@value{}}%
    {\svn@ifequal{#1}{ }%
      {\gdef\svn@value{}}%
      {\svn@stripspace#1\relax\relax}%
    }%
}

\def\svn@stripspace#1#2\relax{%
  \svn@ifequal{#1}{ }%
    {\gdef\svn@value{#2}}%
    {\svn@striptrailingspace#1#2\relax}%
}

\def\svn@striptrailingspace#1 \relax{%
  \gdef\svn@value{#1}%
}

\def\svn@gdefverb#1{%
  \begingroup
    \def\svn@temp{#1}%
    \begingroup
      \if@svnmulti@verbatim
        \svn@catcodes
      \fi
      \svn@gdefverb@
}

\def\svn@gdefverb@#1{%
    \endgroup
    \expandafter\gdef\svn@temp{#1}%
  \endgroup
}

\def\svn@namegdefverb#1{%
  \begingroup
    \expandafter\def
    \expandafter\svn@temp
    \expandafter{\csname #1\endcsname}%
    \begingroup
      \if@svnmulti@verbatim
        \svn@catcodes
      \fi
      \svn@gdefverb@
}

\def\@svn@scandate#1{\@svn@scandate@#1\relax}

\def\@svn@scandate@#1-#2-#3 #4:#5:#6#7#8\relax{%
  \gdef\svnfileyear{#1}%
  \gdef\svnfilemonth{#2}%
  \gdef\svnfileday{#3}%
  \gdef\svnfilehour{#4}%
  \gdef\svnfileminute{#5}%
  \gdef\svnfilesecond{#6#7}%
  \gdef\svnfiletimezonehour{+00}%
  \gdef\svnfiletimezoneminute{00}% #8 always 'Z' for Zulu-time (UTC)
}

\def\@svn@scanlongdate#1{\expandafter\@svn@scanlongdate@#1\relax}
\def\@svn@scanlongdate@#1-#2-#3 #4:#5:#6 #7 #8\relax{%
  \gdef\svnfileyear{#1}%
  \gdef\svnfilemonth{#2}%
  \gdef\svnfileday{#3}%
  \gdef\svnfilehour{#4}%
  \gdef\svnfileminute{#5}%
  \gdef\svnfilesecond{#6}%
  \@svn@parsetimezone#7\relax%
}

\def\@svn@parsetimezone#1#2#3#4#5\relax{%
  \gdef\svnfiletimezonehour{#1#2#3}%
  \gdef\svnfiletimezoneminute{#4#5}%
}

\def\svnpdfdate{%
  \svnyear\svnmonth\svnday
  \svnhour\svnminute\svnsecond\svntimezonehour'\svntimezoneminute'%
}

\newcommand{\svnsetmainfile}{%
  \xdef\svnmainurl{\svnfileurl}%
  \xdef\svnmainfilename{\svnfilefname}%
}
\AtBeginDocument{\svnsetmainfile}

\newcommand{\svnRegisterAuthor}[2]{%
  \expandafter\def\csname svn@author@#1\endcsname{#2}%
}

\newcommand{\svnFullAuthor}{%
  \@ifnextchar{*}%
    {\svnFullAuthor@star}%
    {\svnFullAuthor@normal}%
}%
\def\svnFullAuthor@star*#1{%
  \edef\svn@temp{#1}%
  \svnFullAuthor@{\svn@temp}{~(\svn@temp)}%
}%
\def\svnFullAuthor@normal#1{%
  \edef\svn@temp{#1}%
  \svnFullAuthor@{\svn@temp}{}%
}%
\def\svnFullAuthor@#1#2{%
  \@ifundefined{svn@author@#1}%
    {#1}%
    {\csname svn@author@#1\endcsname #2}%
}

\newcommand{\svnRegisterRevision}[2]{%
  \expandafter\def\csname svn@revision@#1\endcsname{#2}%
}

\newcommand{\svnFullRevision}{%
  \@ifnextchar{*}%
    {\svnFullRevision@star}%
    {\svnFullRevision@normal}%
}
\def\svnFullRevision@star*#1{%
  \edef\svn@temp{#1}%
  \svnFullRevision@{\svn@temp}{~(r\svn@temp)}%
}
\def\svnFullRevision@normal#1{%
  \edef\svn@temp{#1}%
  \svnFullRevision@{\svn@temp}{}%
}
\def\svnFullRevision@#1#2{%
  \@ifundefined{svn@revision@#1}%
    {Revision #1}%
    {\csname svn@revision@#1\endcsname #2}%
}

\if@svnmulti@filehooks

\RequirePackage{filehook}[2011/01/03]
\RequirePackage{currfile}[2011/01/03]

\filehook@prefixwarg\filehook@every@atbegin{%
  \svn@pushfilestack
  \if@svnmulti@groups
    \svn@ifequal{\currfilepath}{\jobname.\currfile@mainext}%
      {\xdef\svn@pg{\svn@g}}%
      {\xdef\svn@pg{\currfiledir\currfilebase}}%
  \fi
}
\filehook@appendwarg\filehook@every@atend{%
  \svn@popfilestack
}
\def\svn@filestack{{}}

\def\svn@pushfilestack{%
  \xdef\svn@filestack{{%
    {\svnfilerev}%
    {\svnfiledate}%
    {\svnfileauthor}%
    {\svnfileyear}%
    {\svnfilemonth}%
    {\svnfileday}%
    {\svnfilehour}%
    {\svnfileminute}%
    {\svnfilesecond}%
    {\svnfiletimezonehour}%
    {\svnfiletimezoneminute}%
    {\svnfileurl}%
    {\svnfilefname}%
    {\svn@g}%
    {\svn@pg}%
    {\ifsvnfilemodified{@firstoftwo}{@secondoftwo}}%
  }\svn@filestack}%
}

\def\svn@restorefilekws#1#2\relax{%
  \svn@restorefilekws@#1\empty
  \empty \empty \empty \empty
  \empty \empty \empty \empty
  \empty \empty \empty \empty \empty
  \svn@ifempty{#2}%
    {\gdef\svn@filestack{{}}}%
    {\gdef\svn@filestack{#2}}%
}
\def\svn@restorefilekws@#1#2#3#4#5#6#7#8#9{%
  \gdef\svnfilerev{#1}%
  \gdef\svnfiledate{#2}%
  \gdef\svnfileauthor{#3}%
  \gdef\svnfileyear{#4}%
  \gdef\svnfilemonth{#5}%
  \gdef\svnfileday{#6}%
  \gdef\svnfilehour{#7}%
  \gdef\svnfileminute{#8}%
  \gdef\svnfilesecond{#9}%
  \svn@restorefilekws@@
}

\def\svn@restorefilekws@@#1#2#3#4#5#6#7{%
  \gdef\svnfiletimezonehour{#1}%
  \gdef\svnfiletimezoneminute{#2}%
  \gdef\svnfileurl{#3}%
  \gdef\svnfilefname{#4}%
  \gdef\svn@g{#5}%
  \gdef\svn@pg{#6}%
  \expandafter\global\expandafter\let
  \expandafter\ifsvnfilemodified\csname#7\endcsname%
}

\def\svn@popfilestack{%
  \ifx\svn@filestack\empty
    \PackageWarning{svn-multi}{Underflow of file keyword stack!}%
  \else
    \svn@ifequal{\svn@filestack}{{}}%
      {\PackageWarning{svn-multi}{Underflow of file keyword stack!}}%
      {\expandafter\svn@restorefilekws\svn@filestack\relax}%
  \fi
}


\fi

\if@svnmulti@groups
\let\svn@glist=\empty

\def\svngroup#1{%
  \svn@ifequal{#1}{*}%
    {\PackageError{svn-multi}%
      {The group name '*' is invalid for '\string\svngroup'}{}%
    }{}%
  \xdef\svn@g{#1}%
  \let\svn@pg\svn@g
  \svn@checkgroup{#1}%
}
\def\svn@checkgroup#1{%
  \begingroup
  \edef\svn@g{#1}%
  \ifx\svn@g\empty\else%
    \expandafter
    \ifx\csname @svng@\svn@g @rev\endcsname\relax%
      \svn@initgroup{\svn@g}%
      \ifx\svn@glist\empty
        \xdef\svn@glist{#1}%
      \else
        \xdef\svn@glist{\svn@glist,#1}%
      \fi
    \fi
  \fi
  \endgroup
}

\def\thesvngroup{\svn@g}

\def\svnsetcg#1{%
  \svn@ifequal{#1}{*}%
    {\def\svn@cg{\svn@g}}%
    {\def\svn@cg{#1}}%
}

\def\svncg@def#1{%
  \expandafter
  \def\csname svncg#1\endcsname{%
    \@ifundefined{svng@\svn@cg @#1}{??}{%
    \csname svng@\svn@cg @#1\endcsname}%
  }%
}

\@for\@tempa:=%
  rev,author,date,year,month,day,hour,minute,second,%
  timezonehour,timezoneminute,url,fname%
\do{%
  \expandafter\svncg@def\expandafter{\@tempa}%
}

\def\thesvncg{\svn@cg}

\def\svng#1#2{%
  \@ifundefined{svng@\svn@temp @#2}%
    {??}%
    {\csname svng@\svn@temp @#2\endcsname}%
}

\def\svn@addfiletogroup#1#2{%
  \svn@ifequal{#1}{#2}{}{%
  \expandafter
  \ifx\csname @svng@#2@files@#1\endcsname\relax%
    \expandafter\gdef\csname @svng@#2@files@#1\endcsname{1}%
    %
    \expandafter\ifx\csname @svng@#2@files\endcsname\empty%
      \expandafter\xdef\csname @svng@#2@files\endcsname{#1}%
    \else
    \@ifundefined{@svng@#2@files}%
      {\expandafter\xdef\csname @svng@#2@files\endcsname{#1}}%
      {\expandafter\xdef\csname @svng@#2@files\endcsname{%
        \csname @svng@#2@files\endcsname,#1%
       }%
      }%
    \fi
  \fi
  }%
}

\AtBeginOfFiles{%
  \svn@ifequal{\currfilepath}{\jobname.\currfile@mainext}%
    {}%
    {\svn@initfile}%
  \svn@ifequal{\currfileext}{\currfile@mainext}%
    {\svn@addfiletogroup{\currfiledir\currfilebase}{\svn@pg}}{}%
  \svn@ifequal{\currfileext}{sty}%
    {\svn@addfiletogroup{\currfiledir\currfilebase}{\svn@pg}}{}%
  \svn@ifequal{\currfileext}{cls}%
    {\svn@addfiletogroup{\currfiledir\currfilebase}{\svn@pg}}{}%
  \svn@addfiletogroup{\currfilepath}{\currfiledir\currfilebase}%
}

\def\svn@writegroup#1{%
  \def\svn@writekw##1{%
   \immediate\write\svn@write{%
     \string\global\string\@namedef{svng@#1@##1}{\csname @svng@#1@##1\endcsname}%
   }%
  }%
  \svn@writekw{rev}%
  \svn@writekw{date}%
  \svn@writekw{author}%
  \svn@writekw{year}%
  \svn@writekw{month}%
  \svn@writekw{day}%
  \svn@writekw{hour}%
  \svn@writekw{minute}%
  \svn@writekw{second}%
  \svn@writekw{timezonehour}%
  \svn@writekw{timezoneminute}%
  \@ifundefined{@svng@#1@files}{}{%
    \immediate\write\svn@write{%
      \noexpand
      \svn@namegdefverb{svng@#1@files}{\csname @svng@#1@files\endcsname}%
    }%
  }%
  \immediate\write\svn@write{%
    \noexpand
    \svn@namegdefverb{svng@#1@url}{\csname @svng@#1@url\endcsname}^^J%
    \noexpand
    \svn@namegdefverb{svng@#1@fname}{\csname @svng@#1@fname\endcsname}^^J%
  }%
}
\def\svn@writeallgroups#1{%
  \begingroup
    \ifx\relax#1\relax\else
      \@for\svn@temp:=#1\do{%
        \svn@ifvalidrev{@svng@\svn@temp @rev}%
          {%
            \expandafter
            \svn@cleanfilelist\csname @svng@\svn@temp @files\endcsname
            \svn@writegroup{\svn@temp}%
            \@ifundefined{@svng@\svn@temp @files}{}%
              {\expandafter\svn@writeallgroups
               \csname @svng@\svn@temp @files\endcsname
              }%
          }{}%
      }%
    \fi
  \endgroup
}

\def\svn@updategroup#1{%
  \@ifundefined{@svng@#1@rev}%
    {\svn@initgroup{#1}}%
    {}%
  \expandafter
  \ifnum\csname @svng@#1@rev\endcsname<\svnfilerev
    \svn@gkwset{#1}{rev}{\svnfilerev}%
    \svn@gkwset{#1}{date}{\svnfiledate}%
    \svn@gkwset{#1}{author}{\svnfileauthor}%
    \svn@gkwset{#1}{year}{\svnfileyear}%
    \svn@gkwset{#1}{month}{\svnfilemonth}%
    \svn@gkwset{#1}{day}{\svnfileday}%
    \svn@gkwset{#1}{hour}{\svnfilehour}%
    \svn@gkwset{#1}{minute}{\svnfileminute}%
    \svn@gkwset{#1}{second}{\svnfilesecond}%
    \svn@gkwset{#1}{timezonehour}{\svnfiletimezonehour}%
    \svn@gkwset{#1}{timezoneminute}{\svnfiletimezoneminute}%
    \svn@gkwset{#1}{url}{\svnfileurl}%
    \svn@gkwset{#1}{fname}{\svnfilefname}%
  \fi
}

\def\svn@definegroup#1{%
  \svn@gkwdef{#1}{rev}%
  \svn@gkwdef{#1}{date}%
  \svn@gkwdef{#1}{author}%
  \svn@gkwdef{#1}{year}%
  \svn@gkwdef{#1}{month}%
  \svn@gkwdef{#1}{day}%
  \svn@gkwdef{#1}{hour}%
  \svn@gkwdef{#1}{minute}%
  \svn@gkwdef{#1}{second}%
  \svn@gkwdef{#1}{timezonehour}%
  \svn@gkwdef{#1}{timezoneminute}%
  \svn@gkwdef{#1}{url}%
  \svn@gkwdef{#1}{fname}%
}

\def\svn@initgroup#1{%
  \svn@gkwset{#1}{rev}{\svn@revinit}%
  \svn@gkwset{#1}{date}{}%
  \svn@gkwset{#1}{author}{}%
  \svn@gkwset{#1}{year}{0000}%
  \svn@gkwset{#1}{month}{00}%
  \svn@gkwset{#1}{day}{00}%
  \svn@gkwset{#1}{hour}{00}%
  \svn@gkwset{#1}{minute}{00}%
  \svn@gkwset{#1}{second}{00}%
  \svn@gkwset{#1}{timezonehour}{+00}%
  \svn@gkwset{#1}{timezoneminute}{00}%
  \svn@gkwset{#1}{url}{}%
  \svn@gkwset{#1}{fname}{}%
}

\def\svn@gkwset#1#2#3{%
  \expandafter
  \xdef\csname @svng@#1@#2\endcsname{#3}%
}

\def\svn@gkwdef#1#2{%
  \expandafter
  \xdef\csname svng@#1@#2\endcsname{\csname @svng@#1@#2\endcsname}%
}

\def\svn@cleanfilelist#1{
  \begingroup
    \def\svn@tmplist{}%
    \ifx\relax#1\relax\else
      \@for\svn@temp:=#1\do{%
        \expandafter\svn@ifvalidrev
        \expandafter{@svng@\svn@temp @rev}%
          {\edef\svn@tmplist{\svn@tmplist,\svn@temp}}%
          {}%
      }%
      \xdef#1{\expandafter\@gobble\svn@tmplist\empty}%
    \fi
  \endgroup
}

\fi


\newif\ifsvnsubgroups
\svnsubgroupsfalse

\if@svnmulti@subgroups
\svnsubgroupstrue

\def\svnsubgroup{%
  \begingroup
    \svn@subgroup{\currfiledir\currfilebase}%
    \svn@subgroup{\currfilepath}%
  \endgroup
}

\def\svn@subgroup#1{%
  \ifnum\svnfilerev=\svn@revinit\else
    \expandafter\ifx\csname svn@g@#1\endcsname\relax%
      \expandafter\gdef\csname svn@g@#1\endcsname{1}%
      \svn@updategroup{#1}%
    \fi
  \fi
}

\def\svnignoreextensions#1{%
  \@for\svn@temp:=#1\do{%
    \expandafter\def\csname svn@ignore@ext@\svn@temp\endcsname{}%
  }%
}

\def\svnconsiderextensions#1{%
  \@for\svn@temp:=#1\do{%
  \expandafter\let\csname svn@ignore@ext@\svn@temp\endcsname\relax%
  }%
}

\svnignoreextensions{aux,bbl,fd,enc,fls,glo,idx,ilg,ind,ist,%
lof,log,lot,out,svn,svt,svx,toc}

\AtEndOfFiles{%
  \if@svnmulti@subgroups
    \ifsvnsubgroups
      \expandafter\ifx\csname svn@ignore@ext@\currfileext\endcsname\relax
      \svnsubgroup
      \fi
    \fi
  \fi
}

\if@svnmulti@subgroups
  \ifsvnsubgroups
    \svn@addfiletogroup{\jobname .\currfile@mainext}{\jobname}%
    \svnsubgroup
  \fi
\fi
\AtBeginDocument{%
  \if@svnmulti@subgroups
    \ifsvnsubgroups
    \@ifundefined{@svng@\svn@g @files@\jobname}%
      {%
      \@namedef{@svng@\svn@g @files@\jobname}{1}%
      \@ifundefined{@svng@\svn@g @files}%
        {%
          \expandafter
          \xdef\csname @svng@\svn@g @files\endcsname{\jobname}%
        }%
        {%
          \expandafter
          \xdef\csname @svng@\svn@g @files\endcsname
            {\jobname,\csname @svng@\svn@g @files\endcsname}%
        }%
      }{}%
      \svnsubgroup
    \fi
  \fi
}

\fi

\if@svnmulti@external

\if@svnmulti@groups
\def\svnexternalgroup#1{%
  \svn@ifequal{#1}{*}%
    {\def\svn@externalgroup{\svn@pg}}%
    {\def\svn@externalgroup{#1}}%
}
\def\svn@externalgroup{\svn@pg}
\else
\def\svn@externalgroup{}
\fi

\if@svnmulti@autokw
\newcommand*\svnexternal[2][]{%
  \svn@pushfilestack
  \svn@ifequal{#1}{*}%
    {\edef\svn@eg{\svn@pg}}%
    {\svn@ifempty{#1}%
      {\edef\svn@eg{\svn@externalgroup}}%
      {\edef\svn@eg{#1}}%
    }%
  \svn@checkgroup{\svn@eg}%
  \svne@@external#2\relax
  \svn@popfilestack
}

\def\svne@@external#1{%
  \ifx\relax#1\empty\else
    \svnegetfile{#1}%
    \begingroup\svn@externalfile{\svn@eg}{#1}%
    \expandafter\svne@@external
  \fi
}
\else
\newcommand*\svnexternal[2][]{%
  \if@filesw
    \begingroup
      \svn@ifequal{#1}{*}%
        {\def\svn@temp{\svn@pg}}%
        {\svn@ifempty{#1}%
          {\def\svn@temp{\svn@externalgroup}}%
          {\def\svn@temp{#1}}%
        }%
      \let\protect\@unexpandable@protect
      \immediate\write\svn@write{%
        \noexpand\@svnexternal[\svn@temp]{\currfilepath}{#2}%
      }%
    \endgroup
  \fi
  \svn@inputsvx{\currfiledir\currfilebase}%
}
\fi

\def\svnexternalpath#1{%
  \if@filesw
    \begingroup
    \let\protect\@unexpandable@protect
    \immediate\write\svn@write{%
      \noexpand\@svnexternalpath{#1}%
    }%
    \endgroup
  \fi
}

\newcommand*\@svnexternal[3][]{}
\def\@svnexternalpath#1{}

\newcommand*\svnexternalfile[1][\currfiledir\currfilebase]{%
  \begingroup % TODO: maybe use \svn@catcodes
    \catcode`\_=12
    \catcode`\&=12
    \catcode`\^=12
    \catcode`\$=12
    \catcode`\#=12
    \svn@externalfile{#1}%
}

\def\svn@externalfile#1#2{%
  \endgroup
  \if@svnmulti@subgroups
    \ifsvnsubgroups
      \svn@ifequal{#1}{\svn@rg}%
        {\svn@addfiletogroup{#2}{\currfiledir\currfilebase}}%
        {\svn@addfiletogroup{#2}{#1}}%
      \svn@subgroup{#2}%
    \fi
  \fi
}

\else
  \def\svnexternalfile#1{}%
\fi

\if@svnmulti@autoload

\AtBeginOfFiles{%
  \svn@ifequal{\currfileext}{tex}%
    {\svn@inputsvx{\currfiledir\currfilebase}}%
    {}%
}

%%\AtEndOfPackage{%
\AtBeginDocument{%
  \svn@inputsvx{\jobname}%
}

\fi


\if@svnmulti@anygraphic

\def\svngraphicsgroup#1{%
  \svn@ifequal{#1}{*}%
    {\def\svn@graphicsgroup{\svn@pg}}%
    {\def\svn@graphicsgroup{#1}}%
}
\def\svn@graphicsgroup{\svn@externalgroup}

\def\svnignoregraphic#1{%
  \expandafter\def\csname svn@ignoregraphic@#1\endcsname{}%
}

\def\svnconsidergraphic#1{%
  \expandafter\let\csname svn@ignoregraphic@#1\endcsname\relax%
}

\fi

\if@svnmulti@graphics
\RequirePackage{graphics}[2006/02/20]

\message{Package svn-multi: patching macro '\string\Gin@setfile' from the
'graphics' package!}%
\let\svnmulti@Gin@setfile\Gin@setfile
\renewcommand*{\Gin@setfile}[3]{%
  \expandafter\ifx\csname svn@ignoregraphic@#3\endcsname\relax%
    \svnexternal[\svn@graphicsgroup]{{#3}}%
  \fi
  \svnmulti@Gin@setfile{#1}{#2}{#3}%
}

\fi

\if@svnmulti@pgfimages
\RequirePackage{pgf}[2008/01/15]

\message{Package svn-multi: patching macro '\string\pgf@declareimage' and will
patch generated macros '\string\pgf@image@<name>!' from the 'pgf' package!}%
\let\svnmulti@pgf@declareimage\pgf@declareimage
\renewcommand*{\pgf@declareimage}[3][]{%
  \svnmulti@pgf@declareimage[#1]{#2}{#3}%
  \ifx\pgf@filename\empty\else
    \expandafter\ifx\csname svn@ignoregraphic@\pgf@filename\endcsname\relax%
      \expandafter\global\expandafter%
      \let\csname svnmulti@pgf@image@#2!\endcsname=\pgf@image%
      \expandafter\xdef\csname pgf@image@#2!\endcsname{%
        \noexpand\svnexternal[\noexpand\svn@graphicsgroup]{{\pgf@filename}}%
        \csname svnmulti@pgf@image@#2!\endcsname
      }%
    \fi
  \fi
}
\fi
\if@svnmulti@table
\ifx\tableofcontents\relax\else
\def\svnrevisionsname{Table of Revisions}%
\def\svn@svt{svt}

\AtBeginDocument{%
\ifx\chapter\relax
  \let\chapter\@undefined
\fi
\ifx\chapter\@undefined

%% Adapted from the \tableofcontents macro, LaTeX `article' class [2005/09/16]
\newcommand\tableofrevisions{%
  \section*{\svnrevisionsname
  \@mkboth{\MakeUppercase\svnrevisionsname}{\MakeUppercase\svnrevisionsname}}%
  \svn@input{\jobname .\svn@svt}%
}

\else

%% Adapted from the \tableofcontents macro, LaTeX `book' class [2005/09/16]
\newcommand\tableofrevisions{%
  \expandafter\ifx
  \csname if@twocolumn\expandafter\endcsname
  \csname iftrue\endcsname
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \chapter*{\svnrevisionsname
    \@mkboth{\MakeUppercase\svnrevisionsname}{\MakeUppercase\svnrevisionsname}}%
  \svn@input{\jobname .\svn@svt}%
  \expandafter\ifx
  \csname if@restonecol\expandafter\endcsname
  \csname iftrue\endcsname
    \twocolumn
  \fi
}

\fi
}
\fi % defined \tableofcontents

\def\svn@writerow#1#2#3{%
  \immediate\write\svn@svtwrite{%
    \expandafter\noexpand\csname svn#1row\endcsname
    \expandafter\noexpand\csname svntab#1\endcsname{#2}{#3}\space
    \@ampersamchar\space
    \svn@tabcell{rev}\space\@ampersamchar\space
    \svn@tabcell{author}\space\@ampersamchar\space
    \noexpand\svntabdate%
    \svn@tabcellarg{year}%
    \svn@tabcellarg{month}%
    \svn@tabcellarg{day}%
    \svn@tabcellarg{hour}%
    \svn@tabcellarg{minute}%
    \svn@tabcellarg{second}%
    \svn@tabcellarg{timezonehour}%
    \svn@tabcellarg{timezoneminute}%
    \space\@backslashchar\@backslashchar
    \expandafter\noexpand\csname endsvn#1row\endcsname
  }%
}

\def\svn@writegrouprow#1{%
  \begingroup
    \def\svn@tabcellarg##1{{\csname @svng@#1@##1\endcsname}}%
    \def\svn@tabcell##1{\expandafter\noexpand\csname svntab##1\endcsname%
      \svn@tabcellarg{##1}%
    }%
    \svn@writerow{group}{#1}{}%
  \endgroup
}

\def\svn@writesubgrouprow#1#2{%
  \begingroup
    \def\svn@tabcellarg##1{{\csname @svng@#2@##1\endcsname}}%
    \def\svn@tabcell##1{\expandafter\noexpand\csname svntab##1\endcsname%
      \svn@tabcellarg{##1}%
    }%
    \svn@writerow{subgroup}{#1}{#2}%
  \endgroup
}

\def\svn@writefilerow#1#2{%
  \begingroup
    \def\svn@tabcellarg##1{{\csname @svng@#2@##1\endcsname}}%
    \def\svn@tabcell##1{\expandafter\noexpand\csname svntab##1\endcsname%
      \svn@tabcellarg{##1}%
    }%
    \svn@writerow{file}{#1}{#2}%
  \endgroup
}

\def\svn@writeglobalrow{%
  \begingroup
  \def\svn@tabcellarg##1{{\csname @svn@##1\endcsname}}%
  \def\svn@tabcell##1{\expandafter\noexpand\csname svntab##1\endcsname%
    \svn@tabcellarg{##1}%
  }%
  \svn@writerow{global}{}{}%
  \endgroup
}

\def\svntable{%
  \begin{tabular}{p{0.425\textwidth}rll}%
    \hline
}
\def\endsvntable{\hline\end{tabular}}

\def\svntablehead{%
    Name & Rev & Last Author & Last Changed At \\\hline
}
\def\svntablefoot{}

\def\svnbeforetable{}
\def\svnaftertable{\clearpage}

\def\svnglobalrow{}
\def\endsvnglobalrow{}
\def\svngrouprow{}
\def\endsvngrouprow{}
\def\svnsubgrouprow{}
\def\endsvnsubgrouprow{}
\def\svnfilerow{}
\def\endsvnfilerow{}

\def\svntabglobal{Document}
\def\svntabgroup#1{Group `#1'}

\def\svntabsubgroup#1{%
  \raggedright
  \addtolength{\leftskip}{#1\medskipamount}%
  \begingroup
  \catcode`\_=12
  \catcode`\&=12
  \catcode`\^=12
  \catcode`\$=12
  \catcode`\#=12
  \svn@tabsubgroup
}
\def\svn@tabsubgroup#1{\endgroup Subgroup `\texttt{\small #1}'}

\def\svntabfile#1{%
  \raggedright
  \addtolength{\leftskip}{#1\medskipamount}%
  \begingroup
  \catcode`\_=12
  \catcode`\&=12
  \catcode`\^=12
  \catcode`\$=12
  \catcode`\#=12
  \svn@tabfile
}
\def\svn@tabfile#1{\endgroup File `\texttt{\small #1}'}

\def\svntabrev{}
\def\svntabauthor#1{\svnFullAuthor{#1}}
\def\svntabdate#1#2#3#4#5#6#7#8{%
    #1-#2-#3 #4:#5:#6% #7#8%
}

\fi

\newcommand{\svn}{\@ifnextchar{*}{\svn@s}{\svn@n}}
\def\svn@n#1{\@svn@n#1}
\def\svn@s*#1{\@svn@s#1}
\def\@svn@n$#1${#1}
\def\@svn@s$#1 ${#1}

%% Adapted from the \url macro of the `hyperref` package.
\DeclareRobustCommand*{\svnnolinkurl}{%
  \@ifundefined{hyper@normalise}%
    {\PackageWarning{svn-multi}{Package hyperref is needed for \noexpand
     \svnnolinkurl.}}%
    {\hyper@normalise\svnnolinkurl@}%
}%
\def\svnnolinkurl@#1{\Hurl{#1}}%

\def\svn@getfilename#1{%
  \begingroup
    \gdef\svnfiledir{}%
    \edef\svn@temp{#1}%
    \expandafter\@svn@getfilename\svn@temp/{}\relax
}%

\def\@svn@getfilename#1/#2\relax{%
  \svn@ifempty{#2}%
    {%
      \endgroup
      \gdef\svnfilefname{#1}%
    }%
    {%
      \xdef\svnfiledir{\svnfiledir#1/}%
      \@svn@getfilename#2\relax
    }%
}%


\let\svn@write\@mainaux
{\catcode`\&=12
\gdef\@ampersamchar{&}
}
\def\svn@writesvn{%
    \if@svnmulti@groups
    \fi
    \immediate\write\svn@write{^^J%
      \@percentchar\space Global values:^^J%
      \noexpand\gdef\noexpand\svnrev{\@svn@rev}^^J%
      \noexpand\global\noexpand\let\noexpand\ifsvnmodified\@backslashchar\@svn@modified^^J%
      \noexpand\gdef\noexpand\svndate{\@svn@date}^^J%
      \noexpand\gdef\noexpand\svnauthor{\@svn@author}^^J%
      \noexpand\gdef\noexpand\svnyear{\@svn@year}^^J%
      \noexpand\gdef\noexpand\svnmonth{\@svn@month}^^J%
      \noexpand\gdef\noexpand\svnday{\@svn@day}^^J%
      \noexpand\gdef\noexpand\svnhour{\@svn@hour}^^J%
      \noexpand\gdef\noexpand\svnminute{\@svn@minute}^^J%
      \noexpand\gdef\noexpand\svnsecond{\@svn@second}^^J%
      \noexpand\gdef\noexpand\svntimezonehour{\@svn@timezonehour}^^J%
      \noexpand\gdef\noexpand\svntimezoneminute{\@svn@timezoneminute}^^J%
      \noexpand\svn@gdefverb\noexpand\svnurl{\@svn@url}^^J%
      \noexpand\svn@gdefverb\noexpand\svnfname{\@svn@fname}^^J%
    }%
    \if@svnmulti@groups
      \svn@cleanfilelist\@svng@@files
      \immediate\write\svn@write{%
        \noexpand\gdef\noexpand\svng@@files{\@svng@@files}^^J%
      }%
      \svn@writeallgroups\@svng@@files
      \ifx\svn@glist\empty\else
        \begingroup
          \immediate\write\svn@write{^^J%
            \@percentchar\space SVN File Groups: \svn@glist
          }%
          \svn@writeallgroups\svn@glist
        \endgroup
      \fi
    \else
      \immediate\write\svn@write{^^J}%
    \fi
}

\def\svn@writegroupfiles#1{%
  \begingroup
    \advance\svn@grouplevel by 1\relax
    \expandafter\let
    \expandafter\svn@files\csname @svng@#1@files\endcsname
    \ifx\svn@files\relax\else
      \svn@cleanfilelist\svn@files
      \@for\svn@file:=\svn@files\do{%
        \svn@ifvalidrev{@svng@\svn@file @rev}%
          {%
            \@ifundefined{@svng@\svn@file @files}%
              {\svn@writefilerow{\the\svn@grouplevel}{\svn@file}}%
              {\svn@ifonlyone{\svn@file}%
                {\svn@writefilerow{\the\svn@grouplevel}%
                  {\csname @svng@\svn@file @files\endcsname}}%
                {\svn@ifempty{\csname @svng@\svn@file @files\endcsname}%
                  {}%
                  {%
                    \svn@writesubgrouprow{\the\svn@grouplevel}{\svn@file}%
                    \svn@writegroupfiles{\svn@file}%
                  }%
                }%
              }%
          }{}%
      }%
    \fi
  \endgroup
}%

\def\svn@writesvt{%
  \if@svnmulti@table
    \newwrite\svn@svtwrite
    \immediate\openout\svn@svtwrite=\jobname.\svn@svt\relax
    \@onelevel@sanitize\svntable%
    \immediate\write\svn@svtwrite{%
      \noexpand\svnbeforetable^^J%
      \svntable
      \noexpand\svntablehead^^J%
    }%
    \let\svn@grouplevel\@tempcnta
    \svn@grouplevel=0\relax
    \svn@writeglobalrow{}%
    \svn@writegroupfiles{}%
    \@for\svn@g:=\svn@glist\do{%
      \@ifundefined{@svng@\svn@g @rev}{}%
      {%
        \expandafter
        \ifnum\csname @svng@\svn@g @rev\endcsname>0\relax
          \svn@writegrouprow{\svn@g}%
          \svn@writegroupfiles{\svn@g}%
        \fi
      }%
    }%

    \@onelevel@sanitize\endsvntable%
    \immediate\write\svn@svtwrite{%
      \noexpand\svntablefoot^^J%
      \endsvntable^^J%
      \noexpand\svnaftertable
    }%
    \immediate\closeout\svn@svtwrite%
  \fi
}

\if@svnmulti@autokwall

\AtBeginOfFiles{%
  \expandafter
  \ifx\csname svn@ignore@ext@\currfileext\endcsname\relax
    \svnegetfile{\currfilepath}%
  \fi
}

\fi

\AtEndDocument{%
  \if@filesw
    \ifx\@svn@rev\empty\else
      \ifnum\@svn@rev<1\else
        \begingroup
        \let\protect\@unexpandable@protect
        \svn@writesvn
        \svn@writesvt
        \endgroup
      \fi
    \fi
  \fi
}
\endinput
%%
%% End of file `svn-multi.sty'.
