[PATCH V3] update: warn if cwd was deleted

Kevin Bullock kbullock+mercurial at ringworld.org
Wed Sep 7 15:43:49 EDT 2016


> On Sep 5, 2016, at 05:32, Stanislau Hlebik <stash at fb.com> wrote:
> 
> # HG changeset patch
> # User Stanislau Hlebik <stash at fb.com>
> # Date 1473071480 25200
> #      Mon Sep 05 03:31:20 2016 -0700
> # Node ID b43aa94306b8f50852a8176afec3839aa3826467
> # Parent  f148bfa40489269be2e48046734f81065129847a
> update: warn if cwd was deleted
> 
> During update directories are deleted as soon as they have no entries.
> But if current working directory is deleted then it cause problems
> in complex commands like 'hg split'. This commit adds a warning
> that will help users figure the problem faster.
> 
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -1043,7 +1043,20 @@
>             repo.ui.note(_("removing %s\n") % f)
>         audit(f)
>         try:
> -            unlink(wjoin(f), ignoremissing=True)
> +            try:
> +                cwd = os.getcwd()
> +            except OSError:
> +                cwd = None
> +            path = wjoin(f)
> +            unlink(path, ignoremissing=True)
> +            try:
> +                os.getcwd()
> +            except OSError:
> +                # Print a warning if cwd was deleted
> +                if cwd and path.startswith(cwd):
> +                    repo.ui.warn(_("cwd was deleted - consider "
> +                                   "changing cwd to repo root %s\n") %
> +                                 repo.root)

Still not a fan of the 'cwd' abbreviation. Also our usual style would put the hint in parentheses. Perhaps something like:

current working directory was deleted
(consider changing to directory shown by "hg root")

pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
Kevin R. Bullock



More information about the Mercurial-devel mailing list