[PATCH] Purge crash on junction point

Matt Mackall mpm at selenic.com
Wed Feb 19 16:16:04 CST 2014


On Tue, 2014-02-18 at 23:08 +0000, Mathieu Cantin wrote:
> # HG changeset patch
> # User Mathieu Cantin <mcantin at coveo.com>
> # Date 1392764497 18000
> #      Tue Feb 18 18:01:37 2014 -0500
> # Node ID bf485635a586a487a732ba27e122531235062da7
> # Parent  0e2877f8605dcaf4fdf2ab7e0046f1f6f80161dd
> purge: delete invalid junction point
> 
> When you have 2 folders linked to each other by a junction point. For exemple
> "A" is a folder and "B" is a junction point to "A". "A" is deleted, then
> os.listdir throws an error on "B" because the target of "B" doesn't exist
> anymore.

Does this issue only exist with purge?

> +    def hasfilesindir(path):
> +        try:
> +            return len(os.listdir(path)) > 0
> +        except OSError:
> +            # It's a junction point with an invalid target

Is this really the only way os.listdir can get an OSError?

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list