Patchwork [1,of,2,follow-up] obsmarker: revert the new "operation" param in favor of existing argument

login
register
mail settings
Submitter Pierre-Yves David
Date May 20, 2017, 12:20 a.m.
Message ID <b2689481ab0c840fe076.1495239640@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20751/
State Changes Requested
Headers show

Comments

Pierre-Yves David - May 20, 2017, 12:20 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1495233243 -7200
#      Sat May 20 00:34:03 2017 +0200
# Node ID b2689481ab0c840fe076834943937d9f98cc4b1b
# Parent  3546a771e376f55e7051149673d368d53d85f8d0
# EXP-Topic operation
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r b2689481ab0c
obsmarker: revert the new "operation" param in favor of existing argument

The previous API already allows to record this data. So we rollback the
API change for the sake of simplicity.
Augie Fackler - May 20, 2017, 12:35 a.m.
> On May 19, 2017, at 17:20, Pierre-Yves David <pierre-yves.david@ens-lyon.org> wrote:
> 
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1495233243 -7200
> #      Sat May 20 00:34:03 2017 +0200
> # Node ID b2689481ab0c840fe076834943937d9f98cc4b1b
> # Parent  3546a771e376f55e7051149673d368d53d85f8d0
> # EXP-Topic operation
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r b2689481ab0c
> obsmarker: revert the new "operation" param in favor of existing argument


No thanks to this - I like making the operation= abstraction super-easy to use so that it's more likely people will actually use it.

> The previous API already allows to record this data. So we rollback the
> API change for the sake of simplicity.
> 
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -1631,7 +1631,8 @@ def safecleanupnode(ui, repo, name, node
>                              key=repo.changelog.rev)
>         markers = [getmarker(t) for t in sortednodes]
>         if markers:
> -            obsolete.createmarkers(repo, markers, operation='histedit')
> +            meta = {'operation': 'histedit'}
> +            obsolete.createmarkers(repo, markers, metadata=meta)
>     else:
>         return cleanupnode(ui, repo, name, nodes)
> 
> diff --git a/hgext/rebase.py b/hgext/rebase.py
> --- a/hgext/rebase.py
> +++ b/hgext/rebase.py
> @@ -1360,7 +1360,8 @@ def clearrebased(ui, repo, state, skippe
>                     succs = (repo[newrev],)
>                 markers.append((repo[rev], succs))
>         if markers:
> -            obsolete.createmarkers(repo, markers, operation='rebase')
> +            meta = {'operation': 'rebase'}
> +            obsolete.createmarkers(repo, markers, metadata=meta)
>     else:
>         rebased = [rev for rev in state
>                    if state[rev] > nullmerge and state[rev] != rev]
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2741,7 +2741,8 @@ def amend(ui, repo, commitfunc, old, ext
>                     if node:
>                         obs.append((ctx, ()))
> 
> -                    obsolete.createmarkers(repo, obs, operation='amend')
> +                    meta = {'operation': 'amend'}
> +                    obsolete.createmarkers(repo, obs, metadata=meta)
>         if not createmarkers and newid != old.node():
>             # Strip the intermediate commit (if there was one) and the amended
>             # commit
> diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
> --- a/mercurial/obsolete.py
> +++ b/mercurial/obsolete.py
> @@ -1203,8 +1203,7 @@ def _computedivergentset(repo):
>     return divergent
> 
> 
> -def createmarkers(repo, relations, flag=0, date=None, metadata=None,
> -                  operation=None):
> +def createmarkers(repo, relations, flag=0, date=None, metadata=None):
>     """Add obsolete markers between changesets in a repo
> 
>     <relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}])
> @@ -1225,8 +1224,6 @@ def createmarkers(repo, relations, flag=
>         metadata = {}
>     if 'user' not in metadata:
>         metadata['user'] = repo.ui.username()
> -    if operation:
> -        metadata['operation'] = operation
>     tr = repo.transaction('add-obsolescence-marker')
>     try:
>         markerargs = []
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1631,7 +1631,8 @@  def safecleanupnode(ui, repo, name, node
                              key=repo.changelog.rev)
         markers = [getmarker(t) for t in sortednodes]
         if markers:
-            obsolete.createmarkers(repo, markers, operation='histedit')
+            meta = {'operation': 'histedit'}
+            obsolete.createmarkers(repo, markers, metadata=meta)
     else:
         return cleanupnode(ui, repo, name, nodes)
 
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1360,7 +1360,8 @@  def clearrebased(ui, repo, state, skippe
                     succs = (repo[newrev],)
                 markers.append((repo[rev], succs))
         if markers:
-            obsolete.createmarkers(repo, markers, operation='rebase')
+            meta = {'operation': 'rebase'}
+            obsolete.createmarkers(repo, markers, metadata=meta)
     else:
         rebased = [rev for rev in state
                    if state[rev] > nullmerge and state[rev] != rev]
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2741,7 +2741,8 @@  def amend(ui, repo, commitfunc, old, ext
                     if node:
                         obs.append((ctx, ()))
 
-                    obsolete.createmarkers(repo, obs, operation='amend')
+                    meta = {'operation': 'amend'}
+                    obsolete.createmarkers(repo, obs, metadata=meta)
         if not createmarkers and newid != old.node():
             # Strip the intermediate commit (if there was one) and the amended
             # commit
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -1203,8 +1203,7 @@  def _computedivergentset(repo):
     return divergent
 
 
-def createmarkers(repo, relations, flag=0, date=None, metadata=None,
-                  operation=None):
+def createmarkers(repo, relations, flag=0, date=None, metadata=None):
     """Add obsolete markers between changesets in a repo
 
     <relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}])
@@ -1225,8 +1224,6 @@  def createmarkers(repo, relations, flag=
         metadata = {}
     if 'user' not in metadata:
         metadata['user'] = repo.ui.username()
-    if operation:
-        metadata['operation'] = operation
     tr = repo.transaction('add-obsolescence-marker')
     try:
         markerargs = []