diff mercurial/cmdutil.py @ 6651:7f0dd352fb4d

addremove: correctly handle intermediate symlinks This fixes problems mentioned in issue660 comments (unrelated to original issue) where directory was renamed, and symlink was added instead. In such situation addremove wasn't able to correctly detect that old files no longer here, but tried to add symlink (and failed due collision with old files).
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 07 May 2008 14:32:00 +0400
parents 30d3d531e11a
children 2cbe0f72c379
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Fri Jun 06 18:23:33 2008 +0200
+++ b/mercurial/cmdutil.py	Wed May 07 14:32:00 2008 +0400
@@ -274,14 +274,20 @@
         similarity = float(opts.get('similarity') or 0)
     add, remove = [], []
     mapping = {}
+    audit_path = util.path_auditor(repo.root)
     for src, abs, rel, exact in walk(repo, pats, opts):
         target = repo.wjoin(abs)
-        if src == 'f' and abs not in repo.dirstate:
+        good = True
+        try:
+            audit_path(abs)
+        except:
+            good = False
+        if src == 'f' and good and abs not in repo.dirstate:
             add.append(abs)
             mapping[abs] = rel, exact
             if repo.ui.verbose or not exact:
                 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
-        if repo.dirstate[abs] != 'r' and (not util.lexists(target)
+        if repo.dirstate[abs] != 'r' and (not good or not util.lexists(target)
             or (os.path.isdir(target) and not os.path.islink(target))):
             remove.append(abs)
             mapping[abs] = rel, exact