[PATCH V2] convert: parse quoted keys and values in mapfiles (BC)

Yuya Nishihara yuya at tcha.org
Mon Sep 25 09:23:27 EDT 2017


On Sun, 24 Sep 2017 18:44:57 +0200, Ingmar Blonk wrote:
> # HG changeset patch
> # User Ingmar Blonk <ingmar.blonk at gmail.com>
> # Date 1506267061 -7200
> #      Sun Sep 24 17:31:01 2017 +0200
> # Node ID 9d95751ccea50ed91a457315762c18f3a9cf69f4
> # Parent  575097b4dce054a5b8d992fe15797d9d62ceaf71
> convert: parse quoted keys and values in mapfiles (BC)
> 
> Parsing quoted texts in mapfiles allows whitespace usage for e.g. branch 
> names
> in a banchmap.

This patch appears to be whitespace damaged. Can you use the patchbomb?

https://www.mercurial-scm.org/wiki/ContributingChanges#Emailing_patches

> diff -r 575097b4dce0 -r 9d95751ccea5 hgext/convert/common.py
> --- a/hgext/convert/common.py    Thu Sep 14 13:14:32 2017 -0700
> +++ b/hgext/convert/common.py    Sun Sep 24 17:31:01 2017 +0200
> @@ -10,7 +10,9 @@
>   import datetime
>   import errno
>   import os
> +import pipes
>   import re
> +import shlex
>   import subprocess
> 
>   from mercurial.i18n import _
> @@ -461,7 +463,7 @@
>                   # Ignore blank lines
>                   continue
>               try:
> -                key, value = line.rsplit(' ', 1)
> +                key, value = shlex.split(line, posix=True)

Even if we can't catch all possibilities of BC breakages, I think it's better
to save common scenario.

> @@ -479,7 +481,7 @@
>                   raise error.Abort(
>                       _('could not open map file %r: %s') %
>                       (self.path, encoding.strtolocal(err.strerror)))
> -        self.fp.write('%s %s\n' % (key, value))
> +        self.fp.write('%s %s\n' % (pipes.quote(key), pipes.quote(value)))
>           self.fp.flush()
>           super(mapfile, self).__setitem__(key, value)

I meant the parsing of branchmap should be a separate function. The mapfile
class has write functionality because it's also used as an internal storage.
rsplit() was introduced at af1117f37fa7, and digging it further, it was
necessary to fix the issue 1224. So changing the syntax of mapfile will
probably break existing repositories.

https://bz.mercurial-scm.org/show_bug.cgi?id=1224


More information about the Mercurial-devel mailing list