mercurial/commands.py
changeset 30514 625ccc95fa96
parent 30510 a0878bc87379
child 30515 cdd1885d0f2f
equal deleted inserted replaced
30513:ff7df4bb75de 30514:625ccc95fa96
    34     bookmarks,
    34     bookmarks,
    35     bundle2,
    35     bundle2,
    36     changegroup,
    36     changegroup,
    37     cmdutil,
    37     cmdutil,
    38     copies,
    38     copies,
    39     dagparser,
       
    40     dagutil,
    39     dagutil,
    41     destutil,
    40     destutil,
    42     dirstateguard,
    41     dirstateguard,
    43     discovery,
    42     discovery,
    44     encoding,
    43     encoding,
  1864     Returns 0 on success, 1 if errors are encountered.
  1863     Returns 0 on success, 1 if errors are encountered.
  1865     """
  1864     """
  1866     with repo.wlock(False):
  1865     with repo.wlock(False):
  1867         return cmdutil.copy(ui, repo, pats, opts)
  1866         return cmdutil.copy(ui, repo, pats, opts)
  1868 
  1867 
  1869 @command('debugdag',
       
  1870     [('t', 'tags', None, _('use tags as labels')),
       
  1871     ('b', 'branches', None, _('annotate with branch names')),
       
  1872     ('', 'dots', None, _('use dots for runs')),
       
  1873     ('s', 'spaces', None, _('separate elements by spaces'))],
       
  1874     _('[OPTION]... [FILE [REV]...]'),
       
  1875     optionalrepo=True)
       
  1876 def debugdag(ui, repo, file_=None, *revs, **opts):
       
  1877     """format the changelog or an index DAG as a concise textual description
       
  1878 
       
  1879     If you pass a revlog index, the revlog's DAG is emitted. If you list
       
  1880     revision numbers, they get labeled in the output as rN.
       
  1881 
       
  1882     Otherwise, the changelog DAG of the current repo is emitted.
       
  1883     """
       
  1884     spaces = opts.get('spaces')
       
  1885     dots = opts.get('dots')
       
  1886     if file_:
       
  1887         rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
       
  1888         revs = set((int(r) for r in revs))
       
  1889         def events():
       
  1890             for r in rlog:
       
  1891                 yield 'n', (r, list(p for p in rlog.parentrevs(r)
       
  1892                                         if p != -1))
       
  1893                 if r in revs:
       
  1894                     yield 'l', (r, "r%i" % r)
       
  1895     elif repo:
       
  1896         cl = repo.changelog
       
  1897         tags = opts.get('tags')
       
  1898         branches = opts.get('branches')
       
  1899         if tags:
       
  1900             labels = {}
       
  1901             for l, n in repo.tags().items():
       
  1902                 labels.setdefault(cl.rev(n), []).append(l)
       
  1903         def events():
       
  1904             b = "default"
       
  1905             for r in cl:
       
  1906                 if branches:
       
  1907                     newb = cl.read(cl.node(r))[5]['branch']
       
  1908                     if newb != b:
       
  1909                         yield 'a', newb
       
  1910                         b = newb
       
  1911                 yield 'n', (r, list(p for p in cl.parentrevs(r)
       
  1912                                         if p != -1))
       
  1913                 if tags:
       
  1914                     ls = labels.get(r)
       
  1915                     if ls:
       
  1916                         for l in ls:
       
  1917                             yield 'l', (r, l)
       
  1918     else:
       
  1919         raise error.Abort(_('need repo for changelog dag'))
       
  1920 
       
  1921     for line in dagparser.dagtextlines(events(),
       
  1922                                        addspaces=spaces,
       
  1923                                        wraplabels=True,
       
  1924                                        wrapannotations=True,
       
  1925                                        wrapnonlinear=dots,
       
  1926                                        usedots=dots,
       
  1927                                        maxlinewidth=70):
       
  1928         ui.write(line)
       
  1929         ui.write("\n")
       
  1930 
       
  1931 @command('debugdata', debugrevlogopts, _('-c|-m|FILE REV'))
  1868 @command('debugdata', debugrevlogopts, _('-c|-m|FILE REV'))
  1932 def debugdata(ui, repo, file_, rev=None, **opts):
  1869 def debugdata(ui, repo, file_, rev=None, **opts):
  1933     """dump the contents of a data file revision"""
  1870     """dump the contents of a data file revision"""
  1934     if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
  1871     if opts.get('changelog') or opts.get('manifest') or opts.get('dir'):
  1935         if rev is not None:
  1872         if rev is not None: