[PATCH] convert: parse quoted keys and values in mapfiles
Ingmar Blonk
ingmar.blonk at gmail.com
Mon Sep 18 20:28:45 UTC 2017
# HG changeset patch
# User Ingmar Blonk <ingmar.blonk at gmail.com>
# Date 1505662991 -7200
#Â Â Â Â Â Sun Sep 17 17:43:11 2017 +0200
# Node ID af658bed1729dd0e48a60c67a82f4bc44f578c97
# Parent 448725a2ef7356524bcc9638a5c5eaaf59f263af
convert: parse quoted keys and values in mapfiles
Parsing quoted texts in mapfiles allows whitespace usage for e.g. branch
names
in a banchmap.
diff -r 448725a2ef73 -r af658bed1729 hgext/convert/__init__.py
--- a/hgext/convert/__init__.py   Fri Sep 15 00:01:57 2017 -0700
+++ b/hgext/convert/__init__.py   Sun Sep 17 17:43:11 2017 +0200
@@ -263,8 +263,8 @@
    where "original_branch_name" is the name of the branch in the
    source repository, and "new_branch_name" is the name of the branch
-Â Â Â is the destination repository. No whitespace is allowed in the new
-Â Â Â branch name. This can be used to (for instance) move code in one
+Â Â Â is the destination repository. Branch names containing whitespace
+Â Â Â should be quoted. This can be used to (for instance) move code in one
    repository from "default" to a named branch.
    Mercurial Source
diff -r 448725a2ef73 -r af658bed1729 hgext/convert/common.py
--- a/hgext/convert/common.py   Fri Sep 15 00:01:57 2017 -0700
+++ b/hgext/convert/common.py   Sun Sep 17 17:43:11 2017 +0200
@@ -11,6 +11,7 @@
 import errno
 import os
 import re
+import shlex
 import subprocess
 from mercurial.i18n import _
@@ -461,7 +462,7 @@
                # Ignore blank lines
                continue
            try:
-Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â key, value = line.rsplit(' ', 1)
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â key, value = shlex.split(line, posix=True)
            except ValueError:
                raise error.Abort(
                    _('syntax error in %s(%d): key/value pair expected')
diff -r 448725a2ef73 -r af658bed1729 tests/test-convert.t
--- a/tests/test-convert.t   Fri Sep 15 00:01:57 2017 -0700
+++ b/tests/test-convert.t   Sun Sep 17 17:43:11 2017 +0200
@@ -125,9 +125,9 @@
      where "original_branch_name" is the name of the branch in the source
      repository, and "new_branch_name" is the name of the branch is the
-Â Â Â Â Â destination repository. No whitespace is allowed in the new
branch name.
-Â Â Â Â Â This can be used to (for instance) move code in one repository from
-Â Â Â Â Â "default" to a named branch.
+Â Â Â Â Â destination repository. Branch names containing whitespace should be
+Â Â Â Â Â quoted. This can be used to (for instance) move code in one
repository
+Â Â Â Â Â from "default" to a named branch.
      Mercurial Source
      ################
@@ -589,7 +589,7 @@
  convert_source=mysource
  $ cat > branchmap.txt << EOF
-Â > old branch new_branch
+Â > "old branch" new_branch
  > EOF
  $ hg -R a branch -q 'old branch'
More information about the Mercurial-devel
mailing list