Patchwork [02,of,10] effectflag: store an empty effect flag right now

login
register
mail settings
Submitter Boris Feld
Date July 7, 2017, 12:38 p.m.
Message ID <ac20a70e9d253605b5be.1499431111@FB>
Download mbox | patch
Permalink /patch/22089/
State Changes Requested
Headers show

Comments

Boris Feld - July 7, 2017, 12:38 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1499345417 -7200
#      Thu Jul 06 14:50:17 2017 +0200
# Node ID ac20a70e9d253605b5be4f60f8791846a3cc00f6
# Parent  030b6e711be36cf764cb053e1d74d71125d63076
# EXP-Topic effectflag
effectflag: store an empty effect flag right now

The idea is to store a bitfield flag when creating an obsmarker. This effect
flag would indicate what is the changes between a changeset and its successor.
It is only informative and helps people collaborating together on the same
stack or even people trying to find the  version of their changeset before
rebasing to check if a bug was already there or not.

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.

Patch

diff -r 030b6e711be3 -r ac20a70e9d25 mercurial/obsolete.py
--- a/mercurial/obsolete.py	Thu Jul 06 14:46:07 2017 +0200
+++ b/mercurial/obsolete.py	Thu Jul 06 14:50:17 2017 +0200
@@ -997,6 +997,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 = []
@@ -1020,6 +1025,12 @@ 
                 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
+                localmetadata["ef1"] = "%d" % obsutil.geteffectflag(rel)
+
             # 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
diff -r 030b6e711be3 -r ac20a70e9d25 mercurial/obsutil.py
--- a/mercurial/obsutil.py	Thu Jul 06 14:46:07 2017 +0200
+++ b/mercurial/obsutil.py	Thu Jul 06 14:50:17 2017 +0200
@@ -535,3 +535,13 @@ 
                 final.reverse() # put small successors set first
                 cache[current] = final
     return cache[initialnode]
+
+def geteffectflag(relation):
+    """ From an obs-marker relation, compute what changed between the
+    predecessor and the successor.
+    """
+    effects = 0
+
+    source = relation[0]
+
+    return effects