[Svnmerge] [PATCH] Prompt for source branch when multiple sourcesexist

Giovanni Bajo rasky at develer.com
Tue Mar 28 02:25:26 PST 2006


Jim Lawton <jim.lawton at gmail.com> wrote:

>> Go for it. I think this would be a handy option.
>
> OK, I've modified the patch so that it adds a -i/--interactive command
> option and
> only prompts for input if this is set (default is not set). If
> non-interactive it bails with
> exactly the same message as before.

Thanks!

I see by code inspection that there is a bug: if the user types a letter,
the int() call will raise a ValueError. You can use input.isdigit() to check
if the input string is made of digits only (but that would reject strings
like "1   ": not sure if we should care). Otherwise, just catch the
exception:

input = raw_input(...)
if not input:
     input = 0
     break

try:
     input = int(input)
     if not 0 <= input < len(props):
        raise ValueError
except ValueError:
     print "please enter..."
else:
     break


Can you please test the above code?

>> +                if input is "":

Don't use "is" with strings: it's implementation-defined.
-- 
Giovanni Bajo




More information about the Svnmerge mailing list