forked from rtcTo/rtc2git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
migration.py
65 lines (51 loc) · 2.05 KB
/
migration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import sys
from rtcFunctions import ImportHandler
from rtcFunctions import WorkspaceHandler
from rtcFunctions import RTCInitializer
from gitFunctions import Initializer
from gitFunctions import Commiter
import configuration
import shouter
def initialize(config):
directory = config.workDirectory
if os.path.exists(directory):
sys.exit("Configured directory already exists, please make sure to use a non-existing directory")
os.makedirs(directory)
os.chdir(directory)
config.deletelogfolder()
git = Initializer(config)
git.initalize()
RTCInitializer.initialize(config)
git.initialcommitandpush()
def resume(config):
os.chdir(config.workDirectory)
os.chdir(config.clonedGitRepoName)
RTCInitializer.loginandcollectstreamuuid(config)
WorkspaceHandler(config).load()
def migrate():
config = configuration.read()
rtc = ImportHandler(config)
rtcworkspace = WorkspaceHandler(config)
git = Commiter
initialize(config)
streamuuid = config.streamuuid
streamname = config.streamname
branchname = streamname + "_branchpoint"
componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(streamuuid)
rtcworkspace.setnewflowtargets(streamuuid)
git.branch(branchname)
history = rtc.readhistory(componentbaselineentries, streamname)
changeentries = rtc.getchangeentriesofstreamcomponents(componentbaselineentries)
rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history))
shouter.shout("All changes until creation of stream '%s' accepted" % streamname)
git.pushbranch(branchname)
git.branch(streamname)
rtcworkspace.setcomponentstobaseline(componentbaselineentries, streamuuid)
rtcworkspace.load()
changeentries = rtc.getchangeentriesofstream(streamuuid)
rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history))
git.pushbranch(streamname)
shouter.shout("All changes of stream '%s' accepted - Migration of stream completed" % streamname)
if __name__ == "__main__":
migrate()