debugobsolete: add a way to record parent information
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 20 Aug 2014 00:43:08 -0700
changeset 22272 406181ee335f
parent 22271 8c69262df82d
child 22273 e6d01239f779
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.
mercurial/commands.py
tests/test-completion.t
tests/test-obsolete.t
--- a/mercurial/commands.py	Tue Aug 19 17:03:10 2014 -0700
+++ b/mercurial/commands.py	Wed Aug 20 00:43:08 2014 -0700
@@ -2308,6 +2308,8 @@
 
 @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 @@
                         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:
--- a/tests/test-completion.t	Tue Aug 19 17:03:10 2014 -0700
+++ b/tests/test-completion.t	Wed Aug 20 00:43:08 2014 -0700
@@ -244,7 +244,7 @@
   debuginstall: 
   debugknown: 
   debuglabelcomplete: 
-  debugobsolete: flags, date, user
+  debugobsolete: flags, record-parents, date, user
   debugpathcomplete: full, normal, added, removed
   debugpushkey: 
   debugpvec: 
--- a/tests/test-obsolete.t	Tue Aug 19 17:03:10 2014 -0700
+++ b/tests/test-obsolete.t	Wed Aug 20 00:43:08 2014 -0700
@@ -417,7 +417,9 @@
   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()'