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

login
register
mail settings
Submitter Siddharth Agarwal
Date Sept. 12, 2014, 7:48 p.m.
Message ID <0302b4d0355c43000ceb.1410551313@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/5805/
State Accepted
Headers show

Comments

Siddharth Agarwal - Sept. 12, 2014, 7:48 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.

Patch

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