git-p4: python3: use print() function
Replace calls to print ... with the function form, print(...), to allow use with python3 as well as python2.x. Converted using 2to3 (and some hand-editing). Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Luke Diamand committed
Jun 19, 2018 at 09:04 UTC
f2606b1797fdffe40b00a6766ca1df6e1e0f3a60
1 file changed
+124
-124
git-p4.py
+124
-124
@@ -892,7 +892,7 @@ def findUpstreamBranchPoint(head = "HEAD"):
892
893
def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent=True):
894
if not silent:
895
- print ("Creating/updating branch(es) in %s based on origin branch(es)"
895
+ print("Creating/updating branch(es) in %s based on origin branch(es)"
896
% localRefPrefix)
897
898
originPrefix = "origin/p4/"
@@ -914,7 +914,7 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
914
update = False
915
if not gitBranchExists(remoteHead):
916
if verbose:
917
- print "creating %s" % remoteHead
917
+ print("creating %s" % remoteHead)
918
update = True
919
else:
920
settings = extractSettingsGitLog(extractLogMessageFromGitCommit(remoteHead))
@@ -923,13 +923,13 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
923
originP4Change = int(original['change'])
924
p4Change = int(settings['change'])
925
if originP4Change > p4Change:
926
- print ("%s (%s) is newer than %s (%s). "
926
+ print("%s (%s) is newer than %s (%s). "
927
"Updating p4 branch from origin."
928
% (originHead, originP4Change,
929
remoteHead, p4Change))
930
update = True
931
else:
932
- print ("Ignoring: %s was imported from %s while "
932
+ print("Ignoring: %s was imported from %s while "
933
"%s was imported from %s"
934
% (originHead, ','.join(original['depot-paths']),
935
remoteHead, ','.join(settings['depot-paths'])))
@@ -1397,9 +1397,9 @@ class P4Debug(Command):
1397
def run(self, args):
1398
j = 0
1399
for output in p4CmdList(args):
1400
- print 'Element: %d' % j
1400
+ print('Element: %d' % j)
1401
j += 1
1402
- print output
1402
+ print(output)
1403
return True
1404
1405
class P4RollBack(Command):
@@ -1440,14 +1440,14 @@ class P4RollBack(Command):
1440
1441
if len(p4Cmd("changes -m 1 " + ' '.join (['%s...@%s' % (p, maxChange)
1442
for p in depotPaths]))) == 0:
1443
- print "Branch %s did not exist at change %s, deleting." % (ref, maxChange)
1443
+ print("Branch %s did not exist at change %s, deleting." % (ref, maxChange))
1444
system("git update-ref -d %s `git rev-parse %s`" % (ref, ref))
1445
continue
1446
1447
while change and int(change) > maxChange:
1448
changed = True
1449
if self.verbose:
1450
- print "%s is at %s ; rewinding towards %s" % (ref, change, maxChange)
1450
+ print("%s is at %s ; rewinding towards %s" % (ref, change, maxChange))
1451
system("git update-ref %s \"%s^\"" % (ref, ref))
1452
log = extractLogMessageFromGitCommit(ref)
1453
settings = extractSettingsGitLog(log)
@@ -1457,7 +1457,7 @@ class P4RollBack(Command):
1457
change = settings['change']
1458
1459
if changed:
1460
- print "%s rewound to %s" % (ref, change)
1460
+ print("%s rewound to %s" % (ref, change))
1461
1462
return True
1463
@@ -1593,10 +1593,10 @@ class P4Submit(Command, P4UserMap):
1593
except:
1594
# cleanup our temporary file
1595
os.unlink(outFileName)
1596
- print "Failed to strip RCS keywords in %s" % file
1596
+ print("Failed to strip RCS keywords in %s" % file)
1597
raise
1598
1599
- print "Patched up RCS keywords in %s" % file
1599
+ print("Patched up RCS keywords in %s" % file)
1600
1601
def p4UserForCommit(self,id):
1602
# Return the tuple (perforce user,git email) for a given git commit id
@@ -1616,7 +1616,7 @@ class P4Submit(Command, P4UserMap):
1616
if not user:
1617
msg = "Cannot find p4 user for email %s in commit %s." % (email, id)
1618
if gitConfigBool("git-p4.allowMissingP4Users"):
1619
- print "%s" % msg
1619
+ print("%s" % msg)
1620
else:
1621
die("Error: %s\nSet git-p4.allowMissingP4Users to true to allow this." % msg)
1622
@@ -1808,8 +1808,8 @@ class P4Submit(Command, P4UserMap):
1808
def applyCommit(self, id):
1809
"""Apply one commit, return True if it succeeded."""
1810
1811
- print "Applying", read_pipe(["git", "show", "-s",
1812
- "--format=format:%h %s", id])
1811
+ print("Applying", read_pipe(["git", "show", "-s",
1812
+ "--format=format:%h %s", id]))
1813
1814
(p4User, gitEmail) = self.p4UserForCommit(id)
1815
@@ -1899,7 +1899,7 @@ class P4Submit(Command, P4UserMap):
1899
if os.system(tryPatchCmd) != 0:
1900
fixed_rcs_keywords = False
1901
patch_succeeded = False
1902
- print "Unfortunately applying the change failed!"
1902
+ print("Unfortunately applying the change failed!")
1903
1904
# Patch failed, maybe it's just RCS keyword woes. Look through
1905
# the patch to see if that's possible.
@@ -1917,13 +1917,13 @@ class P4Submit(Command, P4UserMap):
1917
for line in read_pipe_lines(["git", "diff", "%s^..%s" % (id, id), file]):
1918
if regexp.search(line):
1919
if verbose:
1920
- print "got keyword match on %s in %s in %s" % (pattern, line, file)
1920
+ print("got keyword match on %s in %s in %s" % (pattern, line, file))
1921
kwfiles[file] = pattern
1922
break
1923
1924
for file in kwfiles:
1925
if verbose:
1926
- print "zapping %s with %s" % (line,pattern)
1926
+ print("zapping %s with %s" % (line,pattern))
1927
# File is being deleted, so not open in p4. Must
1928
# disable the read-only bit on windows.
1929
if self.isWindows and file not in editedFiles:
@@ -1932,7 +1932,7 @@ class P4Submit(Command, P4UserMap):
1932
fixed_rcs_keywords = True
1933
1934
if fixed_rcs_keywords:
1935
- print "Retrying the patch with RCS keywords cleaned up"
1935
+ print("Retrying the patch with RCS keywords cleaned up")
1936
if os.system(tryPatchCmd) == 0:
1937
patch_succeeded = True
1938
@@ -2000,34 +2000,34 @@ class P4Submit(Command, P4UserMap):
2000
# Leave the p4 tree prepared, and the submit template around
2001
# and let the user decide what to do next
2002
#
2003
- print
2004
- print "P4 workspace prepared for submission."
2005
- print "To submit or revert, go to client workspace"
2006
- print " " + self.clientPath
2007
- print
2008
- print "To submit, use \"p4 submit\" to write a new description,"
2009
- print "or \"p4 submit -i <%s\" to use the one prepared by" \
2010
- " \"git p4\"." % fileName
2011
- print "You can delete the file \"%s\" when finished." % fileName
2003
+ print()
2004
+ print("P4 workspace prepared for submission.")
2005
+ print("To submit or revert, go to client workspace")
2006
+ print(" " + self.clientPath)
2007
+ print()
2008
+ print("To submit, use \"p4 submit\" to write a new description,")
2009
+ print("or \"p4 submit -i <%s\" to use the one prepared by" \
2010
+ " \"git p4\"." % fileName)
2011
+ print("You can delete the file \"%s\" when finished." % fileName)
2012
2013
if self.preserveUser and p4User and not self.p4UserIsMe(p4User):
2014
- print "To preserve change ownership by user %s, you must\n" \
2014
+ print("To preserve change ownership by user %s, you must\n" \
2015
"do \"p4 change -f <change>\" after submitting and\n" \
2016
- "edit the User field."
2016
+ "edit the User field.")
2017
if pureRenameCopy:
2018
- print "After submitting, renamed files must be re-synced."
2019
- print "Invoke \"p4 sync -f\" on each of these files:"
2018
+ print("After submitting, renamed files must be re-synced.")
2019
+ print("Invoke \"p4 sync -f\" on each of these files:")
2020
for f in pureRenameCopy:
2021
- print " " + f
2021
+ print(" " + f)
2022
2023
- print
2024
- print "To revert the changes, use \"p4 revert ...\", and delete"
2025
- print "the submit template file \"%s\"" % fileName
2023
+ print()
2024
+ print("To revert the changes, use \"p4 revert ...\", and delete")
2025
+ print("the submit template file \"%s\"" % fileName)
2026
if filesToAdd:
2027
- print "Since the commit adds new files, they must be deleted:"
2027
+ print("Since the commit adds new files, they must be deleted:")
2028
for f in filesToAdd:
2029
- print " " + f
2030
- print
2029
+ print(" " + f)
2030
+ print()
2031
return True
2032
2033
#
@@ -2094,7 +2094,7 @@ class P4Submit(Command, P4UserMap):
2094
2095
if not m.match(name):
2096
if verbose:
2097
- print "tag %s does not match regexp %s" % (name, validLabelRegexp)
2097
+ print("tag %s does not match regexp %s" % (name, validLabelRegexp))
2098
continue
2099
2100
# Get the p4 commit this corresponds to
@@ -2104,7 +2104,7 @@ class P4Submit(Command, P4UserMap):
2104
if 'change' not in values:
2105
# a tag pointing to something not sent to p4; ignore
2106
if verbose:
2107
- print "git tag %s does not give a p4 commit" % name
2107
+ print("git tag %s does not give a p4 commit" % name)
2108
continue
2109
else:
2110
changelist = values['change']
@@ -2139,10 +2139,10 @@ class P4Submit(Command, P4UserMap):
2139
labelTemplate += "\t%s\n" % depot_side
2140
2141
if self.dry_run:
2142
- print "Would create p4 label %s for tag" % name
2142
+ print("Would create p4 label %s for tag" % name)
2143
elif self.prepare_p4_only:
2144
- print "Not creating p4 label %s for tag due to option" \
2145
- " --prepare-p4-only" % name
2144
+ print("Not creating p4 label %s for tag due to option" \
2145
+ " --prepare-p4-only" % name)
2146
else:
2147
p4_write_pipe(["label", "-i"], labelTemplate)
2148
@@ -2151,7 +2151,7 @@ class P4Submit(Command, P4UserMap):
2151
["%s@%s" % (depot_side, changelist) for depot_side in clientSpec.mappings])
2152
2153
if verbose:
2154
- print "created p4 label for tag %s" % name
2154
+ print("created p4 label for tag %s" % name)
2155
2156
def run(self, args):
2157
if len(args) == 0:
@@ -2195,10 +2195,10 @@ class P4Submit(Command, P4UserMap):
2195
self.conflict_behavior = val
2196
2197
if self.verbose:
2198
- print "Origin branch is " + self.origin
2198
+ print("Origin branch is " + self.origin)
2199
2200
if len(self.depotPath) == 0:
2201
- print "Internal error: cannot locate perforce depot path from existing branches"
2201
+ print("Internal error: cannot locate perforce depot path from existing branches")
2202
sys.exit(128)
2203
2204
self.useClientSpec = False
@@ -2219,7 +2219,7 @@ class P4Submit(Command, P4UserMap):
2219
if self.clientPath == "":
2220
die("Error: Cannot locate perforce checkout of %s in client view" % self.depotPath)
2221
2222
- print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
2222
+ print("Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath))
2223
self.oldWorkingDirectory = os.getcwd()
2224
2225
# ensure the clientPath exists
@@ -2230,9 +2230,9 @@ class P4Submit(Command, P4UserMap):
2230
2231
chdir(self.clientPath, is_client_path=True)
2232
if self.dry_run:
2233
- print "Would synchronize p4 checkout in %s" % self.clientPath
2233
+ print("Would synchronize p4 checkout in %s" % self.clientPath)
2234
else:
2235
- print "Synchronizing p4 checkout..."
2235
+ print("Synchronizing p4 checkout...")
2236
if new_client_dir:
2237
# old one was destroyed, and maybe nobody told p4
2238
p4_sync("...", "-f")
@@ -2308,13 +2308,13 @@ class P4Submit(Command, P4UserMap):
2308
# continue to try the rest of the patches, or quit.
2309
#
2310
if self.dry_run:
2311
- print "Would apply"
2311
+ print("Would apply")
2312
applied = []
2313
last = len(commits) - 1
2314
for i, commit in enumerate(commits):
2315
if self.dry_run:
2316
- print " ", read_pipe(["git", "show", "-s",
2317
- "--format=format:%h %s", commit])
2316
+ print(" ", read_pipe(["git", "show", "-s",
2317
+ "--format=format:%h %s", commit]))
2318
ok = True
2319
else:
2320
ok = self.applyCommit(commit)
@@ -2322,15 +2322,15 @@ class P4Submit(Command, P4UserMap):
2322
applied.append(commit)
2323
else:
2324
if self.prepare_p4_only and i < last:
2325
- print "Processing only the first commit due to option" \
2326
- " --prepare-p4-only"
2325
+ print("Processing only the first commit due to option" \
2326
+ " --prepare-p4-only")
2327
break
2328
if i < last:
2329
quit = False
2330
while True:
2331
# prompt for what to do, or use the option/variable
2332
if self.conflict_behavior == "ask":
2333
- print "What do you want to do?"
2333
+ print("What do you want to do?")
2334
response = raw_input("[s]kip this commit but apply"
2335
" the rest, or [q]uit? ")
2336
if not response:
@@ -2344,10 +2344,10 @@ class P4Submit(Command, P4UserMap):
2344
self.conflict_behavior)
2345
2346
if response[0] == "s":
2347
- print "Skipping this commit, but applying the rest"
2347
+ print("Skipping this commit, but applying the rest")
2348
break
2349
if response[0] == "q":
2350
- print "Quitting"
2350
+ print("Quitting")
2351
quit = True
2352
break
2353
if quit:
@@ -2360,7 +2360,7 @@ class P4Submit(Command, P4UserMap):
2360
elif self.prepare_p4_only:
2361
pass
2362
elif len(commits) == len(applied):
2363
- print ("All commits {0}!".format(shelved_applied))
2363
+ print("All commits {0}!".format(shelved_applied))
2364
2365
sync = P4Sync()
2366
if self.branch:
@@ -2376,17 +2376,17 @@ class P4Submit(Command, P4UserMap):
2376
2377
else:
2378
if len(applied) == 0:
2379
- print ("No commits {0}.".format(shelved_applied))
2379
+ print("No commits {0}.".format(shelved_applied))
2380
else:
2381
- print ("{0} only the commits marked with '*':".format(shelved_applied.capitalize()))
2381
+ print("{0} only the commits marked with '*':".format(shelved_applied.capitalize()))
2382
for c in commits:
2383
if c in applied:
2384
star = "*"
2385
else:
2386
star = " "
2387
- print star, read_pipe(["git", "show", "-s",
2388
- "--format=format:%h %s", c])
2389
- print "You will have to do 'git p4 sync' and rebase."
2387
+ print(star, read_pipe(["git", "show", "-s",
2388
+ "--format=format:%h %s", c]))
2389
+ print("You will have to do 'git p4 sync' and rebase.")
2390
2391
if gitConfigBool("git-p4.exportLabels"):
2392
self.exportLabels = True
@@ -2596,7 +2596,7 @@ class P4Sync(Command, P4UserMap):
2596
self.gitStream.write("progress checkpoint\n\n")
2597
out = self.gitOutput.readline()
2598
if self.verbose:
2599
- print "checkpoint finished: " + out
2599
+ print("checkpoint finished: " + out)
2600
2601
def cmp_shelved(self, path, filerev, revision):
2602
""" Determine if a path at revision #filerev is the same as the file
@@ -2751,7 +2751,7 @@ class P4Sync(Command, P4UserMap):
2751
encoding = gitConfig('git-p4.pathEncoding')
2752
path = path.decode(encoding, 'replace').encode('utf8', 'replace')
2753
if self.verbose:
2754
- print 'Path with non-ASCII characters detected. Used %s to encode: %s ' % (encoding, path)
2754
+ print('Path with non-ASCII characters detected. Used %s to encode: %s ' % (encoding, path))
2755
return path
2756
2757
# output one file from the P4 stream
@@ -2780,7 +2780,7 @@ class P4Sync(Command, P4UserMap):
2780
# to nothing. This causes p4 errors when checking out such
2781
# a change, and errors here too. Work around it by ignoring
2782
# the bad symlink; hopefully a future change fixes it.
2783
- print "\nIgnoring empty symlink in %s" % file['depotFile']
2783
+ print("\nIgnoring empty symlink in %s" % file['depotFile'])
2784
return
2785
elif data[-1] == '\n':
2786
contents = [data[:-1]]
@@ -2820,7 +2820,7 @@ class P4Sync(Command, P4UserMap):
2820
# Ideally, someday, this script can learn how to generate
2821
# appledouble files directly and import those to git, but
2822
# non-mac machines can never find a use for apple filetype.
2823
- print "\nIgnoring apple filetype file %s" % file['depotFile']
2823
+ print("\nIgnoring apple filetype file %s" % file['depotFile'])
2824
return
2825
2826
# Note that we do not try to de-mangle keywords on utf16 files,
@@ -2969,7 +2969,7 @@ class P4Sync(Command, P4UserMap):
2969
"""
2970
2971
if verbose:
2972
- print "writing tag %s for commit %s" % (labelName, commit)
2972
+ print("writing tag %s for commit %s" % (labelName, commit))
2973
gitStream.write("tag %s\n" % labelName)
2974
gitStream.write("from %s\n" % commit)
2975
@@ -2988,7 +2988,7 @@ class P4Sync(Command, P4UserMap):
2988
2989
gitStream.write("tagger %s\n" % tagger)
2990
2991
- print "labelDetails=",labelDetails
2991
+ print("labelDetails=",labelDetails)
2992
if 'Description' in labelDetails:
2993
description = labelDetails['Description']
2994
else:
@@ -3060,7 +3060,7 @@ class P4Sync(Command, P4UserMap):
3060
3061
if len(parent) > 0:
3062
if self.verbose:
3063
- print "parent %s" % parent
3063
+ print("parent %s" % parent)
3064
self.gitStream.write("from %s\n" % parent)
3065
3066
self.streamP4Files(files)
@@ -3073,7 +3073,7 @@ class P4Sync(Command, P4UserMap):
3073
labelDetails = label[0]
3074
labelRevisions = label[1]
3075
if self.verbose:
3076
- print "Change %s is labelled %s" % (change, labelDetails)
3076
+ print("Change %s is labelled %s" % (change, labelDetails))
3077
3078
files = p4CmdList(["files"] + ["%s...@%s" % (p, change)
3079
for p in self.branchPrefixes])
@@ -3091,12 +3091,12 @@ class P4Sync(Command, P4UserMap):
3091
3092
else:
3093
if not self.silent:
3094
- print ("Tag %s does not match with change %s: files do not match."
3094
+ print("Tag %s does not match with change %s: files do not match."
3095
% (labelDetails["label"], change))
3096
3097
else:
3098
if not self.silent:
3099
- print ("Tag %s does not match with change %s: file count is different."
3099
+ print("Tag %s does not match with change %s: file count is different."
3100
% (labelDetails["label"], change))
3101
3102
# Build a dictionary of changelists and labels, for "detect-labels" option.
@@ -3112,7 +3112,7 @@ class P4Sync(Command, P4UserMap):
3112
revisions = {}
3113
newestChange = 0
3114
if self.verbose:
3115
- print "Querying files for label %s" % label
3115
+ print("Querying files for label %s" % label)
3116
for file in p4CmdList(["files"] +
3117
["%s...@%s" % (p, label)
3118
for p in self.depotPaths]):
@@ -3124,7 +3124,7 @@ class P4Sync(Command, P4UserMap):
3124
self.labels[newestChange] = [output, revisions]
3125
3126
if self.verbose:
3127
- print "Label changes: %s" % self.labels.keys()
3127
+ print("Label changes: %s" % self.labels.keys())
3128
3129
# Import p4 labels as git tags. A direct mapping does not
3130
# exist, so assume that if all the files are at the same revision
@@ -3132,7 +3132,7 @@ class P4Sync(Command, P4UserMap):
3132
# just ignore.
3133
def importP4Labels(self, stream, p4Labels):
3134
if verbose:
3135
- print "import p4 labels: " + ' '.join(p4Labels)
3135
+ print("import p4 labels: " + ' '.join(p4Labels))
3136
3137
ignoredP4Labels = gitConfigList("git-p4.ignoredP4Labels")
3138
validLabelRegexp = gitConfig("git-p4.labelImportRegexp")
@@ -3145,7 +3145,7 @@ class P4Sync(Command, P4UserMap):
3145
3146
if not m.match(name):
3147
if verbose:
3148
- print "label %s does not match regexp %s" % (name,validLabelRegexp)
3148
+ print("label %s does not match regexp %s" % (name,validLabelRegexp))
3149
continue
3150
3151
if name in ignoredP4Labels:
@@ -3167,7 +3167,7 @@ class P4Sync(Command, P4UserMap):
3167
gitCommit = read_pipe(["git", "rev-list", "--max-count=1",
3168
"--reverse", ":/\[git-p4:.*change = %d\]" % changelist], ignore_error=True)
3169
if len(gitCommit) == 0:
3170
- print "importing label %s: could not find git commit for changelist %d" % (name, changelist)
3170
+ print("importing label %s: could not find git commit for changelist %d" % (name, changelist))
3171
else:
3172
commitFound = True
3173
gitCommit = gitCommit.strip()
@@ -3177,16 +3177,16 @@ class P4Sync(Command, P4UserMap):
3177
try:
3178
tmwhen = time.strptime(labelDetails['Update'], "%Y/%m/%d %H:%M:%S")
3179
except ValueError:
3180
- print "Could not convert label time %s" % labelDetails['Update']
3180
+ print("Could not convert label time %s" % labelDetails['Update'])
3181
tmwhen = 1
3182
3183
when = int(time.mktime(tmwhen))
3184
self.streamTag(stream, name, labelDetails, gitCommit, when)
3185
if verbose:
3186
- print "p4 label %s mapped to git commit %s" % (name, gitCommit)
3186
+ print("p4 label %s mapped to git commit %s" % (name, gitCommit))
3187
else:
3188
if verbose:
3189
- print "Label %s has no changelists - possibly deleted?" % name
3189
+ print("Label %s has no changelists - possibly deleted?" % name)
3190
3191
if not commitFound:
3192
# We can't import this label; don't try again as it will get very
@@ -3231,8 +3231,8 @@ class P4Sync(Command, P4UserMap):
3231
3232
if destination in self.knownBranches:
3233
if not self.silent:
3234
- print "p4 branch %s defines a mapping from %s to %s" % (info["branch"], source, destination)
3235
- print "but there exists another mapping from %s to %s already!" % (self.knownBranches[destination], destination)
3234
+ print("p4 branch %s defines a mapping from %s to %s" % (info["branch"], source, destination))
3235
+ print("but there exists another mapping from %s to %s already!" % (self.knownBranches[destination], destination))
3236
continue
3237
3238
self.knownBranches[destination] = source
@@ -3296,28 +3296,28 @@ class P4Sync(Command, P4UserMap):
3296
3297
def gitCommitByP4Change(self, ref, change):
3298
if self.verbose:
3299
- print "looking in ref " + ref + " for change %s using bisect..." % change
3299
+ print("looking in ref " + ref + " for change %s using bisect..." % change)
3300
3301
earliestCommit = ""
3302
latestCommit = parseRevision(ref)
3303
3304
while True:
3305
if self.verbose:
3306
- print "trying: earliest %s latest %s" % (earliestCommit, latestCommit)
3306
+ print("trying: earliest %s latest %s" % (earliestCommit, latestCommit))
3307
next = read_pipe("git rev-list --bisect %s %s" % (latestCommit, earliestCommit)).strip()
3308
if len(next) == 0:
3309
if self.verbose:
3310
- print "argh"
3310
+ print("argh")
3311
return ""
3312
log = extractLogMessageFromGitCommit(next)
3313
settings = extractSettingsGitLog(log)
3314
currentChange = int(settings['change'])
3315
if self.verbose:
3316
- print "current change %s" % currentChange
3316
+ print("current change %s" % currentChange)
3317
3318
if currentChange == change:
3319
if self.verbose:
3320
- print "found %s" % next
3320
+ print("found %s" % next)
3321
return next
3322
3323
if currentChange < change:
@@ -3363,7 +3363,7 @@ class P4Sync(Command, P4UserMap):
3363
if len(read_pipe(["git", "diff-tree", blob, target])) == 0:
3364
parentFound = True
3365
if self.verbose:
3366
- print "Found parent of %s in commit %s" % (branch, blob)
3366
+ print("Found parent of %s in commit %s" % (branch, blob))
3367
break
3368
if parentFound:
3369
return blob
@@ -3394,7 +3394,7 @@ class P4Sync(Command, P4UserMap):
3394
filesForCommit = branches[branch]
3395
3396
if self.verbose:
3397
- print "branch is %s" % branch
3397
+ print("branch is %s" % branch)
3398
3399
self.updatedBranches.add(branch)
3400
@@ -3415,13 +3415,13 @@ class P4Sync(Command, P4UserMap):
3415
print("\n Resuming with change %s" % change);
3416
3417
if self.verbose:
3418
- print "parent determined through known branches: %s" % parent
3418
+ print("parent determined through known branches: %s" % parent)
3419
3420
branch = self.gitRefForBranch(branch)
3421
parent = self.gitRefForBranch(parent)
3422
3423
if self.verbose:
3424
- print "looking for initial parent for %s; current parent is %s" % (branch, parent)
3424
+ print("looking for initial parent for %s; current parent is %s" % (branch, parent))
3425
3426
if len(parent) == 0 and branch in self.initialParents:
3427
parent = self.initialParents[branch]
@@ -3431,7 +3431,7 @@ class P4Sync(Command, P4UserMap):
3431
if len(parent) > 0:
3432
tempBranch = "%s/%d" % (self.tempBranchLocation, change)
3433
if self.verbose:
3434
- print "Creating temporary branch: " + tempBranch
3434
+ print("Creating temporary branch: " + tempBranch)
3435
self.commit(description, filesForCommit, tempBranch)
3436
self.tempBranches.append(tempBranch)
3437
self.checkpoint()
@@ -3440,7 +3440,7 @@ class P4Sync(Command, P4UserMap):
3440
self.commit(description, filesForCommit, branch, blob)
3441
else:
3442
if self.verbose:
3443
- print "Parent of %s not found. Committing into head of %s" % (branch, parent)
3443
+ print("Parent of %s not found. Committing into head of %s" % (branch, parent))
3444
self.commit(description, filesForCommit, branch, parent)
3445
else:
3446
files = self.extractFilesFromCommit(description, shelved, change, origin_revision)
@@ -3449,7 +3449,7 @@ class P4Sync(Command, P4UserMap):
3449
# only needed once, to connect to the previous commit
3450
self.initialParent = ""
3451
except IOError:
3452
- print self.gitError.read()
3452
+ print(self.gitError.read())
3453
sys.exit(1)
3454
3455
def sync_origin_only(self):
@@ -3457,11 +3457,11 @@ class P4Sync(Command, P4UserMap):
3457
self.hasOrigin = originP4BranchesExist()
3458
if self.hasOrigin:
3459
if not self.silent:
3460
- print 'Syncing with origin first, using "git fetch origin"'
3460
+ print('Syncing with origin first, using "git fetch origin"')
3461
system("git fetch origin")
3462
3463
def importHeadRevision(self, revision):
3464
- print "Doing initial import of %s from revision %s into %s" % (' '.join(self.depotPaths), revision, self.branch)
3464
+ print("Doing initial import of %s from revision %s into %s" % (' '.join(self.depotPaths), revision, self.branch))
3465
3466
details = {}
3467
details["user"] = "git perforce import user"
@@ -3513,8 +3513,8 @@ class P4Sync(Command, P4UserMap):
3513
try:
3514
self.commit(details, self.extractFilesFromCommit(details), self.branch)
3515
except IOError:
3516
- print "IO error with git fast-import. Is your git version recent enough?"
3517
- print self.gitError.read()
3516
+ print("IO error with git fast-import. Is your git version recent enough?")
3517
+ print(self.gitError.read())
3518
3519
def openStreams(self):
3520
self.importProcess = subprocess.Popen(["git", "fast-import"],
@@ -3576,14 +3576,14 @@ class P4Sync(Command, P4UserMap):
3576
3577
if len(self.p4BranchesInGit) > 1:
3578
if not self.silent:
3579
- print "Importing from/into multiple branches"
3579
+ print("Importing from/into multiple branches")
3580
self.detectBranches = True
3581
for branch in branches.keys():
3582
self.initialParents[self.refPrefix + branch] = \
3583
branches[branch]
3584
3585
if self.verbose:
3586
- print "branches: %s" % self.p4BranchesInGit
3586
+ print("branches: %s" % self.p4BranchesInGit)
3587
3588
p4Change = 0
3589
for branch in self.p4BranchesInGit:
@@ -3618,7 +3618,7 @@ class P4Sync(Command, P4UserMap):
3618
self.depotPaths = sorted(self.previousDepotPaths)
3619
self.changeRange = "@%s,#head" % p4Change
3620
if not self.silent and not self.detectBranches:
3621
- print "Performing incremental import into %s git branch" % self.branch
3621
+ print("Performing incremental import into %s git branch" % self.branch)
3622
3623
# accept multiple ref name abbreviations:
3624
# refs/foo/bar/branch -> use it exactly
@@ -3635,10 +3635,10 @@ class P4Sync(Command, P4UserMap):
3635
3636
if len(args) == 0 and self.depotPaths:
3637
if not self.silent:
3638
- print "Depot paths: %s" % ' '.join(self.depotPaths)
3638
+ print("Depot paths: %s" % ' '.join(self.depotPaths))
3639
else:
3640
if self.depotPaths and self.depotPaths != args:
3641
- print ("previous import used depot path %s and now %s was specified. "
3641
+ print("previous import used depot path %s and now %s was specified. "
3642
"This doesn't work!" % (' '.join (self.depotPaths),
3643
' '.join (args)))
3644
sys.exit(1)
@@ -3705,8 +3705,8 @@ class P4Sync(Command, P4UserMap):
3705
else:
3706
self.getBranchMapping()
3707
if self.verbose:
3708
- print "p4-git branches: %s" % self.p4BranchesInGit
3709
- print "initial parents: %s" % self.initialParents
3708
+ print("p4-git branches: %s" % self.p4BranchesInGit)
3709
+ print("initial parents: %s" % self.initialParents)
3710
for b in self.p4BranchesInGit:
3711
if b != "master":
3712
@@ -3750,8 +3750,8 @@ class P4Sync(Command, P4UserMap):
3750
self.branch)
3751
3752
if self.verbose:
3753
- print "Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
3754
- self.changeRange)
3753
+ print("Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
3754
+ self.changeRange))
3755
changes = p4ChangesForPaths(self.depotPaths, self.changeRange, self.changes_block_size)
3756
3757
if len(self.maxChanges) > 0:
@@ -3759,10 +3759,10 @@ class P4Sync(Command, P4UserMap):
3759
3760
if len(changes) == 0:
3761
if not self.silent:
3762
- print "No changes to import!"
3762
+ print("No changes to import!")
3763
else:
3764
if not self.silent and not self.detectBranches:
3765
- print "Import destination: %s" % self.branch
3765
+ print("Import destination: %s" % self.branch)
3766
3767
self.updatedBranches = set()
3768
@@ -3777,7 +3777,7 @@ class P4Sync(Command, P4UserMap):
3777
self.importChanges(changes)
3778
3779
if not self.silent:
3780
- print ""
3780
+ print("")
3781
if len(self.updatedBranches) > 0:
3782
sys.stdout.write("Updated branches: ")
3783
for b in self.updatedBranches:
@@ -3841,7 +3841,7 @@ class P4Rebase(Command):
3841
# the branchpoint may be p4/foo~3, so strip off the parent
3842
upstream = re.sub("~[0-9]+$", "", upstream)
3843
3844
- print "Rebasing the current branch onto %s" % upstream
3844
+ print("Rebasing the current branch onto %s" % upstream)
3845
oldHead = read_pipe("git rev-parse HEAD").strip()
3846
system("git rebase %s" % upstream)
3847
system("git diff-tree --stat --summary -M %s HEAD --" % oldHead)
@@ -3895,7 +3895,7 @@ class P4Clone(P4Sync):
3895
if not self.cloneDestination:
3896
self.cloneDestination = self.defaultDestination(args)
3897
3898
- print "Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination)
3898
+ print("Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination))
3899
3900
if not os.path.exists(self.cloneDestination):
3901
os.makedirs(self.cloneDestination)
@@ -3917,8 +3917,8 @@ class P4Clone(P4Sync):
3917
if not self.cloneBare:
3918
system([ "git", "checkout", "-f" ])
3919
else:
3920
- print 'Not checking out any branch, use ' \
3921
- '"git checkout -q -b master <branch>"'
3920
+ print('Not checking out any branch, use ' \
3921
+ '"git checkout -q -b master <branch>"')
3922
3923
# auto-set this variable if invoked with --use-client-spec
3924
if self.useClientSpec_from_options:
@@ -4034,7 +4034,7 @@ class P4Branches(Command):
4034
log = extractLogMessageFromGitCommit("refs/remotes/%s" % branch)
4035
settings = extractSettingsGitLog(log)
4036
4037
- print "%s <= %s (%s)" % (branch, ",".join(settings["depot-paths"]), settings["change"])
4037
+ print("%s <= %s (%s)" % (branch, ",".join(settings["depot-paths"]), settings["change"]))
4038
return True
4039
4040
class HelpFormatter(optparse.IndentedHelpFormatter):
@@ -4048,12 +4048,12 @@ class HelpFormatter(optparse.IndentedHelpFormatter):
4048
return ""
4049
4050
def printUsage(commands):
4051
- print "usage: %s <command> [options]" % sys.argv[0]
4052
- print ""
4053
- print "valid commands: %s" % ", ".join(commands)
4054
- print ""
4055
- print "Try %s <command> --help for command specific help." % sys.argv[0]
4056
- print ""
4051
+ print("usage: %s <command> [options]" % sys.argv[0])
4052
+ print("")
4053
+ print("valid commands: %s" % ", ".join(commands))
4054
+ print("")
4055
+ print("Try %s <command> --help for command specific help." % sys.argv[0])
4056
+ print("")
4057
4058
commands = {
4059
"debug" : P4Debug,
@@ -4078,8 +4078,8 @@ def main():
4078
klass = commands[cmdName]
4079
cmd = klass()
4080
except KeyError:
4081
- print "unknown command %s" % cmdName
4082
- print ""
4081
+ print("unknown command %s" % cmdName)
4082
+ print("")
4083
printUsage(commands.keys())
4084
sys.exit(2)
4085