Apply Python 3 futurize transform lib2to3.fixes.fix_has_key.
This commit is contained in:
parent
a49e641719
commit
5f1d06390c
|
@ -575,7 +575,7 @@ def gitBranchExists(branch):
|
|||
_gitConfig = {}
|
||||
|
||||
def gitConfig(key):
|
||||
if not _gitConfig.has_key(key):
|
||||
if key not in _gitConfig:
|
||||
cmd = [ "git", "config", key ]
|
||||
s = read_pipe(cmd, ignore_error=True)
|
||||
_gitConfig[key] = s.strip()
|
||||
|
@ -586,7 +586,7 @@ def gitConfigBool(key):
|
|||
variable is set to true, and False if set to false or not present
|
||||
in the config."""
|
||||
|
||||
if not _gitConfig.has_key(key):
|
||||
if key not in _gitConfig:
|
||||
cmd = [ "git", "config", "--bool", key ]
|
||||
s = read_pipe(cmd, ignore_error=True)
|
||||
v = s.strip()
|
||||
|
@ -594,7 +594,7 @@ def gitConfigBool(key):
|
|||
return _gitConfig[key]
|
||||
|
||||
def gitConfigList(key):
|
||||
if not _gitConfig.has_key(key):
|
||||
if key not in _gitConfig:
|
||||
s = read_pipe(["git", "config", "--get-all", key], ignore_error=True)
|
||||
_gitConfig[key] = s.strip().split(os.linesep)
|
||||
return _gitConfig[key]
|
||||
|
@ -650,7 +650,7 @@ def findUpstreamBranchPoint(head = "HEAD"):
|
|||
tip = branches[branch]
|
||||
log = extractLogMessageFromGitCommit(tip)
|
||||
settings = extractSettingsGitLog(log)
|
||||
if settings.has_key("depot-paths"):
|
||||
if "depot-paths" in settings:
|
||||
paths = ",".join(settings["depot-paths"])
|
||||
branchByDepotPath[paths] = "remotes/p4/" + branch
|
||||
|
||||
|
@ -660,9 +660,9 @@ def findUpstreamBranchPoint(head = "HEAD"):
|
|||
commit = head + "~%s" % parent
|
||||
log = extractLogMessageFromGitCommit(commit)
|
||||
settings = extractSettingsGitLog(log)
|
||||
if settings.has_key("depot-paths"):
|
||||
if "depot-paths" in settings:
|
||||
paths = ",".join(settings["depot-paths"])
|
||||
if branchByDepotPath.has_key(paths):
|
||||
if paths in branchByDepotPath:
|
||||
return [branchByDepotPath[paths], settings]
|
||||
|
||||
parent = parent + 1
|
||||
|
@ -686,8 +686,8 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
|
|||
originHead = line
|
||||
|
||||
original = extractSettingsGitLog(extractLogMessageFromGitCommit(originHead))
|
||||
if (not original.has_key('depot-paths')
|
||||
or not original.has_key('change')):
|
||||
if ('depot-paths' not in original
|
||||
or 'change' not in original):
|
||||
continue
|
||||
|
||||
update = False
|
||||
|
@ -697,7 +697,7 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
|
|||
update = True
|
||||
else:
|
||||
settings = extractSettingsGitLog(extractLogMessageFromGitCommit(remoteHead))
|
||||
if settings.has_key('change') > 0:
|
||||
if ('change' in settings) > 0:
|
||||
if settings['depot-paths'] == original['depot-paths']:
|
||||
originP4Change = int(original['change'])
|
||||
p4Change = int(settings['change'])
|
||||
|
@ -836,7 +836,7 @@ class P4UserMap:
|
|||
|
||||
results = p4CmdList("user -o")
|
||||
for r in results:
|
||||
if r.has_key('User'):
|
||||
if 'User' in r:
|
||||
self.myP4UserId = r['User']
|
||||
return r['User']
|
||||
die("Could not find your p4 user id")
|
||||
|
@ -860,7 +860,7 @@ class P4UserMap:
|
|||
self.emails = {}
|
||||
|
||||
for output in p4CmdList("users"):
|
||||
if not output.has_key("User"):
|
||||
if "User" not in output:
|
||||
continue
|
||||
self.users[output["User"]] = output["FullName"] + " <" + output["Email"] + ">"
|
||||
self.emails[output["Email"]] = output["User"]
|
||||
|
@ -1081,7 +1081,7 @@ class P4Submit(Command, P4UserMap):
|
|||
gitEmail = read_pipe(["git", "log", "--max-count=1",
|
||||
"--format=%ae", id])
|
||||
gitEmail = gitEmail.strip()
|
||||
if not self.emails.has_key(gitEmail):
|
||||
if gitEmail not in self.emails:
|
||||
return (None,gitEmail)
|
||||
else:
|
||||
return (self.emails[gitEmail],gitEmail)
|
||||
|
@ -1105,14 +1105,14 @@ class P4Submit(Command, P4UserMap):
|
|||
results = p4CmdList("client -o") # find the current client
|
||||
client = None
|
||||
for r in results:
|
||||
if r.has_key('Client'):
|
||||
if 'Client' in r:
|
||||
client = r['Client']
|
||||
break
|
||||
if not client:
|
||||
die("could not get client spec")
|
||||
results = p4CmdList(["changes", "-c", client, "-m", "1"])
|
||||
for r in results:
|
||||
if r.has_key('change'):
|
||||
if 'change' in r:
|
||||
return r['change']
|
||||
die("Could not get changelist number for last submit - cannot patch up user details")
|
||||
|
||||
|
@ -1130,10 +1130,10 @@ class P4Submit(Command, P4UserMap):
|
|||
|
||||
result = p4CmdList("change -f -i", stdin=input)
|
||||
for r in result:
|
||||
if r.has_key('code'):
|
||||
if 'code' in r:
|
||||
if r['code'] == 'error':
|
||||
die("Could not modify user field of changelist %s to %s:%s" % (changelist, newUser, r['data']))
|
||||
if r.has_key('data'):
|
||||
if 'data' in r:
|
||||
print("Updated user field for changelist %s to %s" % (changelist, newUser))
|
||||
return
|
||||
die("Could not modify user field of changelist %s to %s" % (changelist, newUser))
|
||||
|
@ -1143,7 +1143,7 @@ class P4Submit(Command, P4UserMap):
|
|||
# which are required to modify changelists.
|
||||
results = p4CmdList(["protects", self.depotPath])
|
||||
for r in results:
|
||||
if r.has_key('perm'):
|
||||
if 'perm' in r:
|
||||
if r['perm'] == 'admin':
|
||||
return 1
|
||||
if r['perm'] == 'super':
|
||||
|
@ -1195,7 +1195,7 @@ class P4Submit(Command, P4UserMap):
|
|||
mtime = os.stat(template_file).st_mtime
|
||||
|
||||
# invoke the editor
|
||||
if os.environ.has_key("P4EDITOR") and (os.environ.get("P4EDITOR") != ""):
|
||||
if "P4EDITOR" in os.environ and (os.environ.get("P4EDITOR") != ""):
|
||||
editor = os.environ.get("P4EDITOR")
|
||||
else:
|
||||
editor = read_pipe("git var GIT_EDITOR").strip()
|
||||
|
@ -1379,7 +1379,7 @@ class P4Submit(Command, P4UserMap):
|
|||
separatorLine = "######## everything below this line is just the diff #######\n"
|
||||
|
||||
# diff
|
||||
if os.environ.has_key("P4DIFF"):
|
||||
if "P4DIFF" in os.environ:
|
||||
del(os.environ["P4DIFF"])
|
||||
diff = ""
|
||||
for editedFile in editedFiles:
|
||||
|
@ -1503,7 +1503,7 @@ class P4Submit(Command, P4UserMap):
|
|||
logMessage = extractLogMessageFromGitCommit(name)
|
||||
values = extractSettingsGitLog(logMessage)
|
||||
|
||||
if not values.has_key('change'):
|
||||
if 'change' not in values:
|
||||
# a tag pointing to something not sent to p4; ignore
|
||||
if verbose:
|
||||
print "git tag %s does not give a p4 commit" % name
|
||||
|
@ -1939,7 +1939,7 @@ class P4Sync(Command, P4UserMap):
|
|||
for path in self.cloneExclude]
|
||||
files = []
|
||||
fnum = 0
|
||||
while commit.has_key("depotFile%s" % fnum):
|
||||
while "depotFile%s" % fnum in commit:
|
||||
path = commit["depotFile%s" % fnum]
|
||||
|
||||
if [p for p in self.cloneExclude
|
||||
|
@ -2003,7 +2003,7 @@ class P4Sync(Command, P4UserMap):
|
|||
|
||||
branches = {}
|
||||
fnum = 0
|
||||
while commit.has_key("depotFile%s" % fnum):
|
||||
while "depotFile%s" % fnum in commit:
|
||||
path = commit["depotFile%s" % fnum]
|
||||
found = [p for p in self.depotPaths
|
||||
if p4PathStartsWith(path, p)]
|
||||
|
@ -2141,7 +2141,7 @@ class P4Sync(Command, P4UserMap):
|
|||
else:
|
||||
die("Error from p4 print: %s" % err)
|
||||
|
||||
if marshalled.has_key('depotFile') and self.stream_have_file_info:
|
||||
if 'depotFile' in marshalled and self.stream_have_file_info:
|
||||
# start of a new file - output the old one first
|
||||
self.streamOneP4File(self.stream_file, self.stream_contents)
|
||||
self.stream_file = {}
|
||||
|
@ -2197,7 +2197,7 @@ class P4Sync(Command, P4UserMap):
|
|||
cb=streamP4FilesCbSelf)
|
||||
|
||||
# do the last chunk
|
||||
if self.stream_file.has_key('depotFile'):
|
||||
if 'depotFile' in self.stream_file:
|
||||
self.streamOneP4File(self.stream_file, self.stream_contents)
|
||||
|
||||
def make_email(self, userid):
|
||||
|
@ -2213,7 +2213,7 @@ class P4Sync(Command, P4UserMap):
|
|||
gitStream.write("tag %s\n" % labelName)
|
||||
gitStream.write("from %s\n" % commit)
|
||||
|
||||
if labelDetails.has_key('Owner'):
|
||||
if 'Owner' in labelDetails:
|
||||
owner = labelDetails["Owner"]
|
||||
else:
|
||||
owner = None
|
||||
|
@ -2229,7 +2229,7 @@ class P4Sync(Command, P4UserMap):
|
|||
gitStream.write("tagger %s\n" % tagger)
|
||||
|
||||
print "labelDetails=",labelDetails
|
||||
if labelDetails.has_key('Description'):
|
||||
if 'Description' in labelDetails:
|
||||
description = labelDetails['Description']
|
||||
else:
|
||||
description = 'Label from git p4'
|
||||
|
@ -2285,7 +2285,7 @@ class P4Sync(Command, P4UserMap):
|
|||
|
||||
change = int(details["change"])
|
||||
|
||||
if self.labels.has_key(change):
|
||||
if change in self.labels:
|
||||
label = self.labels[change]
|
||||
labelDetails = label[0]
|
||||
labelRevisions = label[1]
|
||||
|
@ -2374,7 +2374,7 @@ class P4Sync(Command, P4UserMap):
|
|||
change = p4Cmd(["changes", "-m", "1"] + ["%s...@%s" % (p, name)
|
||||
for p in self.depotPaths])
|
||||
|
||||
if change.has_key('change'):
|
||||
if 'change' in change:
|
||||
# find the corresponding git commit; take the oldest commit
|
||||
changelist = int(change['change'])
|
||||
gitCommit = read_pipe(["git", "rev-list", "--max-count=1",
|
||||
|
@ -2427,7 +2427,7 @@ class P4Sync(Command, P4UserMap):
|
|||
for info in p4CmdList(command):
|
||||
details = p4Cmd(["branch", "-o", info["branch"]])
|
||||
viewIdx = 0
|
||||
while details.has_key("View%s" % viewIdx):
|
||||
while "View%s" % viewIdx in details:
|
||||
paths = details["View%s" % viewIdx].split(" ")
|
||||
viewIdx = viewIdx + 1
|
||||
# require standard //depot/foo/... //depot/bar/... mapping
|
||||
|
@ -2493,7 +2493,7 @@ class P4Sync(Command, P4UserMap):
|
|||
d["options"] = ' '.join(sorted(option_keys.keys()))
|
||||
|
||||
def readOptions(self, d):
|
||||
self.keepRepoPath = (d.has_key('options')
|
||||
self.keepRepoPath = ('options' in d
|
||||
and ('keepRepoPath' in d['options']))
|
||||
|
||||
def gitRefForBranch(self, branch):
|
||||
|
@ -2794,8 +2794,8 @@ class P4Sync(Command, P4UserMap):
|
|||
settings = extractSettingsGitLog(logMsg)
|
||||
|
||||
self.readOptions(settings)
|
||||
if (settings.has_key('depot-paths')
|
||||
and settings.has_key ('change')):
|
||||
if ('depot-paths' in settings
|
||||
and 'change' in settings):
|
||||
change = int(settings['change']) + 1
|
||||
p4Change = max(p4Change, change)
|
||||
|
||||
|
|
Loading…
Reference in a new issue