# HG changeset patch # User Pierre-Yves David # Date 2014-08-20 07:43:08 # Node ID 406181ee335fe42dd2d5d1e6c5a310b5b8b7a10a # Parent 8c69262df82dfe118695466bc89a29de348c9233 debugobsolete: add a way to record parent information We add a ``--record-parents`` flag to debugobsolete. This can be used to record parent information in the marker when the precursors are known locally. This will be useful to test the "relevant markers" computation. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2308,6 +2308,8 @@ def debuglabelcomplete(ui, repo, *args): @command('debugobsolete', [('', 'flags', 0, _('markers flag')), + ('', 'record-parents', False, + _('record parent information for the precursor')), ] + commitopts2, _('[OBSOLETED [REPLACEMENT] [REPL... ]')) def debugobsolete(ui, repo, precursor=None, *successors, **opts): @@ -2342,8 +2344,16 @@ def debugobsolete(ui, repo, precursor=No date = util.parsedate(date) else: date = None - repo.obsstore.create(tr, parsenodeid(precursor), succs, - opts['flags'], date=date, + prec = parsenodeid(precursor) + parents = None + if opts['record_parents']: + if prec not in repo.unfiltered(): + raise util.Abort('cannot used --record-parents on ' + 'unknown changesets') + parents = repo.unfiltered()[prec].parents() + parents = tuple(p.node() for p in parents) + repo.obsstore.create(tr, prec, succs, opts['flags'], + parents=parents, date=date, metadata=metadata) tr.close() except ValueError, exc: diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -244,7 +244,7 @@ Show all commands + options debuginstall: debugknown: debuglabelcomplete: - debugobsolete: flags, date, user + debugobsolete: flags, record-parents, date, user debugpathcomplete: full, normal, added, removed debugpushkey: debugpvec: diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -417,7 +417,9 @@ detect outgoing obsolete and unstable 3 files updated, 0 files merged, 0 files removed, 0 files unresolved $ mkcommit original_d $ mkcommit original_e - $ hg debugobsolete `getid original_d` -d '0 0' + $ hg debugobsolete --record-parents `getid original_d` -d '0 0' + $ hg debugobsolete | grep `getid original_d` + 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'} $ hg log -r 'obsolete()' 4:94b33453f93b (draft) [ ] add original_d $ hg log -G -r '::unstable()'