Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f53fe1

Browse filesBrowse files
committed
Merge branch 'hb/hg-to-git-py3'
The hg-to-git script (in contrib/) has been updated to work with Python 3. * hb/hg-to-git-py3: hg-to-git: make it compatible with both python3 and python2
2 parents ef93bfb + d17ae00 commit 8f53fe1
Copy full SHA for 8f53fe1

File tree

Expand file treeCollapse file tree

1 file changed

+25
-25
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-25
lines changed
Open diff view settings
Collapse file

‎contrib/hg-to-git/hg-to-git.py‎

Copy file name to clipboardExpand all lines: contrib/hg-to-git/hg-to-git.py
+25-25Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
def usage():
4444

45-
print """\
45+
print("""\
4646
%s: [OPTIONS] <hgprj>
4747
4848
options:
@@ -54,7 +54,7 @@ def usage():
5454
5555
required:
5656
hgprj: name of the HG project to import (directory)
57-
""" % sys.argv[0]
57+
""" % sys.argv[0])
5858

5959
#------------------------------------------------------------------------------
6060

@@ -104,22 +104,22 @@ def getgitenv(user, date):
104104
if state:
105105
if os.path.exists(state):
106106
if verbose:
107-
print 'State does exist, reading'
107+
print('State does exist, reading')
108108
f = open(state, 'r')
109109
hgvers = pickle.load(f)
110110
else:
111-
print 'State does not exist, first run'
111+
print('State does not exist, first run')
112112

113113
sock = os.popen('hg tip --template "{rev}"')
114114
tip = sock.read()
115115
if sock.close():
116116
sys.exit(1)
117117
if verbose:
118-
print 'tip is', tip
118+
print('tip is', tip)
119119

120120
# Calculate the branches
121121
if verbose:
122-
print 'analysing the branches...'
122+
print('analysing the branches...')
123123
hgchildren["0"] = ()
124124
hgparents["0"] = (None, None)
125125
hgbranch["0"] = "master"
@@ -154,15 +154,15 @@ def getgitenv(user, date):
154154
else:
155155
hgbranch[str(cset)] = "branch-" + str(cset)
156156

157-
if not hgvers.has_key("0"):
158-
print 'creating repository'
157+
if "0" not in hgvers:
158+
print('creating repository')
159159
os.system('git init')
160160

161161
# loop through every hg changeset
162162
for cset in range(int(tip) + 1):
163163

164164
# incremental, already seen
165-
if hgvers.has_key(str(cset)):
165+
if str(cset) in hgvers:
166166
continue
167167
hgnewcsets += 1
168168

@@ -180,27 +180,27 @@ def getgitenv(user, date):
180180
os.write(fdcomment, csetcomment)
181181
os.close(fdcomment)
182182

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)
189189
if parent:
190-
print 'parent:', parent
190+
print('parent:', parent)
191191
if mparent:
192-
print 'mparent:', mparent
192+
print('mparent:', mparent)
193193
if tag:
194-
print 'tag:', tag
195-
print '-----------------------------------------'
194+
print('tag:', tag)
195+
print('-----------------------------------------')
196196

197197
# checkout the parent if necessary
198198
if cset != 0:
199199
if hgbranch[str(cset)] == "branch-" + str(cset):
200-
print 'creating new branch', hgbranch[str(cset)]
200+
print('creating new branch', hgbranch[str(cset)])
201201
os.system('git checkout -b %s %s' % (hgbranch[str(cset)], hgvers[parent]))
202202
else:
203-
print 'checking out branch', hgbranch[str(cset)]
203+
print('checking out branch', hgbranch[str(cset)])
204204
os.system('git checkout %s' % hgbranch[str(cset)])
205205

206206
# merge
@@ -209,7 +209,7 @@ def getgitenv(user, date):
209209
otherbranch = hgbranch[mparent]
210210
else:
211211
otherbranch = hgbranch[parent]
212-
print 'merging', otherbranch, 'into', hgbranch[str(cset)]
212+
print('merging', otherbranch, 'into', hgbranch[str(cset)])
213213
os.system(getgitenv(user, date) + 'git merge --no-commit -s ours "" %s %s' % (hgbranch[str(cset)], otherbranch))
214214

215215
# remove everything except .git and .hg directories
@@ -233,12 +233,12 @@ def getgitenv(user, date):
233233

234234
# delete branch if not used anymore...
235235
if mparent and len(hgchildren[str(cset)]):
236-
print "Deleting unused branch:", otherbranch
236+
print("Deleting unused branch:", otherbranch)
237237
os.system('git branch -d %s' % otherbranch)
238238

239239
# retrieve and record the version
240240
vvv = os.popen('git show --quiet --pretty=format:%H').read()
241-
print 'record', cset, '->', vvv
241+
print('record', cset, '->', vvv)
242242
hgvers[str(cset)] = vvv
243243

244244
if hgnewcsets >= opt_nrepack and opt_nrepack != -1:
@@ -247,7 +247,7 @@ def getgitenv(user, date):
247247
# write the state for incrementals
248248
if state:
249249
if verbose:
250-
print 'Writing state'
250+
print('Writing state')
251251
f = open(state, 'w')
252252
pickle.dump(hgvers, f)
253253

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.