Mercurial > hg
comparison hgext/shelve.py @ 27288:c14af2d4b08c
shelve: remove redundant acquisition of wlock for sub commands of unshelve
Previous patch ensures that wlock is acquired before processing for
"hg unshelve". It makes acquisition of wlock in each functions below
redundant.
- unshelveabort() for "unshelve --abort"
- unshelvecontinue() for "unshelve --continue"
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 09 Dec 2015 08:28:53 +0900 |
parents | c9ceea3f2d8e |
children | 07fc2f2134ba |
comparison
equal
deleted
inserted
replaced
27287:c9ceea3f2d8e | 27288:c14af2d4b08c |
---|---|
471 cwd = repo.getcwd() | 471 cwd = repo.getcwd() |
472 return [repo.pathto(f, cwd) for f in files] | 472 return [repo.pathto(f, cwd) for f in files] |
473 | 473 |
474 def unshelveabort(ui, repo, state, opts): | 474 def unshelveabort(ui, repo, state, opts): |
475 """subcommand that abort an in-progress unshelve""" | 475 """subcommand that abort an in-progress unshelve""" |
476 wlock = repo.wlock() | |
477 lock = None | 476 lock = None |
478 try: | 477 try: |
479 checkparents(repo, state) | 478 checkparents(repo, state) |
480 | 479 |
481 util.rename(repo.join('unshelverebasestate'), | 480 util.rename(repo.join('unshelverebasestate'), |
495 | 494 |
496 repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') | 495 repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') |
497 finally: | 496 finally: |
498 shelvedstate.clear(repo) | 497 shelvedstate.clear(repo) |
499 ui.warn(_("unshelve of '%s' aborted\n") % state.name) | 498 ui.warn(_("unshelve of '%s' aborted\n") % state.name) |
500 lockmod.release(lock, wlock) | 499 lockmod.release(lock) |
501 | 500 |
502 def mergefiles(ui, repo, wctx, shelvectx): | 501 def mergefiles(ui, repo, wctx, shelvectx): |
503 """updates to wctx and merges the changes from shelvectx into the | 502 """updates to wctx and merges the changes from shelvectx into the |
504 dirstate.""" | 503 dirstate.""" |
505 oldquiet = ui.quiet | 504 oldquiet = ui.quiet |
531 | 530 |
532 def unshelvecontinue(ui, repo, state, opts): | 531 def unshelvecontinue(ui, repo, state, opts): |
533 """subcommand to continue an in-progress unshelve""" | 532 """subcommand to continue an in-progress unshelve""" |
534 # We're finishing off a merge. First parent is our original | 533 # We're finishing off a merge. First parent is our original |
535 # parent, second is the temporary "fake" commit we're unshelving. | 534 # parent, second is the temporary "fake" commit we're unshelving. |
536 wlock = repo.wlock() | |
537 lock = None | 535 lock = None |
538 try: | 536 try: |
539 checkparents(repo, state) | 537 checkparents(repo, state) |
540 ms = merge.mergestate.read(repo) | 538 ms = merge.mergestate.read(repo) |
541 if [f for f in ms if ms[f] == 'u']: | 539 if [f for f in ms if ms[f] == 'u']: |
569 repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') | 567 repair.strip(ui, repo, state.stripnodes, backup=False, topic='shelve') |
570 shelvedstate.clear(repo) | 568 shelvedstate.clear(repo) |
571 unshelvecleanup(ui, repo, state.name, opts) | 569 unshelvecleanup(ui, repo, state.name, opts) |
572 ui.status(_("unshelve of '%s' complete\n") % state.name) | 570 ui.status(_("unshelve of '%s' complete\n") % state.name) |
573 finally: | 571 finally: |
574 lockmod.release(lock, wlock) | 572 lockmod.release(lock) |
575 | 573 |
576 @command('unshelve', | 574 @command('unshelve', |
577 [('a', 'abort', None, | 575 [('a', 'abort', None, |
578 _('abort an incomplete unshelve operation')), | 576 _('abort an incomplete unshelve operation')), |
579 ('c', 'continue', None, | 577 ('c', 'continue', None, |