comparison mercurial/commands.py @ 3649:e50891e461e4

Consolidate brinfo handling
author Matt Mackall <mpm@selenic.com>
date Wed, 15 Nov 2006 15:51:58 -0600
parents b984dcb1df71
children 731e739b8659
comparison
equal deleted inserted replaced
3648:2801a3efc7c3 3649:e50891e461e4
701 "a destination")) 701 "a destination"))
702 base = [repo.lookup(rev) for rev in base] 702 base = [repo.lookup(rev) for rev in base]
703 # create the right base 703 # create the right base
704 # XXX: nodesbetween / changegroup* should be "fixed" instead 704 # XXX: nodesbetween / changegroup* should be "fixed" instead
705 o = [] 705 o = []
706 has = {nullid: None} 706 has = {nullid: None}
707 for n in base: 707 for n in base:
708 has.update(repo.changelog.reachable(n)) 708 has.update(repo.changelog.reachable(n))
709 if revs: 709 if revs:
710 visit = list(revs) 710 visit = list(revs)
711 else: 711 else:
1432 """ 1432 """
1433 if opts['rev']: 1433 if opts['rev']:
1434 heads = repo.heads(repo.lookup(opts['rev'])) 1434 heads = repo.heads(repo.lookup(opts['rev']))
1435 else: 1435 else:
1436 heads = repo.heads() 1436 heads = repo.heads()
1437 br = None
1438 if opts['branches']:
1439 ui.warn(_("the --branches option is deprecated, "
1440 "please use 'hg branches' instead\n"))
1441 br = repo.branchlookup(heads)
1442 displayer = cmdutil.show_changeset(ui, repo, opts) 1437 displayer = cmdutil.show_changeset(ui, repo, opts)
1443 for n in heads: 1438 for n in heads:
1444 displayer.show(changenode=n, brinfo=br) 1439 displayer.show(changenode=n)
1445 1440
1446 def identify(ui, repo): 1441 def identify(ui, repo):
1447 """print information about the working copy 1442 """print information about the working copy
1448 1443
1449 Print a short summary of the current state of the repo. 1444 Print a short summary of the current state of the repo.
1669 files and full commit message is shown. 1664 files and full commit message is shown.
1670 """ 1665 """
1671 1666
1672 getchange = util.cachefunc(lambda r:repo.changectx(r).changeset()) 1667 getchange = util.cachefunc(lambda r:repo.changectx(r).changeset())
1673 changeiter, matchfn = walkchangerevs(ui, repo, pats, getchange, opts) 1668 changeiter, matchfn = walkchangerevs(ui, repo, pats, getchange, opts)
1674
1675 if opts['branches']:
1676 ui.warn(_("the --branches option is deprecated, "
1677 "please use 'hg branches' instead\n"))
1678 1669
1679 if opts['limit']: 1670 if opts['limit']:
1680 try: 1671 try:
1681 limit = int(opts['limit']) 1672 limit = int(opts['limit'])
1682 except ValueError: 1673 except ValueError:
1743 miss = 1 1734 miss = 1
1744 break 1735 break
1745 if miss: 1736 if miss:
1746 continue 1737 continue
1747 1738
1748 br = None
1749 if opts['branches']:
1750 br = repo.branchlookup([repo.changelog.node(rev)])
1751
1752 copies = [] 1739 copies = []
1753 if opts.get('copies') and rev: 1740 if opts.get('copies') and rev:
1754 mf = getchange(rev)[0] 1741 mf = getchange(rev)[0]
1755 for fn in getchange(rev)[3]: 1742 for fn in getchange(rev)[3]:
1756 rename = getrenamed(fn, rev, mf) 1743 rename = getrenamed(fn, rev, mf)
1757 if rename: 1744 if rename:
1758 copies.append((fn, rename[0])) 1745 copies.append((fn, rename[0]))
1759 displayer.show(rev, changenode, brinfo=br, copies=copies) 1746 displayer.show(rev, changenode, copies=copies)
1760 elif st == 'iter': 1747 elif st == 'iter':
1761 if count == limit: break 1748 if count == limit: break
1762 if displayer.flush(rev): 1749 if displayer.flush(rev):
1763 count += 1 1750 count += 1
1764 1751
1848 parents = [p for p in repo.changelog.parents(n) if p != nullid] 1835 parents = [p for p in repo.changelog.parents(n) if p != nullid]
1849 if opts['no_merges'] and len(parents) == 2: 1836 if opts['no_merges'] and len(parents) == 2:
1850 continue 1837 continue
1851 displayer.show(changenode=n) 1838 displayer.show(changenode=n)
1852 1839
1853 def parents(ui, repo, file_=None, rev=None, branches=None, **opts): 1840 def parents(ui, repo, file_=None, rev=None, **opts):
1854 """show the parents of the working dir or revision 1841 """show the parents of the working dir or revision
1855 1842
1856 Print the working directory's parent revisions. 1843 Print the working directory's parent revisions.
1857 """ 1844 """
1858 # legacy 1845 # legacy
1873 ctx = repo.changectx(rev) 1860 ctx = repo.changectx(rev)
1874 p = [cp.node() for cp in ctx.parents()] 1861 p = [cp.node() for cp in ctx.parents()]
1875 else: 1862 else:
1876 p = repo.dirstate.parents() 1863 p = repo.dirstate.parents()
1877 1864
1878 br = None
1879 if branches is not None:
1880 ui.warn(_("the --branches option is deprecated, "
1881 "please use 'hg branches' instead\n"))
1882 br = repo.branchlookup(p)
1883 displayer = cmdutil.show_changeset(ui, repo, opts) 1865 displayer = cmdutil.show_changeset(ui, repo, opts)
1884 for n in p: 1866 for n in p:
1885 if n != nullid: 1867 if n != nullid:
1886 displayer.show(changenode=n, brinfo=br) 1868 displayer.show(changenode=n)
1887 1869
1888 def paths(ui, repo, search=None): 1870 def paths(ui, repo, search=None):
1889 """show definition of symbolic path names 1871 """show definition of symbolic path names
1890 1872
1891 Show definition of symbolic path name NAME. If no name is given, show 1873 Show definition of symbolic path name NAME. If no name is given, show
2499 def tip(ui, repo, **opts): 2481 def tip(ui, repo, **opts):
2500 """show the tip revision 2482 """show the tip revision
2501 2483
2502 Show the tip revision. 2484 Show the tip revision.
2503 """ 2485 """
2504 n = repo.changelog.tip() 2486 cmdutil.show_changeset(ui, repo, opts).show(repo.changelog.count()-1)
2505 br = None
2506 if opts['branches']:
2507 ui.warn(_("the --branches option is deprecated, "
2508 "please use 'hg branches' instead\n"))
2509 br = repo.branchlookup([n])
2510 cmdutil.show_changeset(ui, repo, opts).show(changenode=n, brinfo=br)
2511 2487
2512 def unbundle(ui, repo, fname, **opts): 2488 def unbundle(ui, repo, fname, **opts):
2513 """apply a changegroup file 2489 """apply a changegroup file
2514 2490
2515 Apply a compressed changegroup file generated by the bundle 2491 Apply a compressed changegroup file generated by the bundle
2572 if branch in br[x]: 2548 if branch in br[x]:
2573 found.append(x) 2549 found.append(x)
2574 if len(found) > 1: 2550 if len(found) > 1:
2575 repo.ui.warn(_("Found multiple heads for %s\n") % branch) 2551 repo.ui.warn(_("Found multiple heads for %s\n") % branch)
2576 for x in found: 2552 for x in found:
2577 cmdutil.show_changeset(ui, repo, {}).show( 2553 cmdutil.show_changeset(ui, repo, {}).show(changenode=x)
2578 changenode=x, brinfo=br)
2579 raise util.Abort("") 2554 raise util.Abort("")
2580 if len(found) == 1: 2555 if len(found) == 1:
2581 node = found[0] 2556 node = found[0]
2582 repo.ui.warn(_("Using head %s for branch %s\n") 2557 repo.ui.warn(_("Using head %s for branch %s\n")
2583 % (short(node), branch)) 2558 % (short(node), branch))