All pastes #1904129 Raw Edit

nicdumz

public text v1 · immutable
#1904129 ·published 2010-07-20 02:34 UTC
rendered paste body
# HG changeset patch# User Nicolas Dumazet <nicdumz.commits@gmail.com># Date 1279592973 -32400# Node ID b9d50960176c804b18a73c39f514c78a37ed3ce0# Parent  52dc5022d8fb7be825e53cad4f8e48c8c9089d9dupdate: improve behaviour when working directory is removed (issue2293)chdir to repository root to apply changes, and try to chdir back intothe old working directory after applying changes.If old working directory was removed in the process, warn the user aboutit, and stay in repository root.diff --git a/mercurial/merge.py b/mercurial/merge.py--- a/mercurial/merge.py+++ b/mercurial/merge.py@@ -512,7 +512,17 @@         if not partial:             repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) +        curdir = os.getcwd()+        os.chdir(repo.root)         stats = applyupdates(repo, action, wc, p2, pa)+        try:+            os.chdir(curdir)+        except OSError, inst:+            if inst.errno != errno.ENOENT:+                raise+            repo.ui.warn(_("working directory was removed during update, "+                           "now at repository root\n"))+          if not partial:             repo.dirstate.setparents(fp1, fp2)diff --git a/tests/test-remove-cwd.out b/tests/test-remove-cwd.out--- a/tests/test-remove-cwd.out+++ b/tests/test-remove-cwd.out@@ -1,4 +1,5 @@ adding a/a+working directory was removed during update, now at repository root 0 files updated, 0 files merged, 1 files removed, 0 files unresolved % run hg from removed directory 'import site' failed; use -v for traceback