comparison mercurial/commands.py @ 10328:0798a3d5f812

commands: simplify heads a little bit before I start hacking it up
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Sat, 06 Feb 2010 11:29:48 +0100
parents 8b90e2966219
children d8c0e6c43791
comparison
equal deleted inserted replaced
10327:32197f7eceb3 10328:0798a3d5f812
1407 (see hg commit --close-branch). 1407 (see hg commit --close-branch).
1408 1408
1409 If STARTREV is specified, only those heads that are descendants of 1409 If STARTREV is specified, only those heads that are descendants of
1410 STARTREV will be displayed. 1410 STARTREV will be displayed.
1411 """ 1411 """
1412
1412 if opts.get('rev'): 1413 if opts.get('rev'):
1413 start = repo.lookup(opts['rev']) 1414 start = repo.lookup(opts['rev'])
1414 else: 1415 else:
1415 start = None 1416 start = None
1417
1416 closed = opts.get('closed') 1418 closed = opts.get('closed')
1417 hideinactive, _heads = opts.get('active'), None 1419 hideinactive, _heads = opts.get('active'), None
1418 if not branchrevs: 1420 if not branchrevs:
1419 if closed: 1421 if closed:
1420 raise error.Abort(_('you must specify a branch to use --closed')) 1422 raise error.Abort(_('you must specify a branch to use --closed'))
1421 # Assume we're looking repo-wide heads if no revs were specified. 1423 # Assume we're looking repo-wide heads if no revs were specified.
1422 heads = repo.heads(start) 1424 heads = repo.heads(start)
1425
1423 else: 1426 else:
1424 if hideinactive: 1427 if hideinactive:
1425 _heads = repo.heads(start) 1428 dagheads = repo.heads(start)
1429 decode, encode = encoding.fromlocal, encoding.tolocal
1430 branches = set(repo[decode(br)].branch() for br in branchrevs)
1426 heads = [] 1431 heads = []
1427 visitedset = set() 1432 visitedset = set()
1428 for branchrev in branchrevs: 1433 for b in branches:
1429 branch = repo[encoding.fromlocal(branchrev)].branch()
1430 encodedbranch = encoding.tolocal(branch)
1431 if branch in visitedset:
1432 continue
1433 visitedset.add(branch)
1434 bheads = repo.branchheads(branch, start, closed=closed) 1434 bheads = repo.branchheads(branch, start, closed=closed)
1435 if not bheads: 1435 if not bheads:
1436 encodedbranch = encode(b)
1436 if not opts.get('rev'): 1437 if not opts.get('rev'):
1437 ui.warn(_("no open branch heads on branch %s\n") 1438 ui.warn(_("no open branch heads on branch %s\n")
1438 % encodedbranch) 1439 % encodedbranch)
1439 elif branch != branchrev: 1440 elif branch != branchrev:
1440 ui.warn(_("no changes on branch %s containing %s are " 1441 ui.warn(_("no changes on branch %s containing %s are "
1442 % (encodedbranch, branchrev, opts.get('rev'))) 1443 % (encodedbranch, branchrev, opts.get('rev')))
1443 else: 1444 else:
1444 ui.warn(_("no changes on branch %s are reachable from %s\n") 1445 ui.warn(_("no changes on branch %s are reachable from %s\n")
1445 % (encodedbranch, opts.get('rev'))) 1446 % (encodedbranch, opts.get('rev')))
1446 if hideinactive: 1447 if hideinactive:
1447 bheads = [bhead for bhead in bheads if bhead in _heads] 1448 bheads = [bhead for bhead in bheads if bhead in dagheads]
1448 heads.extend(bheads) 1449 heads.extend(bheads)
1450
1449 if not heads: 1451 if not heads:
1450 return 1 1452 return 1
1453
1451 displayer = cmdutil.show_changeset(ui, repo, opts) 1454 displayer = cmdutil.show_changeset(ui, repo, opts)
1452 for n in heads: 1455 for n in heads:
1453 displayer.show(repo[n]) 1456 displayer.show(repo[n])
1454 displayer.close() 1457 displayer.close()
1455 1458