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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 6, 2013, 8:35 p.m.
Message ID <c35e25c868fcf17fef32.1367872505@juju>
Download mbox | patch
Permalink /patch/1570/
State Accepted, archived
Commit 0848be1f1aad3eb8e8c5cace140616cd7b70ada8
Headers show

Comments

Katsunori FUJIWARA - May 6, 2013, 8:35 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@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.
Matt Mackall - May 7, 2013, 10:06 p.m.
On Tue, 2013-05-07 at 05:35 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@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

Looks like this will work (at least partly) independently of the earlier
patches. Queued for stable, thanks.

Patch

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 ..