Patchwork [4,of,8] obsolete: use 2 argument form of enumerate()

login
register
mail settings
Submitter Gregory Szorc
Date May 13, 2017, 7:54 p.m.
Message ID <e367d7c1b2c46a78056a.1494705276@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/20608/
State Accepted
Headers show

Comments

Gregory Szorc - May 13, 2017, 7:54 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1494700962 25200
#      Sat May 13 11:42:42 2017 -0700
# Node ID e367d7c1b2c46a78056a3093c43d6c9bee8e5bbf
# Parent  aeb25aafb4820c76aec6d5093b7b1142a910b12e
obsolete: use 2 argument form of enumerate()

The 2 argument form of enumerate was added in Python 2.6. This
change effectively reverts 10880c8aad85.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -217,8 +217,8 @@  def _fm0encodeonemarker(marker):
         if not parents:
             # mark that we explicitly recorded no parents
             metadata['p0'] = ''
-        for i, p in enumerate(parents):
-            metadata['p%i' % (i + 1)] = node.hex(p)
+        for i, p in enumerate(parents, 1):
+            metadata['p%i' % i] = node.hex(p)
     metadata = _fm0encodemeta(metadata)
     numsuc = len(sucs)
     format = _fm0fixed + (_fm0node * numsuc)