From patchwork Thu Aug 21 03:20:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5,of,7] debugobsolete: add a way to record parent information From: Pierre-Yves David X-Patchwork-Id: 5542 Message-Id: <6aafbe6ac6d43e7e9eef.1408591255@marginatus.alto.octopoid.net> To: mercurial-devel@selenic.com Cc: Pierre-Yves David Date: Wed, 20 Aug 2014 20:20:55 -0700 # HG changeset patch # User Pierre-Yves David # Date 1408520588 25200 # Wed Aug 20 00:43:08 2014 -0700 # Node ID 6aafbe6ac6d43e7e9eef1a12ca96c58489565b62 # Parent 06e61fc68d923f5d99dc1960ee278a1aaf3aa5f1 debugobsolete: add a way to record parent information We add a ``--record-parents`` flag to debugobsolete. This can be used to record parents information in the marker when the precursors is known locally. This will be useful to test "relevant markers" computation. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2307,10 +2307,12 @@ def debuglabelcomplete(ui, repo, *args): ui.write('\n'.join(sorted(completions))) ui.write('\n') @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): """create arbitrary obsolete marker @@ -2341,12 +2343,20 @@ def debugobsolete(ui, repo, precursor=No date = opts.get('date') if date: 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: raise util.Abort(_('bad obsmarker input: %s') % exc) finally: diff --git a/tests/test-completion.t b/tests/test-completion.t --- a/tests/test-completion.t +++ b/tests/test-completion.t @@ -242,11 +242,11 @@ Show all commands + options debugindex: changelog, manifest, format debugindexdot: debuginstall: debugknown: debuglabelcomplete: - debugobsolete: flags, date, user + debugobsolete: flags, record-parents, date, user debugpathcomplete: full, normal, added, removed debugpushkey: debugpvec: debugrebuilddirstate: rev debugrename: rev diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t --- a/tests/test-obsolete.t +++ b/tests/test-obsolete.t @@ -415,11 +415,13 @@ detect outgoing obsolete and unstable $ hg up 'desc("n3w_3_c")' 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()' @ 5:cda648ca50f5 (draft) [tip ] add original_e |