clone: properly mark branches closed with --uncompressed (issue4428) stable
authorMatt Mackall <mpm@selenic.com>
Sat, 01 Nov 2014 17:30:57 -0500
branchstable
changeset 23126 8b4a8a9176e2
parent 23125 a5d6a609752b
child 23127 7361d8244efb
clone: properly mark branches closed with --uncompressed (issue4428) On streaming clone, we were priming the local branch cache with the remote branchmap, without checking which heads were closed. This fixes an issue introduced in: changeset: 17740:e6067bec18da user: Tomasz Kleczek <tomasz.kleczek@fb.com> date: Wed Oct 03 13:19:53 2012 -0700 summary: branchcache: fetch source branchcache during clone (issue3378) that was exposed in 2.9 by: changeset: 20192:38fad5e76ee8 user: Brodie Rao <brodie@sf.io> date: Mon Sep 16 01:08:29 2013 -0700 summary: branches: simplify with repo.branchmap().iterbranches()
mercurial/localrepo.py
tests/test-ssh.t
--- a/mercurial/localrepo.py	Sat Nov 01 20:00:31 2014 +0100
+++ b/mercurial/localrepo.py	Sat Nov 01 17:30:57 2014 -0500
@@ -1680,15 +1680,22 @@
 
             if rbranchmap:
                 rbheads = []
+                closed = []
                 for bheads in rbranchmap.itervalues():
                     rbheads.extend(bheads)
+                    for h in bheads:
+                        r = self.changelog.rev(h)
+                        b, c = self.changelog.branchinfo(r)
+                        if c:
+                            closed.append(h)
 
                 if rbheads:
                     rtiprev = max((int(self.changelog.rev(node))
                             for node in rbheads))
                     cache = branchmap.branchcache(rbranchmap,
                                                   self[rtiprev].node(),
-                                                  rtiprev)
+                                                  rtiprev,
+                                                  closednodes=closed)
                     # Try to stick it as low as possible
                     # filter above served are unlikely to be fetch from a clone
                     for candidate in ('base', 'immutable', 'served'):
--- a/tests/test-ssh.t	Sat Nov 01 20:00:31 2014 +0100
+++ b/tests/test-ssh.t	Sat Nov 01 17:30:57 2014 -0500
@@ -9,6 +9,20 @@
   $ echo this > foo
   $ echo this > fooO
   $ hg ci -A -m "init" foo fooO
+
+insert a closed branch (issue4428)
+
+  $ hg up null
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ hg branch closed
+  marked working directory as branch closed
+  (branches are permanent and global, did you want a bookmark?)
+  $ hg ci -mc0
+  $ hg ci --close-branch -mc1
+  $ hg up -q default
+
+configure for serving
+
   $ cat <<EOF > .hg/hgrc
   > [server]
   > uncompressed = True
@@ -36,8 +50,8 @@
 
   $ hg clone -e "python \"$TESTDIR/dummyssh\"" --uncompressed ssh://user@dummy/remote local-stream
   streaming all changes
-  4 files to transfer, 392 bytes of data
-  transferred 392 bytes in * seconds (*/sec) (glob)
+  4 files to transfer, 615 bytes of data
+  transferred 615 bytes in * seconds (*) (glob)
   searching for changes
   no changes found
   updating to branch default
@@ -48,7 +62,9 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  2 files, 1 changesets, 2 total revisions
+  2 files, 3 changesets, 2 total revisions
+  $ hg branches
+  default                        0:1160648e36ce
   $ cd ..
 
 clone bookmarks via stream
@@ -56,8 +72,8 @@
   $ hg -R local-stream book mybook
   $ hg clone -e "python \"$TESTDIR/dummyssh\"" --uncompressed ssh://user@dummy/local-stream stream2
   streaming all changes
-  4 files to transfer, 392 bytes of data
-  transferred 392 bytes in * seconds (* KB/sec) (glob)
+  4 files to transfer, 615 bytes of data
+  transferred 615 bytes in * seconds (*) (glob)
   searching for changes
   no changes found
   updating to branch default
@@ -75,7 +91,7 @@
   adding changesets
   adding manifests
   adding file changes
-  added 1 changesets with 2 changes to 2 files
+  added 3 changesets with 2 changes to 2 files
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
@@ -87,7 +103,7 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  2 files, 1 changesets, 2 total revisions
+  2 files, 3 changesets, 2 total revisions
   $ echo '[hooks]' >> .hg/hgrc
   $ echo "changegroup = python \"$TESTDIR/printenv.py\" changegroup-in-local 0 ../dummylog" >> .hg/hgrc
 
@@ -116,8 +132,9 @@
   $ hg out ssh://user@dummy/remote
   comparing with ssh://user@dummy/remote
   searching for changes
-  changeset:   1:a28a9d1a809c
+  changeset:   3:a28a9d1a809c
   tag:         tip
+  parent:      0:1160648e36ce
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add
@@ -128,8 +145,9 @@
   $ hg incoming -R ../remote -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/local
   comparing with ssh://user@dummy/local
   searching for changes
-  changeset:   1:a28a9d1a809c
+  changeset:   3:a28a9d1a809c
   tag:         tip
+  parent:      0:1160648e36ce
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add
@@ -140,8 +158,9 @@
   $ hg incoming -R ../remote -e "python \"$TESTDIR/dummyssh\"" "ssh://user@dummy/`pwd`"
   comparing with ssh://user@dummy/$TESTTMP/local
   searching for changes
-  changeset:   1:a28a9d1a809c
+  changeset:   3:a28a9d1a809c
   tag:         tip
+  parent:      0:1160648e36ce
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add
@@ -161,8 +180,9 @@
 check remote tip
 
   $ hg tip
-  changeset:   1:a28a9d1a809c
+  changeset:   3:a28a9d1a809c
   tag:         tip
+  parent:      0:1160648e36ce
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add
@@ -172,7 +192,7 @@
   checking manifests
   crosschecking files in changesets and manifests
   checking files
-  2 files, 2 changesets, 3 total revisions
+  2 files, 4 changesets, 3 total revisions
   $ hg cat -r tip foo
   bleah
   $ echo z > z
@@ -248,14 +268,14 @@
   remote: added 1 changesets with 1 changes to 1 files
   remote: KABOOM
   $ hg -R ../remote heads
-  changeset:   3:1383141674ec
+  changeset:   5:1383141674ec
   tag:         tip
-  parent:      1:a28a9d1a809c
+  parent:      3:a28a9d1a809c
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     z
   
-  changeset:   2:6c0482d977a3
+  changeset:   4:6c0482d977a3
   parent:      0:1160648e36ce
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
@@ -266,17 +286,17 @@
 
   $ hg -R ../remote bookmark test
   $ hg -R ../remote bookmarks
-   * test                      2:6c0482d977a3
+   * test                      4:6c0482d977a3
   $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/remote local-bookmarks
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
-  added 4 changesets with 5 changes to 4 files (+1 heads)
+  added 6 changesets with 5 changes to 4 files (+1 heads)
   updating to branch default
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg -R local-bookmarks bookmarks
-     test                      2:6c0482d977a3
+     test                      4:6c0482d977a3
 
 passwords in ssh urls are not supported
 (we use a glob here because different Python versions give different
@@ -359,7 +379,7 @@
   adding changesets
   adding manifests
   adding file changes
-  added 4 changesets with 5 changes to 4 files (+1 heads)
+  added 6 changesets with 5 changes to 4 files (+1 heads)
   updating to branch default
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved