git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] contrib: hg-to-git: has_key is removed in Python 3

From
JWJelle van der Waa <jelle@vdwaa.nl>
Date
Apr 1, 2019, 18:52 UTC
Message-ID
<20190401185208.17031-3-jelle@vdwaa.nl>
In-Reply-To
<20190401185208.17031-1-jelle@vdwaa.nl>
From: Jelle van der Waa <jelle@vdwaa.nl>

has_key was deprecated in Python 2 and finally removed in Python 3 in favor of 'foo' in bar.

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
---
 contrib/hg-to-git/hg-to-git.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py
index f898d6f23e..d504624c63 100755
--- a/contrib/hg-to-git/hg-to-git.py
+++ b/contrib/hg-to-git/hg-to-git.py
@@ -155,7 +155,7 @@ def getgitenv(user, date):
         else:
             hgbranch[str(cset)] = "branch-" + str(cset)
 
-if not hgvers.has_key("0"):
+if "0" not in hgvers:
     print('creating repository')
     os.system('git init')
 
@@ -163,7 +163,7 @@ def getgitenv(user, date):
 for cset in range(int(tip) + 1):
 
     # incremental, already seen
-    if hgvers.has_key(str(cset)):
+    if str(cset) in hgvers:
         continue
     hgnewcsets += 1
 
-- 
2.21.0
Previous: Jelle van der Waa
Message 4 of 4 in “Make hg-to-git contrib script Python 3 compatible”
  1. 0/3 Make hg-to-git contrib script Python 3 compatibleJelle van der Waa, Apr 1, 2019
  2. 1/3 contrib: hg-to-git: make print python 3 compatibleJelle van der Waa, Apr 1, 2019
  3. 3/3 contrib: hg-to-git: convert data to bytes for os.writeJelle van der Waa, Apr 1, 2019
  4. 2/3 contrib: hg-to-git: has_key is removed in Python 3Jelle van der Waa, Apr 1, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.