From 126c8a96e811644ad8735e5dc62d5866a6518328 Mon Sep 17 00:00:00 2001 From: Thierry Lacour Date: Wed, 14 Nov 2018 15:00:28 +0100 Subject: [PATCH] Fix #144 Recreate persistent contexts after mixins --- src/main/groovy/togit/ScriptBase.groovy | 5 +++-- src/main/groovy/togit/migration/MigrationManager.groovy | 4 ++++ .../groovy/togit/migration/sources/MigrationSource.groovy | 4 ++-- .../togit/migration/sources/ccbase/ClearCaseSource.groovy | 4 ++-- .../groovy/togit/migration/sources/ccucm/CcucmSource.groovy | 4 ++-- .../groovy/togit/migration/sources/dummy/DummySource.groovy | 4 ++-- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/groovy/togit/ScriptBase.groovy b/src/main/groovy/togit/ScriptBase.groovy index 994cd25..c115868 100644 --- a/src/main/groovy/togit/ScriptBase.groovy +++ b/src/main/groovy/togit/ScriptBase.groovy @@ -84,8 +84,9 @@ abstract class ScriptBase extends Script implements Context { MigrationManager.instance.source = newSource // Mix in specific criteria/extraction contexts - newSource.addCriteria() - newSource.addExtractions() + newSource.mixinCriteria() + newSource.mixinExtractions() + MigrationManager.instance.refreshContexts() } /** diff --git a/src/main/groovy/togit/migration/MigrationManager.groovy b/src/main/groovy/togit/migration/MigrationManager.groovy index 2371992..7a94f52 100644 --- a/src/main/groovy/togit/migration/MigrationManager.groovy +++ b/src/main/groovy/togit/migration/MigrationManager.groovy @@ -27,6 +27,10 @@ class MigrationManager { source = null targets.clear() plan = new MigrationPlan() + refreshContexts() + } + + void refreshContexts() { criteriaContext = new CriteriaContext() extractionsContext = new ExtractionsContext() actionsContext = new ActionsContext() diff --git a/src/main/groovy/togit/migration/sources/MigrationSource.groovy b/src/main/groovy/togit/migration/sources/MigrationSource.groovy index a9008c3..61f89a0 100644 --- a/src/main/groovy/togit/migration/sources/MigrationSource.groovy +++ b/src/main/groovy/togit/migration/sources/MigrationSource.groovy @@ -35,10 +35,10 @@ trait MigrationSource { /** * Adds source-specific contexts to the global CriteriaContext */ - abstract void addCriteria() + abstract void mixinCriteria() /** * Adds source-specific contexts to the global ExtractionsContext */ - abstract void addExtractions() + abstract void mixinExtractions() } diff --git a/src/main/groovy/togit/migration/sources/ccbase/ClearCaseSource.groovy b/src/main/groovy/togit/migration/sources/ccbase/ClearCaseSource.groovy index 6ee50dc..3d8ae76 100644 --- a/src/main/groovy/togit/migration/sources/ccbase/ClearCaseSource.groovy +++ b/src/main/groovy/togit/migration/sources/ccbase/ClearCaseSource.groovy @@ -63,12 +63,12 @@ class ClearCaseSource implements MigrationSource { } @Override - void addCriteria() { + void mixinCriteria() { CriteriaContext.mixin(ClearCaseCriteriaContext) } @Override - void addExtractions() { + void mixinExtractions() { ExtractionsContext.mixin(ClearCaseExtractionsContext) } diff --git a/src/main/groovy/togit/migration/sources/ccucm/CcucmSource.groovy b/src/main/groovy/togit/migration/sources/ccucm/CcucmSource.groovy index 2b4abc1..4726c75 100644 --- a/src/main/groovy/togit/migration/sources/ccucm/CcucmSource.groovy +++ b/src/main/groovy/togit/migration/sources/ccucm/CcucmSource.groovy @@ -65,12 +65,12 @@ class CcucmSource implements MigrationSource { } @Override - void addCriteria() { + void mixinCriteria() { CriteriaContext.mixin(CcucmCriteriaContext) } @Override - void addExtractions() { + void mixinExtractions() { ExtractionsContext.mixin(CcucmExtractionsContext) } diff --git a/src/main/groovy/togit/migration/sources/dummy/DummySource.groovy b/src/main/groovy/togit/migration/sources/dummy/DummySource.groovy index d069852..375343e 100644 --- a/src/main/groovy/togit/migration/sources/dummy/DummySource.groovy +++ b/src/main/groovy/togit/migration/sources/dummy/DummySource.groovy @@ -42,12 +42,12 @@ class DummySource implements MigrationSource { } @Override - void addCriteria() { + void mixinCriteria() { CriteriaContext.mixin(DummyCriteriaContext) } @Override - void addExtractions() { + void mixinExtractions() { ExtractionsContext.mixin(DummyExtractionsContext) } }