changeset 811:acfa2b67cff6

evolve: add a cmddebugrecordpruneparents command This command can be used to create prune marker with parent information from prune marker on changeset known locally.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 24 Feb 2014 19:01:12 -0800
parents de20d5500571
children 60dd0c401034
files hgext/evolve.py
diffstat 1 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py	Mon Feb 24 17:44:12 2014 -0800
+++ b/hgext/evolve.py	Mon Feb 24 19:01:12 2014 -0800
@@ -860,6 +860,44 @@
      _('record the specified user in metadata'), _('USER')),
 ]
 
+@command('debugrecordpruneparents', [], '')
+def cmddebugrecordpruneparents(ui, repo):
+    """add parents data to prune markers when possible
+
+    This commands search the repo for prune markers without parent information.
+    If the pruned node is locally known, a new markers with parent data is
+    created."""
+    pgop = 'reading markers'
+
+    # lock from the beginning to prevent race
+    wlock = lock = tr = None
+    try:
+        wlock = repo.wlock()
+        lock = repo.lock()
+        tr = repo.transaction('recordpruneparents')
+        unfi = repo.unfiltered()
+        nm = unfi.changelog.nodemap
+        store = repo.obsstore
+        pgtotal = len(store._all)
+        for idx, mark in enumerate(list(store._all)):
+            if not mark[1]:
+                rev = nm.get(mark[0])
+                if rev is not None:
+                    ctx = unfi[rev]
+                    meta = obsolete.decodemeta(mark[3])
+                    for i, p in enumerate(ctx.parents(), 1):
+                        meta['p%i' % i] = p.hex()
+                    before = len(store._all)
+                    store.create(tr, mark[0], mark[1], mark[2], meta)
+                    if len(store._all) - before:
+                        ui.write('created new markers for %i\n' % rev)
+            ui.progress(pgop, idx, total=pgtotal)
+        tr.close()
+        ui.progress(pgop, None)
+    finally:
+        if tr is not None:
+            tr.release()
+        lockmod.release(lock, wlock)
 
 @command('debugobsstorestat', [], '')
 def cmddebugobsstorestat(ui, repo):