--- a/mercurial/commands.py Mon Jun 04 00:50:19 2012 +0200
+++ b/mercurial/commands.py Thu Jun 07 19:20:44 2012 +0200
@@ -17,7 +17,7 @@
import minirst, revset, fileset
import dagparser, context, simplemerge
import random, setdiscovery, treediscovery, dagutil, pvec
-import phases
+import phases, obsolete
table = {}
@@ -2050,19 +2050,29 @@
ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
@command('debugobsolete', [] + commitopts2,
- _('OBSOLETED [REPLACEMENT] [REPL...'))
-def debugobsolete(ui, repo, precursor, *successors, **opts):
+ _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
+def debugobsolete(ui, repo, precursor=None, *successors, **opts):
"""create arbitrary obsolete marker"""
- metadata = {}
- if 'date' in opts:
- metadata['date'] = opts['date']
- metadata['user'] = opts['user'] or ui.username()
- succs = tuple(bin(succ) for succ in successors)
- l = repo.lock()
- try:
- repo.obsstore.create(bin(precursor), succs, 0, metadata)
- finally:
- l.release()
+ if precursor is not None:
+ metadata = {}
+ if 'date' in opts:
+ metadata['date'] = opts['date']
+ metadata['user'] = opts['user'] or ui.username()
+ succs = tuple(bin(succ) for succ in successors)
+ l = repo.lock()
+ try:
+ repo.obsstore.create(bin(precursor), succs, 0, metadata)
+ finally:
+ l.release()
+ else:
+ for mctx in obsolete.allmarkers(repo):
+ ui.write(hex(mctx.precnode()))
+ for repl in mctx.succnodes():
+ ui.write(' ')
+ ui.write(hex(repl))
+ ui.write(' %X ' % mctx._data[2])
+ ui.write(mctx.metadata())
+ ui.write('\n')
@command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'))
def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
--- a/tests/test-obsolete.t Mon Jun 04 00:50:19 2012 +0200
+++ b/tests/test-obsolete.t Thu Jun 07 19:20:44 2012 +0200
@@ -16,6 +16,8 @@
$ mkcommit kill_me
$ hg debugobsolete -d '0 0' `getid kill_me` -u babar
+ $ hg debugobsolete
+ 97b7c2d76b1845ed3eb988cd612611e72406cef0 0 {'date': '0 0', 'user': 'babar'}
$ cd ..
Killing a single changeset with replacement
@@ -30,6 +32,8 @@
$ mkcommit new_c
created new head
$ hg debugobsolete `getid original_c` `getid new_c` -d '56 12'
+ $ hg debugobsolete
+ 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'}
do it again (it read the obsstore before adding new changeset)
@@ -38,6 +42,9 @@
$ mkcommit new_2_c
created new head
$ hg debugobsolete -d '1337 0' `getid new_c` `getid new_2_c`
+ $ hg debugobsolete
+ 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'}
+ cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
Register two markers with a missing node
@@ -47,3 +54,8 @@
created new head
$ hg debugobsolete -d '1338 0' `getid new_2_c` 1337133713371337133713371337133713371337
$ hg debugobsolete -d '1339 0' 1337133713371337133713371337133713371337 `getid new_3_c`
+ $ hg debugobsolete
+ 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'}
+ cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
+ ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
+ 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}