D533: effectflag: store an empty effect flag for the moment

lothiraldan (Boris Feld) phabricator at mercurial-scm.org
Mon Aug 28 11:02:43 UTC 2017


lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The idea behind effect flag is to store additional information in obs-markers
  about what changed between a changeset and its successor(s). It's a low-level
  information that comes without guarantees.
  
  This information can be computed a posteriori, but only if we have all
  changesets locally. This is not the case with distributed workflows where you
  work with several people or on several computers (eg: laptop + build server).
  
  Storing the effect-flag as a bitfield has several advantages:
  
  - It's compact, we are using one byte per obs-marker at most for the effect- flag.
  - It's compoundable, the obsfate log approach needs to display evolve history that could spans several obs-markers. Computing the effect-flag between a changeset and its grand-grand-grand-successor is simple thanks to the bitfield.
  
  The effect-flag design has also some limitations:
  
  - Evolving a changeset and reverting these changes just after would lead to two obs-markers with the same effect-flag without information that the first and third changesets are the same.
  
  The effect-flag current design is a trade-off between compactness and
  usefulness.
  
  Storing this information helps commands to display a more complete and
  understandable evolve history. For example, obslog (an Evolve command) use it
  to improve its output:
  
  x  f9b900605b26 (34302) obscache: skip updating outdated obscache...
  
  | rewritten(parent) by Matthieu Laneuville <matthieu.laneuville at octobus... |
  | rewritten(content) by Boris Feld <boris.feld at octobus.net>                |
  |
  
  The effect flag is stored in obs-markers metadata while we iterate on the
  information we want to store. We plan to extend the existing obsmarkers
  bit-field when the effect flag design will be stabilized.
  
  It's different from the CommitCustody concept, effect-flag are not signed and
  can be forged. It's also different from the operation metadata as the command
  name (for example: amend) could alter a changeset in different ways (changing
  the content with hg amend, changing the description with hg amend -e, changing
  the user with hg amend -U). Also it's compatible with every custom command
  that writes obs-markers without needing to be updated.
  
  The effect-flag is placed behind an experimental flag set to off by default.
  
  Hook the saving of effect flag in create markers, but store only an empty one
  for the moment, I will refine the values in effect flag in following patches.
  
  For more information, see:
  
    https://www.mercurial-scm.org/wiki/ChangesetEvolutionDevel#Record_types_of_operation

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/obsolete.py
  mercurial/obsutil.py

CHANGE DETAILS

diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -305,6 +305,19 @@
             foreground = set(repo.set('%ln::', known))
     return set(c.node() for c in foreground)
 
+# logic around storing and using effect flags
+EFFECTFLAGFIELD = "ef1"
+
+def geteffectflag(relation):
+    """ From an obs-marker relation, compute what changed between the
+    predecessor and the successor.
+    """
+    effects = 0
+
+    source = relation[0]
+
+    return effects
+
 def getobsoleted(repo, tr):
     """return the set of pre-existing revisions obsoleted by a transaction"""
     torev = repo.unfiltered().changelog.nodemap.get
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -1036,6 +1036,11 @@
     if useoperation and operation:
         metadata['operation'] = operation
 
+    # Effect flag metadata handling
+    saveeffectflag = repo.ui.configbool('experimental',
+                                        'evolution.effect-flags',
+                                        False)
+
     tr = repo.transaction('add-obsolescence-marker')
     try:
         markerargs = []
@@ -1059,6 +1064,13 @@
                 raise error.Abort(_("changeset %s cannot obsolete itself")
                                   % prec)
 
+            # Effect flag can be different by relation
+            if saveeffectflag:
+                # The effect flag is saved in a versioned field name for future
+                # evolution
+                effectflag = obsutil.geteffectflag(rel)
+                localmetadata[obsutil.EFFECTFLAGFIELD] = "%d" % effectflag
+
             # Creating the marker causes the hidden cache to become invalid,
             # which causes recomputation when we ask for prec.parents() above.
             # Resulting in n^2 behavior.  So let's prepare all of the args



To: lothiraldan, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list