You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Paul Burba <pt...@gmail.com> on 2008/03/10 15:34:59 UTC

Re: svn commit: r29770 - trunk/contrib/client-side/svnmerge

On Fri, Mar 7, 2008 at 1:18 PM, <cm...@tigris.org> wrote:

> Author: cmpilato
> Date: Fri Mar  7 10:18:08 2008
> New Revision: 29770
>
> Log:
> Teach svnmerge-migrate-history.py to handle the differences between
> the svnmerge tracking info format and the format used by Subversion
> for its own merge tracking info.
>
> * contrib/client-side/svnmerge/svnmerge-migrate-history.py
>  (Migrator.add_to_mergeinfo): Convert svnmerge property values into
>    Subversion mergeinfo format before slamming them through APIs that
>    expect the latter.
>
> Modified:
>   trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py
>
> Modified: trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py
> URL: http://svn.collab.net/viewvc/svn/trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py?pathrev=29770&r1=29769&r2=29770
> ==============================================================================
> --- trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py      (original)
> +++ trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py      Fri Mar  7 10:18:08 2008
> @@ -21,6 +21,7 @@
>  import os
>  import sre
>  import getopt
> +import urllib
>  try:
>   my_getopt = getopt.gnu_getopt
>  except AttributeError:
> @@ -191,11 +192,35 @@
>
>   def add_to_mergeinfo(self, svnmerge_prop_val, mergeinfo_prop_val):
>     if svnmerge_prop_val is not None:
> +      # Convert svnmerge-* property value (which uses any whitespace
> +      # for delimiting sources and stores source paths URI-encoded)
> +      # into a svn:mergeinfo syntax (which is newline-separated with
> +      # URI-decoded paths).
> +      sources = svnmerge_prop_val.split()
> +      svnmerge_prop_val = ''
> +      for source in sources:
> +        pieces = source.split(':')
> +        if len(pieces) > 2:

Hi Mike,

What valid svnmerge-integrated property value would cause len(pieces) > 2?

> +          pieces = [pieces[:-1].join(':'), pieces[-1]]

And if we do get here, pieces[:-1] is a list object, which has no join
method, so wouldn't this toss an AttributeError?  Am I grossly
misunderstanding something?

Paul

>
> +        if len(pieces) != 2:
> +          continue
> +        pieces[0] = urllib.unquote(pieces[0])
> +        print "PIECES = " + str(pieces)
> +        svnmerge_prop_val = svnmerge_prop_val + '%s\n' % (':'.join(pieces))
> +
> +      # If there is Subversion mergeinfo to merge with, do so.
> +      # Otherwise, our svnmerge info simply becomes our new mergeinfo.
>       if mergeinfo_prop_val:
>         mergeinfo = svn.core.svn_mergeinfo_parse(mergeinfo_prop_val)
> +        for key, val in mergeinfo.items():
> +          print "ORIG_MERGEINFO(%s) = %s" \
> +                % (key, map(lambda x: "(%d, %d)" % (x.start, x.end), val))
>         to_migrate = svn.core.svn_mergeinfo_parse(svnmerge_prop_val)
> -        mergeinfo = svn.core.svn_mergeinfo_merge(mergeinfo, to_migrate)
> -        mergeinfo_prop_val = svn.core.svn_mergeinfo_to_string(mergeinfo)
> +        for key, val in to_migrate.items():
> +          print "MERGED_MERGEINFO(%s) = %s" \
> +                % (key, map(lambda x: "(%d, %d)" % (x.start, x.end), val))
> +        mergeinfo_prop_val = svn.core.svn_mergeinfo_to_string(
> +          svn.core.svn_mergeinfo_merge(mergeinfo, to_migrate))
>       else:
>         mergeinfo_prop_val = svnmerge_prop_val
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: svn-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: svn-help@subversion.tigris.org
>
>

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

Re: svn commit: r29770 - trunk/contrib/client-side/svnmerge

Posted by David Glasser <gl...@davidglasser.net>.
On Mon, Mar 10, 2008 at 11:41 AM, Paul Burba <pt...@gmail.com> wrote:
>  Does any platform besides pre-OSX Mac even support ':' in pathnames?
>  Does linux? (I can't find it explicitly prohibited nor mentioned as
>  valid...maybe the answer is painfully obvious to linux folk, but not
>  to us Win32 losers)

Unix filesystems generally permit any character in filenames except
for '/', '\0', and '\n'.

Subversion's valid-path-name function is more restrictive, though.

--dave

-- 
David Glasser | glasser@davidglasser.net | http://www.davidglasser.net/

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

Re: svn commit: r29770 - trunk/contrib/client-side/svnmerge

Posted by "C. Michael Pilato" <cm...@collab.net>.
Paul Burba wrote:
>> Index: contrib/client-side/svnmerge/svnmerge-migrate-history.py
>> ===================================================================
>> --- contrib/client-side/svnmerge/svnmerge-migrate-history.py    (revision 29819)
>> +++ contrib/client-side/svnmerge/svnmerge-migrate-history.py    (working copy)
>> @@ -200,8 +200,6 @@
>>
>>        svnmerge_prop_val = ''
>>        for source in sources:
>>          pieces = source.split(':')
>> -        if len(pieces) > 2:
>> -          pieces = [pieces[:-1].join(':'), pieces[-1]]
> 
> I'm +1 on this, unless someone can point to a file system with ':' in
> the pathname.

r29835.

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand


Re: svn commit: r29770 - trunk/contrib/client-side/svnmerge

Posted by Paul Burba <pt...@gmail.com>.
On Mon, Mar 10, 2008 at 10:49 AM, C. Michael Pilato <cm...@collab.net> wrote:
>
>
>
> Paul Burba wrote:
> > On Fri, Mar 7, 2008 at 1:18 PM, <cm...@tigris.org> wrote:
> >
> >> Author: cmpilato
> >> Date: Fri Mar  7 10:18:08 2008
> >> New Revision: 29770
> >>
> >> Log:
> >> Teach svnmerge-migrate-history.py to handle the differences between
> >> the svnmerge tracking info format and the format used by Subversion
> >> for its own merge tracking info.
> >>
> >> * contrib/client-side/svnmerge/svnmerge-migrate-history.py
> >>  (Migrator.add_to_mergeinfo): Convert svnmerge property values into
> >>    Subversion mergeinfo format before slamming them through APIs that
> >>    expect the latter.
> >>
> >> Modified:
> >>   trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py
> >>
> >> Modified: trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py
> >> URL: http://svn.collab.net/viewvc/svn/trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py?pathrev=29770&r1=29769&r2=29770
> >> ==============================================================================
> >> --- trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py      (original)
> >> +++ trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py      Fri Mar  7 10:18:08 2008
> >> @@ -21,6 +21,7 @@
> >>  import os
> >>  import sre
> >>  import getopt
> >> +import urllib
> >>  try:
> >>   my_getopt = getopt.gnu_getopt
> >>  except AttributeError:
> >> @@ -191,11 +192,35 @@
> >>
> >>   def add_to_mergeinfo(self, svnmerge_prop_val, mergeinfo_prop_val):
> >>     if svnmerge_prop_val is not None:
> >> +      # Convert svnmerge-* property value (which uses any whitespace
> >> +      # for delimiting sources and stores source paths URI-encoded)
> >> +      # into a svn:mergeinfo syntax (which is newline-separated with
> >> +      # URI-decoded paths).
> >> +      sources = svnmerge_prop_val.split()
> >> +      svnmerge_prop_val = ''
> >> +      for source in sources:
> >> +        pieces = source.split(':')
> >> +        if len(pieces) > 2:
> >
> > Hi Mike,
> >
> > What valid svnmerge-integrated property value would cause len(pieces) > 2?
>
> Probably none -- I was just coding flexibly.
>
>
> >> +          pieces = [pieces[:-1].join(':'), pieces[-1]]
> >
> > And if we do get here, pieces[:-1] is a list object, which has no join
> > method, so wouldn't this toss an AttributeError?  Am I grossly
> > misunderstanding something?
>
> No, I just keep making the same mistake with string joining.  That should be:
>
>     pieces = [':'.join(pieces[:-1]), pieces[-1]]
>
> But maybe the following is better.  I mean, we probably don't need to
> support paths with colons in them, right?

Does any platform besides pre-OSX Mac even support ':' in pathnames?
Does linux? (I can't find it explicitly prohibited nor mentioned as
valid...maybe the answer is painfully obvious to linux folk, but not
to us Win32 losers)

While svnmerge.py seems to support paths with colons, see
svnmerge.py:dict_from_revlist_prop(), it is not currently considered
syntactically valid by svn_mergeinfo_parse().  So even with your
correction a few lines back the migration script will still blow up,
e.g.:

C:\SVN\src-trunk\Release\subversion\tests\cmdline\svn-test-work\working_copies>svnmerge-migrate-history.py
..\repositories\merge_tests-89 --verbose
Examining path 'A' for conversion
No merge history on 'A'
Examining path 'A/C' for conversion
No merge history on 'A/C'
Examining path 'A/B' for conversion
No merge history on 'A/B'
Examining path 'A/B/F' for conversion
No merge history on 'A/B/F'
Examining path 'A/B/E' for conversion
No merge history on 'A/B/E'
Examining path 'A/D' for conversion
No merge history on 'A/D'
Examining path 'A/D/H' for conversion
No merge history on 'A/D/H'
Examining path 'A/D/G' for conversion
No merge history on 'A/D/G'
Examining path 'A_COPY' for conversion
Discovered pre-existing Subversion mergeinfo of '/A:6'
Discovered svnmerge.py mergeinfo of '/A:B:1-6'
Traceback (most recent call last):
  File "C:\SVN\src-trunk\contrib\client-side\svnmerge\svnmerge-migrate-history.py",
line 266, in ?
    main()
  File "C:\SVN\src-trunk\contrib\client-side\svnmerge\svnmerge-migrate-history.py",
line 263, in main
    migrator.run()
  File "C:\SVN\src-trunk\contrib\client-side\svnmerge\svnmerge-migrate-history.py",
line 100, in run
    prefix[len(prefix) - 1] + ".*")
  File "C:\SVN\src-trunk\contrib\client-side\svnmerge\svnmerge-migrate-history.py",
line 115, in process_dir
    if not self.convert_path_history(root, revnum, child_path):
  File "C:\SVN\src-trunk\contrib\client-side\svnmerge\svnmerge-migrate-history.py",
line 146, in convert_path_history
    mergeinfo_prop_val)
  File "C:\SVN\src-trunk\contrib\client-side\svnmerge\svnmerge-migrate-history.py",
line 215, in add_to_mergeinfo
    to_migrate = svn.core.svn_mergeinfo_parse(svnmerge_prop_val)
  File "C:\Python24\lib\site-packages\libsvn\core.py", line 4066, in
svn_mergeinfo_parse
    return apply(_core.svn_mergeinfo_parse, args)
svn.core.SubversionException: ("Could not parse mergeinfo string
'B:1-6\n'", 200020)


> Index: contrib/client-side/svnmerge/svnmerge-migrate-history.py
> ===================================================================
> --- contrib/client-side/svnmerge/svnmerge-migrate-history.py    (revision 29819)
> +++ contrib/client-side/svnmerge/svnmerge-migrate-history.py    (working copy)
> @@ -200,8 +200,6 @@
>
>        svnmerge_prop_val = ''
>        for source in sources:
>          pieces = source.split(':')
> -        if len(pieces) > 2:
> -          pieces = [pieces[:-1].join(':'), pieces[-1]]

I'm +1 on this, unless someone can point to a file system with ':' in
the pathname.

Paul

>          if len(pieces) != 2:
>            continue
>          pieces[0] = urllib.unquote(pieces[0])
>
>
> --
> C. Michael Pilato <cm...@collab.net>
> CollabNet   <>   www.collab.net   <>   Distributed Development On Demand
>
>

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

Re: svn commit: r29770 - trunk/contrib/client-side/svnmerge

Posted by "C. Michael Pilato" <cm...@collab.net>.
Paul Burba wrote:
> On Fri, Mar 7, 2008 at 1:18 PM, <cm...@tigris.org> wrote:
> 
>> Author: cmpilato
>> Date: Fri Mar  7 10:18:08 2008
>> New Revision: 29770
>>
>> Log:
>> Teach svnmerge-migrate-history.py to handle the differences between
>> the svnmerge tracking info format and the format used by Subversion
>> for its own merge tracking info.
>>
>> * contrib/client-side/svnmerge/svnmerge-migrate-history.py
>>  (Migrator.add_to_mergeinfo): Convert svnmerge property values into
>>    Subversion mergeinfo format before slamming them through APIs that
>>    expect the latter.
>>
>> Modified:
>>   trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py
>>
>> Modified: trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py
>> URL: http://svn.collab.net/viewvc/svn/trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py?pathrev=29770&r1=29769&r2=29770
>> ==============================================================================
>> --- trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py      (original)
>> +++ trunk/contrib/client-side/svnmerge/svnmerge-migrate-history.py      Fri Mar  7 10:18:08 2008
>> @@ -21,6 +21,7 @@
>>  import os
>>  import sre
>>  import getopt
>> +import urllib
>>  try:
>>   my_getopt = getopt.gnu_getopt
>>  except AttributeError:
>> @@ -191,11 +192,35 @@
>>
>>   def add_to_mergeinfo(self, svnmerge_prop_val, mergeinfo_prop_val):
>>     if svnmerge_prop_val is not None:
>> +      # Convert svnmerge-* property value (which uses any whitespace
>> +      # for delimiting sources and stores source paths URI-encoded)
>> +      # into a svn:mergeinfo syntax (which is newline-separated with
>> +      # URI-decoded paths).
>> +      sources = svnmerge_prop_val.split()
>> +      svnmerge_prop_val = ''
>> +      for source in sources:
>> +        pieces = source.split(':')
>> +        if len(pieces) > 2:
> 
> Hi Mike,
> 
> What valid svnmerge-integrated property value would cause len(pieces) > 2?

Probably none -- I was just coding flexibly.

>> +          pieces = [pieces[:-1].join(':'), pieces[-1]]
> 
> And if we do get here, pieces[:-1] is a list object, which has no join
> method, so wouldn't this toss an AttributeError?  Am I grossly
> misunderstanding something?

No, I just keep making the same mistake with string joining.  That should be:

     pieces = [':'.join(pieces[:-1]), pieces[-1]]

But maybe the following is better.  I mean, we probably don't need to 
support paths with colons in them, right?

Index: contrib/client-side/svnmerge/svnmerge-migrate-history.py
===================================================================
--- contrib/client-side/svnmerge/svnmerge-migrate-history.py	(revision 29819)
+++ contrib/client-side/svnmerge/svnmerge-migrate-history.py	(working copy)
@@ -200,8 +200,6 @@
        svnmerge_prop_val = ''
        for source in sources:
          pieces = source.split(':')
-        if len(pieces) > 2:
-          pieces = [pieces[:-1].join(':'), pieces[-1]]
          if len(pieces) != 2:
            continue
          pieces[0] = urllib.unquote(pieces[0])


-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand