Patchwork [1,of,2,stable] largefiles: fix revert removing a largefile from a merge

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 10, 2013, 3:06 p.m.
Message ID <0e6dba8c1af060dddded.1357830383@mk-desktop>
Download mbox | patch
Permalink /patch/518/
State Superseded
Commit 26627c30735a610f59979a36885b327b25d8dbff
Headers show

Comments

Mads Kiilerich - Jan. 10, 2013, 3:06 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1357830135 -3600
# Branch stable
# Node ID 0e6dba8c1af060dddded1bbf12bff3b7616d3ed2
# Parent  40185df018d7b2f240f7c8864e1749ac34b8fcae
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.

Patch

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -173,8 +173,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
@@ -1208,6 +1208,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.