changeset 45809:136a86327316

fix: don't include obsolete descendants with -s The `-s/--source` option is for regular users (`-r` is there for power users). If there are obsolete commits that are descendants of the given revision(s), then they almost definitely should just be left alone. That's what `hg rebase` does as well. So this patch makes it so we skip obsolete commits (including those in the input set itself). Differential Revision: https://phab.mercurial-scm.org/D9226
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 16 Oct 2020 15:02:46 -0700
parents 15a98880cc07
children 09914d934cf4
files hgext/fix.py tests/test-fix-topology.t
diffstat 2 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/fix.py	Fri Oct 16 11:15:00 2020 -0700
+++ b/hgext/fix.py	Fri Oct 16 15:02:46 2020 -0700
@@ -417,7 +417,7 @@
         revs = repo.revs(b'(not public() and not obsolete()) or wdir()')
     elif opts[b'source']:
         source_revs = scmutil.revrange(repo, opts[b'source'])
-        revs = set(repo.revs(b'%ld::', source_revs))
+        revs = set(repo.revs(b'(%ld::) - obsolete()', source_revs))
         if wdirrev in source_revs:
             # `wdir()::` is currently empty, so manually add wdir
             revs.add(wdirrev)
--- a/tests/test-fix-topology.t	Fri Oct 16 11:15:00 2020 -0700
+++ b/tests/test-fix-topology.t	Fri Oct 16 15:02:46 2020 -0700
@@ -390,14 +390,11 @@
   o  0 A
   
   $ hg fix -s A
-  abort: fixing obsolete revision could cause divergence
-  [255]
   $ hg fix -s B
-  abort: fixing obsolete revision could cause divergence
+  abort: no changesets specified
+  (use --source or --working-dir)
   [255]
   $ hg fix -s D
-  abort: fixing obsolete revision could cause divergence
-  [255]
   $ hg fix -s E
   $ cd ..