Mercurial > hg-stable
comparison tests/test-pull-r.t @ 25425:9263f86b9681 stable
pull: avoid race condition with 'hg pull --rev name --update' (issue4706)
The previous scheme was:
1) lookup node for all pulled revision,
2) pull said node
3) lookup the node of the checkout target
4) update the repository there.
If the remote repo changes between (1) and (3), the resolved name will be
different and (3) crash. There is actually no need for a remote lookup during
(3), we could just set the value in (1). This prevent the race condition and
save a possible network roundtrip.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 03 Jun 2015 14:29:11 -0700 |
parents | f2719b387380 |
children | e01bd7385f4f |
comparison
equal
deleted
inserted
replaced
25396:78e8890cfb4b | 25425:9263f86b9681 |
---|---|
99 | 99 |
100 This used to abort: received changelog group is empty: | 100 This used to abort: received changelog group is empty: |
101 | 101 |
102 $ hg pull -qr 1 ../repo | 102 $ hg pull -qr 1 ../repo |
103 | 103 |
104 Test race condition with -r and -U (issue4707) | |
105 | |
106 We pull '-U -r <name>' and the name change right after/during the changegroup emission. | |
107 We use http because http is better is our racy-est option. | |
108 | |
109 | |
110 $ echo babar > ../repo/jungle | |
111 $ cat <<EOF > ../repo/.hg/hgrc | |
112 > [hooks] | |
113 > outgoing.makecommit = hg ci -Am 'racy commit'; echo committed in pull-race | |
114 > EOF | |
115 $ hg -R ../repo serve -p $HGPORT2 -d --pid-file=../repo.pid | |
116 $ cat ../repo.pid >> $DAEMON_PIDS | |
117 $ hg pull --rev default --update http://localhost:$HGPORT2/ | |
118 pulling from http://localhost:$HGPORT2/ | |
119 searching for changes | |
120 adding changesets | |
121 adding manifests | |
122 adding file changes | |
123 added 1 changesets with 1 changes to 1 files (+1 heads) | |
124 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
125 $ hg log -G | |
126 @ changeset: 2:effea6de0384 | |
127 | tag: tip | |
128 | parent: 0:bbd179dfa0a7 | |
129 | user: test | |
130 | date: Thu Jan 01 00:00:00 1970 +0000 | |
131 | summary: add bar | |
132 | | |
133 | o changeset: 1:ed1b79f46b9a | |
134 |/ user: test | |
135 | date: Thu Jan 01 00:00:00 1970 +0000 | |
136 | summary: change foo | |
137 | | |
138 o changeset: 0:bbd179dfa0a7 | |
139 user: test | |
140 date: Thu Jan 01 00:00:00 1970 +0000 | |
141 summary: add foo | |
142 | |
143 | |
104 $ cd .. | 144 $ cd .. |