forked from rtcTo/rtc2git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
migration.py
81 lines (66 loc) · 2.72 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import os
import sys
from rtcFunctions import ImportHandler
from rtcFunctions import WorkspaceHandler
from rtcFunctions import RTCInitializer
from gitFunctions import Initializer, Differ
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)
if Differ.has_diff():
sys.exit("Your git repo has some uncommited changes, please add/remove them")
RTCInitializer.loginandcollectstreamuuid(config)
if config.previousstreamname:
prepare(config)
else:
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)
def prepare(config):
rtc = ImportHandler(config)
rtcworkspace = WorkspaceHandler(config)
# git checkout branchpoint
Commiter.checkout(config.previousstreamname + "_branchpoint")
# list baselines of current workspace
componentbaselineentries = rtc.getcomponentbaselineentriesfromstream(config.previousstreamuuid)
# set components to that baselines
rtcworkspace.setcomponentstobaseline(componentbaselineentries, config.previousstreamuuid)
rtcworkspace.load()
if __name__ == "__main__":
migrate()