# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1428082024 25200
#      Fri Apr 03 10:27:04 2015 -0700
# Node ID da01212cd53a11fa477b21924da5360e466cf9cd
# Parent  c1c2af8aecb30188cec7deb4a4f96a953b2a96fb
gitdirstate: use normalized path from _walkexplicit

Since 2bb13f2b778c in Mercurial, _walkexplicit returns a tuple, so ensure
we are up to date and take the normalized path which is the first part of the
tuple.

Based on a patch by David Soria Parra <davidsp@fb.com>.

diff --git a/hggit/gitdirstate.py b/hggit/gitdirstate.py
--- a/hggit/gitdirstate.py
+++ b/hggit/gitdirstate.py
@@ -163,7 +163,11 @@
         results, work, dirsnotfound = self._walkexplicit(match, subrepos)
 
         skipstep3 = skipstep3 and not (work or dirsnotfound)
-        work = [d for d in work if not dirignore(d)]
+        if work and isinstance(work[0], tuple):
+            # Mercurial >= 3.3.3
+            work = [nd for nd, d in work if not dirignore(d)]
+        else:
+            work = [d for d in work if not dirignore(d)]
         wadd = work.append
 
         # step 2: visit subdirectories