[PATCH 08 of 10] Pack data for lightweight copy

Sune Foldager cryo at cyanite.org
Wed Sep 8 14:48:21 CDT 2010


# HG changeset patch
# User Sune Foldager <sune.foldager at edlund.dk>
# Date 1283790061 -7200
# Node ID a130330bb178f2236010034b771d0254b21fac0c
# Parent  9c1601e70b8ec414bb7f93ec94dc09b4a7d93f03
Pack data for lightweight copy

diff --git a/mercurial/filelog.py b/mercurial/filelog.py
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -23,9 +23,17 @@
         return _parsemeta(self.revision(node))
 
     def add(self, text, meta, transaction, link, p1=None, p2=None):
+        hashtext = None
         if meta or text.startswith('\1\n'):
+            if "lwcopy" in meta:
+                hashmeta = dict(meta)
+                del hashmeta["lwcopy"]
+                hashtext = "\1\n%s\1\n%s" % (_packmeta(hashmeta), text)
+                ptext = self._ptext(meta)
+                text = mdiff.textdiff(ptext, text)
             text = "\1\n%s\1\n%s" % (_packmeta(meta), text)
-        return self.addrevision(text, transaction, link, p1, p2)
+        return self.addrevision(text, transaction, link, p1, p2,
+                                hashtext=hashtext)
 
     def renamed(self, node):
         if self.parents(node)[0] != revlog.nullid:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -808,6 +808,8 @@
             self.ui.debug(" %s: copy %s:%s\n" % (fname, cfname, hex(crev)))
             meta["copy"] = cfname
             meta["copyrev"] = hex(crev)
+            if self.sopener.options["lwcopy"]:
+                meta["lwcopy"] = 1
             fparent1, fparent2 = nullid, newfparent
         elif fparent2 != nullid:
             # is one parent an ancestor of the other?
diff --git a/tests/test-bundle-r.t b/tests/test-bundle-r.t
--- a/tests/test-bundle-r.t
+++ b/tests/test-bundle-r.t
@@ -34,10 +34,10 @@
        3        15       9      3       3 19b1fc555737 4c982badb186 000000000000
   $ hg debugindex .hg/store/data/adifferentfile.i
      rev    offset  length   base linkrev nodeid       p1           p2
-       0         0      75      0       7 2565f3199a74 000000000000 000000000000
+       0         0      76      0       7 2565f3199a74 000000000000 000000000000
   $ hg debugindex .hg/store/data/anotherfile.i
      rev    offset  length   base linkrev nodeid       p1           p2
-       0         0      75      0       8 2565f3199a74 000000000000 000000000000
+       0         0      76      0       8 2565f3199a74 000000000000 000000000000
   $ hg debugindex .hg/store/data/fred.i
      rev    offset  length   base linkrev nodeid       p1           p2
        0         0       8      0       6 12ab3bcc5ea4 000000000000 000000000000
diff --git a/tests/test-clone-r.t b/tests/test-clone-r.t
--- a/tests/test-clone-r.t
+++ b/tests/test-clone-r.t
@@ -46,11 +46,11 @@
 
   $ hg debugindex .hg/store/data/adifferentfile.i
      rev    offset  length   base linkrev nodeid       p1           p2
-       0         0      75      0       7 2565f3199a74 000000000000 000000000000
+       0         0      76      0       7 2565f3199a74 000000000000 000000000000
 
   $ hg debugindex .hg/store/data/anotherfile.i
      rev    offset  length   base linkrev nodeid       p1           p2
-       0         0      75      0       8 2565f3199a74 000000000000 000000000000
+       0         0      76      0       8 2565f3199a74 000000000000 000000000000
 
   $ hg debugindex .hg/store/data/fred.i
      rev    offset  length   base linkrev nodeid       p1           p2
diff --git a/tests/test-convert-hg-source.out b/tests/test-convert-hg-source.out
--- a/tests/test-convert-hg-source.out
+++ b/tests/test-convert-hg-source.out
@@ -39,17 +39,17 @@
 4 init
 ignoring: data/b.i at 1e88685f5dde: no match found
 3 changeall
+ignoring: data/b.i at 1e88685f5dde: no node
 2 changebagain
 1 merge
 0 moveb
+ignoring: data/b.i at 0cf8bc74fd2b: no node
 checking changesets
 checking manifests
 crosschecking files in changesets and manifests
 checking files
-3 files, 5 changesets, 5 total revisions
+1 files, 5 changesets, 2 total revisions
 % manifest -r 0
 a
 % manifest -r tip
 a
-c
-d
diff --git a/tests/test-copy.t b/tests/test-copy.t
--- a/tests/test-copy.t
+++ b/tests/test-copy.t
@@ -49,7 +49,7 @@
 
 this should show a revision linked to changeset 0
 
-  $ hg debugindex .hg/store/data/a.i
+  $ hg debugindex a
      rev    offset  length   base linkrev nodeid       p1           p2
        0         0       3      0       0 b789fdd96dc2 000000000000 000000000000
 
@@ -65,18 +65,18 @@
 
 this should show a revision linked to changeset 1
 
-  $ hg debugindex .hg/store/data/b.i
+  $ hg debugindex b
      rev    offset  length   base linkrev nodeid       p1           p2
-       0         0      65      0       1 37d9b5d994ea 000000000000 000000000000
+       0         0      72      0       1 37d9b5d994ea 000000000000 000000000000
 
 this should show the rename information in the metadata
 
-  $ hg debugdata .hg/store/data/b.d 0 | head -3 | tail -2
+  $ hg debugdata b 0 | head -3 | tail -2
   copy: a
   copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
 
   $ $TESTDIR/md5sum.py .hg/store/data/b.i
-  4999f120a3b88713bbefddd195cf5133  .hg/store/data/b.i
+  a0caea24f1bd1d6464f55003d7f54f14  .hg/store/data/b.i
   $ hg cat b > bsum
   $ $TESTDIR/md5sum.py bsum
   60b725f10c9c85c70d97880dfe8191b3  bsum
diff --git a/tests/test-copy2.t b/tests/test-copy2.t
--- a/tests/test-copy2.t
+++ b/tests/test-copy2.t
@@ -69,9 +69,9 @@
 should show no parents for tip
   $ hg debugindex .hg/store/data/bar.i
      rev    offset  length   base linkrev nodeid       p1           p2
-       0         0      69      0       1 7711d36246cc 000000000000 000000000000
-       1        69       6      1       2 bdf70a2b8d03 7711d36246cc 000000000000
-       2        75      81      1       3 b2558327ea8d 000000000000 000000000000
+       0         0      74      0       1 7711d36246cc 000000000000 000000000000
+       1        74       6      1       2 bdf70a2b8d03 7711d36246cc 000000000000
+       2        80      81      1       3 b2558327ea8d 000000000000 000000000000
 should match
   $ hg debugindex .hg/store/data/foo.i
      rev    offset  length   base linkrev nodeid       p1           p2
diff --git a/tests/test-http-clone-r.out b/tests/test-http-clone-r.out
--- a/tests/test-http-clone-r.out
+++ b/tests/test-http-clone-r.out
@@ -8,9 +8,9 @@
      2         8       7      2       2 4c982badb186 125144f7e028 000000000000
      3        15       9      3       3 19b1fc555737 4c982badb186 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
-     0         0      75      0       7 2565f3199a74 000000000000 000000000000
+     0         0      76      0       7 2565f3199a74 000000000000 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
-     0         0      75      0       8 2565f3199a74 000000000000 000000000000
+     0         0      76      0       8 2565f3199a74 000000000000 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       8      0       6 12ab3bcc5ea4 000000000000 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
diff --git a/tests/test-merge-commit.out b/tests/test-merge-commit.out
--- a/tests/test-merge-commit.out
+++ b/tests/test-merge-commit.out
@@ -8,8 +8,8 @@
 line1
 line2
    rev    offset  length   base linkrev nodeid       p1           p2
-     0         0      77      0       2 d35118874825 000000000000 000000000000
-     1        77      76      0       3 5345f5ab8abd 000000000000 d35118874825
+     0         0      84      0       2 d35118874825 000000000000 000000000000
+     1        84      91      0       3 5345f5ab8abd 000000000000 d35118874825
 bar renamed from foo:9e25c27b87571a1edee5ae4dddee5687746cc8e2
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       7      0       0 690b295714ae 000000000000 000000000000
@@ -39,10 +39,10 @@
 line1
 line2
    rev    offset  length   base linkrev nodeid       p1           p2
-     0         0      77      0       2 d35118874825 000000000000 000000000000
-     1        77      76      0       3 5345f5ab8abd 000000000000 d35118874825
-     2       153       7      2       4 ff4b45017382 d35118874825 000000000000
-     3       160      13      3       5 3701b4893544 ff4b45017382 5345f5ab8abd
+     0         0      84      0       2 d35118874825 000000000000 000000000000
+     1        84      91      0       3 5345f5ab8abd 000000000000 d35118874825
+     2       175       7      2       4 ff4b45017382 d35118874825 000000000000
+     3       182      13      3       5 3701b4893544 ff4b45017382 5345f5ab8abd
 
 
 requesting all changes
@@ -60,7 +60,7 @@
 line2
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0      77      0       2 d35118874825 000000000000 000000000000
-     1        77      76      0       3 5345f5ab8abd 000000000000 d35118874825
+     1        77      91      0       3 5345f5ab8abd 000000000000 d35118874825
 bar renamed from foo:9e25c27b87571a1edee5ae4dddee5687746cc8e2
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       7      0       0 690b295714ae 000000000000 000000000000
@@ -91,6 +91,6 @@
 line2
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0      77      0       2 d35118874825 000000000000 000000000000
-     1        77      76      0       3 5345f5ab8abd 000000000000 d35118874825
-     2       153       7      2       4 ff4b45017382 d35118874825 000000000000
-     3       160      13      3       5 3701b4893544 ff4b45017382 5345f5ab8abd
+     1        77      91      0       3 5345f5ab8abd 000000000000 d35118874825
+     2       168       7      2       4 ff4b45017382 d35118874825 000000000000
+     3       175      13      3       5 3701b4893544 ff4b45017382 5345f5ab8abd
diff --git a/tests/test-push-r.out b/tests/test-push-r.out
--- a/tests/test-push-r.out
+++ b/tests/test-push-r.out
@@ -7,9 +7,9 @@
      2         8       7      2       2 4c982badb186 125144f7e028 000000000000
      3        15       9      3       3 19b1fc555737 4c982badb186 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
-     0         0      75      0       7 2565f3199a74 000000000000 000000000000
+     0         0      76      0       7 2565f3199a74 000000000000 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
-     0         0      75      0       8 2565f3199a74 000000000000 000000000000
+     0         0      76      0       8 2565f3199a74 000000000000 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       8      0       6 12ab3bcc5ea4 000000000000 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
diff --git a/tests/test-rename-merge1.out b/tests/test-rename-merge1.out
--- a/tests/test-rename-merge1.out
+++ b/tests/test-rename-merge1.out
@@ -41,6 +41,6 @@
 C c2
 blahblah
    rev    offset  length   base linkrev nodeid       p1           p2
-     0         0      67      0       1 57eacc201a7f 000000000000 000000000000
-     1        67      72      1       3 4727ba907962 000000000000 57eacc201a7f
+     0         0      72      0       1 57eacc201a7f 000000000000 000000000000
+     1        72      72      1       3 4727ba907962 000000000000 57eacc201a7f
 b renamed from a:dd03b83622e78778b403775d0d074b9ac7387a66
diff --git a/tests/test-ssh-clone-r.out b/tests/test-ssh-clone-r.out
--- a/tests/test-ssh-clone-r.out
+++ b/tests/test-ssh-clone-r.out
@@ -8,9 +8,9 @@
      2         8       7      2       2 4c982badb186 125144f7e028 000000000000
      3        15       9      3       3 19b1fc555737 4c982badb186 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
-     0         0      75      0       7 2565f3199a74 000000000000 000000000000
+     0         0      76      0       7 2565f3199a74 000000000000 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
-     0         0      75      0       8 2565f3199a74 000000000000 000000000000
+     0         0      76      0       8 2565f3199a74 000000000000 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2
      0         0       8      0       6 12ab3bcc5ea4 000000000000 000000000000
    rev    offset  length   base linkrev nodeid       p1           p2


More information about the Mercurial-devel mailing list