Patchwork D1191: obsfate: makes successorsetverb takes the markers as argument

login
register
mail settings
Submitter phabricator
Date Oct. 19, 2017, 11:41 a.m.
Message ID <differential-rev-PHID-DREV-lpcv5dkfponw3f5v2fg3-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25236/
State Superseded
Headers show

Comments

phabricator - Oct. 19, 2017, 11:41 a.m.
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Right now, successorsetverb only needs successors to compute the verb. But we
  will want use additional information (effect-flags and operation) in the near
  future to compute a better verb.
  
  Add the markers parameter now so extensions (like Evolve) could wrap the
  function and start experimenting around better obsfate verbs.
  
  As successorsetverb now takes both successorset and markers parameters, rename
  it to obsfateverb, successorsetandmarkersverb was too long.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/obsutil.py
  mercurial/templater.py
  tests/test-obsmarker-template.t

CHANGE DETAILS




To: lothiraldan, #hg-reviewers
Cc: mercurial-devel
phabricator - Oct. 19, 2017, 7:23 p.m.
krbullock requested changes to this revision.
krbullock added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> templater.py:1011
>      """Compute obsfate related information based on successors (EXPERIMENTAL)"""
> -    if len(args) != 1:
> +    if len(args) != 2:
>          # i18n: "obsfateverb" is a keyword

Needs an update to the `@templatefunc(...)` decoration above too.

REPOSITORY
  rHG Mercurial

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

To: lothiraldan, #hg-reviewers, krbullock
Cc: krbullock, mercurial-devel
phabricator - Oct. 19, 2017, 9 p.m.
lothiraldan added inline comments.

INLINE COMMENTS

> krbullock wrote in templater.py:1011
> Needs an update to the `@templatefunc(...)` decoration above too.

Done

REPOSITORY
  rHG Mercurial

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

To: lothiraldan, #hg-reviewers, krbullock
Cc: krbullock, mercurial-devel
phabricator - Oct. 19, 2017, 9:23 p.m.
krbullock added a comment.


  Deferring this until after 4.4, because the added `markers` argument isn't used yet.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/tests/test-obsmarker-template.t b/tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t
+++ b/tests/test-obsmarker-template.t
@@ -13,7 +13,7 @@ 
   > evolution=true
   > [templates]
   > obsfatesuccessors = "{if(successors, " as ")}{join(successors, ", ")}"
-  > obsfateverb = "{obsfateverb(successors)}"
+  > obsfateverb = "{obsfateverb(successors, markers)}"
   > obsfateoperations = "{if(obsfateoperations(markers), " using {join(obsfateoperations(markers), ", ")}")}"
   > obsfateusers = "{if(obsfateusers(markers), " by {join(obsfateusers(markers), ", ")}")}"
   > obsfatedate = "{if(obsfatedate(markers), "{ifeq(min(obsfatedate(markers)), max(obsfatedate(markers)), " (at {min(obsfatedate(markers))|isodate})", " (between {min(obsfatedate(markers))|isodate} and {max(obsfatedate(markers))|isodate})")}")}"
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -1008,14 +1008,15 @@ 
 @templatefunc('obsfateverb(successors)')
 def obsfateverb(context, mapping, args):
     """Compute obsfate related information based on successors (EXPERIMENTAL)"""
-    if len(args) != 1:
+    if len(args) != 2:
         # i18n: "obsfateverb" is a keyword
-        raise error.ParseError(_("obsfateverb expects one arguments"))
+        raise error.ParseError(_("obsfateverb expects two arguments"))
 
     successors = evalfuncarg(context, mapping, args[0])
+    markers = evalfuncarg(context, mapping, args[1])
 
     try:
-        return obsutil.successorsetverb(successors)
+        return obsutil.obsfateverb(successors, markers)
     except TypeError:
         # i18n: "obsfateverb" is a keyword
         errmsg = _("obsfateverb first argument should be countable")
diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -751,8 +751,9 @@ 
 
     return values
 
-def successorsetverb(successorset):
-    """ Return the verb summarizing the successorset
+def obsfateverb(successorset, markers):
+    """ Return the verb summarizing the successorset and potentially using
+    information from the markers
     """
     if not successorset:
         verb = 'pruned'
@@ -795,7 +796,7 @@ 
     line = []
 
     # Verb
-    line.append(successorsetverb(successors))
+    line.append(obsfateverb(successors, markers))
 
     # Operations
     operations = markersoperations(markers)