--- a/mercurial/commands.py Mon Jul 30 15:48:04 2012 +0200
+++ b/mercurial/commands.py Mon Jul 30 19:26:05 2012 +0200
@@ -2067,17 +2067,31 @@
_('[OBSOLETED [REPLACEMENT] [REPL... ]'))
def debugobsolete(ui, repo, precursor=None, *successors, **opts):
"""create arbitrary obsolete marker"""
+ def parsenodeid(s):
+ try:
+ # We do not use revsingle/revrange functions here to accept
+ # arbitrary node identifiers, possibly not present in the
+ # local repository.
+ n = bin(s)
+ if len(n) != len(nullid):
+ raise TypeError()
+ return n
+ except TypeError:
+ raise util.Abort('changeset references must be full hexadecimal '
+ 'node identifiers')
+
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)
+ succs = tuple(parsenodeid(succ) for succ in successors)
l = repo.lock()
try:
tr = repo.transaction('debugobsolete')
try:
- repo.obsstore.create(tr, bin(precursor), succs, 0, metadata)
+ repo.obsstore.create(tr, parsenodeid(precursor), succs, 0,
+ metadata)
tr.close()
finally:
tr.release()
--- a/tests/test-obsolete.t Mon Jul 30 15:48:04 2012 +0200
+++ b/tests/test-obsolete.t Mon Jul 30 19:26:05 2012 +0200
@@ -31,6 +31,12 @@
Killing a single changeset without replacement
$ mkcommit kill_me
+ $ hg debugobsolete 0
+ abort: changeset references must be full hexadecimal node identifiers
+ [255]
+ $ hg debugobsolete '00'
+ abort: changeset references must be full hexadecimal node identifiers
+ [255]
$ hg debugobsolete -d '0 0' `getid kill_me` -u babar
$ hg debugobsolete
97b7c2d76b1845ed3eb988cd612611e72406cef0 0 {'date': '0 0', 'user': 'babar'}