[PATCH 2 of 2] update: improve behaviour when working directory is removed (issue2293)

Nicolas Dumazet nicdumz at gmail.com
Tue Jul 20 02:46:05 CDT 2010


2010/7/20 Nicolas Dumazet <nicdumz at gmail.com>:
> # HG changeset patch
> # User Nicolas Dumazet <nicdumz.commits at gmail.com>
> # Date 1279592973 -32400
> # Node ID c4406f92fb047ff278f5404b7bc9d15f53bd24da
> # Parent  a3660fbdb439bcf7201ceba09abc568d2ce950a3
> update: improve behaviour when working directory is removed (issue2293)
>

After this, test-subrepo-svn was unhappy; failure can trivially be fixed using:

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -329,7 +329,7 @@
         self._ui = ctx._repo.ui

     def _svncommand(self, commands, filename=''):
-        path = os.path.join(self._ctx._repo.origroot, self._path, filename)
+        path = os.path.join(self._ctx._repo.root, self._path, filename)
         cmd = ['svn'] + commands + [path]
         cmd = [util.shellquote(arg) for arg in cmd]
         cmd = util.quotecommand(' '.join(cmd))

(any particular reason to use origroot here? I'm running the tests,
and will report if I find any failures)...

-Nicolas.


> chdir to repository root to apply changes, and try to chdir back into
> the old working directory after applying changes.
> If old working directory was removed in the process, warn the user about
> it, 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,16 @@
>         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\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
>  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
>  % run hg from removed directory
>  'import site' failed; use -v for traceback
>



-- 
Nicolas Dumazet — NicDumZ


More information about the Mercurial-devel mailing list