Patchwork [7,of,9,stable] largefiles: don't let update leave wrong largefiles in wd if fetch fails

login
register
mail settings
Submitter Mads Kiilerich
Date Feb. 26, 2013, 2:41 a.m.
Message ID <51dfa49cb71bb83e7520.1361846487@mk-desktop>
Download mbox | patch
Permalink /patch/1056/
State Accepted
Commit 4846f2115927b359c7017857a67e02caf6f8b05b
Headers show

Comments

Mads Kiilerich - Feb. 26, 2013, 2:41 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1361846443 -3600
# Branch stable
# Node ID 51dfa49cb71bb83e7520003a0c7c6fefccc36519
# Parent  956919132f14f4245fda8858a1d190f2ec964778
largefiles: don't let update leave wrong largefiles in wd if fetch fails

Situations where a largefile for some reason wasn't available sometimes caused
wrong largefile content and state. It has mostly been seen when interrupting
download of largefiles ... and when introducing programming errors.

Instead we now make sure to delete the old and wrong largefile. A missing file
is a well-known error condition and much more reasonable way to handle the
situation.

Patch

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -501,6 +501,8 @@ 
                 # use normallookup() to allocate entry in largefiles dirstate,
                 # because lack of it misleads lfilesrepo.status() into
                 # recognition that such cache missing files are REMOVED.
+                if lfile not in repo[None]: # not switched to normal file
+                    util.unlinkpath(abslfile, ignoremissing=True)
                 lfdirstate.normallookup(lfile)
                 return None # don't try to set the mode
             else: