Patrick Mézard avatar Patrick Mézard committed 87e4d1e

obsolete: add debugsuccessors command

It dumps obsolete changesets and their successors.

Comments (0)

Files changed (2)

hgext/obsolete.py

         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

tests/test-amend.t

   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
   $ hg amend --change 2
   abort: no updates found
   [255]
+  $ hg debugsuccessors
+  07f494440405 a34b93d251e4
+  07f494440405 bd19cbe78fbf
+  bd19cbe78fbf a34b93d251e4
   $ hg phase 2
   2: draft
   $ glog
   $ 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
   |
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.