# Bazaar revision bundle v0.8 # # message: # remove usage of has_key() # committer: Robey Pointer # date: Tue 2006-08-29 13:47:02.492000103 -0700 === modified file bzrlib/bundle/bundle_data.py --- bzrlib/bundle/bundle_data.py +++ bzrlib/bundle/bundle_data.py @@ -284,7 +284,7 @@ sha1 = StrictTestament(rev, inventory).as_sha1() if sha1 != rev_info.sha1: raise TestamentMismatch(rev.revision_id, rev_info.sha1, sha1) - if rev_to_sha1.has_key(rev.revision_id): + if rev.revision_id in rev_to_sha1: raise BzrError('Revision {%s} given twice in the list' % (rev.revision_id)) rev_to_sha1[rev.revision_id] = sha1 @@ -445,8 +445,8 @@ def note_rename(self, old_path, new_path): """A file/directory has been renamed from old_path => new_path""" - assert not self._renamed.has_key(new_path) - assert not self._renamed_r.has_key(old_path) + assert new_path not in self._renamed + assert old_path not in self._renamed_r self._renamed[new_path] = old_path self._renamed_r[old_path] = new_path @@ -457,7 +457,7 @@ self._kinds[new_id] = kind def note_last_changed(self, file_id, revision_id): - if (self._last_changed.has_key(file_id) + if (file_id in self._last_changed and self._last_changed[file_id] != revision_id): raise BzrError('Mismatched last-changed revision for file_id {%s}' ': %s != %s' % (file_id, @@ -500,7 +500,7 @@ old_path = new_path #If the new path wasn't in renamed, the old one shouldn't be in #renamed_r - if self._renamed_r.has_key(old_path): + if old_path in self._renamed_r: return None return old_path @@ -512,7 +512,7 @@ new_path = self._renamed_r.get(old_path) if new_path is not None: return new_path - if self._renamed.has_key(new_path): + if new_path in self._renamed: return None dirname,basename = os.path.split(old_path) if dirname != '': @@ -525,7 +525,7 @@ new_path = old_path #If the old path wasn't in renamed, the new one shouldn't be in #renamed_r - if self._renamed.has_key(new_path): + if new_path in self._renamed: return None return new_path === modified file bzrlib/bundle/serializer/__init__.py --- bzrlib/bundle/serializer/__init__.py +++ bzrlib/bundle/serializer/__init__.py @@ -69,7 +69,7 @@ raise errors.NotABundle('Did not find an opening header') # Now we have a version, to figure out how to read the bundle - if not _serializers.has_key(version): + if version not in _serializers: raise errors.BundleNotSupported(version, 'version not listed in known versions') @@ -87,7 +87,7 @@ :param version: [optional] target serialization version """ - if not _serializers.has_key(version): + if version not in _serializers: raise errors.BundleNotSupported(version, 'unknown bundle format') serializer = _serializers[version](version) @@ -262,7 +262,7 @@ _serializers[version] = klass return - if not _serializers.has_key(version): + if version not in _serializers: _serializers[version] = klass === modified file bzrlib/commands.py --- bzrlib/commands.py +++ bzrlib/commands.py @@ -65,7 +65,7 @@ k_unsquished = _unsquish_command_name(k) else: k_unsquished = k - if not plugin_cmds.has_key(k_unsquished): + if k_unsquished not in plugin_cmds: plugin_cmds[k_unsquished] = cmd mutter('registered plugin command %s', k_unsquished) if decorate and k_unsquished in builtin_command_names(): === modified file bzrlib/export/__init__.py --- bzrlib/export/__init__.py +++ bzrlib/export/__init__.py @@ -42,11 +42,11 @@ """ global _exporters, _exporter_extensions - if not _exporters.has_key(format) or override: + if (format not in _exporters) or override: _exporters[format] = func for ext in extensions: - if not _exporter_extensions.has_key(ext) or override: + if (ext not in _exporter_extensions) or override: _exporter_extensions[ext] = format @@ -90,7 +90,7 @@ if root is None: root = get_root_name(dest) - if not _exporters.has_key(format): + if format not in _exporters: raise errors.NoSuchExportFormat(format) return _exporters[format](tree, dest, root) === modified file bzrlib/inventory.py --- bzrlib/inventory.py +++ bzrlib/inventory.py @@ -1215,7 +1215,7 @@ return bool(self.path2id(names)) def has_id(self, file_id): - return self._byid.has_key(file_id) + return file_id in self._byid def rename(self, file_id, new_parent_id, new_name): """Move a file within the inventory. === modified file bzrlib/knit.py --- bzrlib/knit.py +++ bzrlib/knit.py @@ -1255,7 +1255,7 @@ def has_version(self, version_id): """True if the version is in the index.""" - return self._cache.has_key(version_id) + return version_id in self._cache def get_position(self, version_id): """Return data position and size of specified version.""" === modified file bzrlib/msgeditor.py --- bzrlib/msgeditor.py +++ bzrlib/msgeditor.py @@ -41,7 +41,7 @@ yield e for varname in 'VISUAL', 'EDITOR': - if os.environ.has_key(varname): + if varname in os.environ: yield os.environ[varname] if sys.platform == 'win32': === modified file bzrlib/revision.py --- bzrlib/revision.py +++ bzrlib/revision.py @@ -154,7 +154,7 @@ anc_iter = enumerate(iter_ancestors(revision_id, revision_source, only_present=True)) for anc_order, (anc_id, anc_distance) in anc_iter: - if not found_ancestors.has_key(anc_id): + if anc_id not in found_ancestors: found_ancestors[anc_id] = (anc_order, anc_distance) return found_ancestors === modified file bzrlib/tests/__init__.py --- bzrlib/tests/__init__.py +++ bzrlib/tests/__init__.py @@ -798,7 +798,7 @@ return self.run_bzr_captured(args, retcode=retcode, encoding=encoding, stdin=stdin) def run_bzr_decode(self, *args, **kwargs): - if kwargs.has_key('encoding'): + if 'encoding' in kwargs: encoding = kwargs['encoding'] else: encoding = bzrlib.user_encoding === modified file bzrlib/tests/blackbox/test_too_much.py --- bzrlib/tests/blackbox/test_too_much.py +++ bzrlib/tests/blackbox/test_too_much.py @@ -420,7 +420,7 @@ oldpath = os.environ.get('BZRPATH', None) bzr = self.capture try: - if os.environ.has_key('BZRPATH'): + if 'BZRPATH' in os.environ: del os.environ['BZRPATH'] f = file(cmd_name, 'wb') === modified file bzrlib/tests/test_merge_core.py --- bzrlib/tests/test_merge_core.py +++ bzrlib/tests/test_merge_core.py @@ -139,7 +139,7 @@ return orig_inventory_by_path[parent_dir] def new_path(file_id): - if inventory_change.has_key(file_id): + if fild_id in inventory_change: return inventory_change[file_id] else: parent = parent_id(file_id) @@ -156,7 +156,7 @@ new_inventory[file_id] = path for file_id, path in inventory_change.iteritems(): - if orig_inventory.has_key(file_id): + if file_id in orig_inventory: continue new_inventory[file_id] = path return new_inventory === modified file bzrlib/transport/sftp.py --- bzrlib/transport/sftp.py +++ bzrlib/transport/sftp.py @@ -871,15 +871,15 @@ server_key = t.get_remote_server_key() server_key_hex = paramiko.util.hexify(server_key.get_fingerprint()) keytype = server_key.get_name() - if SYSTEM_HOSTKEYS.has_key(self._host) and SYSTEM_HOSTKEYS[self._host].has_key(keytype): + if (self._host in SYSTEM_HOSTKEYS) and (keytype in SYSTEM_HOSTKEYS[self._host]): our_server_key = SYSTEM_HOSTKEYS[self._host][keytype] our_server_key_hex = paramiko.util.hexify(our_server_key.get_fingerprint()) - elif BZR_HOSTKEYS.has_key(self._host) and BZR_HOSTKEYS[self._host].has_key(keytype): + elif (self._host in BZR_HOSTKEYS) and (keytype in BZR_HOSTKEYS[self._host]): our_server_key = BZR_HOSTKEYS[self._host][keytype] our_server_key_hex = paramiko.util.hexify(our_server_key.get_fingerprint()) else: warning('Adding %s host key for %s: %s' % (keytype, self._host, server_key_hex)) - if not BZR_HOSTKEYS.has_key(self._host): + if self._host not in BZR_HOSTKEYS: BZR_HOSTKEYS[self._host] = {} BZR_HOSTKEYS[self._host][keytype] = server_key our_server_key = server_key === modified file bzrlib/util/configobj/configobj.py --- bzrlib/util/configobj/configobj.py +++ bzrlib/util/configobj/configobj.py @@ -353,7 +353,7 @@ if not isinstance(key, StringTypes): raise ValueError, 'The key "%s" is not a string.' % key # add the comment - if not self.comments.has_key(key): + if key not in self.comments: self.comments[key] = [] self.inline_comments[key] = '' # remove the entry from defaults @@ -361,13 +361,13 @@ self.defaults.remove(key) # if isinstance(value, Section): - if not self.has_key(key): + if key not in self: self.sections.append(key) dict.__setitem__(self, key, value) elif isinstance(value, dict): # First create the new depth level, # then create the section - if not self.has_key(key): + if key not in self: self.sections.append(key) new_depth = self.depth + 1 dict.__setitem__( @@ -380,7 +380,7 @@ indict=value, name=key)) else: - if not self.has_key(key): + if key not in self: self.scalars.append(key) if not self.main.stringify: if isinstance(value, StringTypes): @@ -1344,7 +1344,7 @@ NestingError, infile, cur_index) # sect_name = self._unquote(sect_name) - if parent.has_key(sect_name): + if sect_name in parent: ## print >> sys.stderr, sect_name self._handle_error( 'Duplicate section name at line %s.', @@ -1394,7 +1394,7 @@ # ## print >> sys.stderr, sline key = self._unquote(key) - if this_section.has_key(key): + if key in this_section: self._handle_error( 'Duplicate keyword name at line %s.', DuplicateError, infile, cur_index) @@ -1745,7 +1745,7 @@ for entry in configspec.sections: if entry == '__many__': continue - if not section.has_key(entry): + if entry not in section: section[entry] = {} self._set_configspec_value(configspec[entry], section[entry]) @@ -1776,7 +1776,7 @@ # section.configspec = scalars for entry in sections: - if not section.has_key(entry): + if entry not in section: section[entry] = {} self._handle_repeat(section[entry], sections[entry]) === modified file bzrlib/weave.py --- bzrlib/weave.py +++ bzrlib/weave.py @@ -265,7 +265,7 @@ def has_version(self, version_id): """See VersionedFile.has_version.""" - return self._name_map.has_key(version_id) + return version_id in self._name_map __contains__ = has_version # revision id: robey@lag.net-20060829204702-6d40ae7a33ec62c7 # sha1: 68d9e61355dacc43c51939813b34f34c11a7cd13 # inventory sha1: cb89c6fa803155ef78cc028108134072a0f597c9 # parent ids: # pqm@pqm.ubuntu.com-20060828152314-9bd2bb284d84fab2 # base id: pqm@pqm.ubuntu.com-20060828152314-9bd2bb284d84fab2 # properties: # branch-nick: bzr.dev.no_has_key