comparison mercurial/commands.py @ 20578:e0e223b0a506

merge with stable
author Matt Mackall <mpm@selenic.com>
date Thu, 27 Feb 2014 14:48:36 -0600
parents 02d0d3aa42e3 7f865a94691e
children 710c2755e66a
comparison
equal deleted inserted replaced
20574:5614f8cf0861 20578:e0e223b0a506
4588 4588
4589 Returns 0 on success, 1 if an update had unresolved files. 4589 Returns 0 on success, 1 if an update had unresolved files.
4590 """ 4590 """
4591 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) 4591 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4592 other = hg.peer(repo, opts, source) 4592 other = hg.peer(repo, opts, source)
4593 ui.status(_('pulling from %s\n') % util.hidepassword(source)) 4593 try:
4594 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) 4594 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4595 4595 revs, checkout = hg.addbranchrevs(repo, other, branches,
4596 remotebookmarks = other.listkeys('bookmarks') 4596 opts.get('rev'))
4597 4597
4598 if opts.get('bookmark'): 4598 remotebookmarks = other.listkeys('bookmarks')
4599 if not revs: 4599
4600 revs = [] 4600 if opts.get('bookmark'):
4601 for b in opts['bookmark']: 4601 if not revs:
4602 if b not in remotebookmarks: 4602 revs = []
4603 raise util.Abort(_('remote bookmark %s not found!') % b) 4603 for b in opts['bookmark']:
4604 revs.append(remotebookmarks[b]) 4604 if b not in remotebookmarks:
4605 4605 raise util.Abort(_('remote bookmark %s not found!') % b)
4606 if revs: 4606 revs.append(remotebookmarks[b])
4607
4608 if revs:
4609 try:
4610 revs = [other.lookup(rev) for rev in revs]
4611 except error.CapabilityError:
4612 err = _("other repository doesn't support revision lookup, "
4613 "so a rev cannot be specified.")
4614 raise util.Abort(err)
4615
4616 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
4617 bookmarks.updatefromremote(ui, repo, remotebookmarks, source)
4618 if checkout:
4619 checkout = str(repo.changelog.rev(other.lookup(checkout)))
4620 repo._subtoppath = source
4607 try: 4621 try:
4608 revs = [other.lookup(rev) for rev in revs] 4622 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
4609 except error.CapabilityError: 4623
4610 err = _("other repository doesn't support revision lookup, " 4624 finally:
4611 "so a rev cannot be specified.") 4625 del repo._subtoppath
4612 raise util.Abort(err) 4626
4613 4627 # update specified bookmarks
4614 modheads = repo.pull(other, heads=revs, force=opts.get('force')) 4628 if opts.get('bookmark'):
4615 bookmarks.updatefromremote(ui, repo, remotebookmarks, source) 4629 marks = repo._bookmarks
4616 if checkout: 4630 for b in opts['bookmark']:
4617 checkout = str(repo.changelog.rev(other.lookup(checkout))) 4631 # explicit pull overrides local bookmark if any
4618 repo._subtoppath = source 4632 ui.status(_("importing bookmark %s\n") % b)
4619 try: 4633 marks[b] = repo[remotebookmarks[b]].node()
4620 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout) 4634 marks.write()
4621
4622 finally: 4635 finally:
4623 del repo._subtoppath 4636 other.close()
4624
4625 # update specified bookmarks
4626 if opts.get('bookmark'):
4627 marks = repo._bookmarks
4628 for b in opts['bookmark']:
4629 # explicit pull overrides local bookmark if any
4630 ui.status(_("importing bookmark %s\n") % b)
4631 marks[b] = repo[remotebookmarks[b]].node()
4632 marks.write()
4633
4634 return ret 4637 return ret
4635 4638
4636 @command('^push', 4639 @command('^push',
4637 [('f', 'force', None, _('force push')), 4640 [('f', 'force', None, _('force push')),
4638 ('r', 'rev', [], 4641 ('r', 'rev', [],