[PATCH 2 of 6] convert: for git's getchanges, use explicit index for iteration

Siddharth Agarwal sid0 at fb.com
Fri Sep 12 14:48:33 CDT 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1410503719 25200
#      Thu Sep 11 23:35:19 2014 -0700
# Node ID 0302b4d0355c43000cebb037c2857eb8305178da
# Parent  8010fe5fc2651dd75a2c7849af0ef7870a3b7a6f
convert: for git's getchanges, use explicit index for iteration

Upcoming patches will add support for copies and renames, for which we'll need
to access multiple lines of the difftree output at once.

diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -190,7 +190,12 @@
         entry = None
         subexists = False
         subdeleted = False
-        for l in fh.read().split('\x00'):
+        difftree = fh.read().split('\x00')
+        lcount = len(difftree)
+        i = 0
+        while i < lcount:
+            l = difftree[i]
+            i += 1
             if not entry:
                 if not l.startswith(':'):
                     continue


More information about the Mercurial-devel mailing list