changeset 4531:b51a8138292a

Avoid extra filelogs entries. Right now, there are some situations in which localrepo.filecommit can create filelog entries even though they're not needed. For example: - permissions for a file have changed; - qrefresh can create a filelog entry identical to its parent (see the added test); - convert-repo creates extra filelog entries in every merge where the first parent has added files (for example, changeset ebebe9577a1a of the kernel repo added extra filelog entries to files in the arch/blackfin directory, even though the merge should only touch the drivers/ata directory). This makes "hg log file" in a converted repo less useful than it could be, since it may mention many merges that don't actually touch that specific file. They all come from the same basic problem: localrepo.commit (through filecommit) creates new filelog entries for all files passed to it (except for some cases during a merge). Patch and test case provided by Benoit. This should fix issue351.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 09 Jun 2007 01:04:28 -0300
parents 0ac7fee4f024
children c3a78a49d7f0
files mercurial/localrepo.py tests/test-extra-filelog-entry tests/test-extra-filelog-entry.out tests/test-flags.out
diffstat 4 files changed, 33 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Jun 09 01:04:28 2007 -0300
+++ b/mercurial/localrepo.py	Sat Jun 09 01:04:28 2007 -0300
@@ -693,9 +693,9 @@
             elif fpa == fp2:
                 fp2 = nullid
 
-            # is the file unmodified from the parent? report existing entry
-            if fp2 == nullid and not fl.cmp(fp1, t):
-                return fp1
+        # is the file unmodified from the parent? report existing entry
+        if fp2 == nullid and not fl.cmp(fp1, t):
+            return fp1
 
         changelist.append(fn)
         return fl.add(t, meta, transaction, linkrev, fp1, fp2)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-extra-filelog-entry	Sat Jun 09 01:04:28 2007 -0300
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# test for issue351
+
+# Environement setup for MQ
+echo "[extensions]" >> $HGRCPATH
+echo "mq=" >> $HGRCPATH
+
+#Repo init
+hg init
+hg qinit
+
+echo b > b
+hg ci -A -m foo
+echo cc > b
+hg qnew -f foo.diff
+echo b > b
+hg qrefresh
+hg debugindex .hg/store/data/b.i
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-extra-filelog-entry.out	Sat Jun 09 01:04:28 2007 -0300
@@ -0,0 +1,3 @@
+adding b
+   rev    offset  length   base linkrev nodeid       p1           p2
+     0         0       3      0       0 1e88685f5dde 000000000000 000000000000
--- a/tests/test-flags.out	Sat Jun 09 01:04:28 2007 -0300
+++ b/tests/test-flags.out	Sat Jun 09 01:04:28 2007 -0300
@@ -14,9 +14,9 @@
 adding changesets
 adding manifests
 adding file changes
-added 1 changesets with 1 changes to 1 files (+1 heads)
+added 1 changesets with 0 changes to 0 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
-changeset:   2:b833d578451e
+changeset:   2:37dccb76c058
 tag:         tip
 parent:      0:4536b1c2ca69
 user:        test
@@ -28,7 +28,7 @@
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     a updated
 
-changeset:   2:b833d578451e
+changeset:   2:37dccb76c058
 tag:         tip
 parent:      0:4536b1c2ca69
 user:        test
@@ -46,17 +46,16 @@
 summary:     added a b
 
 resolving manifests
-merging a
-0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 pulling from ../test2
 searching for changes
 adding changesets
 adding manifests
 adding file changes
-added 1 changesets with 1 changes to 1 files (+1 heads)
+added 1 changesets with 0 changes to 0 files (+1 heads)
 (run 'hg heads' to see heads, 'hg merge' to merge)
-changeset:   2:b833d578451e
+changeset:   2:37dccb76c058
 tag:         tip
 parent:      0:4536b1c2ca69
 user:        test
@@ -68,7 +67,7 @@
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     b updated
 
-changeset:   2:b833d578451e
+changeset:   2:37dccb76c058
 tag:         tip
 parent:      0:4536b1c2ca69
 user:        test
@@ -86,19 +85,15 @@
 summary:     added a b
 
 resolving manifests
-getting a
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 -rwxr-x---
 -rwxr-x---
 -rwxr-x---
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       0      0       0 b80de5d13875 000000000000 000000000000
-     1         0       0      0       2 37c42bd6cc03 b80de5d13875 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       0      0       0 b80de5d13875 000000000000 000000000000
-     1         0       0      0       1 37c42bd6cc03 b80de5d13875 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       0      0       0 b80de5d13875 000000000000 000000000000
      1         0       5      1       1 7fe919cc0336 b80de5d13875 000000000000
-     2         5       0      2       2 37c42bd6cc03 b80de5d13875 000000000000