@@ -34,7 +34,7 @@ def run(self):
34
34
orig_head = GitExplodeUtils .get_head ()
35
35
commits , deps_from , deps_on = self .get_dependencies ()
36
36
self .explode (commits , deps_from , deps_on )
37
- print ( " checkout %s" % orig_head )
37
+ self . checkout ( orig_head )
38
38
39
39
def get_dependencies (self ):
40
40
"""
@@ -101,14 +101,12 @@ def explode(self, commits, deps_from, deps_on):
101
101
deps = deps_from [sha ]
102
102
103
103
if not deps :
104
- base_desc = GitUtils .commit_summary (self .base_commit )
105
104
branch = self .topic_mgr .register (sha )
106
- print ("checkout %s on base %s" % (branch , base_desc ))
107
- self .current_branch = branch
105
+ self .checkout_new (branch , self .base )
108
106
else :
109
107
self .prepare_cherrypick_base (sha , deps .keys (), commits )
110
108
111
- print ( "cherrypick %s" % GitUtils . commit_summary ( commit ) )
109
+ GitExplodeUtils . git ( 'cherry-pick' , sha )
112
110
113
111
self .queue_new_leaves (todo , commit , commits , deps_on ,
114
112
unexploded_deps_from )
@@ -121,21 +119,18 @@ def prepare_cherrypick_base(self, sha, deps, commits):
121
119
branch = existing_branch
122
120
self .topic_mgr .assign (branch , sha )
123
121
if self .current_branch != branch :
124
- print ("checkout %s" % branch )
125
- self .current_branch = branch
122
+ self .checkout (branch )
126
123
else :
127
124
if existing_branch is None :
128
125
branch = self .topic_mgr .register (* deps )
129
- base_desc = GitUtils .commit_summary (commits [deps [0 ]])
130
- print ("checkout %s on %s" % (branch , base_desc ))
131
- self .current_branch = branch
126
+ self .checkout_new (branch , deps [0 ])
132
127
to_merge = deps [1 :]
133
- print ( " merge %s" % ' ' . join ( to_merge ) )
128
+ GitExplodeUtils . git ( ' merge' , * to_merge )
134
129
else :
135
130
# Can reuse existing merge commit, but
136
131
# create a new branch at the same point
137
132
branch = self .topic_mgr .register (* deps )
138
- print ( "checkout -b %s %s" % ( branch , existing_branch ) )
133
+ self . checkout_new ( branch , existing_branch )
139
134
140
135
def queue_new_leaves (self , todo , exploded_commit , commits , deps_on ,
141
136
unexploded_deps_from ):
@@ -165,3 +160,13 @@ def get_leaves(self, commits, deps_from):
165
160
if len (dependencies ) == 0 :
166
161
leaves .append (commits [sha ])
167
162
return leaves
163
+
164
+ def checkout (self , branch ):
165
+ self .logger .debug ("checkout %s" % branch )
166
+ GitExplodeUtils .checkout (branch )
167
+ self .current_branch = branch
168
+
169
+ def checkout_new (self , branch , at ):
170
+ self .logger .debug ("checkout -b %s %s" % (branch , at ))
171
+ GitExplodeUtils .checkout_new (branch , at )
172
+ self .current_branch = branch
0 commit comments