Apply Python 3 futurize transform libfuturize.fixes.fix_print_with_import.
This commit is contained in:
parent
27981480a2
commit
328816a329
|
@ -6,6 +6,7 @@
|
||||||
# Setup: First, you need to install python-irc version 8.5.3
|
# Setup: First, you need to install python-irc version 8.5.3
|
||||||
# (https://bitbucket.org/jaraco/irc)
|
# (https://bitbucket.org/jaraco/irc)
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import irc.bot
|
import irc.bot
|
||||||
import irc.strings
|
import irc.strings
|
||||||
from irc.client import ip_numstr_to_quad, ip_quad_to_numstr
|
from irc.client import ip_numstr_to_quad, ip_quad_to_numstr
|
||||||
|
@ -53,12 +54,12 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Forward the PM to Zulip
|
# Forward the PM to Zulip
|
||||||
print zulip_client.send_message({
|
print(zulip_client.send_message({
|
||||||
"sender": sender,
|
"sender": sender,
|
||||||
"type": "private",
|
"type": "private",
|
||||||
"to": "username@example.com",
|
"to": "username@example.com",
|
||||||
"content": content,
|
"content": content,
|
||||||
})
|
}))
|
||||||
|
|
||||||
def on_pubmsg(self, c, e):
|
def on_pubmsg(self, c, e):
|
||||||
content = e.arguments[0]
|
content = e.arguments[0]
|
||||||
|
@ -68,14 +69,14 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Forward the stream message to Zulip
|
# Forward the stream message to Zulip
|
||||||
print zulip_client.send_message({
|
print(zulip_client.send_message({
|
||||||
"forged": "yes",
|
"forged": "yes",
|
||||||
"sender": sender,
|
"sender": sender,
|
||||||
"type": "stream",
|
"type": "stream",
|
||||||
"to": stream,
|
"to": stream,
|
||||||
"subject": "IRC",
|
"subject": "IRC",
|
||||||
"content": content,
|
"content": content,
|
||||||
})
|
}))
|
||||||
|
|
||||||
def on_dccmsg(self, c, e):
|
def on_dccmsg(self, c, e):
|
||||||
c.privmsg("You said: " + e.arguments[0])
|
c.privmsg("You said: " + e.arguments[0])
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
@ -39,7 +40,7 @@ args.extend(sys.argv[1:])
|
||||||
|
|
||||||
backoff = RandomExponentialBackoff(timeout_success_equivalent=300)
|
backoff = RandomExponentialBackoff(timeout_success_equivalent=300)
|
||||||
while backoff.keep_going():
|
while backoff.keep_going():
|
||||||
print "Starting Jabber mirroring bot"
|
print("Starting Jabber mirroring bot")
|
||||||
try:
|
try:
|
||||||
ret = subprocess.call(args)
|
ret = subprocess.call(args)
|
||||||
except:
|
except:
|
||||||
|
@ -51,9 +52,9 @@ while backoff.keep_going():
|
||||||
|
|
||||||
backoff.fail()
|
backoff.fail()
|
||||||
|
|
||||||
print ""
|
print("")
|
||||||
print ""
|
print("")
|
||||||
print "ERROR: The Jabber mirroring bot is unable to continue mirroring Jabber."
|
print("ERROR: The Jabber mirroring bot is unable to continue mirroring Jabber.")
|
||||||
print "Please contact zulip-devel@googlegroups.com if you need assistance."
|
print("Please contact zulip-devel@googlegroups.com if you need assistance.")
|
||||||
print ""
|
print("")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import print_function
|
||||||
# This is hacky code to analyze data on our support stream. The main
|
# This is hacky code to analyze data on our support stream. The main
|
||||||
# reusable bits are get_recent_messages and get_words.
|
# reusable bits are get_recent_messages and get_words.
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ def analyze_messages(msgs, word_count, email_count):
|
||||||
if False:
|
if False:
|
||||||
if ' ack' in msg['content']:
|
if ' ack' in msg['content']:
|
||||||
name = msg['sender_full_name'].split()[0]
|
name = msg['sender_full_name'].split()[0]
|
||||||
print 'ACK', name
|
print('ACK', name)
|
||||||
m = re.search('ticket (Z....).*email: (\S+).*~~~(.*)', msg['content'], re.M | re.S)
|
m = re.search('ticket (Z....).*email: (\S+).*~~~(.*)', msg['content'], re.M | re.S)
|
||||||
if m:
|
if m:
|
||||||
ticket, email, req = m.groups()
|
ticket, email, req = m.groups()
|
||||||
|
@ -40,9 +41,9 @@ def analyze_messages(msgs, word_count, email_count):
|
||||||
word_count[word] += 1
|
word_count[word] += 1
|
||||||
email_count[email] += 1
|
email_count[email] += 1
|
||||||
if False:
|
if False:
|
||||||
print
|
print()
|
||||||
for k, v in msg.items():
|
for k, v in msg.items():
|
||||||
print '%-20s: %s' % (k, v)
|
print('%-20s: %s' % (k, v))
|
||||||
|
|
||||||
def generate_support_stats():
|
def generate_support_stats():
|
||||||
client = zulip.Client()
|
client = zulip.Client()
|
||||||
|
@ -68,12 +69,12 @@ def generate_support_stats():
|
||||||
words = filter(lambda w: len(w) >= 5, words)
|
words = filter(lambda w: len(w) >= 5, words)
|
||||||
words = sorted(words, key=lambda w: word_count[w], reverse=True)
|
words = sorted(words, key=lambda w: word_count[w], reverse=True)
|
||||||
for word in words:
|
for word in words:
|
||||||
print word, word_count[word]
|
print(word, word_count[word])
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
emails = email_count.keys()
|
emails = email_count.keys()
|
||||||
emails = sorted(emails, key=lambda w: email_count[w], reverse=True)
|
emails = sorted(emails, key=lambda w: email_count[w], reverse=True)
|
||||||
for email in emails:
|
for email in emails:
|
||||||
print email, email_count[email]
|
print(email, email_count[email])
|
||||||
|
|
||||||
generate_support_stats()
|
generate_support_stats()
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
@ -53,30 +54,30 @@ if options.forward_class_messages and not options.noshard:
|
||||||
if options.on_startup_command is not None:
|
if options.on_startup_command is not None:
|
||||||
subprocess.call([options.on_startup_command])
|
subprocess.call([options.on_startup_command])
|
||||||
from zerver.lib.parallel import run_parallel
|
from zerver.lib.parallel import run_parallel
|
||||||
print "Starting parallel zephyr class mirroring bot"
|
print("Starting parallel zephyr class mirroring bot")
|
||||||
jobs = list("0123456789abcdef")
|
jobs = list("0123456789abcdef")
|
||||||
def run_job(shard):
|
def run_job(shard):
|
||||||
subprocess.call(args + ["--shard=%s" % (shard,)])
|
subprocess.call(args + ["--shard=%s" % (shard,)])
|
||||||
return 0
|
return 0
|
||||||
for (status, job) in run_parallel(run_job, jobs, threads=16):
|
for (status, job) in run_parallel(run_job, jobs, threads=16):
|
||||||
print "A mirroring shard died!"
|
print("A mirroring shard died!")
|
||||||
pass
|
pass
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
backoff = RandomExponentialBackoff(timeout_success_equivalent=300)
|
backoff = RandomExponentialBackoff(timeout_success_equivalent=300)
|
||||||
while backoff.keep_going():
|
while backoff.keep_going():
|
||||||
print "Starting zephyr mirroring bot"
|
print("Starting zephyr mirroring bot")
|
||||||
try:
|
try:
|
||||||
subprocess.call(args)
|
subprocess.call(args)
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
backoff.fail()
|
backoff.fail()
|
||||||
|
|
||||||
print ""
|
print("")
|
||||||
print ""
|
print("")
|
||||||
print "ERROR: The Zephyr mirroring bot is unable to continue mirroring Zephyrs."
|
print("ERROR: The Zephyr mirroring bot is unable to continue mirroring Zephyrs.")
|
||||||
print "This is often caused by failing to maintain unexpired Kerberos tickets"
|
print("This is often caused by failing to maintain unexpired Kerberos tickets")
|
||||||
print "or AFS tokens. See https://zulip.com/zephyr for documentation on how to"
|
print("or AFS tokens. See https://zulip.com/zephyr for documentation on how to")
|
||||||
print "maintain unexpired Kerberos tickets and AFS tokens."
|
print("maintain unexpired Kerberos tickets and AFS tokens.")
|
||||||
print ""
|
print("")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
# 2007 Trolltech ASA
|
# 2007 Trolltech ASA
|
||||||
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
|
||||||
#
|
#
|
||||||
|
from __future__ import print_function
|
||||||
import sys
|
import sys
|
||||||
if sys.hexversion < 0x02040000:
|
if sys.hexversion < 0x02040000:
|
||||||
# The limiter is the subprocess module
|
# The limiter is the subprocess module
|
||||||
|
@ -693,7 +694,7 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
|
||||||
update = False
|
update = False
|
||||||
if not gitBranchExists(remoteHead):
|
if not gitBranchExists(remoteHead):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "creating %s" % remoteHead
|
print("creating %s" % remoteHead)
|
||||||
update = True
|
update = True
|
||||||
else:
|
else:
|
||||||
settings = extractSettingsGitLog(extractLogMessageFromGitCommit(remoteHead))
|
settings = extractSettingsGitLog(extractLogMessageFromGitCommit(remoteHead))
|
||||||
|
@ -895,9 +896,9 @@ class P4Debug(Command):
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
j = 0
|
j = 0
|
||||||
for output in p4CmdList(args):
|
for output in p4CmdList(args):
|
||||||
print 'Element: %d' % j
|
print('Element: %d' % j)
|
||||||
j += 1
|
j += 1
|
||||||
print output
|
print(output)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class P4RollBack(Command):
|
class P4RollBack(Command):
|
||||||
|
@ -938,14 +939,14 @@ class P4RollBack(Command):
|
||||||
|
|
||||||
if len(p4Cmd("changes -m 1 " + ' '.join (['%s...@%s' % (p, maxChange)
|
if len(p4Cmd("changes -m 1 " + ' '.join (['%s...@%s' % (p, maxChange)
|
||||||
for p in depotPaths]))) == 0:
|
for p in depotPaths]))) == 0:
|
||||||
print "Branch %s did not exist at change %s, deleting." % (ref, maxChange)
|
print("Branch %s did not exist at change %s, deleting." % (ref, maxChange))
|
||||||
system("git update-ref -d %s `git rev-parse %s`" % (ref, ref))
|
system("git update-ref -d %s `git rev-parse %s`" % (ref, ref))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
while change and int(change) > maxChange:
|
while change and int(change) > maxChange:
|
||||||
changed = True
|
changed = True
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "%s is at %s ; rewinding towards %s" % (ref, change, maxChange)
|
print("%s is at %s ; rewinding towards %s" % (ref, change, maxChange))
|
||||||
system("git update-ref %s \"%s^\"" % (ref, ref))
|
system("git update-ref %s \"%s^\"" % (ref, ref))
|
||||||
log = extractLogMessageFromGitCommit(ref)
|
log = extractLogMessageFromGitCommit(ref)
|
||||||
settings = extractSettingsGitLog(log)
|
settings = extractSettingsGitLog(log)
|
||||||
|
@ -955,7 +956,7 @@ class P4RollBack(Command):
|
||||||
change = settings['change']
|
change = settings['change']
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
print "%s rewound to %s" % (ref, change)
|
print("%s rewound to %s" % (ref, change))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -1069,10 +1070,10 @@ class P4Submit(Command, P4UserMap):
|
||||||
except:
|
except:
|
||||||
# cleanup our temporary file
|
# cleanup our temporary file
|
||||||
os.unlink(outFileName)
|
os.unlink(outFileName)
|
||||||
print "Failed to strip RCS keywords in %s" % file
|
print("Failed to strip RCS keywords in %s" % file)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
print "Patched up RCS keywords in %s" % file
|
print("Patched up RCS keywords in %s" % file)
|
||||||
|
|
||||||
def p4UserForCommit(self, id):
|
def p4UserForCommit(self, id):
|
||||||
# Return the tuple (perforce user,git email) for a given git commit id
|
# Return the tuple (perforce user,git email) for a given git commit id
|
||||||
|
@ -1092,7 +1093,7 @@ class P4Submit(Command, P4UserMap):
|
||||||
if not user:
|
if not user:
|
||||||
msg = "Cannot find p4 user for email %s in commit %s." % (email, id)
|
msg = "Cannot find p4 user for email %s in commit %s." % (email, id)
|
||||||
if gitConfigBool("git-p4.allowMissingP4Users"):
|
if gitConfigBool("git-p4.allowMissingP4Users"):
|
||||||
print "%s" % msg
|
print("%s" % msg)
|
||||||
else:
|
else:
|
||||||
die("Error: %s\nSet git-p4.allowMissingP4Users to true to allow this." % msg)
|
die("Error: %s\nSet git-p4.allowMissingP4Users to true to allow this." % msg)
|
||||||
|
|
||||||
|
@ -1219,8 +1220,8 @@ class P4Submit(Command, P4UserMap):
|
||||||
def applyCommit(self, id):
|
def applyCommit(self, id):
|
||||||
"""Apply one commit, return True if it succeeded."""
|
"""Apply one commit, return True if it succeeded."""
|
||||||
|
|
||||||
print "Applying", read_pipe(["git", "show", "-s",
|
print("Applying", read_pipe(["git", "show", "-s",
|
||||||
"--format=format:%h %s", id])
|
"--format=format:%h %s", id]))
|
||||||
|
|
||||||
(p4User, gitEmail) = self.p4UserForCommit(id)
|
(p4User, gitEmail) = self.p4UserForCommit(id)
|
||||||
|
|
||||||
|
@ -1298,7 +1299,7 @@ class P4Submit(Command, P4UserMap):
|
||||||
if os.system(tryPatchCmd) != 0:
|
if os.system(tryPatchCmd) != 0:
|
||||||
fixed_rcs_keywords = False
|
fixed_rcs_keywords = False
|
||||||
patch_succeeded = False
|
patch_succeeded = False
|
||||||
print "Unfortunately applying the change failed!"
|
print("Unfortunately applying the change failed!")
|
||||||
|
|
||||||
# Patch failed, maybe it's just RCS keyword woes. Look through
|
# Patch failed, maybe it's just RCS keyword woes. Look through
|
||||||
# the patch to see if that's possible.
|
# the patch to see if that's possible.
|
||||||
|
@ -1316,13 +1317,13 @@ class P4Submit(Command, P4UserMap):
|
||||||
for line in read_pipe_lines(["git", "diff", "%s^..%s" % (id, id), file]):
|
for line in read_pipe_lines(["git", "diff", "%s^..%s" % (id, id), file]):
|
||||||
if regexp.search(line):
|
if regexp.search(line):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "got keyword match on %s in %s in %s" % (pattern, line, file)
|
print("got keyword match on %s in %s in %s" % (pattern, line, file))
|
||||||
kwfiles[file] = pattern
|
kwfiles[file] = pattern
|
||||||
break
|
break
|
||||||
|
|
||||||
for file in kwfiles:
|
for file in kwfiles:
|
||||||
if verbose:
|
if verbose:
|
||||||
print "zapping %s with %s" % (line, pattern)
|
print("zapping %s with %s" % (line, pattern))
|
||||||
# File is being deleted, so not open in p4. Must
|
# File is being deleted, so not open in p4. Must
|
||||||
# disable the read-only bit on windows.
|
# disable the read-only bit on windows.
|
||||||
if self.isWindows and file not in editedFiles:
|
if self.isWindows and file not in editedFiles:
|
||||||
|
@ -1331,7 +1332,7 @@ class P4Submit(Command, P4UserMap):
|
||||||
fixed_rcs_keywords = True
|
fixed_rcs_keywords = True
|
||||||
|
|
||||||
if fixed_rcs_keywords:
|
if fixed_rcs_keywords:
|
||||||
print "Retrying the patch with RCS keywords cleaned up"
|
print("Retrying the patch with RCS keywords cleaned up")
|
||||||
if os.system(tryPatchCmd) == 0:
|
if os.system(tryPatchCmd) == 0:
|
||||||
patch_succeeded = True
|
patch_succeeded = True
|
||||||
|
|
||||||
|
@ -1411,34 +1412,34 @@ class P4Submit(Command, P4UserMap):
|
||||||
# Leave the p4 tree prepared, and the submit template around
|
# Leave the p4 tree prepared, and the submit template around
|
||||||
# and let the user decide what to do next
|
# and let the user decide what to do next
|
||||||
#
|
#
|
||||||
print
|
print()
|
||||||
print "P4 workspace prepared for submission."
|
print("P4 workspace prepared for submission.")
|
||||||
print "To submit or revert, go to client workspace"
|
print("To submit or revert, go to client workspace")
|
||||||
print " " + self.clientPath
|
print(" " + self.clientPath)
|
||||||
print
|
print()
|
||||||
print "To submit, use \"p4 submit\" to write a new description,"
|
print("To submit, use \"p4 submit\" to write a new description,")
|
||||||
print "or \"p4 submit -i %s\" to use the one prepared by" \
|
print("or \"p4 submit -i %s\" to use the one prepared by" \
|
||||||
" \"git p4\"." % fileName
|
" \"git p4\"." % fileName)
|
||||||
print "You can delete the file \"%s\" when finished." % fileName
|
print("You can delete the file \"%s\" when finished." % fileName)
|
||||||
|
|
||||||
if self.preserveUser and p4User and not self.p4UserIsMe(p4User):
|
if self.preserveUser and p4User and not self.p4UserIsMe(p4User):
|
||||||
print "To preserve change ownership by user %s, you must\n" \
|
print("To preserve change ownership by user %s, you must\n" \
|
||||||
"do \"p4 change -f <change>\" after submitting and\n" \
|
"do \"p4 change -f <change>\" after submitting and\n" \
|
||||||
"edit the User field."
|
"edit the User field.")
|
||||||
if pureRenameCopy:
|
if pureRenameCopy:
|
||||||
print "After submitting, renamed files must be re-synced."
|
print("After submitting, renamed files must be re-synced.")
|
||||||
print "Invoke \"p4 sync -f\" on each of these files:"
|
print("Invoke \"p4 sync -f\" on each of these files:")
|
||||||
for f in pureRenameCopy:
|
for f in pureRenameCopy:
|
||||||
print " " + f
|
print(" " + f)
|
||||||
|
|
||||||
print
|
print()
|
||||||
print "To revert the changes, use \"p4 revert ...\", and delete"
|
print("To revert the changes, use \"p4 revert ...\", and delete")
|
||||||
print "the submit template file \"%s\"" % fileName
|
print("the submit template file \"%s\"" % fileName)
|
||||||
if filesToAdd:
|
if filesToAdd:
|
||||||
print "Since the commit adds new files, they must be deleted:"
|
print("Since the commit adds new files, they must be deleted:")
|
||||||
for f in filesToAdd:
|
for f in filesToAdd:
|
||||||
print " " + f
|
print(" " + f)
|
||||||
print
|
print()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -1471,7 +1472,7 @@ class P4Submit(Command, P4UserMap):
|
||||||
else:
|
else:
|
||||||
# skip this patch
|
# skip this patch
|
||||||
ret = False
|
ret = False
|
||||||
print "Submission cancelled, undoing p4 changes."
|
print("Submission cancelled, undoing p4 changes.")
|
||||||
for f in editedFiles:
|
for f in editedFiles:
|
||||||
p4_revert(f)
|
p4_revert(f)
|
||||||
for f in filesToAdd:
|
for f in filesToAdd:
|
||||||
|
@ -1495,7 +1496,7 @@ class P4Submit(Command, P4UserMap):
|
||||||
|
|
||||||
if not m.match(name):
|
if not m.match(name):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "tag %s does not match regexp %s" % (name, validLabelRegexp)
|
print("tag %s does not match regexp %s" % (name, validLabelRegexp))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Get the p4 commit this corresponds to
|
# Get the p4 commit this corresponds to
|
||||||
|
@ -1505,7 +1506,7 @@ class P4Submit(Command, P4UserMap):
|
||||||
if 'change' not in values:
|
if 'change' not in values:
|
||||||
# a tag pointing to something not sent to p4; ignore
|
# a tag pointing to something not sent to p4; ignore
|
||||||
if verbose:
|
if verbose:
|
||||||
print "git tag %s does not give a p4 commit" % name
|
print("git tag %s does not give a p4 commit" % name)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
changelist = values['change']
|
changelist = values['change']
|
||||||
|
@ -1540,10 +1541,10 @@ class P4Submit(Command, P4UserMap):
|
||||||
labelTemplate += "\t%s\n" % depot_side
|
labelTemplate += "\t%s\n" % depot_side
|
||||||
|
|
||||||
if self.dry_run:
|
if self.dry_run:
|
||||||
print "Would create p4 label %s for tag" % name
|
print("Would create p4 label %s for tag" % name)
|
||||||
elif self.prepare_p4_only:
|
elif self.prepare_p4_only:
|
||||||
print "Not creating p4 label %s for tag due to option" \
|
print("Not creating p4 label %s for tag due to option" \
|
||||||
" --prepare-p4-only" % name
|
" --prepare-p4-only" % name)
|
||||||
else:
|
else:
|
||||||
p4_write_pipe(["label", "-i"], labelTemplate)
|
p4_write_pipe(["label", "-i"], labelTemplate)
|
||||||
|
|
||||||
|
@ -1552,7 +1553,7 @@ class P4Submit(Command, P4UserMap):
|
||||||
["%s@%s" % (depot_side, changelist) for depot_side in clientSpec.mappings])
|
["%s@%s" % (depot_side, changelist) for depot_side in clientSpec.mappings])
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print "created p4 label for tag %s" % name
|
print("created p4 label for tag %s" % name)
|
||||||
|
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
if len(args) == 0:
|
if len(args) == 0:
|
||||||
|
@ -1590,10 +1591,10 @@ class P4Submit(Command, P4UserMap):
|
||||||
self.conflict_behavior = val
|
self.conflict_behavior = val
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Origin branch is " + self.origin
|
print("Origin branch is " + self.origin)
|
||||||
|
|
||||||
if len(self.depotPath) == 0:
|
if len(self.depotPath) == 0:
|
||||||
print "Internal error: cannot locate perforce depot path from existing branches"
|
print("Internal error: cannot locate perforce depot path from existing branches")
|
||||||
sys.exit(128)
|
sys.exit(128)
|
||||||
|
|
||||||
self.useClientSpec = False
|
self.useClientSpec = False
|
||||||
|
@ -1611,7 +1612,7 @@ class P4Submit(Command, P4UserMap):
|
||||||
if self.clientPath == "":
|
if self.clientPath == "":
|
||||||
die("Error: Cannot locate perforce checkout of %s in client view" % self.depotPath)
|
die("Error: Cannot locate perforce checkout of %s in client view" % self.depotPath)
|
||||||
|
|
||||||
print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
|
print("Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath))
|
||||||
self.oldWorkingDirectory = os.getcwd()
|
self.oldWorkingDirectory = os.getcwd()
|
||||||
|
|
||||||
# ensure the clientPath exists
|
# ensure the clientPath exists
|
||||||
|
@ -1622,9 +1623,9 @@ class P4Submit(Command, P4UserMap):
|
||||||
|
|
||||||
chdir(self.clientPath, is_client_path=True)
|
chdir(self.clientPath, is_client_path=True)
|
||||||
if self.dry_run:
|
if self.dry_run:
|
||||||
print "Would synchronize p4 checkout in %s" % self.clientPath
|
print("Would synchronize p4 checkout in %s" % self.clientPath)
|
||||||
else:
|
else:
|
||||||
print "Synchronizing p4 checkout..."
|
print("Synchronizing p4 checkout...")
|
||||||
if new_client_dir:
|
if new_client_dir:
|
||||||
# old one was destroyed, and maybe nobody told p4
|
# old one was destroyed, and maybe nobody told p4
|
||||||
p4_sync("...", "-f")
|
p4_sync("...", "-f")
|
||||||
|
@ -1681,13 +1682,13 @@ class P4Submit(Command, P4UserMap):
|
||||||
# continue to try the rest of the patches, or quit.
|
# continue to try the rest of the patches, or quit.
|
||||||
#
|
#
|
||||||
if self.dry_run:
|
if self.dry_run:
|
||||||
print "Would apply"
|
print("Would apply")
|
||||||
applied = []
|
applied = []
|
||||||
last = len(commits) - 1
|
last = len(commits) - 1
|
||||||
for i, commit in enumerate(commits):
|
for i, commit in enumerate(commits):
|
||||||
if self.dry_run:
|
if self.dry_run:
|
||||||
print " ", read_pipe(["git", "show", "-s",
|
print(" ", read_pipe(["git", "show", "-s",
|
||||||
"--format=format:%h %s", commit])
|
"--format=format:%h %s", commit]))
|
||||||
ok = True
|
ok = True
|
||||||
else:
|
else:
|
||||||
ok = self.applyCommit(commit)
|
ok = self.applyCommit(commit)
|
||||||
|
@ -1695,15 +1696,15 @@ class P4Submit(Command, P4UserMap):
|
||||||
applied.append(commit)
|
applied.append(commit)
|
||||||
else:
|
else:
|
||||||
if self.prepare_p4_only and i < last:
|
if self.prepare_p4_only and i < last:
|
||||||
print "Processing only the first commit due to option" \
|
print("Processing only the first commit due to option" \
|
||||||
" --prepare-p4-only"
|
" --prepare-p4-only")
|
||||||
break
|
break
|
||||||
if i < last:
|
if i < last:
|
||||||
quit = False
|
quit = False
|
||||||
while True:
|
while True:
|
||||||
# prompt for what to do, or use the option/variable
|
# prompt for what to do, or use the option/variable
|
||||||
if self.conflict_behavior == "ask":
|
if self.conflict_behavior == "ask":
|
||||||
print "What do you want to do?"
|
print("What do you want to do?")
|
||||||
response = raw_input("[s]kip this commit but apply"
|
response = raw_input("[s]kip this commit but apply"
|
||||||
" the rest, or [q]uit? ")
|
" the rest, or [q]uit? ")
|
||||||
if not response:
|
if not response:
|
||||||
|
@ -1717,10 +1718,10 @@ class P4Submit(Command, P4UserMap):
|
||||||
self.conflict_behavior)
|
self.conflict_behavior)
|
||||||
|
|
||||||
if response[0] == "s":
|
if response[0] == "s":
|
||||||
print "Skipping this commit, but applying the rest"
|
print("Skipping this commit, but applying the rest")
|
||||||
break
|
break
|
||||||
if response[0] == "q":
|
if response[0] == "q":
|
||||||
print "Quitting"
|
print("Quitting")
|
||||||
quit = True
|
quit = True
|
||||||
break
|
break
|
||||||
if quit:
|
if quit:
|
||||||
|
@ -1733,7 +1734,7 @@ class P4Submit(Command, P4UserMap):
|
||||||
elif self.prepare_p4_only:
|
elif self.prepare_p4_only:
|
||||||
pass
|
pass
|
||||||
elif len(commits) == len(applied):
|
elif len(commits) == len(applied):
|
||||||
print "All commits applied!"
|
print("All commits applied!")
|
||||||
|
|
||||||
sync = P4Sync()
|
sync = P4Sync()
|
||||||
if self.branch:
|
if self.branch:
|
||||||
|
@ -1745,17 +1746,17 @@ class P4Submit(Command, P4UserMap):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if len(applied) == 0:
|
if len(applied) == 0:
|
||||||
print "No commits applied."
|
print("No commits applied.")
|
||||||
else:
|
else:
|
||||||
print "Applied only the commits marked with '*':"
|
print("Applied only the commits marked with '*':")
|
||||||
for c in commits:
|
for c in commits:
|
||||||
if c in applied:
|
if c in applied:
|
||||||
star = "*"
|
star = "*"
|
||||||
else:
|
else:
|
||||||
star = " "
|
star = " "
|
||||||
print star, read_pipe(["git", "show", "-s",
|
print(star, read_pipe(["git", "show", "-s",
|
||||||
"--format=format:%h %s", c])
|
"--format=format:%h %s", c]))
|
||||||
print "You will have to do 'git p4 sync' and rebase."
|
print("You will have to do 'git p4 sync' and rebase.")
|
||||||
|
|
||||||
if gitConfigBool("git-p4.exportLabels"):
|
if gitConfigBool("git-p4.exportLabels"):
|
||||||
self.exportLabels = True
|
self.exportLabels = True
|
||||||
|
@ -1931,7 +1932,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
self.gitStream.write("progress checkpoint\n\n")
|
self.gitStream.write("progress checkpoint\n\n")
|
||||||
out = self.gitOutput.readline()
|
out = self.gitOutput.readline()
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "checkpoint finished: " + out
|
print("checkpoint finished: " + out)
|
||||||
|
|
||||||
def extractFilesFromCommit(self, commit):
|
def extractFilesFromCommit(self, commit):
|
||||||
self.cloneExclude = [re.sub(r"\.\.\.$", "", path)
|
self.cloneExclude = [re.sub(r"\.\.\.$", "", path)
|
||||||
|
@ -2084,7 +2085,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
# Ideally, someday, this script can learn how to generate
|
# Ideally, someday, this script can learn how to generate
|
||||||
# appledouble files directly and import those to git, but
|
# appledouble files directly and import those to git, but
|
||||||
# non-mac machines can never find a use for apple filetype.
|
# non-mac machines can never find a use for apple filetype.
|
||||||
print "\nIgnoring apple filetype file %s" % file['depotFile']
|
print("\nIgnoring apple filetype file %s" % file['depotFile'])
|
||||||
return
|
return
|
||||||
|
|
||||||
# Note that we do not try to de-mangle keywords on utf16 files,
|
# Note that we do not try to de-mangle keywords on utf16 files,
|
||||||
|
@ -2208,7 +2209,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
# Stream a p4 tag
|
# Stream a p4 tag
|
||||||
def streamTag(self, gitStream, labelName, labelDetails, commit, epoch):
|
def streamTag(self, gitStream, labelName, labelDetails, commit, epoch):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "writing tag %s for commit %s" % (labelName, commit)
|
print("writing tag %s for commit %s" % (labelName, commit))
|
||||||
gitStream.write("tag %s\n" % labelName)
|
gitStream.write("tag %s\n" % labelName)
|
||||||
gitStream.write("from %s\n" % commit)
|
gitStream.write("from %s\n" % commit)
|
||||||
|
|
||||||
|
@ -2227,7 +2228,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
|
|
||||||
gitStream.write("tagger %s\n" % tagger)
|
gitStream.write("tagger %s\n" % tagger)
|
||||||
|
|
||||||
print "labelDetails=", labelDetails
|
print("labelDetails=", labelDetails)
|
||||||
if 'Description' in labelDetails:
|
if 'Description' in labelDetails:
|
||||||
description = labelDetails['Description']
|
description = labelDetails['Description']
|
||||||
else:
|
else:
|
||||||
|
@ -2242,7 +2243,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
author = details["user"]
|
author = details["user"]
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "commit into %s" % branch
|
print("commit into %s" % branch)
|
||||||
|
|
||||||
# start with reading files; if that fails, we should not
|
# start with reading files; if that fails, we should not
|
||||||
# create a commit.
|
# create a commit.
|
||||||
|
@ -2276,7 +2277,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
|
|
||||||
if len(parent) > 0:
|
if len(parent) > 0:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "parent %s" % parent
|
print("parent %s" % parent)
|
||||||
self.gitStream.write("from %s\n" % parent)
|
self.gitStream.write("from %s\n" % parent)
|
||||||
|
|
||||||
self.streamP4Files(new_files)
|
self.streamP4Files(new_files)
|
||||||
|
@ -2289,7 +2290,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
labelDetails = label[0]
|
labelDetails = label[0]
|
||||||
labelRevisions = label[1]
|
labelRevisions = label[1]
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Change %s is labelled %s" % (change, labelDetails)
|
print("Change %s is labelled %s" % (change, labelDetails))
|
||||||
|
|
||||||
files = p4CmdList(["files"] + ["%s...@%s" % (p, change)
|
files = p4CmdList(["files"] + ["%s...@%s" % (p, change)
|
||||||
for p in self.branchPrefixes])
|
for p in self.branchPrefixes])
|
||||||
|
@ -2321,14 +2322,14 @@ class P4Sync(Command, P4UserMap):
|
||||||
|
|
||||||
l = p4CmdList(["labels"] + ["%s..." % p for p in self.depotPaths])
|
l = p4CmdList(["labels"] + ["%s..." % p for p in self.depotPaths])
|
||||||
if len(l) > 0 and not self.silent:
|
if len(l) > 0 and not self.silent:
|
||||||
print "Finding files belonging to labels in %s" % repr(self.depotPaths)
|
print("Finding files belonging to labels in %s" % repr(self.depotPaths))
|
||||||
|
|
||||||
for output in l:
|
for output in l:
|
||||||
label = output["label"]
|
label = output["label"]
|
||||||
revisions = {}
|
revisions = {}
|
||||||
newestChange = 0
|
newestChange = 0
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Querying files for label %s" % label
|
print("Querying files for label %s" % label)
|
||||||
for file in p4CmdList(["files"] +
|
for file in p4CmdList(["files"] +
|
||||||
["%s...@%s" % (p, label)
|
["%s...@%s" % (p, label)
|
||||||
for p in self.depotPaths]):
|
for p in self.depotPaths]):
|
||||||
|
@ -2340,7 +2341,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
self.labels[newestChange] = [output, revisions]
|
self.labels[newestChange] = [output, revisions]
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Label changes: %s" % self.labels.keys()
|
print("Label changes: %s" % self.labels.keys())
|
||||||
|
|
||||||
# Import p4 labels as git tags. A direct mapping does not
|
# Import p4 labels as git tags. A direct mapping does not
|
||||||
# exist, so assume that if all the files are at the same revision
|
# exist, so assume that if all the files are at the same revision
|
||||||
|
@ -2348,7 +2349,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
# just ignore.
|
# just ignore.
|
||||||
def importP4Labels(self, stream, p4Labels):
|
def importP4Labels(self, stream, p4Labels):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "import p4 labels: " + ' '.join(p4Labels)
|
print("import p4 labels: " + ' '.join(p4Labels))
|
||||||
|
|
||||||
ignoredP4Labels = gitConfigList("git-p4.ignoredP4Labels")
|
ignoredP4Labels = gitConfigList("git-p4.ignoredP4Labels")
|
||||||
validLabelRegexp = gitConfig("git-p4.labelImportRegexp")
|
validLabelRegexp = gitConfig("git-p4.labelImportRegexp")
|
||||||
|
@ -2361,7 +2362,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
|
|
||||||
if not m.match(name):
|
if not m.match(name):
|
||||||
if verbose:
|
if verbose:
|
||||||
print "label %s does not match regexp %s" % (name, validLabelRegexp)
|
print("label %s does not match regexp %s" % (name, validLabelRegexp))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if name in ignoredP4Labels:
|
if name in ignoredP4Labels:
|
||||||
|
@ -2379,7 +2380,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
gitCommit = read_pipe(["git", "rev-list", "--max-count=1",
|
gitCommit = read_pipe(["git", "rev-list", "--max-count=1",
|
||||||
"--reverse", ":/\[git-p4:.*change = %d\]" % changelist])
|
"--reverse", ":/\[git-p4:.*change = %d\]" % changelist])
|
||||||
if len(gitCommit) == 0:
|
if len(gitCommit) == 0:
|
||||||
print "could not find git commit for changelist %d" % changelist
|
print("could not find git commit for changelist %d" % changelist)
|
||||||
else:
|
else:
|
||||||
gitCommit = gitCommit.strip()
|
gitCommit = gitCommit.strip()
|
||||||
commitFound = True
|
commitFound = True
|
||||||
|
@ -2387,16 +2388,16 @@ class P4Sync(Command, P4UserMap):
|
||||||
try:
|
try:
|
||||||
tmwhen = time.strptime(labelDetails['Update'], "%Y/%m/%d %H:%M:%S")
|
tmwhen = time.strptime(labelDetails['Update'], "%Y/%m/%d %H:%M:%S")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print "Could not convert label time %s" % labelDetails['Update']
|
print("Could not convert label time %s" % labelDetails['Update'])
|
||||||
tmwhen = 1
|
tmwhen = 1
|
||||||
|
|
||||||
when = int(time.mktime(tmwhen))
|
when = int(time.mktime(tmwhen))
|
||||||
self.streamTag(stream, name, labelDetails, gitCommit, when)
|
self.streamTag(stream, name, labelDetails, gitCommit, when)
|
||||||
if verbose:
|
if verbose:
|
||||||
print "p4 label %s mapped to git commit %s" % (name, gitCommit)
|
print("p4 label %s mapped to git commit %s" % (name, gitCommit))
|
||||||
else:
|
else:
|
||||||
if verbose:
|
if verbose:
|
||||||
print "Label %s has no changelists - possibly deleted?" % name
|
print("Label %s has no changelists - possibly deleted?" % name)
|
||||||
|
|
||||||
if not commitFound:
|
if not commitFound:
|
||||||
# We can't import this label; don't try again as it will get very
|
# We can't import this label; don't try again as it will get very
|
||||||
|
@ -2441,8 +2442,8 @@ class P4Sync(Command, P4UserMap):
|
||||||
|
|
||||||
if destination in self.knownBranches:
|
if destination in self.knownBranches:
|
||||||
if not self.silent:
|
if not self.silent:
|
||||||
print "p4 branch %s defines a mapping from %s to %s" % (info["branch"], source, destination)
|
print("p4 branch %s defines a mapping from %s to %s" % (info["branch"], source, destination))
|
||||||
print "but there exists another mapping from %s to %s already!" % (self.knownBranches[destination], destination)
|
print("but there exists another mapping from %s to %s already!" % (self.knownBranches[destination], destination))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.knownBranches[destination] = source
|
self.knownBranches[destination] = source
|
||||||
|
@ -2506,28 +2507,28 @@ class P4Sync(Command, P4UserMap):
|
||||||
|
|
||||||
def gitCommitByP4Change(self, ref, change):
|
def gitCommitByP4Change(self, ref, change):
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "looking in ref " + ref + " for change %s using bisect..." % change
|
print("looking in ref " + ref + " for change %s using bisect..." % change)
|
||||||
|
|
||||||
earliestCommit = ""
|
earliestCommit = ""
|
||||||
latestCommit = parseRevision(ref)
|
latestCommit = parseRevision(ref)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "trying: earliest %s latest %s" % (earliestCommit, latestCommit)
|
print("trying: earliest %s latest %s" % (earliestCommit, latestCommit))
|
||||||
next = read_pipe("git rev-list --bisect %s %s" % (latestCommit, earliestCommit)).strip()
|
next = read_pipe("git rev-list --bisect %s %s" % (latestCommit, earliestCommit)).strip()
|
||||||
if len(next) == 0:
|
if len(next) == 0:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "argh"
|
print("argh")
|
||||||
return ""
|
return ""
|
||||||
log = extractLogMessageFromGitCommit(next)
|
log = extractLogMessageFromGitCommit(next)
|
||||||
settings = extractSettingsGitLog(log)
|
settings = extractSettingsGitLog(log)
|
||||||
currentChange = int(settings['change'])
|
currentChange = int(settings['change'])
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "current change %s" % currentChange
|
print("current change %s" % currentChange)
|
||||||
|
|
||||||
if currentChange == change:
|
if currentChange == change:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "found %s" % next
|
print("found %s" % next)
|
||||||
return next
|
return next
|
||||||
|
|
||||||
if currentChange < change:
|
if currentChange < change:
|
||||||
|
@ -2573,7 +2574,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
if len(read_pipe(["git", "diff-tree", blob, target])) == 0:
|
if len(read_pipe(["git", "diff-tree", blob, target])) == 0:
|
||||||
parentFound = True
|
parentFound = True
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Found parent of %s in commit %s" % (branch, blob)
|
print("Found parent of %s in commit %s" % (branch, blob))
|
||||||
break
|
break
|
||||||
if parentFound:
|
if parentFound:
|
||||||
return blob
|
return blob
|
||||||
|
@ -2604,7 +2605,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
filesForCommit = branches[branch]
|
filesForCommit = branches[branch]
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "branch is %s" % branch
|
print("branch is %s" % branch)
|
||||||
|
|
||||||
self.updatedBranches.add(branch)
|
self.updatedBranches.add(branch)
|
||||||
|
|
||||||
|
@ -2625,13 +2626,13 @@ class P4Sync(Command, P4UserMap):
|
||||||
print("\n Resuming with change %s" % change);
|
print("\n Resuming with change %s" % change);
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "parent determined through known branches: %s" % parent
|
print("parent determined through known branches: %s" % parent)
|
||||||
|
|
||||||
branch = self.gitRefForBranch(branch)
|
branch = self.gitRefForBranch(branch)
|
||||||
parent = self.gitRefForBranch(parent)
|
parent = self.gitRefForBranch(parent)
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "looking for initial parent for %s; current parent is %s" % (branch, parent)
|
print("looking for initial parent for %s; current parent is %s" % (branch, parent))
|
||||||
|
|
||||||
if len(parent) == 0 and branch in self.initialParents:
|
if len(parent) == 0 and branch in self.initialParents:
|
||||||
parent = self.initialParents[branch]
|
parent = self.initialParents[branch]
|
||||||
|
@ -2641,7 +2642,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
if len(parent) > 0:
|
if len(parent) > 0:
|
||||||
tempBranch = "%s/%d" % (self.tempBranchLocation, change)
|
tempBranch = "%s/%d" % (self.tempBranchLocation, change)
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Creating temporary branch: " + tempBranch
|
print("Creating temporary branch: " + tempBranch)
|
||||||
self.commit(description, filesForCommit, tempBranch)
|
self.commit(description, filesForCommit, tempBranch)
|
||||||
self.tempBranches.append(tempBranch)
|
self.tempBranches.append(tempBranch)
|
||||||
self.checkpoint()
|
self.checkpoint()
|
||||||
|
@ -2650,7 +2651,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
self.commit(description, filesForCommit, branch, blob)
|
self.commit(description, filesForCommit, branch, blob)
|
||||||
else:
|
else:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Parent of %s not found. Committing into head of %s" % (branch, parent)
|
print("Parent of %s not found. Committing into head of %s" % (branch, parent))
|
||||||
self.commit(description, filesForCommit, branch, parent)
|
self.commit(description, filesForCommit, branch, parent)
|
||||||
else:
|
else:
|
||||||
files = self.extractFilesFromCommit(description)
|
files = self.extractFilesFromCommit(description)
|
||||||
|
@ -2659,11 +2660,11 @@ class P4Sync(Command, P4UserMap):
|
||||||
# only needed once, to connect to the previous commit
|
# only needed once, to connect to the previous commit
|
||||||
self.initialParent = ""
|
self.initialParent = ""
|
||||||
except IOError:
|
except IOError:
|
||||||
print self.gitError.read()
|
print(self.gitError.read())
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def importHeadRevision(self, revision):
|
def importHeadRevision(self, revision):
|
||||||
print "Doing initial import of %s from revision %s into %s" % (' '.join(self.depotPaths), revision, self.branch)
|
print("Doing initial import of %s from revision %s into %s" % (' '.join(self.depotPaths), revision, self.branch))
|
||||||
|
|
||||||
details = {}
|
details = {}
|
||||||
details["user"] = "git perforce import user"
|
details["user"] = "git perforce import user"
|
||||||
|
@ -2715,8 +2716,8 @@ class P4Sync(Command, P4UserMap):
|
||||||
try:
|
try:
|
||||||
self.commit(details, self.extractFilesFromCommit(details), self.branch)
|
self.commit(details, self.extractFilesFromCommit(details), self.branch)
|
||||||
except IOError:
|
except IOError:
|
||||||
print "IO error with git fast-import. Is your git version recent enough?"
|
print("IO error with git fast-import. Is your git version recent enough?")
|
||||||
print self.gitError.read()
|
print(self.gitError.read())
|
||||||
|
|
||||||
|
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
|
@ -2738,7 +2739,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
self.hasOrigin = originP4BranchesExist()
|
self.hasOrigin = originP4BranchesExist()
|
||||||
if self.hasOrigin:
|
if self.hasOrigin:
|
||||||
if not self.silent:
|
if not self.silent:
|
||||||
print 'Syncing with origin first, using "git fetch origin"'
|
print('Syncing with origin first, using "git fetch origin"')
|
||||||
system("git fetch origin")
|
system("git fetch origin")
|
||||||
|
|
||||||
branch_arg_given = bool(self.branch)
|
branch_arg_given = bool(self.branch)
|
||||||
|
@ -2777,14 +2778,14 @@ class P4Sync(Command, P4UserMap):
|
||||||
|
|
||||||
if len(self.p4BranchesInGit) > 1:
|
if len(self.p4BranchesInGit) > 1:
|
||||||
if not self.silent:
|
if not self.silent:
|
||||||
print "Importing from/into multiple branches"
|
print("Importing from/into multiple branches")
|
||||||
self.detectBranches = True
|
self.detectBranches = True
|
||||||
for branch in branches.keys():
|
for branch in branches.keys():
|
||||||
self.initialParents[self.refPrefix + branch] = \
|
self.initialParents[self.refPrefix + branch] = \
|
||||||
branches[branch]
|
branches[branch]
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "branches: %s" % self.p4BranchesInGit
|
print("branches: %s" % self.p4BranchesInGit)
|
||||||
|
|
||||||
p4Change = 0
|
p4Change = 0
|
||||||
for branch in self.p4BranchesInGit:
|
for branch in self.p4BranchesInGit:
|
||||||
|
@ -2819,7 +2820,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
self.depotPaths = sorted(self.previousDepotPaths)
|
self.depotPaths = sorted(self.previousDepotPaths)
|
||||||
self.changeRange = "@%s,#head" % p4Change
|
self.changeRange = "@%s,#head" % p4Change
|
||||||
if not self.silent and not self.detectBranches:
|
if not self.silent and not self.detectBranches:
|
||||||
print "Performing incremental import into %s git branch" % self.branch
|
print("Performing incremental import into %s git branch" % self.branch)
|
||||||
|
|
||||||
# accept multiple ref name abbreviations:
|
# accept multiple ref name abbreviations:
|
||||||
# refs/foo/bar/branch -> use it exactly
|
# refs/foo/bar/branch -> use it exactly
|
||||||
|
@ -2836,7 +2837,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
|
|
||||||
if len(args) == 0 and self.depotPaths:
|
if len(args) == 0 and self.depotPaths:
|
||||||
if not self.silent:
|
if not self.silent:
|
||||||
print "Depot paths: %s" % ' '.join(self.depotPaths)
|
print("Depot paths: %s" % ' '.join(self.depotPaths))
|
||||||
else:
|
else:
|
||||||
if self.depotPaths and self.depotPaths != args:
|
if self.depotPaths and self.depotPaths != args:
|
||||||
print ("previous import used depot path %s and now %s was specified. "
|
print ("previous import used depot path %s and now %s was specified. "
|
||||||
|
@ -2906,8 +2907,8 @@ class P4Sync(Command, P4UserMap):
|
||||||
else:
|
else:
|
||||||
self.getBranchMapping()
|
self.getBranchMapping()
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "p4-git branches: %s" % self.p4BranchesInGit
|
print("p4-git branches: %s" % self.p4BranchesInGit)
|
||||||
print "initial parents: %s" % self.initialParents
|
print("initial parents: %s" % self.initialParents)
|
||||||
for b in self.p4BranchesInGit:
|
for b in self.p4BranchesInGit:
|
||||||
if b != "master":
|
if b != "master":
|
||||||
|
|
||||||
|
@ -2959,8 +2960,8 @@ class P4Sync(Command, P4UserMap):
|
||||||
self.branch)
|
self.branch)
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
|
print("Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
|
||||||
self.changeRange)
|
self.changeRange))
|
||||||
changes = p4ChangesForPaths(self.depotPaths, self.changeRange)
|
changes = p4ChangesForPaths(self.depotPaths, self.changeRange)
|
||||||
|
|
||||||
if len(self.maxChanges) > 0:
|
if len(self.maxChanges) > 0:
|
||||||
|
@ -2968,10 +2969,10 @@ class P4Sync(Command, P4UserMap):
|
||||||
|
|
||||||
if len(changes) == 0:
|
if len(changes) == 0:
|
||||||
if not self.silent:
|
if not self.silent:
|
||||||
print "No changes to import!"
|
print("No changes to import!")
|
||||||
else:
|
else:
|
||||||
if not self.silent and not self.detectBranches:
|
if not self.silent and not self.detectBranches:
|
||||||
print "Import destination: %s" % self.branch
|
print("Import destination: %s" % self.branch)
|
||||||
|
|
||||||
self.updatedBranches = set()
|
self.updatedBranches = set()
|
||||||
|
|
||||||
|
@ -2986,7 +2987,7 @@ class P4Sync(Command, P4UserMap):
|
||||||
self.importChanges(changes)
|
self.importChanges(changes)
|
||||||
|
|
||||||
if not self.silent:
|
if not self.silent:
|
||||||
print ""
|
print("")
|
||||||
if len(self.updatedBranches) > 0:
|
if len(self.updatedBranches) > 0:
|
||||||
sys.stdout.write("Updated branches: ")
|
sys.stdout.write("Updated branches: ")
|
||||||
for b in self.updatedBranches:
|
for b in self.updatedBranches:
|
||||||
|
@ -3054,7 +3055,7 @@ class P4Rebase(Command):
|
||||||
# the branchpoint may be p4/foo~3, so strip off the parent
|
# the branchpoint may be p4/foo~3, so strip off the parent
|
||||||
upstream = re.sub("~[0-9]+$", "", upstream)
|
upstream = re.sub("~[0-9]+$", "", upstream)
|
||||||
|
|
||||||
print "Rebasing the current branch onto %s" % upstream
|
print("Rebasing the current branch onto %s" % upstream)
|
||||||
oldHead = read_pipe("git rev-parse HEAD").strip()
|
oldHead = read_pipe("git rev-parse HEAD").strip()
|
||||||
system("git rebase %s" % upstream)
|
system("git rebase %s" % upstream)
|
||||||
system("git diff-tree --stat --summary -M %s HEAD" % oldHead)
|
system("git diff-tree --stat --summary -M %s HEAD" % oldHead)
|
||||||
|
@ -3117,7 +3118,7 @@ class P4Clone(P4Sync):
|
||||||
if not self.cloneDestination:
|
if not self.cloneDestination:
|
||||||
self.cloneDestination = self.defaultDestination(args)
|
self.cloneDestination = self.defaultDestination(args)
|
||||||
|
|
||||||
print "Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination)
|
print("Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination))
|
||||||
|
|
||||||
if not os.path.exists(self.cloneDestination):
|
if not os.path.exists(self.cloneDestination):
|
||||||
os.makedirs(self.cloneDestination)
|
os.makedirs(self.cloneDestination)
|
||||||
|
@ -3139,8 +3140,8 @@ class P4Clone(P4Sync):
|
||||||
if not self.cloneBare:
|
if not self.cloneBare:
|
||||||
system([ "git", "checkout", "-f" ])
|
system([ "git", "checkout", "-f" ])
|
||||||
else:
|
else:
|
||||||
print 'Not checking out any branch, use ' \
|
print('Not checking out any branch, use ' \
|
||||||
'"git checkout -q -b master <branch>"'
|
'"git checkout -q -b master <branch>"')
|
||||||
|
|
||||||
# auto-set this variable if invoked with --use-client-spec
|
# auto-set this variable if invoked with --use-client-spec
|
||||||
if self.useClientSpec_from_options:
|
if self.useClientSpec_from_options:
|
||||||
|
@ -3173,7 +3174,7 @@ class P4Branches(Command):
|
||||||
log = extractLogMessageFromGitCommit("refs/remotes/%s" % branch)
|
log = extractLogMessageFromGitCommit("refs/remotes/%s" % branch)
|
||||||
settings = extractSettingsGitLog(log)
|
settings = extractSettingsGitLog(log)
|
||||||
|
|
||||||
print "%s <= %s (%s)" % (branch, ",".join(settings["depot-paths"]), settings["change"])
|
print("%s <= %s (%s)" % (branch, ",".join(settings["depot-paths"]), settings["change"]))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class HelpFormatter(optparse.IndentedHelpFormatter):
|
class HelpFormatter(optparse.IndentedHelpFormatter):
|
||||||
|
@ -3187,12 +3188,12 @@ class HelpFormatter(optparse.IndentedHelpFormatter):
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def printUsage(commands):
|
def printUsage(commands):
|
||||||
print "usage: %s <command> [options]" % sys.argv[0]
|
print("usage: %s <command> [options]" % sys.argv[0])
|
||||||
print ""
|
print("")
|
||||||
print "valid commands: %s" % ", ".join(commands)
|
print("valid commands: %s" % ", ".join(commands))
|
||||||
print ""
|
print("")
|
||||||
print "Try %s <command> --help for command specific help." % sys.argv[0]
|
print("Try %s <command> --help for command specific help." % sys.argv[0])
|
||||||
print ""
|
print("")
|
||||||
|
|
||||||
commands = {
|
commands = {
|
||||||
"debug" : P4Debug,
|
"debug" : P4Debug,
|
||||||
|
@ -3216,8 +3217,8 @@ def main():
|
||||||
klass = commands[cmdName]
|
klass = commands[cmdName]
|
||||||
cmd = klass()
|
cmd = klass()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print "unknown command %s" % cmdName
|
print("unknown command %s" % cmdName)
|
||||||
print ""
|
print("")
|
||||||
printUsage(commands.keys())
|
printUsage(commands.keys())
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ For example:
|
||||||
1234 //depot/security/src/
|
1234 //depot/security/src/
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -59,12 +60,12 @@ try:
|
||||||
changelist = int(sys.argv[1])
|
changelist = int(sys.argv[1])
|
||||||
changeroot = sys.argv[2]
|
changeroot = sys.argv[2]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
print >> sys.stderr, "Wrong number of arguments.\n\n",
|
print("Wrong number of arguments.\n\n", end=' ', file=sys.stderr)
|
||||||
print >> sys.stderr, __doc__
|
print(__doc__, file=sys.stderr)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print >> sys.stderr, "First argument must be an integer.\n\n",
|
print("First argument must be an integer.\n\n", end=' ', file=sys.stderr)
|
||||||
print >> sys.stderr, __doc__
|
print(__doc__, file=sys.stderr)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
metadata = git_p4.p4_describe(changelist)
|
metadata = git_p4.p4_describe(changelist)
|
||||||
|
|
5
setup.py
5
setup.py
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python2.7
|
#!/usr/bin/env python2.7
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -60,13 +61,13 @@ except ImportError:
|
||||||
try:
|
try:
|
||||||
import simplejson
|
import simplejson
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print >>sys.stderr, "simplejson is not installed"
|
print("simplejson is not installed", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
import requests
|
import requests
|
||||||
assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1'))
|
assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1'))
|
||||||
except (ImportError, AssertionError):
|
except (ImportError, AssertionError):
|
||||||
print >>sys.stderr, "requests >=0.12.1 is not installed"
|
print("requests >=0.12.1 is not installed", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import simplejson
|
import simplejson
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
@ -87,7 +88,7 @@ class RandomExponentialBackoff(CountingBackoff):
|
||||||
try:
|
try:
|
||||||
logger.warning(message)
|
logger.warning(message)
|
||||||
except NameError:
|
except NameError:
|
||||||
print message
|
print(message)
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
|
|
||||||
def _default_client():
|
def _default_client():
|
||||||
|
@ -273,9 +274,9 @@ class Client(object):
|
||||||
def end_error_retry(succeeded):
|
def end_error_retry(succeeded):
|
||||||
if query_state["had_error_retry"] and self.verbose:
|
if query_state["had_error_retry"] and self.verbose:
|
||||||
if succeeded:
|
if succeeded:
|
||||||
print "Success!"
|
print("Success!")
|
||||||
else:
|
else:
|
||||||
print "Failed!"
|
print("Failed!")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -364,7 +365,7 @@ class Client(object):
|
||||||
|
|
||||||
if 'error' in res.get('result'):
|
if 'error' in res.get('result'):
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Server returned error:\n%s" % res['msg']
|
print("Server returned error:\n%s" % res['msg'])
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
return (res['queue_id'], res['last_event_id'])
|
return (res['queue_id'], res['last_event_id'])
|
||||||
|
@ -378,13 +379,13 @@ class Client(object):
|
||||||
if 'error' in res.get('result'):
|
if 'error' in res.get('result'):
|
||||||
if res["result"] == "http-error":
|
if res["result"] == "http-error":
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "HTTP error fetching events -- probably a server restart"
|
print("HTTP error fetching events -- probably a server restart")
|
||||||
elif res["result"] == "connection-error":
|
elif res["result"] == "connection-error":
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Connection error fetching events -- probably server is temporarily down?"
|
print("Connection error fetching events -- probably server is temporarily down?")
|
||||||
else:
|
else:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print "Server returned error:\n%s" % res["msg"]
|
print("Server returned error:\n%s" % res["msg"])
|
||||||
if res["msg"].startswith("Bad event queue id:"):
|
if res["msg"].startswith("Bad event queue id:"):
|
||||||
# Our event queue went away, probably because
|
# Our event queue went away, probably because
|
||||||
# we were asleep or the server restarted
|
# we were asleep or the server restarted
|
||||||
|
|
Loading…
Reference in a new issue