Patchwork D9226: fix: don't include obsolete descendants with -s

login
register
mail settings
Submitter phabricator
Date Oct. 16, 2020, 11:04 p.m.
Message ID <differential-rev-PHID-DREV-eocrpoek2h2twvcjbmr2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47490/
State New
Headers show

Comments

phabricator - Oct. 16, 2020, 11:04 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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).

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9226

AFFECTED FILES
  hgext/fix.py
  tests/test-fix-topology.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-fix-topology.t b/tests/test-fix-topology.t
--- a/tests/test-fix-topology.t
+++ b/tests/test-fix-topology.t
@@ -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 ..
 
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -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)