comparison mercurial/commands.py @ 20576:7f865a94691e stable

pull: close peer repo on completion (issue2491) (issue2797) When pulling changes from a compressed bundle Mercurial first uncompresses it to a temporary file in .hg directory. This file will not be deleted unless the bundlerepo (other) is explicitly closed. This is similar to cleanup that occurs after incoming.
author Piotr Klecha <pklecha@forcom.com.pl>
date Tue, 25 Feb 2014 21:26:25 +0100
parents 2f6b3900be64
children e0e223b0a506 ba619c50a355
comparison
equal deleted inserted replaced
20575:3d77e567de56 20576:7f865a94691e
4603 4603
4604 Returns 0 on success, 1 if an update had unresolved files. 4604 Returns 0 on success, 1 if an update had unresolved files.
4605 """ 4605 """
4606 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) 4606 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4607 other = hg.peer(repo, opts, source) 4607 other = hg.peer(repo, opts, source)
4608 ui.status(_('pulling from %s\n') % util.hidepassword(source)) 4608 try:
4609 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) 4609 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4610 4610 revs, checkout = hg.addbranchrevs(repo, other, branches,
4611 remotebookmarks = other.listkeys('bookmarks') 4611 opts.get('rev'))
4612 4612
4613 if opts.get('bookmark'): 4613 remotebookmarks = other.listkeys('bookmarks')
4614 if not revs: 4614
4615 revs = [] 4615 if opts.get('bookmark'):
4616 for b in opts['bookmark']: 4616 if not revs:
4617 if b not in remotebookmarks: 4617 revs = []
4618 raise util.Abort(_('remote bookmark %s not found!') % b) 4618 for b in opts['bookmark']:
4619 revs.append(remotebookmarks[b]) 4619 if b not in remotebookmarks:
4620 4620 raise util.Abort(_('remote bookmark %s not found!') % b)
4621 if revs: 4621 revs.append(remotebookmarks[b])
4622
4623 if revs:
4624 try:
4625 revs = [other.lookup(rev) for rev in revs]
4626 except error.CapabilityError:
4627 err = _("other repository doesn't support revision lookup, "
4628 "so a rev cannot be specified.")
4629 raise util.Abort(err)
4630
4631 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
4632 bookmarks.updatefromremote(ui, repo, remotebookmarks, source)
4633 if checkout:
4634 checkout = str(repo.changelog.rev(other.lookup(checkout)))
4635 repo._subtoppath = source
4622 try: 4636 try:
4623 revs = [other.lookup(rev) for rev in revs] 4637 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
4624 except error.CapabilityError: 4638
4625 err = _("other repository doesn't support revision lookup, " 4639 finally:
4626 "so a rev cannot be specified.") 4640 del repo._subtoppath
4627 raise util.Abort(err) 4641
4628 4642 # update specified bookmarks
4629 modheads = repo.pull(other, heads=revs, force=opts.get('force')) 4643 if opts.get('bookmark'):
4630 bookmarks.updatefromremote(ui, repo, remotebookmarks, source) 4644 marks = repo._bookmarks
4631 if checkout: 4645 for b in opts['bookmark']:
4632 checkout = str(repo.changelog.rev(other.lookup(checkout))) 4646 # explicit pull overrides local bookmark if any
4633 repo._subtoppath = source 4647 ui.status(_("importing bookmark %s\n") % b)
4634 try: 4648 marks[b] = repo[remotebookmarks[b]].node()
4635 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout) 4649 marks.write()
4636
4637 finally: 4650 finally:
4638 del repo._subtoppath 4651 other.close()
4639
4640 # update specified bookmarks
4641 if opts.get('bookmark'):
4642 marks = repo._bookmarks
4643 for b in opts['bookmark']:
4644 # explicit pull overrides local bookmark if any
4645 ui.status(_("importing bookmark %s\n") % b)
4646 marks[b] = repo[remotebookmarks[b]].node()
4647 marks.write()
4648
4649 return ret 4652 return ret
4650 4653
4651 @command('^push', 4654 @command('^push',
4652 [('f', 'force', None, _('force push')), 4655 [('f', 'force', None, _('force push')),
4653 ('r', 'rev', [], 4656 ('r', 'rev', [],