diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py --- a/hgext/largefiles/lfcommands.py +++ b/hgext/largefiles/lfcommands.py @@ -455,6 +455,7 @@ def updatelfiles(ui, repo, filelist=None lfiles = [f for f in lfiles if f in filelist] update = {} + dropped = set() updated, removed = 0, 0 wvfs = repo.wvfs wctx = repo[None] @@ -476,7 +477,11 @@ def updatelfiles(ui, repo, filelist=None expecthash = lfutil.readasstandin(wctx[relstandin]) if expecthash != '': if lfile not in wctx: # not switched to normal file - wvfs.unlinkpath(rellfile, ignoremissing=True) + if repo.dirstate[relstandin] != '?': + wvfs.unlinkpath(rellfile, ignoremissing=True) + else: + dropped.add(rellfile) + # use normallookup() to allocate an entry in largefiles # dirstate to prevent lfilesrepo.status() from reporting # missing files as removed. @@ -496,6 +501,15 @@ def updatelfiles(ui, repo, filelist=None lfdirstate.write() if lfiles: + lfiles = [f for f in lfiles if f not in dropped] + + for f in dropped: + repo.wvfs.unlinkpath(lfutil.standin(f)) + + # This needs to happen for dropped files, otherwise they stay in + # the M state. + lfutil.synclfdirstate(repo, lfdirstate, f, normallookup) + statuswriter(_('getting changed largefiles\n')) cachelfiles(ui, repo, None, lfiles) diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t --- a/tests/test-largefiles-misc.t +++ b/tests/test-largefiles-misc.t @@ -1148,20 +1148,18 @@ Move (and then undo) a directory move wi ? dir/subdir2/large.bin ? large.orig -BUG: The content of the forgotten file shouldn't be clobbered +The content of the forgotten file shouldn't be clobbered $ cat dir/subdir2/large.bin - large2 + modified -BUG: the standin for subdir2 should be deleted, not just dropped +The standin for subdir2 should be deleted, not just dropped $ listtree .hglf dir* large* .hglf/ .hglf/dir/ .hglf/dir/subdir/ .hglf/dir/subdir/large.bin - .hglf/dir/subdir2/ - .hglf/dir/subdir2/large.bin .hglf/large dir/ dir/subdir/ @@ -1173,13 +1171,13 @@ BUG: the standin for subdir2 should be d $ rm -r dir/subdir2 -BUG: subdir should not be in the destination. This is caused by the directory -existing under .hglf/. +'subdir' should not be in the destination. It would be if the subdir2 directory +existed under .hglf/. $ hg mv dir/subdir dir/subdir2 - moving .hglf/dir/subdir/large.bin to .hglf/dir/subdir2/subdir/large.bin (glob) + moving .hglf/dir/subdir/large.bin to .hglf/dir/subdir2/large.bin (glob) $ hg status -C - A dir/subdir2/subdir/large.bin + A dir/subdir2/large.bin dir/subdir/large.bin R dir/subdir/large.bin ? large.orig @@ -1189,13 +1187,10 @@ existing under .hglf/. .hglf/dir/ .hglf/dir/subdir2/ .hglf/dir/subdir2/large.bin - .hglf/dir/subdir2/subdir/ - .hglf/dir/subdir2/subdir/large.bin .hglf/large dir/ dir/subdir2/ - dir/subdir2/subdir/ - dir/subdir2/subdir/large.bin + dir/subdir2/large.bin large large.orig @@ -1236,9 +1231,6 @@ Start from scratch, and rename something .hglf/dir/ .hglf/dir/subdir/ .hglf/dir/subdir/large.bin - .hglf/dir2/ - .hglf/dir2/subdir/ - .hglf/dir2/subdir/large.bin .hglf/large dir/ dir/subdir/