comparison mercurial/commands.py @ 21045:7f875ed19475

summary: separate checking incoming/outgoing and showing remote summary This patch separates checking incoming/outgoing and showing remote summary, as a preparation for refactoring in succeeding patches, because: - checking incoming/outgoing may be needed, even if "--remote" is not specified for "hg summary" - checking incoming/outgoing may not be needed simultaneously "hg summary --large" without "--remote" is typical case for these.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 16 Apr 2014 00:37:24 +0900
parents a2cc3c08c3ac
children f0003f989e72
comparison
equal deleted inserted replaced
21044:52a5eabf1f2f 21045:7f875ed19475
5520 (new, len(bheads))) 5520 (new, len(bheads)))
5521 5521
5522 cmdutil.summaryhooks(ui, repo) 5522 cmdutil.summaryhooks(ui, repo)
5523 5523
5524 if opts.get('remote'): 5524 if opts.get('remote'):
5525 t = [] 5525 needsincoming, needsoutgoing = True, True
5526 else:
5527 needsincoming, needsoutgoing = False, False
5528
5529 def getincoming():
5526 source, branches = hg.parseurl(ui.expandpath('default')) 5530 source, branches = hg.parseurl(ui.expandpath('default'))
5527 sbranch = branches[0] 5531 sbranch = branches[0]
5528 other = hg.peer(repo, {}, source) 5532 other = hg.peer(repo, {}, source)
5529 revs, checkout = hg.addbranchrevs(repo, other, branches, None) 5533 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5530 if revs: 5534 if revs:
5531 revs = [other.lookup(rev) for rev in revs] 5535 revs = [other.lookup(rev) for rev in revs]
5532 ui.debug('comparing with %s\n' % util.hidepassword(source)) 5536 ui.debug('comparing with %s\n' % util.hidepassword(source))
5533 repo.ui.pushbuffer() 5537 repo.ui.pushbuffer()
5534 commoninc = discovery.findcommonincoming(repo, other, heads=revs) 5538 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5535 _common, incoming, _rheads = commoninc
5536 repo.ui.popbuffer() 5539 repo.ui.popbuffer()
5537 if incoming: 5540 return source, sbranch, other, commoninc, commoninc[1]
5538 t.append(_('1 or more incoming')) 5541
5539 5542 if needsincoming:
5543 source, sbranch, sother, commoninc, incoming = getincoming()
5544 else:
5545 source = sbranch = sother = commoninc = incoming = None
5546
5547 def getoutgoing():
5540 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) 5548 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5541 dbranch = branches[0] 5549 dbranch = branches[0]
5542 revs, checkout = hg.addbranchrevs(repo, repo, branches, None) 5550 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5543 if source != dest: 5551 if source != dest:
5544 other = hg.peer(repo, {}, dest) 5552 dother = hg.peer(repo, {}, dest)
5545 ui.debug('comparing with %s\n' % util.hidepassword(dest)) 5553 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5554 else:
5555 dother = sother
5546 if (source != dest or (sbranch is not None and sbranch != dbranch)): 5556 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5547 commoninc = None 5557 common = None
5558 else:
5559 common = commoninc
5548 if revs: 5560 if revs:
5549 revs = [repo.lookup(rev) for rev in revs] 5561 revs = [repo.lookup(rev) for rev in revs]
5550 repo.ui.pushbuffer() 5562 repo.ui.pushbuffer()
5551 outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs, 5563 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5552 commoninc=commoninc) 5564 commoninc=common)
5553 repo.ui.popbuffer() 5565 repo.ui.popbuffer()
5566 return dest, dbranch, dother, outgoing
5567
5568 if needsoutgoing:
5569 dest, dbranch, dother, outgoing = getoutgoing()
5570 else:
5571 dest = dbranch = dother = outgoing = None
5572
5573 if opts.get('remote'):
5574 t = []
5575 if incoming:
5576 t.append(_('1 or more incoming'))
5554 o = outgoing.missing 5577 o = outgoing.missing
5555 if o: 5578 if o:
5556 t.append(_('%d outgoing') % len(o)) 5579 t.append(_('%d outgoing') % len(o))
5580 other = dother or sother
5557 if 'bookmarks' in other.listkeys('namespaces'): 5581 if 'bookmarks' in other.listkeys('namespaces'):
5558 lmarks = repo.listkeys('bookmarks') 5582 lmarks = repo.listkeys('bookmarks')
5559 rmarks = other.listkeys('bookmarks') 5583 rmarks = other.listkeys('bookmarks')
5560 diff = set(rmarks) - set(lmarks) 5584 diff = set(rmarks) - set(lmarks)
5561 if len(diff) > 0: 5585 if len(diff) > 0: