hgext3rd/evolve/obshistory.py
changeset 2415 89a5dabbb43d
parent 2411 bd937b7ce7d2
child 2416 23c0bef0b5d4
--- a/hgext3rd/evolve/obshistory.py	Thu May 18 17:40:07 2017 +0200
+++ b/hgext3rd/evolve/obshistory.py	Thu May 18 18:04:47 2017 +0200
@@ -8,12 +8,67 @@
 # GNU General Public License version 2 or any later version.
 
 from mercurial import (
-    node as nodemod,
     cmdutil,
+    commands,
+    error,
     graphmod,
-    error
+    node as nodemod,
+    scmutil,
+)
+
+from mercurial.i18n import _
+
+from . import (
+    exthelper,
 )
 
+eh = exthelper.exthelper()
+
+@eh.command(
+    '^debugobshistory',
+    [('G', 'graph', True, _("show the revision DAG")),
+     ('r', 'rev', [], _('show the specified revision or revset'), _('REV'))
+    ] + commands.formatteropts,
+    _('hg debugobshistory [OPTION]... [REV]'))
+def cmdobshistory(ui, repo, *revs, **opts):
+    """show the obsolescence history of the specified revisions.
+
+    By default this command prints the selected revisions and all its
+    precursors. For precursors pointing on existing revisions in the repository,
+    it will display revisions node id, revision number and the first line of the
+    description. For precursors pointing on non existing revisions in the
+    repository (that can happen when exchanging obsolescence-markers), display
+    only the node id.
+
+    In both case, for each node, its obsolescence marker will be displayed with
+    the obsolescence operation (rewritten or pruned) in addition of the user and
+    date of the operation.
+
+    The output is a graph by default but can deactivated with the option '--no-
+    graph'.
+
+    'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
+    and '+' represents a fork where the changeset from the lines below is a
+    parent of the 'o' merge on the same line.
+
+    Paths in the DAG are represented with '|', '/' and so forth.
+
+    Returns 0 on success.
+    """
+    revs = list(revs) + opts['rev']
+    if not revs:
+        revs = ['.']
+    revs = scmutil.revrange(repo, revs)
+
+    if opts['graph']:
+        return _debugobshistorygraph(ui, repo, revs, opts)
+
+    fm = ui.formatter('debugobshistory', opts)
+    revs.reverse()
+    _debugobshistorysingle(fm, repo, revs)
+
+    fm.end()
+
 class obsmarker_printer(cmdutil.changeset_printer):
     """show (available) information about a node