[PATCH] canonpath: allow canonicalization of non-existant paths

Dan Villiom Podlaski Christiansen danchr at gmail.com
Sun Jan 8 08:43:52 CST 2012


# HG changeset patch
# User Dan Villiom Podlaski Christiansen  <danchr at gmail.com>
# Date 1326032606 -3600
# Node ID 17af723eceecd448cf8236aeadd738228438763c
# Parent  3fe39d6d2bd8331932df063d272fff8af327881c
canonpath: allow canonicalization of non-existant paths

Such as a copy destination; see the added test.

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -313,8 +313,8 @@ def canonpath(root, cwd, myname, auditor
             try:
                 name_st = os.stat(name)
             except OSError:
-                break
-            if util.samestat(name_st, root_st):
+                name_st = None
+            if name_st and util.samestat(name_st, root_st):
                 if not rel:
                     # name was actually the same as root (maybe a symlink)
                     return ''
diff --git a/tests/test-symlinks.t b/tests/test-symlinks.t
--- a/tests/test-symlinks.t
+++ b/tests/test-symlinks.t
@@ -168,11 +168,12 @@ now addremove should remove old files
   ? foo
   $ hg status ../link
   ? foo
+  $ hg add foo
+  $ hg cp foo "$TESTTMP/link/bar"
+  foo has not been committed yet, so no copy data will be stored for bar.
   $ cd ..
 
 
-
-
   $ hg init b
   $ cd b
   $ ln -s nothing dangling


More information about the Mercurial-devel mailing list