391962 Create atomic repositories by default

- Bug 344851 already added the possibility to set the atomic flag on
composite repositories. As follow-up of the discussion on bug 356561,
the default for newly created repositories is changed to atomic=true.

Bug: 391962
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java
index 03d3a1f..7ae1a45 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/CompositeRepositoryApplication.java
@@ -122,8 +122,6 @@
 			//No existing repository; create a new repository at destinationLocation but with source's attributes.
 			IArtifactRepository repo = mgr.createRepository(toInit.getRepoLocation(), toInit.getName() != null ? toInit.getName() : (source != null ? source.getName() : Messages.CompositeRepository_default_artifactRepo_name), IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, source != null ? source.getProperties() : null);
 			initRepository(repo, toInit);
-			if (toInit.getAtomic() != null)
-				repo.setProperty(CompositeMetadataRepository.PROP_ATOMIC_LOADING, Boolean.toString(Boolean.valueOf(toInit.getAtomic())));
 			return repo;
 		} catch (IllegalStateException e) {
 			mgr.removeRepository(toInit.getRepoLocation());
@@ -162,8 +160,6 @@
 			//No existing repository; create a new repository at destinationLocation but with source's attributes.
 			IMetadataRepository repo = mgr.createRepository(toInit.getRepoLocation(), toInit.getName() != null ? toInit.getName() : (source != null ? source.getName() : Messages.CompositeRepository_default_metadataRepo_name), IMetadataRepositoryManager.TYPE_COMPOSITE_REPOSITORY, source != null ? source.getProperties() : null);
 			initRepository(repo, toInit);
-			if (toInit.getAtomic() != null)
-				repo.setProperty(CompositeMetadataRepository.PROP_ATOMIC_LOADING, Boolean.toString(Boolean.valueOf(toInit.getAtomic())));
 			return repo;
 		} catch (IllegalStateException e) {
 			mgr.removeRepository(toInit.getRepoLocation());
@@ -194,6 +190,16 @@
 		RepositoryHelper.validDestinationRepository(repository);
 		if (desc.isCompressed() && !repository.getProperties().containsKey(IRepository.PROP_COMPRESSED))
 			repository.setProperty(IRepository.PROP_COMPRESSED, String.valueOf(true));
+
+		setAtomicLoadingProperty(repository, desc);
+	}
+
+	private void setAtomicLoadingProperty(IRepository<?> repository, RepositoryDescriptor desc) {
+		// bug 356561: newly created repositories shall be atomic (by default)
+		boolean atomic = true;
+		if (desc.getAtomic() != null)
+			atomic = Boolean.valueOf(desc.getAtomic());
+		repository.setProperty(CompositeMetadataRepository.PROP_ATOMIC_LOADING, Boolean.toString(atomic));
 	}
 
 	public void setComparator(String value) {
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeArtifactRepositoryTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeArtifactRepositoryTask.java
index 5cfac91..000d325 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeArtifactRepositoryTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/CreateCompositeArtifactRepositoryTask.java
@@ -31,7 +31,7 @@
 
 	URI location; // desired location of the composite repository
 	String name = "Composite Artifact Repository";
-	boolean atomic = false;
+	boolean atomic = true; // bug 356561: newly created repositories shall be atomic (by default)
 	boolean compressed = true;
 	boolean failOnExists = false; // should we fail if a repo already exists?
 	Map<String, String> properties = new HashMap<String, String>();
@@ -69,8 +69,7 @@
 		// set the properties
 		if (compressed)
 			properties.put(IRepository.PROP_COMPRESSED, Boolean.toString(true));
-		if (atomic)
-			properties.put(CompositeArtifactRepository.PROP_ATOMIC_LOADING, Boolean.toString(true));
+		properties.put(CompositeArtifactRepository.PROP_ATOMIC_LOADING, Boolean.toString(atomic));
 
 		// create the repository
 		try {