largefiles: test and simplify empty directory removal in remove

This commit is contained in:
Patrick Mezard 2012-01-19 10:07:13 +01:00
parent dbffdfd960
commit 7768e63bf5
2 changed files with 9 additions and 5 deletions

View File

@ -159,11 +159,7 @@ def remove_largefiles(ui, repo, *pats, **opts):
if getattr(repo, "_isaddremove", False):
ui.status(_('removing %s\n' % f))
if os.path.exists(repo.wjoin(f)):
os.unlink(repo.wjoin(f))
currentdir = os.path.split(f)[0]
while currentdir and not os.listdir(repo.wjoin(currentdir)):
os.rmdir(repo.wjoin(currentdir))
currentdir = os.path.split(currentdir)[0]
util.unlinkpath(repo.wjoin(f))
lfdirstate.remove(f)
lfdirstate.write()
forget = [lfutil.standin(f) for f in forget]

View File

@ -556,6 +556,14 @@ Test removing empty largefiles directories on update
[1]
$ hg update -q
Test hg remove removes empty largefiles directories
$ test -d sub2 && echo "sub2 exists"
sub2 exists
$ hg remove sub2/*
$ test -d sub2 && echo "error: sub2 should not exist anymore"
[1]
$ hg revert sub2/large6 sub2/large7
"revert" works on largefiles (and normal files too).
$ echo hack3 >> normal3
$ echo hack4 >> sub/normal4