diff --git a/config.ini.sample b/config.ini.sample index a19409a..b6751e7 100644 --- a/config.ini.sample +++ b/config.ini.sample @@ -22,6 +22,9 @@ StreamToMigrate = MyDevelopmentStream # (eg. When Migrating Stream_Version2, Previous-Stream would be Stream_Version1 PreviousStream= +# Optional - Used by author to load and migrate a single component instead of a whole workspace. Value must be set as component Name +component2Load = + # Optional, can be defined additionally to set the workspace to a specific baseline # Use following format: ComponentName = BaseLineName, AnotherComponentName=BaseLineName # If its not set, it will determine the oldest baseline (takes some time, depending of how much components you have in your stream) diff --git a/configuration.py b/configuration.py index 4db6290..ad35fb6 100644 --- a/configuration.py +++ b/configuration.py @@ -45,6 +45,9 @@ def read(configname=None): workdirectory = generalsection.get('Directory', os.getcwd()) streamname = shlex.quote(migrationsection['StreamToMigrate'].strip()) previousstreamname = migrationsection.get('PreviousStream', '').strip() + + component2load = shlex.quote(migrationsection['component2Load'].strip()) + baselines = getinitialcomponentbaselines(migrationsection.get('InitialBaseLines')) ignorefileextensionsproperty = parsedconfig.get(miscsectionname, 'IgnoreFileExtensions', fallback='') ignorefileextensions = parsesplittedproperty(ignorefileextensionsproperty) @@ -62,6 +65,7 @@ def read(configname=None): configbuilder.setmaxchangesetstoaccepttogether(maxchangesetstoaccepttogether) configbuilder.setworkdirectory(workdirectory).setstreamname(streamname).setinitialcomponentbaselines(baselines) configbuilder.setpreviousstreamname(previousstreamname) + configbuilder.setcomponent2load(component2load) configbuilder.setignorefileextensions(ignorefileextensions) configbuilder.setignoredirectories(ignoredirectories) configbuilder.setincludecomponentroots(includecomponentroots).setcommitmessageprefix(commitmessageprefix) @@ -141,6 +145,7 @@ def __init__(self): self.includecomponentroots = "" self.commitmessageprefix = "" self.gitattributes = "" + self.component2load = "" def setuser(self, user): self.user = user @@ -182,6 +187,10 @@ def setstreamname(self, streamname): self.streamname = streamname return self + def setcomponent2load(self, component2load): + self.component2load = component2load + return self + def setgitreponame(self, reponame): self.gitreponame = reponame self.clonedgitreponame = reponame[:-4] # cut .git @@ -237,14 +246,14 @@ def build(self): self.streamname, self.gitreponame, self.useprovidedhistory, self.useautomaticconflictresolution, self.maxchangesetstoaccepttogether, self.clonedgitreponame, self.rootFolder, self.previousstreamname, self.ignorefileextensions, self.ignoredirectories, self.includecomponentroots, - self.commitmessageprefix, self.gitattributes) + self.commitmessageprefix, self.gitattributes, self.component2load) class ConfigObject: def __init__(self, user, password, repourl, scmcommand, workspace, useexistingworkspace, workdirectory, initialcomponentbaselines, streamname, gitreponame, useprovidedhistory, useautomaticconflictresolution, maxchangesetstoaccepttogether, clonedgitreponame, rootfolder, previousstreamname, - ignorefileextensions, ignoredirectories, includecomponentroots, commitmessageprefix, gitattributes): + ignorefileextensions, ignoredirectories, includecomponentroots, commitmessageprefix, gitattributes, component2load): self.user = user self.password = password self.repo = repourl @@ -270,6 +279,7 @@ def __init__(self, user, password, repourl, scmcommand, workspace, useexistingwo self.includecomponentroots = includecomponentroots self.commitmessageprefix = commitmessageprefix self.gitattributes = gitattributes + self.component2load = component2load def getlogpath(self, filename): if not self.hasCreatedLogFolder: diff --git a/rtcFunctions.py b/rtcFunctions.py index 0c0ab84..74a0d6d 100644 --- a/rtcFunctions.py +++ b/rtcFunctions.py @@ -45,7 +45,12 @@ def __init__(self): self.scmcommand = self.config.scmcommand def createandload(self, stream, componentbaselineentries=[]): - shell.execute("%s create workspace -r %s -s %s %s" % (self.scmcommand, self.repo, stream, self.workspace)) + if self.config.component2load: + shell.execute("%s create workspace -r %s %s --empty" % (self.scmcommand, self.repo, self.workspace)) + shell.execute("%s add component -r %s %s %s" % (self.scmcommand, self.repo, self.workspace, self.config.component2load)) + else: + shell.execute("%s create workspace -r %s -s %s %s" % (self.scmcommand, self.repo, stream, self.workspace)) + if componentbaselineentries: self.setcomponentstobaseline(componentbaselineentries, stream) else: @@ -57,6 +62,8 @@ def load(self): command = "%s load -r %s %s --force" % (self.scmcommand, self.repo, self.workspace) if self.config.includecomponentroots: command += " --include-root" + if self.config.component2load: + command += " %s" % (self.config.component2load) shouter.shout("Start (re)loading current workspace: " + command) shell.execute(command) shouter.shout("Load of workspace finished") @@ -168,10 +175,13 @@ def getcomponentbaselineentriesfromstream(self, stream): else: baseline = uuidpart[5].strip()[1:-1] baselinename = splittedinformationline[1] - if baseline and component: - componentbaselinesentries.append( - ComponentBaseLineEntry(component, baseline, componentname, baselinename)) + # if component2load is specified append only its entry + if not self.config.component2load or self.config.component2load == componentname: + shouter.shout("Append to componentbaselinesentries:" + " c=%s cn=%s b=%s bn=%s" % (component, componentname, baseline, baselinename)) + componentbaselinesentries.append( + ComponentBaseLineEntry(component, baseline, componentname, baselinename)) baseline = "" component = "" componentname = "" diff --git a/tests/resources/test_config.ini b/tests/resources/test_config.ini index 2627793..a46b85d 100644 --- a/tests/resources/test_config.ini +++ b/tests/resources/test_config.ini @@ -12,6 +12,7 @@ encoding = UTF-8 [Migration] StreamToMigrate = Superstream PreviousStream = Previousstream +component2Load = InitialBaseLines = Component1=Baseline1, Component2=Baseline2 UseProvidedHistory = True UseAutomaticConflictResolution = True diff --git a/tests/resources/test_minimum_config.ini b/tests/resources/test_minimum_config.ini index 5fb5817..f69cdeb 100644 --- a/tests/resources/test_minimum_config.ini +++ b/tests/resources/test_minimum_config.ini @@ -7,3 +7,4 @@ WorkspaceName = Miniworkspace [Migration] StreamToMigrate = Ministream +component2Load =