Slashes in branch names are usable, but referencing a non-existent branch causes a "syntax error"

Matt Mackall mpm at selenic.com
Fri Jan 20 12:55:07 CST 2012


On Sat, 2012-01-14 at 14:35 -0500, Ryan Kelly wrote:
> NOTE: I originally posted this to mercurial at selenic.com but I don't think that
> is the correct place. Let me know if I'm wrong, though.

Looks like this fell through the cracks. I've queued a version of this
that allows slash in symbols after the first character, thanks.

> It seems that it is perfectly fine to create and use a branch with a '/'
> in it:
> 
> $ hg branch my/branch
> $ hg commit -m "a slash"
> $ hg update default
> $ hg update my/branch
> 
> But, if the branch does not exist, you will receive the following error:
> 
> $ hg update bogus/branch
> hg: parse error at 4: syntax error
> 
> Which is confusing. The code in revset.py is where the error originates
> and adding '/' to the list of "allowed" characters seems to make
> mercurial exhibit more sensible behavior:
> 
> $ hg update bogus/branch
> abort: unknown revision 'bogus/branch'
> 
> The attached (trivial) patch corrects this behavior.
> 
> -Ryan Kelly
> 
> 
> diff -r c47d69ce5208 mercurial/revset.py
> --- a/mercurial/revset.py	Wed Jan 11 09:27:53 2012 -0600
> +++ b/mercurial/revset.py	Thu Jan 12 23:20:12 2012 -0500
> @@ -74,12 +74,12 @@
>                  pos += 1
>              else:
>                  raise error.ParseError(_("unterminated string"), s)
> -        elif c.isalnum() or c in '._' or ord(c) > 127: # gather up a symbol/keyword
> +        elif c.isalnum() or c in '._/' or ord(c) > 127: # gather up a symbol/keyword
>              s = pos
>              pos += 1
>              while pos < l: # find end of symbol
>                  d = program[pos]
> -                if not (d.isalnum() or d in "._" or ord(d) > 127):
> +                if not (d.isalnum() or d in "._/" or ord(d) > 127):
>                      break
>                  if d == '.' and program[pos - 1] == '.': # special case for ..
>                      pos -= 1
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list