diff --git a/mercurial/context.py b/mercurial/context.py
index dbca8f134f00fb10f7154b2f6cd9b8188095b1de_bWVyY3VyaWFsL2NvbnRleHQucHk=..2754c82731326453a3cf20f43eb68eeae5e22123_bWVyY3VyaWFsL2NvbnRleHQucHk= 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -844,7 +844,7 @@
                 if self._repo.dirstate[f] != 'r':
                     self._repo.ui.warn(_("%s not removed!\n") % f)
                 else:
-                    fctx = f in pctxs[0] and pctxs[0] or pctxs[1]
+                    fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f]
                     t = fctx.data()
                     self._repo.wwrite(f, t, fctx.flags())
                     self._repo.dirstate.normal(f)
diff --git a/tests/test-mq-qrename.t b/tests/test-mq-qrename.t
index dbca8f134f00fb10f7154b2f6cd9b8188095b1de_dGVzdHMvdGVzdC1tcS1xcmVuYW1lLnQ=..2754c82731326453a3cf20f43eb68eeae5e22123_dGVzdHMvdGVzdC1tcS1xcmVuYW1lLnQ= 100644
--- a/tests/test-mq-qrename.t
+++ b/tests/test-mq-qrename.t
@@ -59,4 +59,5 @@
 
   $ cd ..
 
+Test overlapping renames (issue2388)
 
@@ -62,1 +63,21 @@
 
+  $ hg init c
+  $ cd c
+  $ hg qinit -c
+  $ echo a > a
+  $ hg add
+  adding a
+  $ hg qnew patcha
+  $ echo b > b
+  $ hg add
+  adding b
+  $ hg qnew patchb
+  $ hg ci --mq -m c1
+  $ hg qrename patchb patchc
+  $ hg qrename patcha patchb
+  $ hg st --mq
+  M patchb
+  M series
+  A patchc
+  R patcha
+  $ cd ..