42
42
43
43
def usage ():
44
44
45
- print """\
45
+ print ( """\
46
46
%s: [OPTIONS] <hgprj>
47
47
48
48
options:
@@ -54,7 +54,7 @@ def usage():
54
54
55
55
required:
56
56
hgprj: name of the HG project to import (directory)
57
- """ % sys .argv [0 ]
57
+ """ % sys .argv [0 ])
58
58
59
59
#------------------------------------------------------------------------------
60
60
@@ -104,22 +104,22 @@ def getgitenv(user, date):
104
104
if state :
105
105
if os .path .exists (state ):
106
106
if verbose :
107
- print 'State does exist, reading'
107
+ print ( 'State does exist, reading' )
108
108
f = open (state , 'r' )
109
109
hgvers = pickle .load (f )
110
110
else :
111
- print 'State does not exist, first run'
111
+ print ( 'State does not exist, first run' )
112
112
113
113
sock = os .popen ('hg tip --template "{rev}"' )
114
114
tip = sock .read ()
115
115
if sock .close ():
116
116
sys .exit (1 )
117
117
if verbose :
118
- print 'tip is' , tip
118
+ print ( 'tip is' , tip )
119
119
120
120
# Calculate the branches
121
121
if verbose :
122
- print 'analysing the branches...'
122
+ print ( 'analysing the branches...' )
123
123
hgchildren ["0" ] = ()
124
124
hgparents ["0" ] = (None , None )
125
125
hgbranch ["0" ] = "master"
@@ -154,15 +154,15 @@ def getgitenv(user, date):
154
154
else :
155
155
hgbranch [str (cset )] = "branch-" + str (cset )
156
156
157
- if not hgvers . has_key ( "0" ) :
158
- print 'creating repository'
157
+ if "0" not in hgvers :
158
+ print ( 'creating repository' )
159
159
os .system ('git init' )
160
160
161
161
# loop through every hg changeset
162
162
for cset in range (int (tip ) + 1 ):
163
163
164
164
# incremental, already seen
165
- if hgvers . has_key ( str (cset )) :
165
+ if str (cset ) in hgvers :
166
166
continue
167
167
hgnewcsets += 1
168
168
@@ -180,27 +180,27 @@ def getgitenv(user, date):
180
180
os .write (fdcomment , csetcomment )
181
181
os .close (fdcomment )
182
182
183
- print '-----------------------------------------'
184
- print 'cset:' , cset
185
- print 'branch:' , hgbranch [str (cset )]
186
- print 'user:' , user
187
- print 'date:' , date
188
- print 'comment:' , csetcomment
183
+ print ( '-----------------------------------------' )
184
+ print ( 'cset:' , cset )
185
+ print ( 'branch:' , hgbranch [str (cset )])
186
+ print ( 'user:' , user )
187
+ print ( 'date:' , date )
188
+ print ( 'comment:' , csetcomment )
189
189
if parent :
190
- print 'parent:' , parent
190
+ print ( 'parent:' , parent )
191
191
if mparent :
192
- print 'mparent:' , mparent
192
+ print ( 'mparent:' , mparent )
193
193
if tag :
194
- print 'tag:' , tag
195
- print '-----------------------------------------'
194
+ print ( 'tag:' , tag )
195
+ print ( '-----------------------------------------' )
196
196
197
197
# checkout the parent if necessary
198
198
if cset != 0 :
199
199
if hgbranch [str (cset )] == "branch-" + str (cset ):
200
- print 'creating new branch' , hgbranch [str (cset )]
200
+ print ( 'creating new branch' , hgbranch [str (cset )])
201
201
os .system ('git checkout -b %s %s' % (hgbranch [str (cset )], hgvers [parent ]))
202
202
else :
203
- print 'checking out branch' , hgbranch [str (cset )]
203
+ print ( 'checking out branch' , hgbranch [str (cset )])
204
204
os .system ('git checkout %s' % hgbranch [str (cset )])
205
205
206
206
# merge
@@ -209,7 +209,7 @@ def getgitenv(user, date):
209
209
otherbranch = hgbranch [mparent ]
210
210
else :
211
211
otherbranch = hgbranch [parent ]
212
- print 'merging' , otherbranch , 'into' , hgbranch [str (cset )]
212
+ print ( 'merging' , otherbranch , 'into' , hgbranch [str (cset )])
213
213
os .system (getgitenv (user , date ) + 'git merge --no-commit -s ours "" %s %s' % (hgbranch [str (cset )], otherbranch ))
214
214
215
215
# remove everything except .git and .hg directories
@@ -233,12 +233,12 @@ def getgitenv(user, date):
233
233
234
234
# delete branch if not used anymore...
235
235
if mparent and len (hgchildren [str (cset )]):
236
- print "Deleting unused branch:" , otherbranch
236
+ print ( "Deleting unused branch:" , otherbranch )
237
237
os .system ('git branch -d %s' % otherbranch )
238
238
239
239
# retrieve and record the version
240
240
vvv = os .popen ('git show --quiet --pretty=format:%H' ).read ()
241
- print 'record' , cset , '->' , vvv
241
+ print ( 'record' , cset , '->' , vvv )
242
242
hgvers [str (cset )] = vvv
243
243
244
244
if hgnewcsets >= opt_nrepack and opt_nrepack != - 1 :
@@ -247,7 +247,7 @@ def getgitenv(user, date):
247
247
# write the state for incrementals
248
248
if state :
249
249
if verbose :
250
- print 'Writing state'
250
+ print ( 'Writing state' )
251
251
f = open (state , 'w' )
252
252
pickle .dump (hgvers , f )
253
253
0 commit comments