diff hgsubversion/wrappers.py @ 992:110794582448

push: avoid failure when push is being called from a newly created subdirectory The failure was occuring during push when a new file is added inside a new subdirectory and push is being called from this subdirectory. This subdirectory disappears when the commit is being rebased[during push] causing the push to fail with 'no such file/directory' error.
author Kapil Bajaj <kapilbajaj@fb.com>
date Thu, 17 Jan 2013 17:01:45 -0800
parents 26e9fd21f3bf
children 3f45bd7b60cf
line wrap: on
line diff
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -14,6 +14,7 @@ from mercurial import i18n
 from mercurial import extensions
 from mercurial import repair
 
+import os
 import replay
 import pushmod
 import stupid as stupidmod
@@ -287,6 +288,11 @@ def push(repo, dest, force, revs):
                 if not c.node() in hashes and not c.node() in outgoing:
                     util.swap_out_encoding(old_encoding)
                     try:
+                        # Path changed as subdirectories were getting
+                        # deleted during push.
+                        saved_path = os.getcwd()
+                        os.chdir(repo.root)
+
                         def extrafn(ctx, extra):
                             extra['branch'] = ctx.branch()
 
@@ -297,6 +303,7 @@ def push(repo, dest, force, revs):
                                         rev=[needs_rebase_set],
                                         extrafn=extrafn, keep=True)
                     finally:
+                        os.chdir(saved_path)
                         util.swap_out_encoding()