hg: perform update after pulling during clone with share (issue5103)
When pooled storage is enabled, `hg clone` will initialize a repo
from a local repo using the store sharing mechanism then pull from
the originally requested repo.
Before this patch, the working directory update occurred between
these steps. This meant that we would only update to revisions that
were already present in the local pooled storage.
This patch moves the update to after we pull from the originally
requested repository so we may check out a revision that didn't yet
exist locally. In other words, it makes the behavior like normal
`hg clone`.
--- a/mercurial/hg.py Sat Feb 20 17:41:59 2016 -0800
+++ b/mercurial/hg.py Sat Feb 20 17:44:29 2016 -0800
@@ -356,7 +356,7 @@
rev=rev, update=False, stream=stream)
sharerepo = repository(ui, path=sharepath)
- share(ui, sharerepo, dest=dest, update=update, bookmarks=False)
+ share(ui, sharerepo, dest=dest, update=False, bookmarks=False)
# We need to perform a pull against the dest repo to fetch bookmarks
# and other non-store data that isn't shared by default. In the case of
@@ -366,6 +366,8 @@
destrepo = repository(ui, path=dest)
exchange.pull(destrepo, srcpeer, heads=revs)
+ _postshareupdate(destrepo, update)
+
return srcpeer, peer(ui, peeropts, dest)
def clone(ui, peeropts, source, dest=None, pull=False, rev=None,
--- a/tests/test-clone.t Sat Feb 20 17:41:59 2016 -0800
+++ b/tests/test-clone.t Sat Feb 20 17:44:29 2016 -0800
@@ -774,11 +774,11 @@
adding manifests
adding file changes
added 3 changesets with 3 changes to 1 files
- updating working directory
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
searching for changes
no changes found
adding remote bookmark bookA
+ updating working directory
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
The shared repo should have been created
@@ -804,8 +804,6 @@
$ hg --config share.pool=share clone source1b share-dest1b
(sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
- updating working directory
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
searching for changes
adding changesets
adding manifests
@@ -813,6 +811,8 @@
added 4 changesets with 4 changes to 1 files (+4 heads)
adding remote bookmark head1
adding remote bookmark head2
+ updating working directory
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ ls share
b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1
@@ -831,6 +831,17 @@
$ hg -R share-dest1b config paths.default
$TESTTMP/source1a (glob)
+Checked out revision should be head of default branch
+
+ $ hg -R share-dest1b log -r .
+ changeset: 4:99f71071f117
+ bookmark: head2
+ parent: 0:b5f04eac9d8f
+ user: test
+ date: Thu Jan 01 00:00:00 1970 +0000
+ summary: head2
+
+
Clone from unrelated repo should result in new share
$ hg --config share.pool=share clone source2 share-dest2
@@ -840,10 +851,10 @@
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
+ searching for changes
+ no changes found
updating working directory
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
- searching for changes
- no changes found
$ ls share
22aeff664783fd44c6d9b435618173c118c3448e
@@ -858,11 +869,11 @@
adding manifests
adding file changes
added 3 changesets with 3 changes to 1 files
- updating working directory
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
searching for changes
no changes found
adding remote bookmark bookA
+ updating working directory
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ ls shareremote
195bb1fcdb595c14a6c13e0269129ed78f6debde
@@ -874,12 +885,12 @@
adding manifests
adding file changes
added 6 changesets with 6 changes to 1 files (+4 heads)
- updating working directory
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
searching for changes
no changes found
adding remote bookmark head1
adding remote bookmark head2
+ updating working directory
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ ls shareremote
195bb1fcdb595c14a6c13e0269129ed78f6debde
@@ -893,10 +904,10 @@
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
+ no changes found
+ adding remote bookmark head1
updating working directory
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
- no changes found
- adding remote bookmark head1
$ hg -R share-1arev log -G
@ changeset: 1:4a8dc1ab4c13
@@ -916,8 +927,6 @@
$ hg --config share.pool=sharerevs clone -r 99f71071f117 source1b share-1brev
(sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
- updating working directory
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
searching for changes
adding changesets
adding manifests
@@ -925,9 +934,11 @@
added 1 changesets with 1 changes to 1 files (+1 heads)
adding remote bookmark head1
adding remote bookmark head2
+ updating working directory
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg -R share-1brev log -G
- o changeset: 2:99f71071f117
+ @ changeset: 2:99f71071f117
| bookmark: head2
| tag: tip
| parent: 0:b5f04eac9d8f
@@ -935,7 +946,7 @@
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: head2
|
- | @ changeset: 1:4a8dc1ab4c13
+ | o changeset: 1:4a8dc1ab4c13
|/ bookmark: head1
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
@@ -955,9 +966,9 @@
adding manifests
adding file changes
added 2 changesets with 2 changes to 1 files
+ no changes found
updating working directory
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
- no changes found
$ hg -R share-1bbranch1 log -G
o changeset: 1:5f92a6c1a1b1
@@ -975,13 +986,13 @@
$ hg --config share.pool=sharebranch clone -b branch2 source1b share-1bbranch2
(sharing from existing pooled repository b5f04eac9d8f7a6a9fcb070243cccea7dc5ea0c1)
- updating working directory
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
+ updating working directory
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg -R share-1bbranch2 log -G
o changeset: 2:6bacf4683960