<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" id="owaParaStyle" style="display: none;">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body dir="ltr" fpstyle="1" aria-label="Corps du message" tabindex="0">
<div name="divtagdefaultwrapper" id="divtagdefaultwrapper" style="font-family: Calibri,Arial,Helvetica,sans-serif; font-size: 12pt; color: #000000; margin: 0">
<div># HG changeset patch</div>
<div># User Mathieu Cantin <mcantin@coveo.com></div>
<div># Date 1392764497 18000</div>
<div>#      Tue Feb 18 18:01:37 2014 -0500</div>
<div># Node ID bf485635a586a487a732ba27e122531235062da7</div>
<div># Parent  0e2877f8605dcaf4fdf2ab7e0046f1f6f80161dd</div>
<div>purge: delete invalid junction point</div>
<div><br>
</div>
<div>When you have 2 folders linked to each other by a junction point. For exemple</div>
<div>"A" is a folder and "B" is a junction point to "A". "A" is deleted, then</div>
<div>os.listdir throws an error on "B" because the target of "B" doesn't exist</div>
<div>anymore.</div>
<div><br>
</div>
<div>diff -r 0e2877f8605d -r bf485635a586 hgext/purge.py</div>
<div>--- a/hgext/purge.py<span class="Apple-tab-span" style="white-space:pre"> </span>
Sat Feb 15 22:09:32 2014 -0600</div>
<div>+++ b/hgext/purge.py<span class="Apple-tab-span" style="white-space:pre"> </span>
Tue Feb 18 18:01:37 2014 -0500</div>
<div>@@ -95,6 +95,13 @@</div>
<div>             os.chmod(path, stat.S_IMODE(s.st_mode) | stat.S_IWRITE)</div>
<div>             os.remove(path)</div>
<div> </div>
<div>+    def hasfilesindir(path):</div>
<div>+        try:</div>
<div>+            return len(os.listdir(path)) > 0</div>
<div>+        except OSError:</div>
<div>+            # It's a junction point with an invalid target</div>
<div>+            return False</div>
<div>+</div>
<div>     directories = []</div>
<div>     match = scmutil.match(repo[None], dirs, opts)</div>
<div>     match.explicitdir = match.traversedir = directories.append</div>
<div>@@ -105,6 +112,6 @@</div>
<div>         remove(removefile, f)</div>
<div> </div>
<div>     for f in sorted(directories, reverse=True):</div>
<div>-        if match(f) and not os.listdir(repo.wjoin(f)):</div>
<div>+        if match(f) and not hasfilesindir(repo.wjoin(f)):</div>
<div>             ui.note(_('removing directory %s\n') % f)</div>
<div>-            remove(os.rmdir, f)</div>
<div>+            remove(os.rmdir, f)</div>
<div>\ No newline at end of file</div>
<div><br>
</div>
</div>
</body>
</html>