diff --git a/mercurial/hg.py b/mercurial/hg.py
index 13c004b54cbe296b2fa236281e7769dc28554f3b_bWVyY3VyaWFsL2hnLnB5..3e0f86f09f26b3f474b1b34e90ac657869d3ef51_bWVyY3VyaWFsL2hnLnB5 100644
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -1425,6 +1425,7 @@
     others = []
     for path in urlutil.get_push_paths(repo, ui, dests):
         dest = path.loc
+        repo._subtoppath = dest
         if subpath is not None:
             subpath = urlutil.url(subpath)
             if subpath.isabs():
@@ -1528,6 +1529,7 @@
     finally:
         for oth in others:
             oth.close()
+        del repo._subtoppath
 
 
 def verify(repo, level=None):