diff --git a/mercurial/context.py b/mercurial/context.py
index 02e80e37fbbc999398c0949404cc09361ce5ef62_bWVyY3VyaWFsL2NvbnRleHQucHk=..873f3a56993ff077cdd95c98da37e2c740674538_bWVyY3VyaWFsL2NvbnRleHQucHk= 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1896,7 +1896,7 @@
         components = path.split('/')
         for i in pycompat.xrange(len(components)):
             component = "/".join(components[0:i])
-            if component in self.p1():
+            if component in self.p1() and self._cache[component]['exists']:
                 fail(path, component)
 
         # Test the other direction -- that this path from p2 isn't a directory
diff --git a/tests/test-rebase-inmemory.t b/tests/test-rebase-inmemory.t
index 02e80e37fbbc999398c0949404cc09361ce5ef62_dGVzdHMvdGVzdC1yZWJhc2UtaW5tZW1vcnkudA==..873f3a56993ff077cdd95c98da37e2c740674538_dGVzdHMvdGVzdC1yZWJhc2UtaW5tZW1vcnkudA== 100644
--- a/tests/test-rebase-inmemory.t
+++ b/tests/test-rebase-inmemory.t
@@ -177,8 +177,7 @@
   
   $ hg rebase -r . -d 2
   rebasing 4:daf7dfc139cb "a/a" (tip)
-  abort: error: 'a/a' conflicts with file 'a' in 2.
-  [255]
+  saved backup bundle to $TESTTMP/repo1/repo2/.hg/strip-backup/daf7dfc139cb-fdbfcf4f-rebase.hg
 
   $ cd ..