Patchwork D9147: packaging: normalize - to _ in WiX Id values

login
register
mail settings
Submitter phabricator
Date Oct. 5, 2020, 5:39 a.m.
Message ID <differential-rev-PHID-DREV-fsky3qyr4iz3uhz2xysm-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47376/
State Superseded
Headers show

Comments

phabricator - Oct. 5, 2020, 5:39 a.m.
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  - is not a valid identifier character in WiX Ids. So let's
  
  normalize accordingly.
  
  I discovered this issue after a subsequent change which introduces
  a directory with a - in its name.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9147

AFFECTED FILES
  contrib/packaging/hgpackaging/wix.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/contrib/packaging/hgpackaging/wix.py b/contrib/packaging/hgpackaging/wix.py
--- a/contrib/packaging/hgpackaging/wix.py
+++ b/contrib/packaging/hgpackaging/wix.py
@@ -165,7 +165,9 @@ 
         if dir_name == '.':
             parent_directory_id = 'INSTALLDIR'
         else:
-            parent_directory_id = 'hg.dir.%s' % dir_name.replace('/', '.')
+            parent_directory_id = 'hg.dir.%s' % dir_name.replace(
+                '/', '.'
+            ).replace('-', '_')
 
         fragment = doc.createElement('Fragment')
         directory_ref = doc.createElement('DirectoryRef')
@@ -178,7 +180,9 @@ 
                 and '/' not in possible_child
                 and possible_child != '.'
             ):
-                child_directory_id = 'hg.dir.%s' % possible_child
+                child_directory_id = ('hg.dir.%s' % possible_child).replace(
+                    '-', '_'
+                )
                 name = possible_child
             else:
                 if not possible_child.startswith('%s/' % dir_name):
@@ -189,7 +193,7 @@ 
 
                 child_directory_id = 'hg.dir.%s' % possible_child.replace(
                     '/', '.'
-                )
+                ).replace('-', '_')
 
             directory = doc.createElement('Directory')
             directory.setAttribute('Id', child_directory_id)