We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
rio-merge ignores --driver
Due to a [typo](https://github.com/mapbox/rasterio/blob/master/rasterio/rio/merge.py#L90):

``` python
kwargs['driver'] == driver
```

Instead of:

``` python
kwargs['driver']  = driver
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rasterio/rio/merge.py`
Content:
```
1 # Merge command.
2 
3 
4 import logging
5 import math
6 import os.path
7 import warnings
8 
9 import click
10 from cligj import files_inout_arg, format_opt
11 
12 from .helpers import resolve_inout
13 from . import options
14 import rasterio
15 from rasterio.transform import Affine
16 
17 
18 @click.command(short_help="Merge a stack of raster datasets.")
19 @files_inout_arg
20 @options.output_opt
21 @format_opt
22 @options.bounds_opt
23 @click.option('-r', '--res', nargs=2, type=float, default=None,
24               help="Output dataset resolution: pixel width, pixel height")
25 @click.option('--nodata', type=float, default=None,
26               help="Override nodata values defined in input datasets")
27 @click.pass_context
28 def merge(ctx, files, output, driver, bounds, res, nodata):
29     """Copy valid pixels from input files to an output file.
30 
31     All files must have the same number of bands, data type, and
32     coordinate reference system.
33 
34     Input files are merged in their listed order using the reverse
35     painter's algorithm. If the output file exists, its values will be
36     overwritten by input values.
37 
38     Geospatial bounds and resolution of a new output file in the
39     units of the input file coordinate reference system may be provided
40     and are otherwise taken from the first input file.
41     """
42     import numpy as np
43 
44     verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1
45     logger = logging.getLogger('rio')
46 
47     try:
48         with rasterio.drivers(CPL_DEBUG=verbosity>2):
49             output, files = resolve_inout(files=files, output=output)
50 
51             with rasterio.open(files[0]) as first:
52                 first_res = first.res
53                 kwargs = first.meta
54                 kwargs.pop('affine')
55                 nodataval = first.nodatavals[0]
56                 dtype = first.dtypes[0]
57 
58             if os.path.exists(output):
59                 # TODO: prompt user to update existing file (-i option) like:
60                 # overwrite b.tif? (y/n [n]) n
61                 # not overwritten
62                 dst = rasterio.open(output, 'r+')
63                 nodataval = dst.nodatavals[0]
64                 dtype = dst.dtypes[0]
65                 dest = np.zeros((dst.count,) + dst.shape, dtype=dtype)
66             else:
67                 # Create new output file.
68                 # Extent from option or extent of all inputs.
69                 if not bounds:
70                     # scan input files.
71                     xs = []
72                     ys = []
73                     for f in files:
74                         with rasterio.open(f) as src:
75                             left, bottom, right, top = src.bounds
76                             xs.extend([left, right])
77                             ys.extend([bottom, top])
78                     bounds = min(xs), min(ys), max(xs), max(ys)
79                 output_transform = Affine.translation(bounds[0], bounds[3])
80 
81                 # Resolution/pixel size.
82                 if not res:
83                     res = first_res
84                 output_transform *= Affine.scale(res[0], -res[1])
85 
86                 # Dataset shape.
87                 output_width = int(math.ceil((bounds[2]-bounds[0])/res[0]))
88                 output_height = int(math.ceil((bounds[3]-bounds[1])/res[1]))
89 
90                 kwargs['driver'] == driver
91                 kwargs['transform'] = output_transform
92                 kwargs['width'] = output_width
93                 kwargs['height'] = output_height
94 
95                 logger.debug("Kwargs: %r", kwargs)
96                 logger.debug("bounds: %r", bounds)
97                 logger.debug("Res: %r", res)
98 
99                 dst = rasterio.open(output, 'w', **kwargs)
100                 dest = np.zeros((first.count, output_height, output_width),
101                         dtype=dtype)
102 
103                 logger.debug("In merge, dest shape: %r", dest.shape)
104 
105             if nodata is not None:
106                 nodataval = nodata
107 
108             if nodataval is not None:
109                 # Only fill if the nodataval is within dtype's range.
110                 inrange = False
111                 if np.dtype(dtype).kind in ('i', 'u'):
112                     info = np.iinfo(dtype)
113                     inrange = (info.min <= nodataval <= info.max)
114                 elif np.dtype(dtype).kind == 'f':
115                     info = np.finfo(dtype)
116                     inrange = (info.min <= nodataval <= info.max)
117                 if inrange:
118                     dest.fill(nodataval)
119                 else:
120                     warnings.warn(
121                         "Input file's nodata value, %s, is beyond the valid "
122                         "range of its data type, %s. Consider overriding it "
123                         "using the --nodata option for better results." % (
124                             nodataval, dtype))
125             else:
126                 nodataval = 0
127 
128             dst_w, dst_s, dst_e, dst_n = dst.bounds
129 
130             for fname in reversed(files):
131                 with rasterio.open(fname) as src:
132                     # Real World (tm) use of boundless reads.
133                     # This approach uses the maximum amount of memory to solve
134                     # the problem. Making it more efficient is a TODO.
135 
136                     # 1. Compute spatial intersection of destination
137                     #    and source.
138                     src_w, src_s, src_e, src_n = src.bounds
139 
140                     int_w = src_w if src_w > dst_w else dst_w
141                     int_s = src_s if src_s > dst_s else dst_s
142                     int_e = src_e if src_e < dst_e else dst_e
143                     int_n = src_n if src_n < dst_n else dst_n
144 
145                     # 2. Compute the source window.
146                     src_window = src.window(int_w, int_s, int_e, int_n)
147 
148                     # 3. Compute the destination window.
149                     dst_window = dst.window(int_w, int_s, int_e, int_n)
150 
151                     # 4. Initialize temp array.
152                     temp = np.zeros(
153                             (first.count,) + tuple(b - a for a, b in dst_window),
154                             dtype=dtype)
155 
156                     temp = src.read(
157                             out=temp,
158                             window=src_window,
159                             boundless=False,
160                             masked=True)
161 
162                     # 5. Copy elements of temp into dest.
163                     roff, coff = dst.index(int_w, int_n)
164                     h, w = temp.shape[-2:]
165 
166                     region = dest[:,roff:roff+h,coff:coff+w]
167                     np.copyto(region, temp,
168                         where=np.logical_and(
169                         region==nodataval, temp.mask==False))
170 
171             if dst.mode == 'r+':
172                 temp = dst.read(masked=True)
173                 np.copyto(dest, temp,
174                     where=np.logical_and(
175                     dest==nodataval, temp.mask==False))
176 
177             dst.write(dest)
178             dst.close()
179 
180     except Exception:
181         logger.exception("Exception caught during processing")
182         raise click.Abort()
183
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/rasterio/rio/merge.py b/rasterio/rio/merge.py
--- a/rasterio/rio/merge.py
+++ b/rasterio/rio/merge.py
@@ -87,7 +87,7 @@
                 output_width = int(math.ceil((bounds[2]-bounds[0])/res[0]))
                 output_height = int(math.ceil((bounds[3]-bounds[1])/res[1]))
 
-                kwargs['driver'] == driver
+                kwargs['driver'] = driver
                 kwargs['transform'] = output_transform
                 kwargs['width'] = output_width
                 kwargs['height'] = output_height

{"golden_diff": "diff --git a/rasterio/rio/merge.py b/rasterio/rio/merge.py\n--- a/rasterio/rio/merge.py\n+++ b/rasterio/rio/merge.py\n@@ -87,7 +87,7 @@\n                 output_width = int(math.ceil((bounds[2]-bounds[0])/res[0]))\n                 output_height = int(math.ceil((bounds[3]-bounds[1])/res[1]))\n \n-                kwargs['driver'] == driver\n+                kwargs['driver'] = driver\n                 kwargs['transform'] = output_transform\n                 kwargs['width'] = output_width\n                 kwargs['height'] = output_height\n", "issue": "rio-merge ignores --driver\nDue to a [typo](https://github.com/mapbox/rasterio/blob/master/rasterio/rio/merge.py#L90):\n\n``` python\nkwargs['driver'] == driver\n```\n\nInstead of:\n\n``` python\nkwargs['driver']  = driver\n```\n\n", "before_files": [{"content": "# Merge command.\n\n\nimport logging\nimport math\nimport os.path\nimport warnings\n\nimport click\nfrom cligj import files_inout_arg, format_opt\n\nfrom .helpers import resolve_inout\nfrom . import options\nimport rasterio\nfrom rasterio.transform import Affine\n\n\n@click.command(short_help=\"Merge a stack of raster datasets.\")\n@files_inout_arg\n@options.output_opt\n@format_opt\n@options.bounds_opt\n@click.option('-r', '--res', nargs=2, type=float, default=None,\n              help=\"Output dataset resolution: pixel width, pixel height\")\n@click.option('--nodata', type=float, default=None,\n              help=\"Override nodata values defined in input datasets\")\n@click.pass_context\ndef merge(ctx, files, output, driver, bounds, res, nodata):\n    \"\"\"Copy valid pixels from input files to an output file.\n\n    All files must have the same number of bands, data type, and\n    coordinate reference system.\n\n    Input files are merged in their listed order using the reverse\n    painter's algorithm. If the output file exists, its values will be\n    overwritten by input values.\n\n    Geospatial bounds and resolution of a new output file in the\n    units of the input file coordinate reference system may be provided\n    and are otherwise taken from the first input file.\n    \"\"\"\n    import numpy as np\n\n    verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1\n    logger = logging.getLogger('rio')\n\n    try:\n        with rasterio.drivers(CPL_DEBUG=verbosity>2):\n            output, files = resolve_inout(files=files, output=output)\n\n            with rasterio.open(files[0]) as first:\n                first_res = first.res\n                kwargs = first.meta\n                kwargs.pop('affine')\n                nodataval = first.nodatavals[0]\n                dtype = first.dtypes[0]\n\n            if os.path.exists(output):\n                # TODO: prompt user to update existing file (-i option) like:\n                # overwrite b.tif? (y/n [n]) n\n                # not overwritten\n                dst = rasterio.open(output, 'r+')\n                nodataval = dst.nodatavals[0]\n                dtype = dst.dtypes[0]\n                dest = np.zeros((dst.count,) + dst.shape, dtype=dtype)\n            else:\n                # Create new output file.\n                # Extent from option or extent of all inputs.\n                if not bounds:\n                    # scan input files.\n                    xs = []\n                    ys = []\n                    for f in files:\n                        with rasterio.open(f) as src:\n                            left, bottom, right, top = src.bounds\n                            xs.extend([left, right])\n                            ys.extend([bottom, top])\n                    bounds = min(xs), min(ys), max(xs), max(ys)\n                output_transform = Affine.translation(bounds[0], bounds[3])\n\n                # Resolution/pixel size.\n                if not res:\n                    res = first_res\n                output_transform *= Affine.scale(res[0], -res[1])\n\n                # Dataset shape.\n                output_width = int(math.ceil((bounds[2]-bounds[0])/res[0]))\n                output_height = int(math.ceil((bounds[3]-bounds[1])/res[1]))\n\n                kwargs['driver'] == driver\n                kwargs['transform'] = output_transform\n                kwargs['width'] = output_width\n                kwargs['height'] = output_height\n\n                logger.debug(\"Kwargs: %r\", kwargs)\n                logger.debug(\"bounds: %r\", bounds)\n                logger.debug(\"Res: %r\", res)\n\n                dst = rasterio.open(output, 'w', **kwargs)\n                dest = np.zeros((first.count, output_height, output_width),\n                        dtype=dtype)\n\n                logger.debug(\"In merge, dest shape: %r\", dest.shape)\n\n            if nodata is not None:\n                nodataval = nodata\n\n            if nodataval is not None:\n                # Only fill if the nodataval is within dtype's range.\n                inrange = False\n                if np.dtype(dtype).kind in ('i', 'u'):\n                    info = np.iinfo(dtype)\n                    inrange = (info.min <= nodataval <= info.max)\n                elif np.dtype(dtype).kind == 'f':\n                    info = np.finfo(dtype)\n                    inrange = (info.min <= nodataval <= info.max)\n                if inrange:\n                    dest.fill(nodataval)\n                else:\n                    warnings.warn(\n                        \"Input file's nodata value, %s, is beyond the valid \"\n                        \"range of its data type, %s. Consider overriding it \"\n                        \"using the --nodata option for better results.\" % (\n                            nodataval, dtype))\n            else:\n                nodataval = 0\n\n            dst_w, dst_s, dst_e, dst_n = dst.bounds\n\n            for fname in reversed(files):\n                with rasterio.open(fname) as src:\n                    # Real World (tm) use of boundless reads.\n                    # This approach uses the maximum amount of memory to solve\n                    # the problem. Making it more efficient is a TODO.\n\n                    # 1. Compute spatial intersection of destination\n                    #    and source.\n                    src_w, src_s, src_e, src_n = src.bounds\n\n                    int_w = src_w if src_w > dst_w else dst_w\n                    int_s = src_s if src_s > dst_s else dst_s\n                    int_e = src_e if src_e < dst_e else dst_e\n                    int_n = src_n if src_n < dst_n else dst_n\n\n                    # 2. Compute the source window.\n                    src_window = src.window(int_w, int_s, int_e, int_n)\n\n                    # 3. Compute the destination window.\n                    dst_window = dst.window(int_w, int_s, int_e, int_n)\n\n                    # 4. Initialize temp array.\n                    temp = np.zeros(\n                            (first.count,) + tuple(b - a for a, b in dst_window),\n                            dtype=dtype)\n\n                    temp = src.read(\n                            out=temp,\n                            window=src_window,\n                            boundless=False,\n                            masked=True)\n\n                    # 5. Copy elements of temp into dest.\n                    roff, coff = dst.index(int_w, int_n)\n                    h, w = temp.shape[-2:]\n\n                    region = dest[:,roff:roff+h,coff:coff+w]\n                    np.copyto(region, temp,\n                        where=np.logical_and(\n                        region==nodataval, temp.mask==False))\n\n            if dst.mode == 'r+':\n                temp = dst.read(masked=True)\n                np.copyto(dest, temp,\n                    where=np.logical_and(\n                    dest==nodataval, temp.mask==False))\n\n            dst.write(dest)\n            dst.close()\n\n    except Exception:\n        logger.exception(\"Exception caught during processing\")\n        raise click.Abort()\n", "path": "rasterio/rio/merge.py"}], "after_files": [{"content": "# Merge command.\n\n\nimport logging\nimport math\nimport os.path\nimport warnings\n\nimport click\nfrom cligj import files_inout_arg, format_opt\n\nfrom .helpers import resolve_inout\nfrom . import options\nimport rasterio\nfrom rasterio.transform import Affine\n\n\n@click.command(short_help=\"Merge a stack of raster datasets.\")\n@files_inout_arg\n@options.output_opt\n@format_opt\n@options.bounds_opt\n@click.option('-r', '--res', nargs=2, type=float, default=None,\n              help=\"Output dataset resolution: pixel width, pixel height\")\n@click.option('--nodata', type=float, default=None,\n              help=\"Override nodata values defined in input datasets\")\n@click.pass_context\ndef merge(ctx, files, output, driver, bounds, res, nodata):\n    \"\"\"Copy valid pixels from input files to an output file.\n\n    All files must have the same number of bands, data type, and\n    coordinate reference system.\n\n    Input files are merged in their listed order using the reverse\n    painter's algorithm. If the output file exists, its values will be\n    overwritten by input values.\n\n    Geospatial bounds and resolution of a new output file in the\n    units of the input file coordinate reference system may be provided\n    and are otherwise taken from the first input file.\n    \"\"\"\n    import numpy as np\n\n    verbosity = (ctx.obj and ctx.obj.get('verbosity')) or 1\n    logger = logging.getLogger('rio')\n\n    try:\n        with rasterio.drivers(CPL_DEBUG=verbosity>2):\n            output, files = resolve_inout(files=files, output=output)\n\n            with rasterio.open(files[0]) as first:\n                first_res = first.res\n                kwargs = first.meta\n                kwargs.pop('affine')\n                nodataval = first.nodatavals[0]\n                dtype = first.dtypes[0]\n\n            if os.path.exists(output):\n                # TODO: prompt user to update existing file (-i option) like:\n                # overwrite b.tif? (y/n [n]) n\n                # not overwritten\n                dst = rasterio.open(output, 'r+')\n                nodataval = dst.nodatavals[0]\n                dtype = dst.dtypes[0]\n                dest = np.zeros((dst.count,) + dst.shape, dtype=dtype)\n            else:\n                # Create new output file.\n                # Extent from option or extent of all inputs.\n                if not bounds:\n                    # scan input files.\n                    xs = []\n                    ys = []\n                    for f in files:\n                        with rasterio.open(f) as src:\n                            left, bottom, right, top = src.bounds\n                            xs.extend([left, right])\n                            ys.extend([bottom, top])\n                    bounds = min(xs), min(ys), max(xs), max(ys)\n                output_transform = Affine.translation(bounds[0], bounds[3])\n\n                # Resolution/pixel size.\n                if not res:\n                    res = first_res\n                output_transform *= Affine.scale(res[0], -res[1])\n\n                # Dataset shape.\n                output_width = int(math.ceil((bounds[2]-bounds[0])/res[0]))\n                output_height = int(math.ceil((bounds[3]-bounds[1])/res[1]))\n\n                kwargs['driver'] = driver\n                kwargs['transform'] = output_transform\n                kwargs['width'] = output_width\n                kwargs['height'] = output_height\n\n                logger.debug(\"Kwargs: %r\", kwargs)\n                logger.debug(\"bounds: %r\", bounds)\n                logger.debug(\"Res: %r\", res)\n\n                dst = rasterio.open(output, 'w', **kwargs)\n                dest = np.zeros((first.count, output_height, output_width),\n                        dtype=dtype)\n\n                logger.debug(\"In merge, dest shape: %r\", dest.shape)\n\n            if nodata is not None:\n                nodataval = nodata\n\n            if nodataval is not None:\n                # Only fill if the nodataval is within dtype's range.\n                inrange = False\n                if np.dtype(dtype).kind in ('i', 'u'):\n                    info = np.iinfo(dtype)\n                    inrange = (info.min <= nodataval <= info.max)\n                elif np.dtype(dtype).kind == 'f':\n                    info = np.finfo(dtype)\n                    inrange = (info.min <= nodataval <= info.max)\n                if inrange:\n                    dest.fill(nodataval)\n                else:\n                    warnings.warn(\n                        \"Input file's nodata value, %s, is beyond the valid \"\n                        \"range of its data type, %s. Consider overriding it \"\n                        \"using the --nodata option for better results.\" % (\n                            nodataval, dtype))\n            else:\n                nodataval = 0\n\n            dst_w, dst_s, dst_e, dst_n = dst.bounds\n\n            for fname in reversed(files):\n                with rasterio.open(fname) as src:\n                    # Real World (tm) use of boundless reads.\n                    # This approach uses the maximum amount of memory to solve\n                    # the problem. Making it more efficient is a TODO.\n\n                    # 1. Compute spatial intersection of destination\n                    #    and source.\n                    src_w, src_s, src_e, src_n = src.bounds\n\n                    int_w = src_w if src_w > dst_w else dst_w\n                    int_s = src_s if src_s > dst_s else dst_s\n                    int_e = src_e if src_e < dst_e else dst_e\n                    int_n = src_n if src_n < dst_n else dst_n\n\n                    # 2. Compute the source window.\n                    src_window = src.window(int_w, int_s, int_e, int_n)\n\n                    # 3. Compute the destination window.\n                    dst_window = dst.window(int_w, int_s, int_e, int_n)\n\n                    # 4. Initialize temp array.\n                    temp = np.zeros(\n                            (first.count,) + tuple(b - a for a, b in dst_window),\n                            dtype=dtype)\n\n                    temp = src.read(\n                            out=temp,\n                            window=src_window,\n                            boundless=False,\n                            masked=True)\n\n                    # 5. Copy elements of temp into dest.\n                    roff, coff = dst.index(int_w, int_n)\n                    h, w = temp.shape[-2:]\n\n                    region = dest[:,roff:roff+h,coff:coff+w]\n                    np.copyto(region, temp,\n                        where=np.logical_and(\n                        region==nodataval, temp.mask==False))\n\n            if dst.mode == 'r+':\n                temp = dst.read(masked=True)\n                np.copyto(dest, temp,\n                    where=np.logical_and(\n                    dest==nodataval, temp.mask==False))\n\n            dst.write(dest)\n            dst.close()\n\n    except Exception:\n        logger.exception(\"Exception caught during processing\")\n        raise click.Abort()\n", "path": "rasterio/rio/merge.py"}]}