Skip to content

Commit f12a5e2

Browse files
committed
Merge branch 'scm-version-config-option' of https://github.com/zevanty/rtc2git into zevanty-scm-version-config-option
2 parents 56e63b5 + 2b970cd commit f12a5e2

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

config.ini.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ScmCommand = lscm
1313
# Optional - Set encoding of files (For example encoding = UTF-8)
1414
# See "https://github.com/rtcTo/rtc2git/wiki/Encoding" for further instructions
1515
encoding =
16+
# Optional - SCM version. Different SCM versions have different commands. If not specific, default is 5.
17+
ScmVersion = 5
1618

1719
[Migration]
1820
# Stream to be migrated, referenced by Name or UUID

configuration.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def read(configname=None):
3434
scmcommand = generalsection.get('ScmCommand', "lscm")
3535
shell.logcommands = parsedconfig.get(miscsectionname, 'LogShellCommands', fallback="False") == "True"
3636
shell.setencoding(generalsection.get('encoding'))
37+
scmversion = generalsection.get('ScmVersion', "5");
3738

3839
workspace = shlex.quote(generalsection['WorkspaceName'])
3940
gitreponame = generalsection['GIT-Reponame']
@@ -56,7 +57,8 @@ def read(configname=None):
5657
gitattributesproperty = parsedconfig.get(migrationsectionname, 'Gitattributes', fallback='')
5758
gitattributes = parsesplittedproperty(gitattributesproperty)
5859

59-
configbuilder = Builder().setuser(user).setpassword(password).setstored(stored).setrepourl(repositoryurl).setscmcommand(scmcommand)
60+
configbuilder = Builder().setuser(user).setpassword(password).setstored(stored).setrepourl(repositoryurl)
61+
configbuilder.setscmcommand(scmcommand).setscmversion(scmversion)
6062
configbuilder.setworkspace(workspace).setgitreponame(gitreponame).setrootfolder(os.getcwd())
6163
configbuilder.setuseexistingworkspace(useexistingworkspace).setuseprovidedhistory(useprovidedhistory)
6264
configbuilder.setuseautomaticconflictresolution(useautomaticconflictresolution)
@@ -129,6 +131,7 @@ def __init__(self):
129131
self.stored = False
130132
self.repourl = ""
131133
self.scmcommand = "lscm"
134+
self.scmversion = ""
132135
self.workspace = ""
133136
self.useexistingworkspace = ""
134137
self.useprovidedhistory = ""
@@ -169,6 +172,10 @@ def setscmcommand(self, scmcommand):
169172
self.scmcommand = scmcommand
170173
return self
171174

175+
def setscmversion(self, scmversion):
176+
self.scmversion = int(scmversion)
177+
return self
178+
172179
def setworkspace(self, workspace):
173180
self.workspace = workspace
174181
return self
@@ -243,7 +250,7 @@ def isenabled(stringwithbooleanexpression):
243250
return stringwithbooleanexpression == "True"
244251

245252
def build(self):
246-
return ConfigObject(self.user, self.password, self.stored, self.repourl, self.scmcommand, self.workspace,
253+
return ConfigObject(self.user, self.password, self.stored, self.repourl, self.scmcommand, self.scmversion, self.workspace,
247254
self.useexistingworkspace, self.workdirectory, self.initialcomponentbaselines,
248255
self.streamname, self.gitreponame, self.useprovidedhistory,
249256
self.useautomaticconflictresolution, self.maxchangesetstoaccepttogether, self.clonedgitreponame, self.rootFolder,
@@ -252,7 +259,8 @@ def build(self):
252259

253260

254261
class ConfigObject:
255-
def __init__(self, user, password, stored, repourl, scmcommand, workspace, useexistingworkspace, workdirectory,
262+
263+
def __init__(self, user, password, stored, repourl, scmcommand, scmversion, workspace, useexistingworkspace, workdirectory,
256264
initialcomponentbaselines, streamname, gitreponame, useprovidedhistory,
257265
useautomaticconflictresolution, maxchangesetstoaccepttogether, clonedgitreponame, rootfolder, previousstreamname,
258266
ignorefileextensions, ignoredirectories, includecomponentroots, commitmessageprefix, gitattributes):
@@ -261,6 +269,7 @@ def __init__(self, user, password, stored, repourl, scmcommand, workspace, useex
261269
self.stored = stored
262270
self.repo = repourl
263271
self.scmcommand = scmcommand
272+
self.scmversion = scmversion
264273
self.workspace = workspace
265274
self.useexistingworkspace = useexistingworkspace
266275
self.useprovidedhistory = useprovidedhistory

tests/resources/test_config.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Directory = /tmp/migration
88
useExistingWorkspace = True
99
ScmCommand = scm
1010
encoding = UTF-8
11+
ScmVersion = 6
1112

1213
[Migration]
1314
StreamToMigrate = Superstream

tests/test_configuration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def _assertTestConfig(self, config, user=None, password=None):
137137
self.assertTrue(config.useexistingworkspace)
138138
self.assertEqual('scm', config.scmcommand)
139139
self.assertEqual('UTF-8', shell.encoding) # directly deviated to shell
140+
self.assertEqual(6, config.scmversion)
140141
# [Migration]
141142
self.assertEqual('Superstream', config.streamname)
142143
self.assertEqual('Previousstream', config.previousstreamname)
@@ -181,6 +182,7 @@ def _assertDefaultConfig(self, config):
181182
self.assertFalse(config.useexistingworkspace)
182183
self.assertEqual('lscm', config.scmcommand)
183184
self.assertEqual(None, shell.encoding) # directly deviated to shell
185+
self.assertEqual(5, config.scmversion)
184186
# [Migration]
185187
self.assertEqual('Ministream', config.streamname)
186188
self.assertEqual('', config.previousstreamname)

0 commit comments

Comments
 (0)