##// END OF EJS Templates
pull: prevent race condition in bookmark update when using -B (issue4689)...
Pierre-Yves David -
r25446:b5311068 default
parent child Browse files
Show More
@@ -5129,6 +5129,7 b' def pull(ui, repo, source="default", **o'
5129 # not ending up with the name of the bookmark because of a race
5129 # not ending up with the name of the bookmark because of a race
5130 # condition on the server. (See issue 4689 for details)
5130 # condition on the server. (See issue 4689 for details)
5131 remotebookmarks = other.listkeys('bookmarks')
5131 remotebookmarks = other.listkeys('bookmarks')
5132 pullopargs['remotebookmarks'] = remotebookmarks
5132 for b in opts['bookmark']:
5133 for b in opts['bookmark']:
5133 if b not in remotebookmarks:
5134 if b not in remotebookmarks:
5134 raise util.Abort(_('remote bookmark %s not found!') % b)
5135 raise util.Abort(_('remote bookmark %s not found!') % b)
@@ -808,7 +808,8 b' class pulloperation(object):'
808 afterward.
808 afterward.
809 """
809 """
810
810
811 def __init__(self, repo, remote, heads=None, force=False, bookmarks=()):
811 def __init__(self, repo, remote, heads=None, force=False, bookmarks=(),
812 remotebookmarks=None):
812 # repo we pull into
813 # repo we pull into
813 self.repo = repo
814 self.repo = repo
814 # repo we pull from
815 # repo we pull from
@@ -828,7 +829,7 b' class pulloperation(object):'
828 # list of missing changeset to fetch remotely
829 # list of missing changeset to fetch remotely
829 self.fetch = None
830 self.fetch = None
830 # remote bookmarks data
831 # remote bookmarks data
831 self.remotebookmarks = None
832 self.remotebookmarks = remotebookmarks
832 # result of changegroup pulling (used as return code by pull)
833 # result of changegroup pulling (used as return code by pull)
833 self.cgresult = None
834 self.cgresult = None
834 # list of step already done
835 # list of step already done
@@ -308,6 +308,43 b' race conditions'
308 Y 4:b0a5eff05604
308 Y 4:b0a5eff05604
309 Z 1:0d2164f0ce0d
309 Z 1:0d2164f0ce0d
310
310
311 Update a bookmark right after the initial lookup -B (issue4689)
312
313 $ echo c6 > ../pull-race/f3 # to be committed during the race
314 $ cat <<EOF > ../pull-race/.hg/hgrc
315 > [hooks]
316 > # If anything to commit, commit it right after the first key listing used
317 > # during lookup. This makes the commit appear before the actual getbundle
318 > # call.
319 > listkeys.makecommit= ((hg st | grep -q M) && (hg commit -m race; echo commited in pull-race)) || exit 0
320 > EOF
321
322 (new config need server restart)
323
324 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
325 $ hg -R ../pull-race serve -p $HGPORT -d --pid-file=../pull-race.pid -E main-error.log
326 $ cat ../pull-race.pid >> $DAEMON_PIDS
327
328 $ hg -R $TESTTMP/pull-race book
329 @ 1:0d2164f0ce0d
330 X 1:0d2164f0ce0d
331 * Y 5:35d1ef0a8d1b
332 Z 1:0d2164f0ce0d
333 $ hg pull -B Y
334 pulling from http://localhost:$HGPORT/
335 searching for changes
336 adding changesets
337 adding manifests
338 adding file changes
339 added 1 changesets with 1 changes to 1 files
340 updating bookmark Y
341 (run 'hg update' to get a working copy)
342 $ hg book
343 * @ 1:0d2164f0ce0d
344 X 1:0d2164f0ce0d
345 Y 5:35d1ef0a8d1b
346 Z 1:0d2164f0ce0d
347
311 (done with this section of the test)
348 (done with this section of the test)
312
349
313 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
350 $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
@@ -253,7 +253,6 b' listkeys hook'
253 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
253 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
254 no changes found
254 no changes found
255 listkeys hook: HG_NAMESPACE=phase HG_VALUES={}
255 listkeys hook: HG_NAMESPACE=phase HG_VALUES={}
256 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
257 adding remote bookmark bar
256 adding remote bookmark bar
258 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
257 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
259 $ cd ../a
258 $ cd ../a
General Comments 0
You need to be logged in to leave comments. Login now