<p dir="ltr">I'd suggest printing the absolute path to the repo root. Asking someone to run a command from an imaginary directory is asking for trouble. "cd .." Might fail...</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Sep 2, 2016 4:44 PM, "Stanislau Hlebik" <<a href="mailto:stash@fb.com">stash@fb.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Stanislau Hlebik <<a href="mailto:stash@fb.com">stash@fb.com</a>><br>
# Date 1472848944 25200<br>
#      Fri Sep 02 13:42:24 2016 -0700<br>
# Node ID 374caff3f6ba064070d01329eec1bd<wbr>33a6a45370<br>
# Parent  318e2b600b80e4ed3c6f37df46ec75<wbr>44f60d4c0b<br>
update: warn if cwd was deleted<br>
<br>
During update directories are deleted as soon as they have no entries.<br>
But if current working directory is deleted then it cause problems<br>
in complex commands like 'hg split'. This commit adds a warning<br>
that will help users figure the problem faster.<br>
<br>
diff --git a/mercurial/merge.py b/mercurial/merge.py<br>
--- a/mercurial/merge.py<br>
+++ b/mercurial/merge.py<br>
@@ -1043,7 +1043,19 @@<br>
             repo.ui.note(_("removing %s\n") % f)<br>
         audit(f)<br>
         try:<br>
-            unlink(wjoin(f), ignoremissing=True)<br>
+            try:<br>
+                cwd = os.getcwd()<br>
+            except OSError:<br>
+                cwd = None<br>
+            path = wjoin(f)<br>
+            unlink(path, ignoremissing=True)<br>
+            try:<br>
+                os.getcwd()<br>
+            except OSError:<br>
+                # Print a warning if cwd was deleted<br>
+                if cwd and path.startswith(cwd):<br>
+                    repo.ui.warn(_("cwd was deleted - consider "<br>
+                                   "changing cwd to repo root\n"))<br>
         except OSError as inst:<br>
             repo.ui.warn(_("update failed to remove %s: %s!\n") %<br>
                          (f, inst.strerror))<br>
diff --git a/tests/test-rebase-scenario-<wbr>global.t b/tests/test-rebase-scenario-<wbr>global.t<br>
--- a/tests/test-rebase-scenario-<wbr>global.t<br>
+++ b/tests/test-rebase-scenario-<wbr>global.t<br>
@@ -758,6 +758,7 @@<br>
   $ hg commit -m 'second source with subdir'<br>
   $ hg rebase -b . -d 1 --traceback<br>
   rebasing 2:779a07b1b7a0 "first source commit"<br>
+  cwd was deleted - consider changing cwd to repo root<br>
   rebasing 3:a7d6f3a00bf3 "second source with subdir" (tip)<br>
   saved backup bundle to $TESTTMP/cwd-vanish/.hg/strip-<wbr>backup/779a07b1b7a0-853e0073-<wbr>backup.hg (glob)<br>
<br>
diff --git a/tests/test-update-names.t b/tests/test-update-names.t<br>
--- a/tests/test-update-names.t<br>
+++ b/tests/test-update-names.t<br>
@@ -72,3 +72,14 @@<br>
   $ cd ..<br>
<br>
 #endif<br>
+<br>
+Test that warning is printed if cwd is deleted during update<br>
+  $ hg init r4 && cd r4<br>
+  $ mkdir dir<br>
+  $ cd dir<br>
+  $ echo a > a<br>
+  $ echo b > b<br>
+  $ hg add a b<br>
+  $ hg ci -m "file and dir"<br>
+  $ hg up -q null<br>
+  cwd was deleted - consider changing cwd to repo root<br>
______________________________<wbr>_________________<br>
Mercurial-devel mailing list<br>
<a href="mailto:Mercurial-devel@mercurial-scm.org">Mercurial-devel@mercurial-scm.<wbr>org</a><br>
<a href="https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel" rel="noreferrer" target="_blank">https://www.mercurial-scm.org/<wbr>mailman/listinfo/mercurial-<wbr>devel</a><br>
</blockquote></div></div>