[PATCH] largefiles: better handling of merge of largefiles that not are available

Mads Kiilerich mads at kiilerich.com
Mon Oct 12 17:29:43 UTC 2015


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1444670554 -7200
#      Mon Oct 12 19:22:34 2015 +0200
# Node ID a4b81dd281da896a4c3241a246b765a0ab9d379f
# Parent  6e715040c1725b5debce888c4f7d3fdbf55cc900
largefiles: better handling of merge of largefiles that not are available

Before, when merging revisions with missing largefiles, the missing largefiles
would be fetched as a part of the merge. If that failed (for example because
the main repository temporarily was unavailable), the largefile would be left
missing. However, the next commit would abort and (seemed to) fail when
markcommitted tried to mark the standin file as normal and thus had to hash the
largefile that didn't exist. (Actually, the commit would succeed but the
largefile update that follows right after the commit transaction would abort -
quite confusing.)

To fix that, make sure that synclfdirstate only marks files as normal if they
actually exist.

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -399,7 +399,8 @@ def synclfdirstate(repo, lfdirstate, lfi
     else:
         state, mtime = '?', -1
     if state == 'n':
-        if normallookup or mtime < 0:
+        if (normallookup or mtime < 0 or
+            not os.path.exists(repo.wjoin(lfile))):
             # state 'n' doesn't ensure 'clean' in this case
             lfdirstate.normallookup(lfile)
         else:
diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t
--- a/tests/test-largefiles-update.t
+++ b/tests/test-largefiles-update.t
@@ -141,6 +141,28 @@ Test that "hg merge" updates largefiles 
   $ cat .hglf/large1
   58e24f733a964da346e2407a2bee99d9001184f5
 
+(merge non-existing largefiles from "other" via conflict prompt -
+make sure the following commit doesn't abort in a confusing way when trying to
+mark the non-existing file as normal in lfdirstate)
+
+  $ mv .hg/largefiles/58e24f733a964da346e2407a2bee99d9001184f5 .
+  $ hg update -q -C 3
+  $ hg merge --config largefiles.usercache=not --config debug.dirstate.delaywrite=2 --tool :local --config ui.interactive=True <<EOF
+  > o
+  > EOF
+  largefile large1 has a merge conflict
+  ancestor was 4669e532d5b2c093a78eca010077e708a071bb64
+  keep (l)ocal e5bb990443d6a92aaf7223813720f7566c9dd05b or
+  take (o)ther 58e24f733a964da346e2407a2bee99d9001184f5? o
+  getting changed largefiles
+  large1: largefile 58e24f733a964da346e2407a2bee99d9001184f5 not available from file:/*/$TESTTMP/repo (glob)
+  0 largefiles updated, 0 removed
+  0 files updated, 2 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg commit -m '1-2-3 testing'
+  $ hg rollback -q
+  $ mv 58e24f733a964da346e2407a2bee99d9001184f5 .hg/largefiles/
+
 Test that "hg revert -r REV" updates largefiles from "REV" correctly
 
   $ hg update -q -C 3


More information about the Mercurial-devel mailing list