# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1357918229 -3600
# Node ID a7a88a458a4cf1dcbd7d6bc15e263781a8b789f9
# Parent  3598c585e464f715574f67bb9f7a83b8c0573612
largefiles: fix revert removing a largefile from a merge

Before revert could fail with:
  abort: .hglf/large@33fdd332ec64: not found in manifest!

The LookupError will now be caught and handled correctly.

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -142,8 +142,11 @@
     s = lfdirstate.status(match, [], False, False, False)
     unsure, modified, added, removed, missing, unknown, ignored, clean = s
     for lfile in unsure:
-        if repo[rev][standin(lfile)].data().strip() != \
-                hashfile(repo.wjoin(lfile)):
+        try:
+            fctx = repo[rev][standin(lfile)]
+        except LookupError:
+            fctx = None
+        if not fctx or fctx.data().strip() != hashfile(repo.wjoin(lfile)):
             modified.append(lfile)
         else:
             clean.append(lfile)
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -1220,6 +1220,10 @@
   $ hg status
   M large
 
+- revert should be able to revert files introduced in a pending merge
+  $ hg revert --all -r .
+  removing .hglf/large
+
 Test that a normal file and a largefile with the same name and path cannot
 coexist.