D2682: [PoC] changegroup: delete obs markers when applying changegroup

2020-01-24 Thread baymax (Baymax, Your Personal Patch-care Companion)
This revision now requires changes to proceed.
baymax added a comment.
baymax requested changes to this revision.


  There seems to have been no activities on this Diff for the past 3 Months.
  
  By policy, we are automatically moving it out of the `need-review` state.
  
  Please, move it back to `need-review` without hesitation if this diff should 
still be discussed.
  
  :baymax:need-review-idle:

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D2682/new/

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

To: indygreg, #hg-reviewers, baymax
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2682: [PoC] changegroup: delete obs markers when applying changegroup

2018-03-04 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In local-only obsolescence mode, our short-term hack to unhide a
  changeset is to delete obsolescence markers causing it to be hidden.
  We need to do this every time a changeset is introduced into the
  repository.
  
  I was hoping we could implement the unhide logic once, around
  transaction close time. However, it appears that we'll need to
  teach every mechanism that introduces changesets to unhide
  changesets because of interaction between those mechanisms and
  visibility. For example, changegroup application no-ops on incoming
  changesets that are present but hidden. The code that scans for
  "new" changesets is based on changesets between the old and new
  changelog length. Since the unhidden changeset is possibly older
  than the old changelog length, we need to either track unhides
  explicitly or deal with them specially.
  
  This commit teaches changegroup application to record which changesets
  are in the incoming changegroup so it can scan for relevant
  obsolescence markers after changegroup applications and delete
  their markers.
  
  I'm not convinced this is the best approach to the problem. But it's
  a start.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/changegroup.py
  tests/test-amend.t

CHANGE DETAILS

diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -102,15 +102,13 @@
 
   $ hg unbundle .hg/strip-backup/112478962961-7e959a55-amend.hg
   adding changesets
+  unhiding 1 changesets
   adding manifests
   adding file changes
   added 0 changesets with 0 changes to 1 files
   (run 'hg update' to get a working copy)
 
-TODO obsmarker should be deleted, both versions should be visible
-
   $ hg debugobsolete
-  112478962961147124edd43549aedd1a335e44bf 
be169c7e8dbe21cd10b3d79691cbe7f241e3c21c 0 (Thu Jan 01 00:00:00 1970 +) 
{'ef1': '8', 'operation': 'amend', 'user': 'test'}
 
   $ hg log -G
   @  changeset:   2:be169c7e8dbe
@@ -120,11 +118,10 @@
   |  date:Thu Jan 01 00:00:00 1970 +
   |  summary: B
   |
-  | x  changeset:   1:112478962961
+  | o  changeset:   1:112478962961
   |/   tag: B
   |user:test
   |date:Thu Jan 01 00:00:00 1970 +
-  |obsolete:rewritten using amend as 2:be169c7e8dbe
   |summary: B
   |
   o  changeset:   0:426bada5c675
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -23,6 +23,7 @@
 dagutil,
 error,
 mdiff,
+obsolete,
 phases,
 pycompat,
 util,
@@ -259,7 +260,15 @@
 - number of heads stays the same: 1
 """
 repo = repo.unfiltered()
+
+incomingnodes = set()
+localonlyobs = obsolete.getoptions(repo)[obsolete.localonlymodeopt]
+
 def csmap(x):
+# Don't bother tracking if we don't do anything with data.
+if localonlyobs:
+incomingnodes.add(x)
+
 repo.ui.debug("add changeset %s\n" % short(x))
 return len(cl)
 
@@ -308,6 +317,17 @@
 cgnodes = cl.addgroup(deltas, csmap, trp, 
addrevisioncb=onchangelog)
 efiles = len(efiles)
 
+# TODO do we need to invalidate visibility caches when we
+# remove markers?
+if localonlyobs and incomingnodes:
+indices = [i for i, t in enumerate(repo.obsstore._all)
+   if t[0] in incomingnodes]
+if indices:
+from . import repair
+# TODO is # markers == # unhidden changesets?
+repo.ui.status(_('unhiding %d changesets\n') % 
len(indices))
+repair.deleteobsmarkers(repo.obsstore, indices)
+
 if not cgnodes:
 repo.ui.develwarn('applied empty changegroup',
   config='warn-empty-changegroup')



To: indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel