diff --git a/.travis.yml b/.travis.yml index ffb1bc46f2d960..62557dc8fd37ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,6 +39,10 @@ matrix: compiler: script: ci/test-documentation.sh after_failure: + - env: jobname=LintPython + language: python + before_install: pip install flake8 + script: flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics before_install: ci/install-dependencies.sh script: ci/run-build-and-tests.sh diff --git a/contrib/fast-import/import-zips.py b/contrib/fast-import/import-zips.py index d12c2962230b80..138194475cbc71 100755 --- a/contrib/fast-import/import-zips.py +++ b/contrib/fast-import/import-zips.py @@ -8,6 +8,7 @@ ## python import-zips.py *.zip ## git log --stat import-zips +from __future__ import print_function from os import popen, path from sys import argv, exit, hexversion, stderr from time import mktime @@ -19,7 +20,7 @@ exit(1) if len(argv) < 2: - print 'usage:', argv[0], '...' + print('usage:', argv[0], '...') exit(1) branch_ref = 'refs/heads/import-zips' diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py index de3f81667ed972..1d5e5156a4f1f3 100755 --- a/contrib/hg-to-git/hg-to-git.py +++ b/contrib/hg-to-git/hg-to-git.py @@ -18,6 +18,7 @@ along with this program; if not, see . """ +from __future__ import print_function import os, os.path, sys import tempfile, pickle, getopt import re @@ -42,7 +43,7 @@ def usage(): - print """\ + print("""\ %s: [OPTIONS] options: @@ -54,7 +55,7 @@ def usage(): required: hgprj: name of the HG project to import (directory) -""" % sys.argv[0] +""" % sys.argv[0]) #------------------------------------------------------------------------------ @@ -104,22 +105,22 @@ def getgitenv(user, date): if state: if os.path.exists(state): if verbose: - print 'State does exist, reading' + print('State does exist, reading') f = open(state, 'r') hgvers = pickle.load(f) else: - print 'State does not exist, first run' + print('State does not exist, first run') sock = os.popen('hg tip --template "{rev}"') tip = sock.read() if sock.close(): sys.exit(1) if verbose: - print 'tip is', tip + print('tip is', tip) # Calculate the branches if verbose: - print 'analysing the branches...' + print('analysing the branches...') hgchildren["0"] = () hgparents["0"] = (None, None) hgbranch["0"] = "master" @@ -155,7 +156,7 @@ def getgitenv(user, date): hgbranch[str(cset)] = "branch-" + str(cset) if not hgvers.has_key("0"): - print 'creating repository' + print('creating repository') os.system('git init') # loop through every hg changeset @@ -180,27 +181,27 @@ def getgitenv(user, date): os.write(fdcomment, csetcomment) os.close(fdcomment) - print '-----------------------------------------' - print 'cset:', cset - print 'branch:', hgbranch[str(cset)] - print 'user:', user - print 'date:', date - print 'comment:', csetcomment + print('-----------------------------------------') + print('cset:', cset) + print('branch:', hgbranch[str(cset)]) + print('user:', user) + print('date:', date) + print('comment:', csetcomment) if parent: - print 'parent:', parent + print('parent:', parent) if mparent: - print 'mparent:', mparent + print('mparent:', mparent) if tag: - print 'tag:', tag - print '-----------------------------------------' + print('tag:', tag) + print('-----------------------------------------') # checkout the parent if necessary if cset != 0: if hgbranch[str(cset)] == "branch-" + str(cset): - print 'creating new branch', hgbranch[str(cset)] + print('creating new branch', hgbranch[str(cset)]) os.system('git checkout -b %s %s' % (hgbranch[str(cset)], hgvers[parent])) else: - print 'checking out branch', hgbranch[str(cset)] + print('checking out branch', hgbranch[str(cset)]) os.system('git checkout %s' % hgbranch[str(cset)]) # merge @@ -209,7 +210,7 @@ def getgitenv(user, date): otherbranch = hgbranch[mparent] else: otherbranch = hgbranch[parent] - print 'merging', otherbranch, 'into', hgbranch[str(cset)] + print('merging', otherbranch, 'into', hgbranch[str(cset)]) os.system(getgitenv(user, date) + 'git merge --no-commit -s ours "" %s %s' % (hgbranch[str(cset)], otherbranch)) # remove everything except .git and .hg directories @@ -233,12 +234,12 @@ def getgitenv(user, date): # delete branch if not used anymore... if mparent and len(hgchildren[str(cset)]): - print "Deleting unused branch:", otherbranch + print("Deleting unused branch:", otherbranch) os.system('git branch -d %s' % otherbranch) # retrieve and record the version vvv = os.popen('git show --quiet --pretty=format:%H').read() - print 'record', cset, '->', vvv + print('record', cset, '->', vvv) hgvers[str(cset)] = vvv if hgnewcsets >= opt_nrepack and opt_nrepack != -1: @@ -247,7 +248,7 @@ def getgitenv(user, date): # write the state for incrementals if state: if verbose: - print 'Writing state' + print('Writing state') f = open(state, 'w') pickle.dump(hgvers, f) diff --git a/git-p4.py b/git-p4.py index 3991e7d1a7fc4d..9faee25db26da3 100755 --- a/git-p4.py +++ b/git-p4.py @@ -36,6 +36,8 @@ unicode = str bytes = bytes basestring = (str,bytes) + raw_input = input + from functools import reduce else: # 'unicode' exists, must be Python 2 str = str @@ -3968,6 +3970,7 @@ def renameBranch(self, branch_name): break if not found: + sync = P4Sync() sys.exit("gave up trying to rename existing branch {0}".format(sync.branch)) def findLastP4Revision(self, starting_point):