changeset 273:87e4d1eec5e8

obsolete: add debugsuccessors command It dumps obsolete changesets and their successors.
author Patrick Mezard <patrick@mezard.eu>
date Tue, 19 Jun 2012 10:02:32 +0200
parents 78d01e341438
children 6622a24f3b0f
files hgext/obsolete.py tests/test-amend.t
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/obsolete.py	Mon Jun 18 12:11:06 2012 +0200
+++ b/hgext/obsolete.py	Tue Jun 19 10:02:32 2012 +0200
@@ -433,9 +433,28 @@
         l.release()
     ui.status('%i obsolete marker converted\n' % cnt)
 
+def cmddebugsuccessors(ui, repo):
+    """dump obsolete changesets and their successors
+
+    Each line matches an existing marker, the first identifier is the
+    obsolete changeset identifier, followed by it successors.
+    """
+    lock = repo.lock()
+    try:
+        allsuccessors = repo.obsoletestore.objects
+        for old in sorted(allsuccessors):
+            successors = [sorted(m['subjects']) for m in allsuccessors[old]]
+            for i, group in enumerate(sorted(successors)):
+                ui.write('%s' % short(old))
+                for new in group:
+                    ui.write(' %s' % short(new))
+                ui.write('\n')
+    finally:
+        lock.release()
 
 cmdtable = {'debugobsolete': (cmddebugobsolete, [], '<subject> <object>'),
             'debugconvertobsolete': (cmddebugconvertobsolete, [], ''),
+            'debugsuccessors': (cmddebugsuccessors, [], ''),
            }
 
 ### Altering existing command
--- a/tests/test-amend.t	Mon Jun 18 12:11:06 2012 +0200
+++ b/tests/test-amend.t	Tue Jun 19 10:02:32 2012 +0200
@@ -24,6 +24,10 @@
   marked working directory as branch foo
   (branches are permanent and global, did you want a bookmark?)
   $ hg amend
+  $ hg debugsuccessors
+  07f494440405 a34b93d251e4
+  07f494440405 bd19cbe78fbf
+  bd19cbe78fbf a34b93d251e4
   $ hg branch
   foo
   $ hg branches
@@ -59,6 +63,10 @@
   $ hg amend --change 2
   abort: no updates found
   [255]
+  $ hg debugsuccessors
+  07f494440405 a34b93d251e4
+  07f494440405 bd19cbe78fbf
+  bd19cbe78fbf a34b93d251e4
   $ hg phase 2
   2: draft
   $ glog
@@ -82,6 +90,11 @@
   $ hg amend --change 2
   abort: no updates found
   [255]
+  $ hg debugsuccessors
+  07f494440405 a34b93d251e4
+  07f494440405 bd19cbe78fbf
+  7384bbcba36f 000000000000
+  bd19cbe78fbf a34b93d251e4
   $ glog
   @  6@foo(secret) amends a34b93d251e49c93d5685ebacad785c73a7e8605
   |