##// END OF EJS Templates
commands: simplify heads a little bit before I start hacking it up
Dirkjan Ochtman -
r10328:0798a3d5 default
parent child Browse files
Show More
@@ -1409,10 +1409,12 b' def heads(ui, repo, *branchrevs, **opts)'
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:
@@ -1420,19 +1422,18 b' def heads(ui, repo, *branchrevs, **opts)'
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)
@@ -1444,10 +1445,12 b' def heads(ui, repo, *branchrevs, **opts)'
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])
General Comments 0
You need to be logged in to leave comments. Login now