Discussion:
auto-props syntax in file vs. property
Chris
2018-01-09 15:15:18 UTC
Permalink
Hi,

I am really confused by how to set an auto-property when I need multiple "parameters" to a single property.
When setting svn:auto-props, it seems I can do this:

*.java = svn:mime-type=text/java;;charset=iso-8859-1;svn:eol-style=LF

That is, use ;; as an escape between the "parameters" for file type and charset. Adding a java-file and doing propget gives this:
text/java;charset=iso-8859-1
Which seems to be correct. Right?

Using the exact same line in ~/.subversion/config seems to see "charset" as a separate property from "mime-type" and set two different properties on the file with "charset" having no meaning. Using svn_apply_autoprops.py on that syntax at least gave me those separate props. A quick web search showed someone enclosing the entire property in quotes and only using a single semicolon, i.e.:
*.java = "svn:mime-type=text/java;charset=iso-8859-1";svn:eol-style=LF
Haven't tested this yet and I don't know if it works or not

I can't find anything in the manual (http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html) describing what the right separator/escape sequence is for these two and if there's some common syntax that can be used for both.
If would have been nice if I could use the exact same syntax for both so I can just paste in filetype-part of the config file into the auto-props, but it won't kill me if I have to use separate ones, as long as I know how to use it :)

At least for a transition period, I will need to keep the config-file in order to run svn_apply_autoprops on files coming in from branches created added before we added svn:auto-props (and have wrong props) so I need both working and I'm unsure of what the right way for doing this is.

TIA,
Chris
Daniel Shahaf
2018-01-09 16:05:29 UTC
Permalink
Post by Chris
*.java = svn:mime-type=text/java;;charset=iso-8859-1;svn:eol-style=LF
That is, use ;; as an escape between the "parameters" for file type and
text/java;charset=iso-8859-1
Which seems to be correct. Right?
Yes.
Post by Chris
Using the exact same line in ~/.subversion/config seems to see "charset"
as a separate property from "mime-type" and set two different properties
on the file with "charset" having no meaning.
I can't reproduce this. With that line in ~/.subversion/config I get:

[[[
% svn add foo.java
A foo.java
% svn pl -v foo.java
Properties on 'foo.java':
svn:eol-style
native
svn:mime-type
text/java;charset=iso-8859-1
]]]

(The value 'native' was inherited from svn:auto-props in the working
copy I was testing in.)

Also, does it really set *two* properties on the file? Not three? "svn:mime-type",
"charset", "svn:eol-style"?

What client and version do you use?

Cheers,

Daniel
Chris
2018-01-10 07:25:07 UTC
Permalink
Hi Daniel,

thanks for the reply.
You're right that it seems to work when I do "svn add" and with that config file, but when I do the same with svn_apply_autoprops.py, it acts badly. I simply forgot to check the regular add :)
So I get the problem when I do:
./svn_apply_autoprops.py --config myconfig /path/to/workspace

Then it will set charset and mime-type as two separate properties.
(and yes, it sets 3 properties overall, I just meant that the mime-type got split into two)

I guess there's something in the parser in svn_apply_autoprops that is misbehaving rather than svn itself. A quick look in that file shows this line:
for prop in props.split(';'):
Which I suspect is the root cause of the issue, although I haven't verified it yet. I guess I need to figure out some python basics and see if I can ugly-hack that to work for double semicolons.

/Chris

--------------------------------------------
On Tue, 1/9/18, Daniel Shahaf <***@daniel.shahaf.name> wrote:

Subject: Re: auto-props syntax in file vs. property
To: ***@subversion.apache.org
Date: Tuesday, January 9, 2018, 5:05 PM

Chris wrote on Tue, 09 Jan 2018
Post by Chris
When setting
  *.java =
svn:mime-type=text/java;;charset=iso-8859-1;svn:eol-style=LF
Post by Chris
That is, use ;; as
an escape between the "parameters" for file type
and
Post by Chris
charset. Adding a java-file and
doing propget gives this:
text/java;charset=iso-8859-1
Post by Chris
Which
seems to be correct. Right?

Yes.
Using the exact same line in ~/.subversion/config seems to
see "charset"
Post by Chris
as a separate
property from "mime-type" and set two different
properties
Post by Chris
on the file with
"charset" having no meaning.

I can't reproduce this.  With that line in
~/.subversion/config I get:

[[[
% svn add foo.java
A        foo.java
% svn pl
-v foo.java
Properties on
'foo.java':
  svn:eol-style
    native
  svn:mime-type
    text/java;charset=iso-8859-1
]]]

(The value
'native' was inherited from svn:auto-props in the
working
copy I was testing in.)

Also, does it really set *two*
properties on the file?  Not three? 
"svn:mime-type",
"charset",
"svn:eol-style"?

What client and version do you use?

Cheers,

Daniel
Chris
2018-01-10 08:26:00 UTC
Permalink
I think the fix to svn_apply_autoprops.py should be something like below (/subversion/trunk/contrib/client-side/svn_apply_autoprops.py)
If anyone with commit rights wants to fix it on the repo, feel free to use the below, or improve it as necessary (my python knowledge is non-existing)

Index: svn_apply_autoprops.py
===================================================================
--- svn_apply_autoprops.py (revision 103617)
+++ svn_apply_autoprops.py (revision 103618)
@@ -101,7 +101,11 @@
# leading and trailing whitespce from the propery names and
# values.
props_list = []
- for prop in props.split(';'):
+ # Since ;; is a separator within one property, we need to do
+ # regex and use both negative lookahead and lookbehind to avoid
+ # ever matching a more than one semicolon in the split
+ semicolonpattern = re.compile("(?<!;);(?!;)")
+ for prop in re.split(semicolonpattern, props):
prop = prop.strip()
if not len(prop):
continue

/Chris

--------------------------------------------
On Wed, 1/10/18, Chris <***@yahoo.se> wrote:

Subject: Re: auto-props syntax in file vs. property
To: ***@subversion.apache.org, "Daniel Shahaf" <***@daniel.shahaf.name>
Date: Wednesday, January 10, 2018, 8:25 AM

Hi Daniel,

thanks for the reply.
You're right that it seems to work when
I do "svn add" and with that config file, but when I do the
same with svn_apply_autoprops.py, it acts badly. I simply
forgot to check the regular add :)
So I get the problem when I do:
  ./svn_apply_autoprops.py
--config myconfig /path/to/workspace

Then it will set charset and mime-type
as two separate properties.
(and yes, it sets 3 properties overall,
I just meant that the mime-type got split into two)

I guess there's something in the parser
in svn_apply_autoprops that is misbehaving rather than svn
itself. A quick look in that file shows this line:
    for prop in
props.split(';'):
Which I suspect is the root cause of
the issue, although I haven't verified it yet. I guess I
need to figure out some python basics and see if I can
ugly-hack that to work for double semicolons.

/Chris

--------------------------------------------
On Tue, 1/9/18, Daniel Shahaf <***@daniel.shahaf.name>
wrote:

Subject: Re: auto-props syntax in file
vs. property
To: ***@subversion.apache.org
Date: Tuesday, January 9, 2018, 5:05
PM

Chris wrote on Tue, 09 Jan 2018
Post by Chris
When setting
svn:auto-props, it seems I can do
Post by Chris
  *.java =
svn:mime-type=text/java;;charset=iso-8859-1;svn:eol-style=LF
Post by Chris
That is, use ;; as
an escape between the "parameters" for
file type
and
Post by Chris
charset. Adding a java-file and
doing propget gives this:
text/java;charset=iso-8859-1
Post by Chris
Which
seems to be correct. Right?

Yes.
Using the exact same line in
~/.subversion/config seems to
see "charset"
Post by Chris
as a separate
property from "mime-type" and set two
different
properties
Post by Chris
on the file with
"charset" having no meaning.

I can't reproduce this.  With that
line in
~/.subversion/config I get:

[[[
% svn add foo.java
A         foo.java
% svn pl
-v foo.java
Properties on
'foo.java':
  svn:eol-style
    native
  svn:mime-type
    text/java;charset=iso-8859-1
]]]

(The value
'native' was inherited from
svn:auto-props in the
working
copy I was testing in.)

Also, does it really set *two*
properties on the file?  Not
three? 
"svn:mime-type",
"charset",
"svn:eol-style"?

What client and version do you use?

Cheers,

Daniel
Daniel Shahaf
2018-01-10 19:51:52 UTC
Permalink
Post by Chris
I think the fix to svn_apply_autoprops.py should be something like below
(/subversion/trunk/contrib/client-side/svn_apply_autoprops.py)
If anyone with commit rights wants to fix it on the repo, feel free to
use the below, or improve it as necessary (my python knowledge is non-
existing)
Index: svn_apply_autoprops.py
===================================================================
--- svn_apply_autoprops.py (revision 103617)
+++ svn_apply_autoprops.py (revision 103618)
@@ -101,7 +101,11 @@
# leading and trailing whitespce from the propery names and
# values.
props_list = []
+ # Since ;; is a separator within one property, we need to do
+ # regex and use both negative lookahead and lookbehind to avoid
+ # ever matching a more than one semicolon in the split
+ semicolonpattern = re.compile("(?<!;);(?!;)")
That's clever, but it will misparse sequences of three or more semicolons in a row, such as

*.foo = key=val;;with;;semicolons;;;anotherkey=anotherval

Daniel

Loading...