mercurial/commands.py
changeset 3648 b984dcb1df71
parent 3646 b4ad640a3bcf
child 3652 d2d8d23944a9
child 3656 e50891e461e4
equal deleted inserted replaced
3647:b7547efe78fb 3648:b984dcb1df71
  1590         for n in o:
  1590         for n in o:
  1591             parents = [p for p in other.changelog.parents(n) if p != nullid]
  1591             parents = [p for p in other.changelog.parents(n) if p != nullid]
  1592             if opts['no_merges'] and len(parents) == 2:
  1592             if opts['no_merges'] and len(parents) == 2:
  1593                 continue
  1593                 continue
  1594             displayer.show(changenode=n)
  1594             displayer.show(changenode=n)
  1595             if opts['patch']:
       
  1596                 prev = (parents and parents[0]) or nullid
       
  1597                 patch.diff(other, prev, n, fp=repo.ui)
       
  1598                 ui.write("\n")
       
  1599     finally:
  1595     finally:
  1600         if hasattr(other, 'close'):
  1596         if hasattr(other, 'close'):
  1601             other.close()
  1597             other.close()
  1602         if cleanup:
  1598         if cleanup:
  1603             os.unlink(cleanup)
  1599             os.unlink(cleanup)
  1670     By default this command outputs: changeset id and hash, tags,
  1666     By default this command outputs: changeset id and hash, tags,
  1671     non-trivial parents, user, date and time, and a summary for each
  1667     non-trivial parents, user, date and time, and a summary for each
  1672     commit. When the -v/--verbose switch is used, the list of changed
  1668     commit. When the -v/--verbose switch is used, the list of changed
  1673     files and full commit message is shown.
  1669     files and full commit message is shown.
  1674     """
  1670     """
  1675     class dui(object):
       
  1676         # Implement and delegate some ui protocol.  Save hunks of
       
  1677         # output for later display in the desired order.
       
  1678         def __init__(self, ui):
       
  1679             self.ui = ui
       
  1680             self.hunk = {}
       
  1681             self.header = {}
       
  1682             self.quiet = ui.quiet
       
  1683             self.verbose = ui.verbose
       
  1684             self.debugflag = ui.debugflag
       
  1685         def bump(self, rev):
       
  1686             self.rev = rev
       
  1687             self.hunk[rev] = []
       
  1688             self.header[rev] = []
       
  1689         def note(self, *args):
       
  1690             if self.verbose:
       
  1691                 self.write(*args)
       
  1692         def status(self, *args):
       
  1693             if not self.quiet:
       
  1694                 self.write(*args)
       
  1695         def write(self, *args):
       
  1696             self.hunk[self.rev].extend(args)
       
  1697         def write_header(self, *args):
       
  1698             self.header[self.rev].extend(args)
       
  1699         def debug(self, *args):
       
  1700             if self.debugflag:
       
  1701                 self.write(*args)
       
  1702         def __getattr__(self, key):
       
  1703             return getattr(self.ui, key)
       
  1704 
  1671 
  1705     getchange = util.cachefunc(lambda r:repo.changectx(r).changeset())
  1672     getchange = util.cachefunc(lambda r:repo.changectx(r).changeset())
  1706     changeiter, matchfn = walkchangerevs(ui, repo, pats, getchange, opts)
  1673     changeiter, matchfn = walkchangerevs(ui, repo, pats, getchange, opts)
  1707 
  1674 
  1708     if opts['branches']:
  1675     if opts['branches']:
  1753             dcache[:] = [man, repo.manifest.readdelta(man)]
  1720             dcache[:] = [man, repo.manifest.readdelta(man)]
  1754         if fn in dcache[1]:
  1721         if fn in dcache[1]:
  1755             return ncache[fn].get(dcache[1][fn])
  1722             return ncache[fn].get(dcache[1][fn])
  1756         return None
  1723         return None
  1757 
  1724 
  1758     displayer = cmdutil.show_changeset(ui, repo, opts)
  1725     displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
  1759     for st, rev, fns in changeiter:
  1726     for st, rev, fns in changeiter:
  1760         if st == 'window':
  1727         if st == 'add':
  1761             du = dui(ui)
       
  1762             displayer.ui = du
       
  1763         elif st == 'add':
       
  1764             du.bump(rev)
       
  1765             changenode = repo.changelog.node(rev)
  1728             changenode = repo.changelog.node(rev)
  1766             parents = [p for p in repo.changelog.parentrevs(rev)
  1729             parents = [p for p in repo.changelog.parentrevs(rev)
  1767                        if p != nullrev]
  1730                        if p != nullrev]
  1768             if opts['no_merges'] and len(parents) == 2:
  1731             if opts['no_merges'] and len(parents) == 2:
  1769                 continue
  1732                 continue
  1792                 for fn in getchange(rev)[3]:
  1755                 for fn in getchange(rev)[3]:
  1793                     rename = getrenamed(fn, rev, mf)
  1756                     rename = getrenamed(fn, rev, mf)
  1794                     if rename:
  1757                     if rename:
  1795                         copies.append((fn, rename[0]))
  1758                         copies.append((fn, rename[0]))
  1796             displayer.show(rev, changenode, brinfo=br, copies=copies)
  1759             displayer.show(rev, changenode, brinfo=br, copies=copies)
  1797             if opts['patch']:
       
  1798                 if parents:
       
  1799                     prev = parents[0]
       
  1800                 else:
       
  1801                     prev = nullrev
       
  1802                 prev = repo.changelog.node(prev)
       
  1803                 patch.diff(repo, prev, changenode, match=matchfn, fp=du)
       
  1804                 du.write("\n\n")
       
  1805         elif st == 'iter':
  1760         elif st == 'iter':
  1806             if count == limit: break
  1761             if count == limit: break
  1807             if du.header[rev]:
  1762             if displayer.flush(rev):
  1808                 ui.write_header(*du.header[rev])
       
  1809             if du.hunk[rev]:
       
  1810                 count += 1
  1763                 count += 1
  1811                 ui.write(*du.hunk[rev])
       
  1812 
  1764 
  1813 def manifest(ui, repo, rev=None):
  1765 def manifest(ui, repo, rev=None):
  1814     """output the latest or given revision of the project manifest
  1766     """output the latest or given revision of the project manifest
  1815 
  1767 
  1816     Print a list of version controlled files for the given revision.
  1768     Print a list of version controlled files for the given revision.
  1895     for n in o:
  1847     for n in o:
  1896         parents = [p for p in repo.changelog.parents(n) if p != nullid]
  1848         parents = [p for p in repo.changelog.parents(n) if p != nullid]
  1897         if opts['no_merges'] and len(parents) == 2:
  1849         if opts['no_merges'] and len(parents) == 2:
  1898             continue
  1850             continue
  1899         displayer.show(changenode=n)
  1851         displayer.show(changenode=n)
  1900         if opts['patch']:
       
  1901             prev = (parents and parents[0]) or nullid
       
  1902             patch.diff(repo, prev, n)
       
  1903             ui.write("\n")
       
  1904 
  1852 
  1905 def parents(ui, repo, file_=None, rev=None, branches=None, **opts):
  1853 def parents(ui, repo, file_=None, rev=None, branches=None, **opts):
  1906     """show the parents of the working dir or revision
  1854     """show the parents of the working dir or revision
  1907 
  1855 
  1908     Print the working directory's parent revisions.
  1856     Print the working directory's parent revisions.
  2558     if opts['branches']:
  2506     if opts['branches']:
  2559         ui.warn(_("the --branches option is deprecated, "
  2507         ui.warn(_("the --branches option is deprecated, "
  2560                   "please use 'hg branches' instead\n"))
  2508                   "please use 'hg branches' instead\n"))
  2561         br = repo.branchlookup([n])
  2509         br = repo.branchlookup([n])
  2562     cmdutil.show_changeset(ui, repo, opts).show(changenode=n, brinfo=br)
  2510     cmdutil.show_changeset(ui, repo, opts).show(changenode=n, brinfo=br)
  2563     if opts['patch']:
       
  2564         patch.diff(repo, repo.changelog.parents(n)[0], n)
       
  2565 
  2511 
  2566 def unbundle(ui, repo, fname, **opts):
  2512 def unbundle(ui, repo, fname, **opts):
  2567     """apply a changegroup file
  2513     """apply a changegroup file
  2568 
  2514 
  2569     Apply a compressed changegroup file generated by the bundle
  2515     Apply a compressed changegroup file generated by the bundle