remotefilelog: before creating filenode, check in manifest if the file exists

Summary:
When hg addremove needs to remove a file, remotefilelog tries to create a filenode in order to prefetch the removed files from the server.  If the file is not in the parent context manifest, this throws an exception.

To solve this we have to first check if the file exists or not in the parent manifest.  If the file does not exist in the manifest then we don't need to prefetch it, and addremove will behave like forget rather than remove.

Reviewed By: markbt

Differential Revision: D7009649

fbshipit-source-id: 0570bc00db546a455b9c2e4628740e24ca819dd6
This commit is contained in:
Rohit Yadav 2018-02-19 08:57:37 -08:00 committed by Saurabh Singh
parent 3560fd1139
commit 4838457b17
2 changed files with 13 additions and 1 deletions

View File

@ -385,7 +385,9 @@ def onetimeclientsetup(ui):
if shallowrepo.requirement in repo.requirements:
files = []
parentctx = repo['.']
m1 = parentctx.manifest()
for f in removed:
if f in m1:
files.append((f, hex(parentctx.filenode(f))))
# batch fetch the needed files from the server
repo.fileservice.prefetch(files)

View File

@ -50,6 +50,7 @@
$ hg addremove
adding dir/a.py
$ cd ..
$ cd ..
$ hg init sim
$ cd sim
@ -91,4 +92,13 @@
$ hg st
! c
$ hg forget c
$ touch foo
$ hg addremove
adding foo
$ rm foo
$ hg addremove
removing foo
$ cd ..