0
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
#
|
|
16 |
|
|
17 |
import sys
|
|
18 |
import logging
|
5
|
19 |
import re
|
0
|
20 |
from optparse import OptionParser, OptionGroup
|
|
21 |
import cone_common
|
|
22 |
|
|
23 |
from cone.public import api, utils, exceptions
|
|
24 |
|
|
25 |
VERSION = '1.0'
|
|
26 |
|
|
27 |
logger = logging.getLogger('cone')
|
|
28 |
|
|
29 |
class MergeFailedException(Exception):
|
|
30 |
"""
|
|
31 |
Exception raised if the merge failed for some reason.
|
|
32 |
"""
|
|
33 |
pass
|
|
34 |
|
|
35 |
class MergePolicy(object):
|
|
36 |
"""
|
|
37 |
Merge policy constants.
|
|
38 |
"""
|
|
39 |
#: Replace/add files from the source layer into the
|
|
40 |
#: target layer, preserving files in the target layer
|
|
41 |
#: that do not exist in the source layer
|
|
42 |
REPLACE_ADD = 'replace-add'
|
|
43 |
|
|
44 |
#: Overwrite the entire target layer, so that it contains
|
|
45 |
#: only the contents of the source layer
|
|
46 |
OVERWRITE_LAYER = 'overwrite-layer'
|
|
47 |
|
|
48 |
ALL = (REPLACE_ADD, OVERWRITE_LAYER)
|
|
49 |
|
|
50 |
@classmethod
|
|
51 |
def is_valid(cls, policy):
|
|
52 |
return policy in cls.ALL
|
|
53 |
|
|
54 |
def get_new_layer_name(oldname,rootconfig):
|
|
55 |
newpath = utils.resourceref.get_path(oldname)
|
|
56 |
newpath+= "_" + utils.resourceref.remove_ext(utils.resourceref.get_filename(rootconfig))
|
|
57 |
newpath+= "/" + utils.resourceref.get_filename(oldname)
|
|
58 |
return newpath
|
|
59 |
|
|
60 |
def merge_configuration_layer(sourceconfig, targetconfig, merge_policy):
|
|
61 |
"""
|
|
62 |
Merge the contents of the source layer into the target layer.
|
|
63 |
@param sourceconfig: Source layer root configuration object.
|
|
64 |
@param targetconfig: Target layer root configuration object.
|
|
65 |
@param merge_policy: The used layer merge policy.
|
|
66 |
"""
|
|
67 |
# If policy tells to entirely overwrite the layer, remove all
|
|
68 |
# resources from the layer first
|
|
69 |
if merge_policy == MergePolicy.OVERWRITE_LAYER:
|
|
70 |
# Remove configurations from the layer root
|
|
71 |
confs = targetconfig.list_configurations()
|
|
72 |
for conf in confs:
|
|
73 |
targetconfig.remove_configuration(conf)
|
|
74 |
|
|
75 |
# Remove all related resources
|
|
76 |
layerobj = targetconfig.get_layer()
|
|
77 |
# Round one: remove all files
|
|
78 |
resources = layerobj.list_all_related(empty_folders=False)
|
|
79 |
for res in resources: layerobj.delete_resource(res)
|
|
80 |
# Round two: remove any remaining empty directories
|
|
81 |
resources = layerobj.list_all_related(empty_folders=True)
|
|
82 |
for res in resources: layerobj.delete_folder(res)
|
|
83 |
|
|
84 |
# Find all ConfML files
|
|
85 |
confml_resources = sourceconfig.list_configurations()
|
|
86 |
|
|
87 |
# Find all other related files and folders (content/, doc/ etc.)
|
|
88 |
layerobj = sourceconfig.get_layer()
|
|
89 |
targetobj = targetconfig.get_layer()
|
|
90 |
other_resources = layerobj.list_all_related(empty_folders=True)
|
|
91 |
|
|
92 |
# Copy the resources to the target configuration
|
|
93 |
for res_path in confml_resources + other_resources:
|
|
94 |
try:
|
|
95 |
rres = layerobj.open_resource(res_path,"rb")
|
|
96 |
wres = targetobj.open_resource(res_path,"wb")
|
|
97 |
print "Copying %s" % rres.path
|
|
98 |
logger.info('Copying layer resource %s to %s' % (rres.path, wres.path))
|
|
99 |
wres.write(rres.read())
|
|
100 |
wres.close()
|
|
101 |
rres.close()
|
|
102 |
except exceptions.NotResource:
|
|
103 |
# If it isn't a resource (file), it's a folder
|
|
104 |
targetobj.create_folder(res_path)
|
|
105 |
|
|
106 |
# Remove all configurations from the target layer root
|
|
107 |
already_included = targetconfig.list_configurations()
|
|
108 |
for confml_path in already_included:
|
|
109 |
targetconfig.remove_configuration(confml_path)
|
|
110 |
|
|
111 |
# Include them back
|
|
112 |
for confml_path in already_included:
|
|
113 |
targetconfig.include_configuration(confml_path)
|
|
114 |
|
|
115 |
# Include all added configurations
|
|
116 |
for confml_path in confml_resources:
|
|
117 |
if confml_path not in already_included:
|
|
118 |
print "Including %s in layer root %s" % (confml_path, targetconfig.path)
|
|
119 |
targetconfig.include_configuration(confml_path)
|
3
|
120 |
|
|
121 |
merge_metadata(sourceconfig, targetconfig)
|
0
|
122 |
|
|
123 |
def find_layers_to_merge(layer_indices, rename, sourceconfig, targetconfig):
|
|
124 |
"""
|
|
125 |
Return a list of layers to merge.
|
|
126 |
|
|
127 |
@param layer_indices: List of layer indices to merge, can also be
|
|
128 |
None to indicate that all layers are to be merged.
|
|
129 |
@param rename: True if the layers should be renamed in the target
|
|
130 |
config, False if not.
|
|
131 |
@return: A list of tuples (layer_root, target_layer_root), where
|
|
132 |
layer_root is the path to the layer root in the source
|
|
133 |
configuration and target_layer_root the one in the target
|
|
134 |
configuration.
|
|
135 |
"""
|
|
136 |
# Get a list of all configurations to merge
|
|
137 |
if layer_indices is None:
|
|
138 |
mergeconfigs = sourceconfig.list_configurations()
|
|
139 |
else:
|
|
140 |
mergeconfigs = sort_mergeconfigs(layer_indices, sourceconfig.list_configurations())
|
|
141 |
|
|
142 |
result = []
|
|
143 |
if rename:
|
|
144 |
for source_path in mergeconfigs:
|
|
145 |
target_path = get_new_layer_name(source_path, targetconfig.path)
|
|
146 |
result.append((source_path, target_path))
|
|
147 |
else:
|
|
148 |
for source_path in mergeconfigs:
|
|
149 |
result.append((source_path, source_path))
|
|
150 |
|
|
151 |
return result
|
|
152 |
|
|
153 |
def sort_mergeconfigs(layers, sourceconfigs):
|
|
154 |
"""
|
|
155 |
Return a correctly sorted list of source configuration layers.
|
3
|
156 |
@param layers: List of the indices of the layers to merge. Can be None, in
|
0
|
157 |
which case all layers are returned.
|
|
158 |
@param sourceconfigs: List of all configuration layer root paths in the
|
|
159 |
source project.
|
|
160 |
@return: List of configuration layer root paths.
|
|
161 |
"""
|
|
162 |
sorted_configs = [None for _ in xrange(len(sourceconfigs))]
|
|
163 |
for layer in layers:
|
|
164 |
sorted_configs[layer]=sourceconfigs[layer]
|
|
165 |
sorted_configs = filter(lambda x: x != None, sorted_configs)
|
|
166 |
return sorted_configs
|
|
167 |
|
3
|
168 |
def merge_metadata(source_config, target_config):
|
|
169 |
# Merge (well, replace) configuration meta-data
|
|
170 |
if source_config.meta:
|
|
171 |
target_config.meta = source_config.meta._clone(recursion=True)
|
|
172 |
else:
|
|
173 |
del target_config.meta
|
|
174 |
|
|
175 |
def get_active_root_if_necessary(project, configuration, name):
|
|
176 |
if configuration:
|
|
177 |
return configuration
|
|
178 |
else:
|
|
179 |
active_root = project.get_storage().get_active_configuration()
|
|
180 |
if active_root == "":
|
|
181 |
raise MergeFailedException("No %s configuration given and the project does not have an active root" % name)
|
|
182 |
else:
|
|
183 |
return active_root
|
|
184 |
|
0
|
185 |
def merge_config_root_to_config_root(source_project, target_project,
|
|
186 |
source_config, target_config,
|
3
|
187 |
layer_finder_func,
|
5
|
188 |
merge_policy,
|
|
189 |
find_pattern=None):
|
0
|
190 |
"""
|
|
191 |
Merge the source configuration root to the target configuration root.
|
3
|
192 |
|
|
193 |
@param source_config: Name of the source configuration.
|
|
194 |
@param target_config: Name of the target configuration.
|
|
195 |
@param layer_finder_func: Function for finding the layers that are to be
|
|
196 |
merged. It should take source and target configuration objects as
|
|
197 |
arguments and return a list of tuples (layer_root, target_layer_root),
|
|
198 |
where layer_root is the path to the layer root in the source
|
|
199 |
configuration and target_layer_root the one in the target
|
|
200 |
configuration.
|
0
|
201 |
@param merge_policy: The used merge policy.
|
5
|
202 |
@param find_pattern: Layers found with this pattern will be used from
|
|
203 |
the source configuration. If the configuration project has a root
|
|
204 |
configuration which has the same ctr code as the source config,
|
|
205 |
the other layers are taken from the found root config.
|
0
|
206 |
"""
|
|
207 |
target_root = get_active_root_if_necessary(target_project, target_config, 'target')
|
|
208 |
source_root = get_active_root_if_necessary(source_project, source_config, 'source')
|
|
209 |
|
|
210 |
print "Target config: %s" % target_root
|
|
211 |
print "Source config: %s" % source_root
|
|
212 |
|
|
213 |
try:
|
|
214 |
source_config = source_project.get_configuration(source_root)
|
|
215 |
except exceptions.NotFound:
|
|
216 |
raise MergeFailedException("Configuration root '%s' not found in source project" % source_root)
|
|
217 |
|
5
|
218 |
|
|
219 |
def get_matching_config_in_target_project(target_prj, src_config):
|
|
220 |
|
|
221 |
def get_based_on_ctr(meta):
|
|
222 |
if meta:
|
|
223 |
for prop in meta.array:
|
|
224 |
if 'name' in prop.attrs and 'value' in prop.attrs:
|
|
225 |
name = prop.attrs['name']
|
|
226 |
if name == 'based_on_ctr':
|
|
227 |
ctr_codes = prop.attrs['value'].split(',')
|
|
228 |
return [ctr.strip() for ctr in ctr_codes]
|
|
229 |
return []
|
|
230 |
|
|
231 |
root_configs = target_prj.list_configurations()
|
|
232 |
based_on_ctr_s = sorted(get_based_on_ctr(src_config.meta))
|
|
233 |
for c in root_configs:
|
|
234 |
based_on_ctr_c = sorted(get_based_on_ctr(target_prj.get_configuration(c).meta))
|
|
235 |
if based_on_ctr_c and based_on_ctr_s:
|
|
236 |
# if only one ctr code specified in source config, try to find root config that has that code
|
|
237 |
# (and maybe some others)
|
|
238 |
if len(based_on_ctr_s) == 1:
|
|
239 |
if based_on_ctr_s[0] in based_on_ctr_c:
|
|
240 |
return c
|
|
241 |
# otherwise try to find a config that has all the same ctr codes
|
|
242 |
elif based_on_ctr_c == based_on_ctr_s:
|
|
243 |
return c
|
|
244 |
return None
|
|
245 |
|
|
246 |
|
0
|
247 |
# Create or get the target configuration root
|
|
248 |
try:
|
|
249 |
target_config = target_project.get_configuration(target_root)
|
|
250 |
except exceptions.NotFound:
|
|
251 |
logger.info('Creating new root configuration %s' % (target_config))
|
|
252 |
target_config = target_project.create_configuration(target_config)
|
5
|
253 |
# try to find a matching configuration in target project (based_on_ctr)
|
|
254 |
cmp_config_in_target_prj = get_matching_config_in_target_project(target_project, source_config)
|
|
255 |
#cmp_config_in_target_prj = None
|
|
256 |
if cmp_config_in_target_prj:
|
|
257 |
logger.info('Found root %s with the same ctr code(s) from target project.' % cmp_config_in_target_prj)
|
|
258 |
cmp_configurations = target_project.get_configuration(cmp_config_in_target_prj).list_configurations()
|
|
259 |
p = re.compile(find_pattern)
|
|
260 |
for cmp_layer_path in cmp_configurations:
|
|
261 |
if not p.search(cmp_layer_path):
|
|
262 |
if target_config.get_storage().is_resource(cmp_layer_path):
|
|
263 |
logger.info('Including layer %s to root %s' % (cmp_layer_path, target_config.path))
|
|
264 |
target_config.include_configuration(cmp_layer_path)
|
|
265 |
else:
|
|
266 |
logger.info('Creating new layer %s to root %s' % (cmp_layer_path, target_config.path))
|
|
267 |
target_config.create_configuration(cmp_layer_path)
|
|
268 |
|
|
269 |
for sourcelayer_path in source_config.list_configurations():
|
|
270 |
sourcelayer = source_config.get_configuration(sourcelayer_path)
|
|
271 |
sourcelayer_path = sourcelayer.path
|
|
272 |
if p.search(sourcelayer_path):
|
|
273 |
if target_config.get_storage().is_resource(sourcelayer.path):
|
|
274 |
logger.info('Including layer %s to root %s' % (sourcelayer_path, target_config.path))
|
|
275 |
target_config.include_configuration(sourcelayer_path)
|
|
276 |
else:
|
|
277 |
logger.info('Creating new layer %s to root %s' % (sourcelayer_path, target_config.path))
|
|
278 |
target_config.create_configuration(sourcelayer_path)
|
|
279 |
else:
|
|
280 |
for sourcelayer_path in source_config.list_configurations():
|
|
281 |
sourcelayer = source_config.get_configuration(sourcelayer_path)
|
|
282 |
sourcelayer_path = sourcelayer.path
|
|
283 |
if target_config.get_storage().is_resource(sourcelayer.path):
|
|
284 |
logger.info('Including layer %s to root %s' % (sourcelayer_path, target_config.path))
|
|
285 |
target_config.include_configuration(sourcelayer_path)
|
|
286 |
else:
|
|
287 |
logger.info('Creating new layer %s to root %s' % (sourcelayer_path, target_config.path))
|
|
288 |
target_config.create_configuration(sourcelayer_path)
|
0
|
289 |
|
|
290 |
# Collect a correctly sorted list of all layer paths to merge
|
3
|
291 |
layers_to_merge = layer_finder_func(source_config, target_config)
|
0
|
292 |
|
|
293 |
print "Merging %d layer(s)..." % len(layers_to_merge)
|
|
294 |
|
|
295 |
# Merge the layers
|
|
296 |
for source_path, target_path in layers_to_merge:
|
|
297 |
print "Merging %s -> %s" % (source_path, target_path)
|
|
298 |
|
|
299 |
source_layer = source_project.get_configuration(source_path)
|
|
300 |
|
|
301 |
if source_path != target_path:
|
|
302 |
try:
|
|
303 |
target_config.remove_configuration(source_path)
|
|
304 |
except exceptions.NotFound:
|
|
305 |
pass
|
|
306 |
target_config.create_configuration(target_path)
|
|
307 |
|
|
308 |
# Get or create the target configuration layer
|
|
309 |
try:
|
|
310 |
target_layer = target_config.get_configuration(target_path)
|
|
311 |
except exceptions.NotFound:
|
|
312 |
logger.info('Creating new layer configuration %s' % (target_path))
|
|
313 |
target_layer = target_config.create_configuration(target_path)
|
|
314 |
|
|
315 |
merge_configuration_layer(source_layer, target_layer, merge_policy)
|
3
|
316 |
|
|
317 |
merge_metadata(source_config, target_config)
|
0
|
318 |
|
|
319 |
def main(argv=sys.argv):
|
3
|
320 |
""" Merge a configuration/layer to the project. """
|
0
|
321 |
parser = OptionParser(version="%%prog %s" % VERSION)
|
|
322 |
|
|
323 |
parser.add_options(cone_common.COMMON_OPTIONS)
|
|
324 |
|
|
325 |
parser.add_option("-c", "--configuration",\
|
|
326 |
dest="configuration",\
|
|
327 |
help="defines the name of the target configuration for the action",\
|
|
328 |
metavar="CONFIG")
|
|
329 |
|
|
330 |
parser.add_option("-p", "--project",\
|
|
331 |
dest="project",\
|
|
332 |
help="defines the location of current project. Default is the current working directory.",\
|
|
333 |
default=".",\
|
|
334 |
metavar="STORAGE")
|
|
335 |
|
|
336 |
group = OptionGroup(parser, 'Merge options',
|
|
337 |
'The merge functionality is meant to merge configurations/layers '
|
|
338 |
'from a remote project (defined with -r) to the current project (defined with -p). '
|
|
339 |
'Default value for the current project is the currently working directory. '
|
|
340 |
'A project can be either a folder or a cpf/zip file. There are two ways to '
|
|
341 |
'use merge: merge configuration roots (multiple layers), or specific layers. '
|
|
342 |
'See the ConE documentation for details and examples.')
|
|
343 |
|
|
344 |
group.add_option("-r", "--remote",\
|
|
345 |
dest="remote",\
|
|
346 |
help="defines the location of remote storage",\
|
|
347 |
metavar="STORAGE")
|
|
348 |
|
|
349 |
group.add_option("-s", "--sourceconfiguration",\
|
|
350 |
dest="sourceconfiguration",\
|
|
351 |
help="defines the name of the remote configuration inside the remote storage for the merge action. "\
|
|
352 |
"Default is the active root of the remote project.",\
|
|
353 |
metavar="CONFIG")
|
|
354 |
|
|
355 |
group.add_option("--sourcelayer",
|
|
356 |
help="Defines a specific layer to use as the layer to merge "\
|
|
357 |
"from the remote project. Must be the layer root (ConfML file)."\
|
|
358 |
"For example: --sourcelayer assets/somelayer/root.confml",
|
|
359 |
metavar="LAYER_ROOT",
|
|
360 |
default=None)
|
|
361 |
|
|
362 |
group.add_option("--targetlayer",
|
|
363 |
help="Defines a specific layer (root) to use as the layer to merge "\
|
|
364 |
"into the target project. Must be the layer root (ConfML file)."\
|
|
365 |
"For example: --targetlayer assets/somelayer/root.confml",
|
|
366 |
metavar="LAYER_ROOT",
|
|
367 |
default=None)
|
|
368 |
|
|
369 |
group.add_option("--rename",\
|
|
370 |
action="store_true",
|
|
371 |
dest="rename",\
|
|
372 |
help="defines that the merged layers need to be renamed",
|
|
373 |
default=False)
|
|
374 |
|
|
375 |
group.add_option("--all",\
|
|
376 |
action="store_true",
|
|
377 |
dest="all",\
|
|
378 |
help="Defines that the entire configuration (all layers) needs to be merged. "\
|
|
379 |
"This has no effect when merging layers directly using --sourcelayer and --targetlayer.",
|
|
380 |
default=False)
|
|
381 |
|
|
382 |
group.add_option("-l", "--layer",\
|
|
383 |
dest="layers",\
|
|
384 |
type="int",
|
|
385 |
action="append",
|
|
386 |
help="Define the layers of the source configuration that are included to merge action. "\
|
|
387 |
"The layer operation can be used several times in a single command. "\
|
|
388 |
"Note that this can only be used when merging configuration roots, not "\
|
|
389 |
"specific layers using --sourcelayer and --targetlayer. "\
|
|
390 |
"Example -l -1 --layer=-2, which would append a layers -1 and -2 to the layers => layers = -1,-2",
|
|
391 |
metavar="LAYERS",\
|
|
392 |
default=None)
|
|
393 |
|
|
394 |
group.add_option("--merge-policy",
|
|
395 |
help="Specifies the merge policy to use when merging layers. "\
|
|
396 |
"Possible values: "\
|
|
397 |
"replace-add - Add/replace files from source layer, but leave other files in the target as they are. "\
|
|
398 |
" "\
|
|
399 |
"overwrite-layer - Overwrite the entire layer (remove all previous content).",
|
|
400 |
default=MergePolicy.REPLACE_ADD)
|
|
401 |
|
|
402 |
parser.add_option_group(group)
|
|
403 |
(options, _) = parser.parse_args(argv)
|
|
404 |
|
|
405 |
cone_common.handle_common_options(options)
|
|
406 |
|
|
407 |
# Check the passed options
|
|
408 |
if not MergePolicy.is_valid(options.merge_policy):
|
|
409 |
parser.error("Invalid merge policy: %s\nMust be one of %s" % (options.merge_policy, '\n'.join(MergePolicy.ALL)))
|
|
410 |
if not options.remote: parser.error("Remote project must be given")
|
|
411 |
if options.layers and (options.sourcelayer or options.targetlayer):
|
|
412 |
parser.error("Specifying layer indices using --layer is not supported when using --sourcelayer or --targetlayer!")
|
|
413 |
if options.sourcelayer and not options.targetlayer:
|
|
414 |
parser.error("Merging a layer into a configuration is not supported at the moment!")
|
|
415 |
if options.sourcelayer and not options.sourcelayer.lower().endswith('.confml'):
|
|
416 |
parser.error("Source layer root should be a .confml file")
|
|
417 |
if options.targetlayer and not options.targetlayer.lower().endswith('.confml'):
|
|
418 |
parser.error("Target layer root should be a .confml file")
|
|
419 |
if not options.sourcelayer and options.targetlayer:
|
|
420 |
parser.error("Cannot merge a configuration into a layer!")
|
|
421 |
|
|
422 |
# If layers for configuration root merging are not specifically given,
|
|
423 |
# the default is the last layer
|
|
424 |
if options.layers is None:
|
|
425 |
options.layers = [-1]
|
|
426 |
|
|
427 |
target_project = api.Project(api.Storage.open(options.project,"a", username=options.username, password=options.password))
|
|
428 |
source_project = api.Project(api.Storage.open(options.remote,"r", username=options.username, password=options.password))
|
|
429 |
|
|
430 |
print "Target project: %s" % options.project
|
|
431 |
print "Source project: %s" % options.remote
|
|
432 |
|
|
433 |
target_config = None
|
|
434 |
try:
|
|
435 |
if options.sourcelayer and options.targetlayer:
|
|
436 |
print "Target layer: %s" % options.targetlayer
|
|
437 |
print "Source layer: %s" % options.sourcelayer
|
|
438 |
|
|
439 |
try:
|
|
440 |
source_config = source_project.get_configuration(options.sourcelayer)
|
|
441 |
except exceptions.NotFound:
|
|
442 |
raise MergeFailedException("Layer root '%s' not found in source project" % options.sourcelayer)
|
|
443 |
|
|
444 |
try:
|
|
445 |
target_config = target_project.get_configuration(options.targetlayer)
|
|
446 |
except exceptions.NotFound:
|
|
447 |
logger.info('Creating new layer %s' % (options.targetlayer))
|
|
448 |
target_config = target_project.create_configuration(options.targetlayer)
|
|
449 |
|
|
450 |
print "Merging layers..."
|
|
451 |
merge_configuration_layer(source_config, target_config, options.merge_policy)
|
|
452 |
else:
|
|
453 |
# Merging a configuration root into a configuration root
|
|
454 |
|
|
455 |
if options.all: layer_indices = None
|
|
456 |
else: layer_indices = utils.distinct_array(options.layers)
|
|
457 |
|
3
|
458 |
def find_layers(source_config, target_config):
|
|
459 |
return find_layers_to_merge(
|
|
460 |
layer_indices = layer_indices,
|
|
461 |
rename = options.rename,
|
|
462 |
sourceconfig = source_config,
|
|
463 |
targetconfig = target_config)
|
|
464 |
|
0
|
465 |
merge_config_root_to_config_root(
|
3
|
466 |
source_project = source_project,
|
|
467 |
target_project = target_project,
|
|
468 |
source_config = options.sourceconfiguration,
|
|
469 |
target_config = options.configuration,
|
|
470 |
layer_finder_func = find_layers,
|
|
471 |
merge_policy = options.merge_policy)
|
0
|
472 |
except MergeFailedException, e:
|
|
473 |
print "Could not merge: %s" % e
|
|
474 |
sys.exit(2)
|
|
475 |
else:
|
|
476 |
# Merge successful, so save the target configuration and project
|
|
477 |
# to persist the changes
|
|
478 |
if target_config: target_config.save()
|
|
479 |
target_project.save()
|
|
480 |
|
|
481 |
target_project.close()
|
|
482 |
source_project.close()
|
|
483 |
|
|
484 |
|
|
485 |
if __name__ == "__main__":
|
|
486 |
main()
|