D540: effectflag: detect when meta changed
lothiraldan (Boris Feld)
phabricator at mercurial-scm.org
Wed Sep 27 08:08:16 UTC 2017
lothiraldan updated this revision to Diff 2111.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D540?vs=1344&id=2111
REVISION DETAIL
https://phab.mercurial-scm.org/D540
AFFECTED FILES
mercurial/obsutil.py
tests/test-obsmarkers-effectflag.t
CHANGE DETAILS
diff --git a/tests/test-obsmarkers-effectflag.t b/tests/test-obsmarkers-effectflag.t
--- a/tests/test-obsmarkers-effectflag.t
+++ b/tests/test-obsmarkers-effectflag.t
@@ -164,4 +164,4 @@
check result
$ hg debugobsolete -r .
- 2f599e54c1c6974299065cdf54e1ad640bfb7b5d 12c6238b5e371eea00fd2013b12edce3f070928b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'amend', 'user': 'test'}
+ 2f599e54c1c6974299065cdf54e1ad640bfb7b5d 12c6238b5e371eea00fd2013b12edce3f070928b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '2', 'operation': 'amend', 'user': 'test'}
diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -7,6 +7,8 @@
from __future__ import absolute_import
+import re
+
from . import (
phases,
util
@@ -309,11 +311,30 @@
EFFECTFLAGFIELD = "ef1"
DESCCHANGED = 1 << 0 # action changed the description
+METACHANGED = 1 << 1 # action change the meta
PARENTCHANGED = 1 << 2 # action change the parent
USERCHANGED = 1 << 4 # the user changed
DATECHANGED = 1 << 5 # the date changed
BRANCHCHANGED = 1 << 6 # the branch changed
+METABLACKLIST = [
+ re.compile('^branch$'),
+ re.compile('^.*-source$'),
+ re.compile('^.*_source$'),
+ re.compile('^source$'),
+]
+
+def ismetablacklisted(metaitem):
+ """ Check that the key of a meta item (extrakey, extravalue) does not
+ match at least one of the blacklist pattern
+ """
+ metakey = metaitem[0]
+ for pattern in METABLACKLIST:
+ if pattern.match(metakey):
+ return False
+
+ return True
+
def geteffectflag(relation):
""" From an obs-marker relation, compute what changed between the
predecessor and the successor.
@@ -343,6 +364,16 @@
if changectx.parents() != source.parents():
effects |= PARENTCHANGED
+ # Check if other meta has changed
+ changeextra = changectx.extra().items()
+ ctxmeta = filter(ismetablacklisted, changeextra)
+
+ sourceextra = source.extra().items()
+ srcmeta = filter(ismetablacklisted, sourceextra)
+
+ if ctxmeta != srcmeta:
+ effects |= METACHANGED
+
return effects
def getobsoleted(repo, tr):
To: lothiraldan, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list