You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Laker Netman <la...@yahoo.com> on 2008/06/25 15:30:43 UTC

Newline in return value from propget, is it a bug?

I'm running Subversion 1.4.6 and checked the bug tracker under "propget", but didn't find anything relevent. I am having an issue where testing a value being returned by propget in a post-commit perl script always fails. The example below explains what is happening.

Here is my test script:
 my $repos = $ARGV[0];
 my $wcLoc = $ARGV[1];
 $wcType = `svn propget wcType svn://repoServer/$repos/$wcLoc`;
 my $updateType = $wcType eq "support" ? "" : $wcLoc eq "branches" ? "alpha" : "beta";
 print "WC type=\"$wcType\" and WC location=\"$wcLoc\" therefore updateType=\"$updateType\"\n";

Basically, if the repo has a wcType=support then there are no alpha or beta directories to deal with during my post-commit process. If wcType is something else, or doesn't exist, then based on the commit being made to "branches" or "trunk", I have to account for "alpha" or "beta" subdirectories (respectively) elsewhere in the script.

$repos is the repository name
$wcLoc is the repository directory where working copy is making the commit

When I run this against a repository without wcType set at all this is the result (as expected):
testprop.pl images trunk
WC type="" and WC location="trunk" therefore updateType="beta"

However, when I run this against a repository with wcType=support this is the (incorrect) result:
testprop.pl images trunk
WC type="support
" and WC location="trunk" therefore updateType="beta"

And I expected this:
testprop.pl images trunk
WC type="support" and WC location="trunk" therefore updateType=""

But the newline after "support" is messing up the first part of the ternary operation.

I know I can fiddle with the string returned by propget, but that seems like a workaround. It looks like propget is automatically appending a newline to the returned value. When I
edit the property via TortiseSVNs edit function no newline is present,
however, when I run "svn propget" in a perl script and dump the
variable to stdout, a newline is definitely present. I created a test repository and tried this out with the same result.

So, is this A) a bug, B) by design, or C) caused by something else?

Thanks,
Laker



      

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Newline in return value from propget, is it a bug?

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Jun 25, 2008, at 10:30 AM, Laker Netman wrote:

> I'm running Subversion 1.4.6 and checked the bug tracker under  
> "propget", but didn't find anything relevent. I am having an issue  
> where testing a value being returned by propget in a post-commit  
> perl script always fails. The example below explains what is  
> happening.
>
> Here is my test script:
>  my $repos = $ARGV[0];
>  my $wcLoc = $ARGV[1];
>  $wcType = `svn propget wcType svn://repoServer/$repos/$wcLoc`;
>  my $updateType = $wcType eq "support" ? "" : $wcLoc eq  
> "branches" ? "alpha" : "beta";
>  print "WC type=\"$wcType\" and WC location=\"$wcLoc\" therefore  
> updateType=\"$updateType\"\n";
>
> Basically, if the repo has a wcType=support then there are no alpha  
> or beta directories to deal with during my post-commit process. If  
> wcType is something else, or doesn't exist, then based on the  
> commit being made to "branches" or "trunk", I have to account for  
> "alpha" or "beta" subdirectories (respectively) elsewhere in the  
> script.
>
> $repos is the repository name
> $wcLoc is the repository directory where working copy is making the  
> commit
>
> When I run this against a repository without wcType set at all this  
> is the result (as expected):
> testprop.pl images trunk
> WC type="" and WC location="trunk" therefore updateType="beta"
>
> However, when I run this against a repository with wcType=support  
> this is the (incorrect) result:
> testprop.pl images trunk
> WC type="support
> " and WC location="trunk" therefore updateType="beta"
>
> And I expected this:
> testprop.pl images trunk
> WC type="support" and WC location="trunk" therefore updateType=""
>
> But the newline after "support" is messing up the first part of the  
> ternary operation.
>
> I know I can fiddle with the string returned by propget, but that  
> seems like a workaround. It looks like propget is automatically  
> appending a newline to the returned value. When I
> edit the property via TortiseSVNs edit function no newline is present,
> however, when I run "svn propget" in a perl script and dump the
> variable to stdout, a newline is definitely present. I created a  
> test repository and tried this out with the same result.
>
> So, is this A) a bug, B) by design, or C) caused by something else?

I can confirm the issue. I'm not sure if it's to be considered a bug.  
I guess the newline is meant to make display on a terminal look  
better. For example:


$ svn pg wcType .
support
$


If it didn't output a newline, if would look like this:


$ svn pg wcType .
support$


As you say, you could work around the problem, e.g. like this:


$wcType = `svn propget wcType svn://repoServer/$repos/$wcLoc | xargs  
echo -n`;


Or if you switched from parsing the command line output to using the  
perl language bindings, I'm sure it would provide a cleaner way to  
get the property values.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Newline in return value from propget, is it a bug?

Posted by Eric Gillespie <ep...@pretzelnet.org>.
Laker Netman <la...@yahoo.com> writes:

> I know I can fiddle with the string returned by propget, but that seems like 
> a workaround. It looks like propget is automatically appending a newline to t
> he returned value. When I
> edit the property via TortiseSVNs edit function no newline is present,
> however, when I run "svn propget" in a perl script and dump the
> variable to stdout, a newline is definitely present. I created a test reposit
> ory and tried this out with the same result.

--strict

--  
Eric Gillespie <*> epg@pretzelnet.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org