[PATCH 5 of 7 STABLE] largefiles: check existence of the file with case awareness of the filesystem

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Mon May 6 15:35:05 CDT 2013


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1367870651 -32400
#      Tue May 07 05:04:11 2013 +0900
# Branch stable
# Node ID c35e25c868fcf17fef3239dd43f03031aa5980fb
# Parent  a5d959e18918dbd0cf01ab193a00b5ba83c93596
largefiles: check existence of the file with case awareness of the filesystem

Before this patch, largefiles extension always unlinks largefiles
untracked on the target context in merging/updating after updating
working directory.

For example, it is assumed that the revision X consists of ".hglf/A"
(and "A" implicitly) and revision Y consists of "a" (not ".hglf/A").

In the case of updating from X to Y, largefiles extension tries to
unlink "A" after updating "a" in working directory. This causes
unexpected unlinking "a" on the case insensitive filesystem.

This patch checks existence of the file in the working context with
case awareness of the filesystem to prevent from such unexpected
unlinking.

"lfcommands._updatelfile()" also unlinks target file in the case
"largefile is tracked in the target context, but fails to be fetched".

This patch doesn't apply "repo.dirstate.normalize()" in this case,
because it should be already ensured in the manifest merging that
there is no normal file colliding against any largefiles.

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -502,7 +502,8 @@
         # lfile is added to the repository again. This happens when a
         # largefile is converted back to a normal file: the standin
         # disappears, but a new (normal) file appears as the lfile.
-        if os.path.exists(abslfile) and lfile not in repo[None]:
+        if (os.path.exists(abslfile) and
+            repo.dirstate.normalize(lfile) not in repo[None]):
             util.unlinkpath(abslfile)
             ret = -1
     state = repo.dirstate[lfutil.standin(lfile)]
diff --git a/tests/test-casefolding.t b/tests/test-casefolding.t
--- a/tests/test-casefolding.t
+++ b/tests/test-casefolding.t
@@ -106,6 +106,28 @@
   [255]
   $ cat a
   gold
+  $ rm a
+
+test that normal file in different case on target context is not
+unlinked by largefiles extension.
+
+  $ cat >> .hg/hgrc <<EOF
+  > [extensions]
+  > largefiles=
+  > EOF
+  $ hg update -q -C 1
+  $ hg status -A
+  $ echo 'A as largefiles' > A
+  $ hg add --large A
+  $ hg commit -m '#3'
+  created new head
+  $ hg manifest -r 3
+  .hglf/A
+  $ hg manifest -r 0
+  a
+  $ hg update -q -C 0
+  $ hg status -A
+  C a
 
   $ cd ..
 


More information about the Mercurial-devel mailing list