@@ -289,76 +289,92 @@ void SnapshotMerger::runMerge()
289289 {
290290 Snapshot::Properties properties;
291291
292- properties[" cppscanner.version" ] = cppscanner::versioncstr ();
293- properties[" cppscanner.os" ] = cppscanner::system_name ();
294-
295- bool a_new_home = false ;
296-
297- // look at home value for each project
292+ // process properties as found in the snapshots
298293 {
299- std::optional<std::string> common_home;
300- ValueUpdater updater{ common_home };
294+ std::set<std::string> property_names;
301295
302296 for (InputSnapshot& snapshot : m_snapshots)
303297 {
304- updater.update (snapshot.properties .at (" project.home" ));
298+ for (const auto & p : snapshot.properties )
299+ {
300+ property_names.insert (p.first );
301+ }
305302 }
306303
307- if (updater.valid ())
308- {
309- home = common_home.value ();
310- }
311- else
304+ for (const std::string& key : property_names)
312305 {
313- a_new_home = true ;
314- // TODO: print warning ?
306+ std::optional<std::string> value;
307+ ValueUpdater updater{ value };
308+
309+ for (InputSnapshot& snapshot : m_snapshots)
310+ {
311+ updater.update (getProperty (snapshot.properties , key));
312+ }
313+
314+ if (updater.valid ())
315+ {
316+ properties[key] = *value;
317+ }
315318 }
316319 }
317320
318- if (m_project_home_path. has_value ())
321+ // compute the "home" property
319322 {
320- std::string final_home = Snapshot::normalizedPath (m_project_home_path->generic_u8string ());
321- a_new_home = a_new_home || final_home != home;
322- home = std::move (final_home);
323- }
323+ bool a_new_home = false ;
324324
325- if (home.empty ())
326- {
327- // this is bad.
328- // TODO: abort merge ?
329- }
325+ // look at home value for each project
326+ {
327+ std::optional<std::string> common_home;
328+ ValueUpdater updater{ common_home };
330329
331- if (a_new_home)
332- {
333- // TODO: voir si on peut trouver une autre façon de rapporter l'info
334- std::cout << " Input snapshots do not have a common project.home property, or a new one was specified." << " \n " ;
335- std::cout << " Some data may be erased." << std::endl;
336- }
330+ for (InputSnapshot& snapshot : m_snapshots)
331+ {
332+ updater.update (snapshot.properties .at (" project.home" ));
333+ }
337334
338- properties[" project.home" ] = home;
335+ if (updater.valid ())
336+ {
337+ home = common_home.value ();
338+ }
339+ else
340+ {
341+ a_new_home = true ;
342+ // TODO: print warning ?
343+ }
344+ }
339345
340- const std::vector<std::string> extraProps{ " scanner.indexLocalSymbols" , " scanner.indexExternalFiles" , " scanner.root" };
341- for (const std::string& key : extraProps)
342- {
343- std::optional<std::string> value;
344- ValueUpdater updater{ value };
346+ if (m_project_home_path.has_value ())
347+ {
348+ std::string final_home = Snapshot::normalizedPath (m_project_home_path->generic_u8string ());
349+ a_new_home = a_new_home || final_home != home;
350+ home = std::move (final_home);
351+ }
345352
346- for (InputSnapshot& snapshot : m_snapshots )
353+ if (home. empty () )
347354 {
348- updater.update (getProperty (snapshot.properties , key));
355+ // this is bad.
356+ // TODO: abort merge ?
349357 }
350358
351- if (updater. valid () )
359+ if (a_new_home )
352360 {
353- properties[key] = *value;
361+ // TODO: voir si on peut trouver une autre façon de rapporter l'info
362+ std::cout << " Input snapshots do not have a common project.home property, or a new one was specified." << " \n " ;
363+ std::cout << " Some data may be erased." << std::endl;
354364 }
355- }
356365
366+ properties[" project.home" ] = home;
367+ }
368+
369+ // write extra properties
357370 for (const auto & p : m_extra_properties)
358371 {
359372 properties[p.first ] = p.second ;
360373 }
361374
375+ properties[" cppscanner.version" ] = cppscanner::versioncstr ();
376+ properties[" cppscanner.os" ] = cppscanner::system_name ();
377+
362378 writer ().beginTransaction ();
363379 writer ().insert (properties);
364380 writer ().endTransaction ();
0 commit comments