Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 26028:6fbe35588433 stable
update: wlock the repo for the whole 'hg update' command
The update command is touching the repository and should lock it for
the length of its operations. Equally importantly, it should lock the
repository when it is writing bookmarks. It wasn't doing so until now,
leaving doors open for all kinds of drunk beaver parties.
This results in some minor tests changes, and the fixing of a couple
of bugs from race conditions.
Code does not receive any changes beside extra indentation.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 11 Aug 2015 16:26:12 -0700 |
parents | 4eb8d8a44bf1 |
children | 5243890224ff f31ddc9bfa5f |
comparison
equal
deleted
inserted
replaced
26027:7b7e25a85f63 | 26028:6fbe35588433 |
---|---|
6449 raise util.Abort(_("please specify just one revision")) | 6449 raise util.Abort(_("please specify just one revision")) |
6450 | 6450 |
6451 if rev is None or rev == '': | 6451 if rev is None or rev == '': |
6452 rev = node | 6452 rev = node |
6453 | 6453 |
6454 cmdutil.clearunfinished(repo) | 6454 wlock = repo.wlock() |
6455 | 6455 try: |
6456 # with no argument, we also move the active bookmark, if any | 6456 cmdutil.clearunfinished(repo) |
6457 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev) | 6457 |
6458 | 6458 # with no argument, we also move the active bookmark, if any |
6459 # if we defined a bookmark, we have to remember the original bookmark name | 6459 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev) |
6460 brev = rev | 6460 |
6461 rev = scmutil.revsingle(repo, rev, rev).rev() | 6461 # if we defined a bookmark, we have to remember the original name |
6462 | 6462 brev = rev |
6463 if check and clean: | 6463 rev = scmutil.revsingle(repo, rev, rev).rev() |
6464 raise util.Abort(_("cannot specify both -c/--check and -C/--clean")) | 6464 |
6465 | 6465 if check and clean: |
6466 if date: | 6466 raise util.Abort(_("cannot specify both -c/--check and -C/--clean")) |
6467 if rev is not None: | 6467 |
6468 raise util.Abort(_("you can't specify a revision and a date")) | 6468 if date: |
6469 rev = cmdutil.finddate(ui, repo, date) | 6469 if rev is not None: |
6470 | 6470 raise util.Abort(_("you can't specify a revision and a date")) |
6471 if check: | 6471 rev = cmdutil.finddate(ui, repo, date) |
6472 cmdutil.bailifchanged(repo, merge=False) | 6472 |
6473 if rev is None: | 6473 if check: |
6474 rev = repo[repo[None].branch()].rev() | 6474 cmdutil.bailifchanged(repo, merge=False) |
6475 | 6475 if rev is None: |
6476 repo.ui.setconfig('ui', 'forcemerge', tool, 'update') | 6476 rev = repo[repo[None].branch()].rev() |
6477 | 6477 |
6478 if clean: | 6478 repo.ui.setconfig('ui', 'forcemerge', tool, 'update') |
6479 ret = hg.clean(repo, rev) | 6479 |
6480 else: | 6480 if clean: |
6481 ret = hg.update(repo, rev) | 6481 ret = hg.clean(repo, rev) |
6482 | |
6483 if not ret and movemarkfrom: | |
6484 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): | |
6485 ui.status(_("updating bookmark %s\n") % repo._activebookmark) | |
6486 else: | 6482 else: |
6487 # this can happen with a non-linear update | 6483 ret = hg.update(repo, rev) |
6488 ui.status(_("(leaving bookmark %s)\n") % | 6484 |
6489 repo._activebookmark) | 6485 if not ret and movemarkfrom: |
6486 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): | |
6487 ui.status(_("updating bookmark %s\n") % repo._activebookmark) | |
6488 else: | |
6489 # this can happen with a non-linear update | |
6490 ui.status(_("(leaving bookmark %s)\n") % | |
6491 repo._activebookmark) | |
6492 bookmarks.deactivate(repo) | |
6493 elif brev in repo._bookmarks: | |
6494 bookmarks.activate(repo, brev) | |
6495 ui.status(_("(activating bookmark %s)\n") % brev) | |
6496 elif brev: | |
6497 if repo._activebookmark: | |
6498 ui.status(_("(leaving bookmark %s)\n") % | |
6499 repo._activebookmark) | |
6490 bookmarks.deactivate(repo) | 6500 bookmarks.deactivate(repo) |
6491 elif brev in repo._bookmarks: | 6501 finally: |
6492 bookmarks.activate(repo, brev) | 6502 wlock.release() |
6493 ui.status(_("(activating bookmark %s)\n") % brev) | |
6494 elif brev: | |
6495 if repo._activebookmark: | |
6496 ui.status(_("(leaving bookmark %s)\n") % | |
6497 repo._activebookmark) | |
6498 bookmarks.deactivate(repo) | |
6499 | 6503 |
6500 return ret | 6504 return ret |
6501 | 6505 |
6502 @command('verify', []) | 6506 @command('verify', []) |
6503 def verify(ui, repo): | 6507 def verify(ui, repo): |