changeset 42092:91cc8dc866ed

remotefilelog: fix crash on `hg addremove` of added-but-deleted file If you `hg add` a file and then delete it from disk, and then run `hg addremove`, the file ends up in the "removed" set that gets passed to the findrenames() override. We then crash because the file is not in the working copy parent. This patch fixes that. Differential Revision: https://phab.mercurial-scm.org/D6194
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 03 Apr 2019 17:41:58 -0700
parents 57645939df59
children edbcf5b239f9
files hgext/remotefilelog/__init__.py tests/test-remotefilelog-prefetch.t
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/remotefilelog/__init__.py	Fri Apr 05 23:07:11 2019 -0400
+++ b/hgext/remotefilelog/__init__.py	Wed Apr 03 17:41:58 2019 -0700
@@ -478,9 +478,10 @@
     def findrenames(orig, repo, matcher, added, removed, *args, **kwargs):
         if isenabled(repo):
             files = []
-            parentctx = repo['.']
+            pmf = repo['.'].manifest()
             for f in removed:
-                files.append((f, hex(parentctx.filenode(f))))
+                if f in pmf:
+                    files.append((f, hex(pmf[f])))
             # batch fetch the needed files from the server
             repo.fileservice.prefetch(files)
         return orig(repo, matcher, added, removed, *args, **kwargs)
--- a/tests/test-remotefilelog-prefetch.t	Fri Apr 05 23:07:11 2019 -0400
+++ b/tests/test-remotefilelog-prefetch.t	Wed Apr 03 17:41:58 2019 -0700
@@ -197,6 +197,9 @@
   $ mv x x2
   $ mv y y2
   $ mv z z2
+  $ echo a > a
+  $ hg add a
+  $ rm a
   $ clearcache
   $ hg addremove -s 50 > /dev/null
   3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over * (glob)