\usepackage{keyval}
\usepackage{boolean}
\usepackage{copytofile}

%% Configurable commands

\edef \VersionAuxFile{\jobname.rev}
\newcommand{\VersionEval}[1]{\ORL{#1}}

%% Visible command

\newif \ifVersionVisible \VersionVisibletrue
\newcount \VersionDepth 
\newcommand {\theVersionDepth}{\the \Version@Depth}

%% Hidden commands

\let \rev@depth \VersionDepth 
\rev@depth 0\relax
\let \version@level  \rev@depth 

\def \rev@show {\advance \rev@depth by 1\relax\ignorespaces}
\def \rev@hide {\copytofile{\VersionAuxFile}}

\newif \if@rev

%% Environment \end{version} must be at the beginning of a line. 
\newenvironment{version}[1]
   {\VersionEval{#1}{\rev@show}{\rev@hide}}
   {}

%% Shorter version
\newcommand {\ifversion}[1]{\VersionEval{#1}}

\endinput

