You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Georges Labrèche <gl...@stream57.com> on 2009/06/15 15:24:57 UTC
Filtering svn info output
Hello all!
When executing the svn info command I'd like to filter the output so that we only display the Revision information.
This would greatly facilitate parsing out that information in my build script.
Is this possible?
Thank and regards!
- Georges
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2362218
To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].
RE: Filtering svn info output
Posted by Georges Labrèche <gl...@stream57.com>.
Hello,
This would not work in a NAnt build script because the svnversion command isn't recognized by the <svn /> task.
However it could work if a <exec /> task was used instead.
Thanks!
-----Original Message-----
From: Stefan Sperling [mailto:stsp@elego.de]
Sent: Monday, June 15, 2009 11:49 AM
To: Georges Labrèche
Cc: users@subversion.tigris.org
Subject: Re: Filtering svn info output
On Mon, Jun 15, 2009 at 11:24:57AM -0400, Georges Labrèche wrote:
> Hello all!
>
> When executing the svn info command I'd like to filter the output so
> that we only display the Revision information.
>
> This would greatly facilitate parsing out that information in my build script.
>
> Is this possible?
You might rather want to use svnversion:
usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]
Produce a compact 'version number' for the working copy path
WC_PATH. TRAIL_URL is the trailing portion of the URL used to
determine if WC_PATH itself is switched (detection of switches
within WC_PATH does not rely on TRAIL_URL). The version number
is written to standard output. For example:
$ svnversion . /repos/svn/trunk
4168
The version number will be a single number if the working
copy is single revision, unmodified, not switched and with
an URL that matches the TRAIL_URL argument. If the working
copy is unusual the version number will be more complex:
4123:4168 mixed revision working copy
4168M modified working copy
4123S switched working copy
4123P partial working copy, from a sparse checkout
4123:4168MS mixed revision, modified, switched working copy
If invoked on a directory that is not a working copy, an
exported directory say, the program will output 'exported'.
If invoked without arguments WC_PATH will be the current directory.
Valid options:
-n [--no-newline] : do not output the trailing newline
-c [--committed] : last changed rather than current revisions
-h [--help] : display this help
--version : show program version information
Stefan
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2362237
To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].
Re: Filtering svn info output
Posted by Stefan Sperling <st...@elego.de>.
On Mon, Jun 15, 2009 at 11:24:57AM -0400, Georges Labrèche wrote:
> Hello all!
>
> When executing the svn info command I'd like to filter the output so
> that we only display the Revision information.
>
> This would greatly facilitate parsing out that information in my build script.
>
> Is this possible?
You might rather want to use svnversion:
usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]
Produce a compact 'version number' for the working copy path
WC_PATH. TRAIL_URL is the trailing portion of the URL used to
determine if WC_PATH itself is switched (detection of switches
within WC_PATH does not rely on TRAIL_URL). The version number
is written to standard output. For example:
$ svnversion . /repos/svn/trunk
4168
The version number will be a single number if the working
copy is single revision, unmodified, not switched and with
an URL that matches the TRAIL_URL argument. If the working
copy is unusual the version number will be more complex:
4123:4168 mixed revision working copy
4168M modified working copy
4123S switched working copy
4123P partial working copy, from a sparse checkout
4123:4168MS mixed revision, modified, switched working copy
If invoked on a directory that is not a working copy, an
exported directory say, the program will output 'exported'.
If invoked without arguments WC_PATH will be the current directory.
Valid options:
-n [--no-newline] : do not output the trailing newline
-c [--committed] : last changed rather than current revisions
-h [--help] : display this help
--version : show program version information
Stefan
RE: Filtering svn info output
Posted by Georges Labrèche <gl...@stream57.com>.
Hello,
In my case "| grep ^Revision" wouldn't work for the same reason why ">> output.txt" wouldn't work.
I am using NAnt as a build script and the use of characters such as "|" or ">>" (via the use of >>) in the <svn /> or <exec /> task results in the following errors:
[svn] svn: Error resolving case of '|'
[svn] svn: Error resolving case of '>>'
Even though the same operations work when inputted directly in the command prompt window.
Further, the process being executed on a windows machine, the use of grep would not be possible unless installed and I would like to avoid dependencies to ensure the process executes in all machines.
Also, I can create an xml output but once again, because of NAnt I cannot write any output because of failure of the <svn /> or <exec /> tasks in resolving the case of '>>'. What I can do is use the <record /> task instead in which case it will write a malformed xml file because each line will begin with "[svn]"
Using the build script to do this is the answer. Through NAnt I can use regular expression to retrieve the information I need:
<!-- The svn command line that will be executed in order to retrieve the latest HEAD revision number-->
<property name="svn.info.command.line" value="info --revision HEAD"/>
<!-- Get info on latest HEAD revision and record it in a file -->
<record name="${svn.head.revision.file}" level="Info" action="Start"/>
<svn command="info"
uri="${svn.trunk.url}">
<arg line="${svn.info.command.line}" />
</svn>
<record name="info" action="Close"/>
<!-- Load the written file into a property -->
<loadfile file="info" property="svn.info" />
<!-- Delete the written file, we don't need it anymore now that it has been set as a property -->
<delete file="${svn.head.revision.file}" />
<!-- Use regular expression to retrieve -->
<regex pattern="Revision: (?'match'\d+)" input="${svn.info}" />
<property name="svn.info.revision" value="${match}"/>
<echo>${svn.info.revision}</echo>
Thanks!
-----Original Message-----
From: Tyler Roscoe [mailto:tyler@cryptio.net]
Sent: Monday, June 15, 2009 11:43 AM
To: Georges Labrèche
Cc: users@subversion.tigris.org
Subject: Re: Filtering svn info output
On Mon, Jun 15, 2009 at 11:24:57AM -0400, Georges Labrèche wrote:
> When executing the svn info command I'd like to filter the output so that we only display the Revision information.
>
> This would greatly facilitate parsing out that information in my build script.
I think most people just do something like:
svn info | grep ^Revision
If this is already in a build script, just use your build script's
language to do this. You could also use --xml and parse that.
tyler
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2362236
To unsubscribe from this discussion, e-mail: [users-unsubscribe@subversion.tigris.org].
Re: Filtering svn info output
Posted by Tyler Roscoe <ty...@cryptio.net>.
On Mon, Jun 15, 2009 at 11:24:57AM -0400, Georges Labrèche wrote:
> When executing the svn info command I'd like to filter the output so that we only display the Revision information.
>
> This would greatly facilitate parsing out that information in my build script.
I think most people just do something like:
svn info | grep ^Revision
If this is already in a build script, just use your build script's
language to do this. You could also use --xml and parse that.
tyler