Skip to content

Component2 load #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 12 additions & 2 deletions configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -141,6 +145,7 @@ def __init__(self):
self.includecomponentroots = ""
self.commitmessageprefix = ""
self.gitattributes = ""
self.component2load = ""

def setuser(self, user):
self.user = user
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
18 changes: 14 additions & 4 deletions rtcFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")
Expand Down Expand Up @@ -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 = ""
Expand Down
1 change: 1 addition & 0 deletions tests/resources/test_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ encoding = UTF-8
[Migration]
StreamToMigrate = Superstream
PreviousStream = Previousstream
component2Load =
InitialBaseLines = Component1=Baseline1, Component2=Baseline2
UseProvidedHistory = True
UseAutomaticConflictResolution = True
Expand Down
1 change: 1 addition & 0 deletions tests/resources/test_minimum_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ WorkspaceName = Miniworkspace

[Migration]
StreamToMigrate = Ministream
component2Load =