##// END OF EJS Templates
packaging: stage files and dynamically generate WiX installer...
packaging: stage files and dynamically generate WiX installer Like we did for Inno, we want to make the WiX installer "dumb" and simply consume source files from a directory tree rather than have to define every single file in installer files. This will greatly decrease the amount of effort required to maintain the WiX installer since we don't have to think that much about keeping files in sync. This commit changes the WiX packager to populate a staging directory as part of packaging. After it does so, it scans that directory and dynamically generates WiX XML defining the content within. The IDs and GUIDs being generated are deterministic. So, upgrades should work as expected in Windows Installer land. (WiX has a "heat" tool that can generate XML by walking the filesystem but it doesn't have this deterministic property, sadly.) As part of this change, GUIDs are now effectively reset. So the next upgrade should be a complete wipe and replace. This could potentially cause issues. But in my local testing, I was able to upgrade an existing 5.1.2 install without issue. Compared to the previous commit, the installed files differ in the following: * A ReleaseNotes.txt file is now included * A hgrc.d/editor.rc file is now generated (mercurial.rc has been updated to reflect this logical change to the content source) * All files are marked as read-only. Previously, only a subset of files were. This should help prevent unwanted tampering. Although we may want to consider use cases like modifying template files... This change also means that Inno and WiX are now using very similar code for managing the install layout. This means that on disk both packages are nearly identical. The differences in install layout are as follows: * Inno has a Copying.txt vs a COPYING.rtf for WiX. (The WiX installer wants to use RTF.) * Inno has a Mercurial.url file that is an internet shortcut to www.mercurial-scm.org. (This could potentially be removed.) * Inno includes msvc[mpr]90.dll files and WiX does not. (WiX installs the MSVC runtime via merge modules.) * Inno includes unins000.{dat,exe} files. (WiX's state is managed by Windows Installer, which places things elsewhere.) Because file lists are dynamically generated now, the test ensuring things remain in sync has been deleted. Good riddance. While this is a huge step towards unifying the Windows installers, there's still some improvements that can be made. But I think it is worth celebrating the milestone of getting both Inno and WiX to essentially share core packaging code and workflows. That should make it much easier to change the installers going forward. This will aid support of Python 3. Differential Revision: https://phab.mercurial-scm.org/D7173

File last commit:

r43812:2fe6121c default
r44022:94eac340 default
Show More
hgclient.py
163 lines | 4.0 KiB | text/x-python | PythonLexer
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 # A minimal client for Mercurial's command server
Pulkit Goyal
hgclient: use absolute_import and print_function
r28355 from __future__ import absolute_import, print_function
Yuya Nishihara
py3: rewrite StringIO fallback for Python 3
r40353
import io
Pulkit Goyal
hgclient: use absolute_import and print_function
r28355 import os
Yuya Nishihara
py3: reinvent print() function for contrib/hgclient.py
r40352 import re
Pulkit Goyal
hgclient: use absolute_import and print_function
r28355 import signal
import socket
import struct
import subprocess
import sys
import time
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566
Yuya Nishihara
py3: work around unicode stdio streams in contrib/hgclient.py
r40351 if sys.version_info[0] >= 3:
stdout = sys.stdout.buffer
stderr = sys.stderr.buffer
Yuya Nishihara
py3: rewrite StringIO fallback for Python 3
r40353 stringio = io.BytesIO
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
py3: reinvent print() function for contrib/hgclient.py
r40352 def bprint(*args):
# remove b'' as well for ease of test migration
pargs = [re.sub(br'''\bb(['"])''', br'\1', b'%s' % a) for a in args]
stdout.write(b' '.join(pargs) + b'\n')
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
py3: work around unicode stdio streams in contrib/hgclient.py
r40351 else:
Yuya Nishihara
py3: rewrite StringIO fallback for Python 3
r40353 import cStringIO
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
py3: work around unicode stdio streams in contrib/hgclient.py
r40351 stdout = sys.stdout
stderr = sys.stderr
Yuya Nishihara
py3: rewrite StringIO fallback for Python 3
r40353 stringio = cStringIO.StringIO
Yuya Nishihara
py3: reinvent print() function for contrib/hgclient.py
r40352 bprint = print
Yuya Nishihara
py3: work around unicode stdio streams in contrib/hgclient.py
r40351
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
commandserver: add experimental option to use separate message channel...
r40625 def connectpipe(path=None, extraargs=()):
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 cmdline = [b'hg', b'serve', b'--cmdserver', b'pipe']
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 if path:
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 cmdline += [b'-R', path]
Yuya Nishihara
commandserver: add experimental option to use separate message channel...
r40625 cmdline.extend(extraargs)
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566
Matt Harbison
py3: convert popen() command arguments in hgclient to str on Windows...
r41020 def tonative(cmdline):
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 if os.name != 'nt':
Matt Harbison
py3: convert popen() command arguments in hgclient to str on Windows...
r41020 return cmdline
return [arg.decode("utf-8") for arg in cmdline]
Augie Fackler
formatting: blacken the codebase...
r43346 server = subprocess.Popen(
tonative(cmdline), stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566
return server
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
test-commandserver: add connector for unix domain socket server...
r22993 class unixconnection(object):
def __init__(self, sockpath):
self.sock = sock = socket.socket(socket.AF_UNIX)
sock.connect(sockpath)
self.stdin = sock.makefile('wb')
self.stdout = sock.makefile('rb')
def wait(self):
self.stdin.close()
self.stdout.close()
self.sock.close()
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
test-commandserver: add connector for unix domain socket server...
r22993 class unixserver(object):
def __init__(self, sockpath, logpath=None, repopath=None):
self.sockpath = sockpath
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 cmdline = [b'hg', b'serve', b'--cmdserver', b'unix', b'-a', sockpath]
Yuya Nishihara
test-commandserver: add connector for unix domain socket server...
r22993 if repopath:
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 cmdline += [b'-R', repopath]
Yuya Nishihara
test-commandserver: add connector for unix domain socket server...
r22993 if logpath:
stdout = open(logpath, 'a')
stderr = subprocess.STDOUT
else:
stdout = stderr = None
self.server = subprocess.Popen(cmdline, stdout=stdout, stderr=stderr)
# wait for listen()
while self.server.poll() is None:
if os.path.exists(sockpath):
break
time.sleep(0.1)
def connect(self):
return unixconnection(self.sockpath)
def shutdown(self):
os.kill(self.server.pid, signal.SIGTERM)
self.server.wait()
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 def writeblock(server, data):
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 server.stdin.write(struct.pack(b'>I', len(data)))
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 server.stdin.write(data)
server.stdin.flush()
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 def readchannel(server):
data = server.stdout.read(5)
if not data:
raise EOFError
channel, length = struct.unpack('>cI', data)
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 if channel in b'IL':
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 return channel, length
else:
return channel, server.stdout.read(length)
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 def sep(text):
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 return text.replace(b'\\', b'/')
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566
Augie Fackler
formatting: blacken the codebase...
r43346
def runcommand(
server, args, output=stdout, error=stderr, input=None, outfilter=lambda x: x
):
Yuya Nishihara
py3: reinvent print() function for contrib/hgclient.py
r40352 bprint(b'*** runcommand', b' '.join(args))
Yuya Nishihara
py3: work around unicode stdio streams in contrib/hgclient.py
r40351 stdout.flush()
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 server.stdin.write(b'runcommand\n')
writeblock(server, b'\0'.join(args))
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566
if not input:
timeless
test-commandserver: handle cStringIO.StringIO/io.StringIO divergence
r28836 input = stringio()
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566
while True:
ch, data = readchannel(server)
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 if ch == b'o':
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 output.write(outfilter(data))
output.flush()
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 elif ch == b'e':
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 error.write(data)
error.flush()
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 elif ch == b'I':
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 writeblock(server, input.read(data))
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 elif ch == b'L':
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 writeblock(server, input.readline(data))
Yuya Nishihara
commandserver: add experimental option to use separate message channel...
r40625 elif ch == b'm':
bprint(b"message: %r" % data)
Yuya Nishihara
py3: convert string literals to bytes in contrib/hgclient.py...
r40350 elif ch == b'r':
Augie Fackler
formatting: blacken the codebase...
r43346 (ret,) = struct.unpack('>i', data)
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 if ret != 0:
Yuya Nishihara
py3: reinvent print() function for contrib/hgclient.py
r40352 bprint(b' [%d]' % ret)
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 return ret
else:
Yuya Nishihara
py3: reinvent print() function for contrib/hgclient.py
r40352 bprint(b"unexpected channel %c: %r" % (ch, data))
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 if ch.isupper():
return
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
test-commandserver: allow check() to make connection in different way...
r22992 def check(func, connect=connectpipe):
Yuya Nishihara
py3: work around unicode stdio streams in contrib/hgclient.py
r40351 stdout.flush()
Yuya Nishihara
test-commandserver: remove unused repopath argument from check()...
r22991 server = connect()
Yuya Nishihara
test-commandserver: split helper functions to new hgclient module...
r22566 try:
return func(server)
finally:
server.stdin.close()
server.wait()
Yuya Nishihara
commandserver: add experimental option to use separate message channel...
r40625
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
commandserver: add experimental option to use separate message channel...
r40625 def checkwith(connect=connectpipe, **kwargs):
def wrap(func):
return check(func, lambda: connect(**kwargs))
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
commandserver: add experimental option to use separate message channel...
r40625 return wrap