You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by kf...@collab.net on 2004/12/17 21:27:18 UTC
Re: svn commit: r12356 - in trunk: build/generator subversion/bindings/swig/python/svn
maxb@tigris.org writes:
> Modified:
> trunk/build/generator/gen_win.py
> trunk/subversion/bindings/swig/python/svn/core.py
> Log:
> Unify the handling of shell argument quoting in Python code throughout
> Subversion and cvs2svn.
>
> [Subversion]
> * subversion/bindings/swig/python/svn/core.py: Here.
> * build/generator/gen_win.py: And here.
>
> [cvs2svn]
> * cvs2svn: And also here.
Hrmh. I'm not sure records of sync-changes to slave copies belong in
the master's repository...
-K
> Modified: trunk/build/generator/gen_win.py
> Url: http://svn.collab.net/viewcvs/svn/trunk/build/generator/gen_win.py?view=diff&rev=12356&p1=trunk/build/generator/gen_win.py&r1=12355&p2=trunk/build/generator/gen_win.py&r2=12356
> ==============================================================================
> --- trunk/build/generator/gen_win.py (original)
> +++ trunk/build/generator/gen_win.py Fri Dec 17 13:54:46 2004
> @@ -866,12 +866,56 @@
> def __init__(self, **kw):
> vars(self).update(kw)
>
> +# ============================================================================
> +# Reusable code segment. This code is duplicated in the several locations.
> +# This is NOT the master copy.
> +# The master copy is: subversion/subversion/bindings/swig/python/svn/core.py
> +#
> +# Please keep all copies in sync.
> +#
> if sys.platform == "win32":
> - def escape_shell_arg(str):
> - return '"' + string.replace(str, '"', '"^""') + '"'
> + _escape_shell_arg_re = re.compile(r'(\\+)(\"|$)')
> +
> + def escape_shell_arg(arg):
> + # The (very strange) parsing rules used by the C runtime library are
> + # described at:
> + # http://msdn.microsoft.com/library/en-us/vclang/html/_pluslang_Parsing_C.2b2b_.Command.2d.Line_Arguments.asp
> +
> + # double up slashes, but only if they are followed by a quote character
> + arg = re.sub(_escape_shell_arg_re, r'\1\1\2', arg)
> +
> + # surround by quotes and escape quotes inside
> + arg = '"' + string.replace(arg, '"', '"^""') + '"'
> + return arg
> +
> +
> + def argv_to_command_string(argv):
> + """Flatten a list of command line arguments into a command string.
> +
> + The resulting command string is expected to be passed to the system
> + shell which os functions like popen() and system() invoke internally.
> + """
> +
> + # According cmd's usage notes (cmd /?), it parses the command line by
> + # "seeing if the first character is a quote character and if so, stripping
> + # the leading character and removing the last quote character."
> + # So to prevent the argument string from being changed we add an extra set
> + # of quotes around it here.
> + return '"' + string.join(map(escape_shell_arg, argv), " ") + '"'
> +
> else:
> def escape_shell_arg(str):
> return "'" + string.replace(str, "'", "'\\''") + "'"
> +
> + def argv_to_command_string(argv):
> + """Flatten a list of command line arguments into a command string.
> +
> + The resulting command string is expected to be passed to the system
> + shell which os functions like popen() and system() invoke internally.
> + """
> +
> + return string.join(map(escape_shell_arg, argv), " ")
> +# ============================================================================
>
> FILTER_LIBS = 1
> FILTER_PROJECTS = 2
>
> Modified: trunk/subversion/bindings/swig/python/svn/core.py
> Url: http://svn.collab.net/viewcvs/svn/trunk/subversion/bindings/swig/python/svn/core.py?view=diff&rev=12356&p1=trunk/subversion/bindings/swig/python/svn/core.py&r1=12355&p2=trunk/subversion/bindings/swig/python/svn/core.py&r2=12356
> ==============================================================================
> --- trunk/subversion/bindings/swig/python/svn/core.py (original)
> +++ trunk/subversion/bindings/swig/python/svn/core.py Fri Dec 17 13:54:46 2004
> @@ -110,33 +110,58 @@
> # ### aprtime is microseconds; turn it into seconds
> return aprtime / 1000000
>
> -def argv_to_command_string(argv):
> - """Flatten a list of command line arguments into a command string.
>
> - The resulting command string is expected to be passed to the system
> - shell which os functions like popen() and system() invoke internally.
> - """
>
> - _re_slashquote = re.compile(r'(\\+)(\"|$)')
> +# ============================================================================
> +# Reusable code segment. This code is duplicated in the several locations.
> +# THIS IS THE MASTER COPY.
> +#
> +# Duplicates are located at:
> +# - subversion/build/generator/gen_win.py
> +# - cvs2svn/cvs2svn
> +#
> +# Please keep all copies in sync, and the list above up-to-date.
> +#
> +if sys.platform == "win32":
> + _escape_shell_arg_re = re.compile(r'(\\+)(\"|$)')
>
> - def _escape_arg(arg):
> + def escape_shell_arg(arg):
> # The (very strange) parsing rules used by the C runtime library are
> # described at:
> # http://msdn.microsoft.com/library/en-us/vclang/html/_pluslang_Parsing_C.2b2b_.Command.2d.Line_Arguments.asp
>
> # double up slashes, but only if they are followed by a quote character
> - arg = re.sub(_re_slashquote, r'\1\1\2', arg)
> + arg = re.sub(_escape_shell_arg_re, r'\1\1\2', arg)
>
> # surround by quotes and escape quotes inside
> arg = '"' + string.replace(arg, '"', '"^""') + '"'
> return arg
>
> - if sys.platform == "win32":
> +
> + def argv_to_command_string(argv):
> + """Flatten a list of command line arguments into a command string.
> +
> + The resulting command string is expected to be passed to the system
> + shell which os functions like popen() and system() invoke internally.
> + """
> +
> # According cmd's usage notes (cmd /?), it parses the command line by
> # "seeing if the first character is a quote character and if so, stripping
> # the leading character and removing the last quote character."
> # So to prevent the argument string from being changed we add an extra set
> # of quotes around it here.
> - return '"' + string.join(map(_escape_arg, argv), " ") + '"'
> - else:
> - return string.join(argv, " ")
> + return '"' + string.join(map(escape_shell_arg, argv), " ") + '"'
> +
> +else:
> + def escape_shell_arg(str):
> + return "'" + string.replace(str, "'", "'\\''") + "'"
> +
> + def argv_to_command_string(argv):
> + """Flatten a list of command line arguments into a command string.
> +
> + The resulting command string is expected to be passed to the system
> + shell which os functions like popen() and system() invoke internally.
> + """
> +
> + return string.join(map(escape_shell_arg, argv), " ")
> +# ============================================================================
>
> ---------------------------------------------------------------------
> 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: r12356 - in trunk: build/generator subversion/bindings/swig/python/svn
Posted by kf...@collab.net.
Erik Huelsmann <eh...@gmail.com> writes:
> Heh, then which is the master and which is the slave? I think Max
> pointed out that copy/paste has been used, but that the direction is
> unclear.
Yeah, in a later message to dev@cvs2svn, I said this instead:
> Since these didn't really happen in the same commit, a better way
> (for the cvs2svn log message) might be to say something like
> this:
>
> * cvs2svn: Tweak shell argument quoting to bring it in sync with
> its duplicates. See r12356 in Subversion's repository.
>
> I guess I'm not sure if we consider one of these to be the master
> (earlier I thought it was the Subversion copy, now I'm not so
> sure), but in any case, if we're going to cross-reference, we
> should do it using specific revnums in the respective
> repositories IMHO.
-Karl
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r12356 - in trunk: build/generator subversion/bindings/swig/python/svn
Posted by Max Bowsher <ma...@ukf.net>.
Erik Huelsmann wrote:
> On 17 Dec 2004 15:27:18 -0600, kfogel@collab.net <kf...@collab.net>
> wrote:
>> maxb@tigris.org writes:
>>> Modified:
>>> trunk/build/generator/gen_win.py
>>> trunk/subversion/bindings/swig/python/svn/core.py
>>> Log:
>>> Unify the handling of shell argument quoting in Python code throughout
>>> Subversion and cvs2svn.
>>>
>>> [Subversion]
>>> * subversion/bindings/swig/python/svn/core.py: Here.
>>> * build/generator/gen_win.py: And here.
>>>
>>> [cvs2svn]
>>> * cvs2svn: And also here.
>>
>> Hrmh. I'm not sure records of sync-changes to slave copies belong in
>> the master's repository...
>>
>
> Heh, then which is the master and which is the slave? I think Max
> pointed out that copy/paste has been used, but that the direction is
> unclear.
See comments in the source. It's clear.
Max.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: r12356 - in trunk: build/generator subversion/bindings/swig/python/svn
Posted by Erik Huelsmann <eh...@gmail.com>.
On 17 Dec 2004 15:27:18 -0600, kfogel@collab.net <kf...@collab.net> wrote:
> maxb@tigris.org writes:
> > Modified:
> > trunk/build/generator/gen_win.py
> > trunk/subversion/bindings/swig/python/svn/core.py
> > Log:
> > Unify the handling of shell argument quoting in Python code throughout
> > Subversion and cvs2svn.
> >
> > [Subversion]
> > * subversion/bindings/swig/python/svn/core.py: Here.
> > * build/generator/gen_win.py: And here.
> >
> > [cvs2svn]
> > * cvs2svn: And also here.
>
> Hrmh. I'm not sure records of sync-changes to slave copies belong in
> the master's repository...
>
Heh, then which is the master and which is the slave? I think Max
pointed out that copy/paste has been used, but that the direction is
unclear.
bye,
Erik.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org