Discussion:
auto-props syntax in file vs. property
Chris
2018-02-22 12:52:12 UTC
Permalink
Re-awakening my previous thread about the auto-properties. I get really confused by where to use ;; and ; as a separator.

I currently have this in the auto-props on the repo:
*.txt = svn:mime-type=text/plain;;charset=iso-8859-1;svn:eol-style=LF

And then if I add a text file:
prompt> touch foo.txt; svn add foo.txt; svn pg svn:mime-type foo.txt
A foo.txt
text/plain;charset=iso-8859-1

So the property itself is with just one semicolon in there despite the auto-prop having ;;
Is this the correct behavior?

While if I to the same thing manually, i.e.

prompt> touch foo; svn add foo; svn propset svn:mime-type "text/plain;;charset=iso-8859-1" foo; svn pg svn:mime-type foo
A foo
property 'svn:mime-type' set on 'foo'
text/plain;;charset=iso-8859-1

That is, I'm passing in the exact string that I have in my auto-props into propset for a file without .txt-suffix so I don't get the auto-properties. But as you see in the resulting property that I now have has double semi-colons.

My guess is that the former is the intended behavior and I should not be passing in the ";;" into the manual command, but I'm getting really confused here. I seems very error-prone that manual propset can't use the strings from the config file or auto-props wihtout getting a different result.

Which version is the correct one, or do both actually do the job?

BR
Chris




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

Subject: Re: auto-props syntax in file vs. property
To: "Chris" <***@yahoo.se>, ***@subversion.apache.org
Date: Wednesday, January 10, 2018, 8:51 PM

Chris wrote on Wed, 10 Jan 2018
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
+    #
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):

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
Branko Čibej
2018-02-22 13:10:24 UTC
Permalink
Post by Chris
Re-awakening my previous thread about the auto-properties. I get really confused by where to use ;; and ; as a separator.
*.txt = svn:mime-type=text/plain;;charset=iso-8859-1;svn:eol-style=LF
prompt> touch foo.txt; svn add foo.txt; svn pg svn:mime-type foo.txt
A foo.txt
text/plain;charset=iso-8859-1
More completely: an 'svn proplist -v' would show the folloing properties:

svn:mime-type=text/plain;charset=iso-8859-1
svn:eol-style=LF
Post by Chris
So the property itself is with just one semicolon in there despite the auto-prop having ;;
Is this the correct behavior?
Yes of course. In the auto-props configuration, a single colon separates
individual properties. If you want a colon within a property value, you
have to write ;; in the auto-props configuration to get the ; in the
property value.

If instead you'd had this auto-props configuration:

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


Then, when you added a file to Subversion, you'd get the following
properties set:

svn:mime-type=text/plain
charset=iso-8859-1
svn:eol-style=LF


which is probably not what you want.
Post by Chris
While if I to the same thing manually, i.e.
prompt> touch foo; svn add foo; svn propset svn:mime-type "text/plain;;charset=iso-8859-1" foo; svn pg svn:mime-type foo
A foo
property 'svn:mime-type' set on 'foo'
text/plain;;charset=iso-8859-1
That is, I'm passing in the exact string that I have in my auto-props into propset for a file without .txt-suffix so I don't get the auto-properties. But as you see in the resulting property that I now have has double semi-colons.
On the command-line you can only set a singly property value at a time,
so there's no need to escape the ';' delimiter.
But the auto-props configuration isn't a single property; it's several
properties, delimited with a single ';'.
Post by Chris
My guess is that the former is the intended behavior and I should not be passing in the ";;" into the manual command,
Yes.
Post by Chris
but I'm getting really confused here. I seems very error-prone that manual propset can't use the strings from the config file or auto-props wihtout getting a different result.
Which version is the correct one, or do both actually do the job?
Each does its job in its own context.

-- Brane
Chris
2018-02-22 14:28:33 UTC
Permalink
Hi Brane,

thanks for the reply. Then I understand why it's acting the way it is. It would have been nicer with different separators for the two cases, but it is what it is and I agree that it works.
The downside is that my initial fix (earlier in this thread) for svn_apply_autoprops.py isn't correct since I need to prune the second ; before it calls propset. Need to try another fix then (unless someone has fixed that in the repo already)

/Chris


--------------------------------------------
On Thu, 2/22/18, Branko Čibej <***@apache.org> wrote:

Subject: Re: auto-props syntax in file vs. property
To: ***@subversion.apache.org
Date: Thursday, February 22, 2018, 2:10 PM

On 22.02.2018 13:52, Chris
Post by Chris
Re-awakening my previous thread
about the auto-properties. I get really confused by where to
use ;; and ; as a separator.
Post by Chris
I currently have this in the auto-props on
*.txt =
svn:mime-type=text/plain;;charset=iso-8859-1;svn:eol-style=LF
Post by Chris
And then if I add a
prompt>  touch foo.txt;
svn add foo.txt; svn pg svn:mime-type foo.txt
Post by Chris
A        foo.txt
text/plain;charset=iso-8859-1

More completely: an 'svn proplist -v'
would show the folloing properties:

   
svn:mime-type=text/plain;charset=iso-8859-1
    svn:eol-style=LF
Post by Chris
So the property itself is with just one
semicolon in there despite the auto-prop having ;;
Post by Chris
Is this the correct behavior?
Yes of course. In the
auto-props configuration, a single colon separates
individual properties. If you want a colon
within a property value, you
have to write
;; in the auto-props configuration to get the ; in the
property value.

If instead you'd had this auto-props
configuration:

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


Then, when
you added a file to Subversion, you'd get the
following
properties set:

   
svn:mime-type=text/plain
   
charset=iso-8859-1
    svn:eol-style=LF


which is
probably not what you want.
Post by Chris
While if I to the same
thing manually, i.e.
Post by Chris
prompt> touch foo; svn add foo; svn
propset svn:mime-type
"text/plain;;charset=iso-8859-1" foo; svn pg
svn:mime-type foo
Post by Chris
A        foo
property 'svn:mime-type' set on
'foo'
text/plain;;charset=iso-8859-1
Post by Chris
That is, I'm passing in the exact
string that I have in my auto-props into propset for a file
without .txt-suffix so I don't get the auto-properties.
But as you see in the resulting property that I now have has
double semi-colons.

On the
command-line you can only set a singly property value at a
time,
so there's no need to escape the
';' delimiter.
But the auto-props
configuration isn't a single property; it's
several
properties, delimited with a single
';'.
Post by Chris
My guess
is that the former is the intended behavior and I should not
be passing in the ";;" into the manual command,

Yes.
Post by Chris
  but
I'm getting really confused here. I seems very
error-prone that manual propset can't use the strings
from the config file or auto-props wihtout getting a
different result.
Which version is the correct one, or do both actually do the
job?

Each does its
job in its own context.

--
Brane

Loading...