diff --git a/migration.py b/migration.py index 92305b5..4067123 100644 --- a/migration.py +++ b/migration.py @@ -53,7 +53,9 @@ def migrate(): rtcworkspace = WorkspaceHandler() git = Commiter + resumed = False if existsrepo(): + resumed = True resume() else: initialize() @@ -65,23 +67,26 @@ def migrate(): 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) + if not resumed: + git.branch(branchname) + changeentries = rtc.getchangeentriesofstreamcomponents(componentbaselineentries) + rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history)) + shouter.shout("All changes until creation of stream '%s' accepted" % streamname) + git.pushbranch(branchname) - rtcworkspace.setcomponentstobaseline(componentbaselineentries, streamuuid) - rtcworkspace.load() + rtcworkspace.setcomponentstobaseline(componentbaselineentries, streamuuid) + rtcworkspace.load() + git.branch(streamname) changeentries = rtc.getchangeentriesofstream(streamuuid) - rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history)) - git.pushbranch(streamname) - git.promotebranchtomaster(streamname) + amountofacceptedchanges = rtc.acceptchangesintoworkspace(rtc.getchangeentriestoaccept(changeentries, history)) + if not resumed or amountofacceptedchanges > 0: + git.pushbranch(streamname) + git.promotebranchtomaster(streamname) + RTCLogin.logout() shouter.shout("\nAll changes accepted - Migration of stream '%s' is completed. \n" "You should adjust your .gitignore to ignore the same files as defined in your .jazzignore \n" diff --git a/rtcFunctions.py b/rtcFunctions.py index 7cb537f..4f5e193 100644 --- a/rtcFunctions.py +++ b/rtcFunctions.py @@ -218,6 +218,7 @@ def acceptchangesintoworkspace(self, changeentries): reloaded = True shouter.shout("Accepted change %s/%s into working directory" % (amountofacceptedchanges, amountofchanges)) Commiter.addandcommit(changeEntry) + return amountofacceptedchanges @staticmethod def collect_changes_to_accept_to_avoid_conflicts(changewhichcantacceptedallone, changes):