[PATCH 1 of 4] bookmarks: rename unsetcurrent to deactivate

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue May 5 20:23:08 CDT 2015



On 05/05/2015 07:00 AM, Augie Fackler wrote:
> On Mon, May 04, 2015 at 05:44:48PM -0700, Ryan McElroy wrote:
>> # HG changeset patch
>> # User Ryan McElroy <rmcelroy at fb.com>
>> # Date 1428987217 25200
>> #      Mon Apr 13 21:53:37 2015 -0700
>> # Node ID 33363e62aac24396fdfd8cc5dac99a8e7e07106b
>> # Parent  e5b507efb36e2b9ad8edb1a38459d26c934d74dd
>> bookmarks: rename unsetcurrent to deactivate
>>
>> Today, the terms 'active' and 'current' are interchangeably used throughout the
>> codebase in reference to the active bookmark (the bookmark that will be updated
>> with the next commit). This leads to confusion among developers and users.
>> This patch is part of a series to standardize the usage to 'active' throughout
>> the mercurial codebase and user interface.
>>
>> diff --git a/hgext/rebase.py b/hgext/rebase.py
>> --- a/hgext/rebase.py
>> +++ b/hgext/rebase.py
>> @@ -360,7 +360,7 @@ def rebase(ui, repo, **opts):
>>           currentbookmarks = repo._bookmarks.copy()
>>           activebookmark = activebookmark or repo._bookmarkcurrent
>>           if activebookmark:
>> -            bookmarks.unsetcurrent(repo)
>> +            bookmarks.deactivate(repo)
>>
>>           extrafn = _makeextrafn(extrafns)
>>
>> diff --git a/hgext/strip.py b/hgext/strip.py
>> --- a/hgext/strip.py
>> +++ b/hgext/strip.py
>> @@ -61,7 +61,7 @@ def strip(ui, repo, revs, update=True, b
>>           marks = repo._bookmarks
>>           if bookmark:
>>               if bookmark == repo._bookmarkcurrent:
>> -                bookmarks.unsetcurrent(repo)
>> +                bookmarks.deactivate(repo)
>>               del marks[bookmark]
>>               marks.write()
>>               ui.write(_("bookmark '%s' deleted\n") % bookmark)
>> diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
>> --- a/mercurial/bookmarks.py
>> +++ b/mercurial/bookmarks.py
>> @@ -9,7 +9,7 @@ import os
>>   from mercurial.i18n import _
>>   from mercurial.node import hex, bin
>>   from mercurial import encoding, error, util, obsolete, lock as lockmod
>> -import errno
>> +import errno, warnings
>>
>>   class bmstore(dict):
>>       """Storage for bookmarks.
>> @@ -84,7 +84,7 @@ class bmstore(dict):
>>       def _writerepo(self, repo):
>>           """Factored out for extensibility"""
>>           if repo._bookmarkcurrent not in self:
>> -            unsetcurrent(repo)
>> +            deactivate(repo)
>>
>>           wlock = repo.wlock()
>>           try:
>> @@ -152,6 +152,15 @@ def setcurrent(repo, mark):
>>       repo._bookmarkcurrent = mark
>>
>>   def unsetcurrent(repo):
>> +    warnings.warn('deprecated function bookmarks.unsetcurrent() called. ' +
>> +                  'update extension to call bookmarks.deactivate() instead.',
>> +                  category=DeprecationWarning, stacklevel=2)
>
> Please meditate on http://mercurial.selenic.com/wiki/MercurialApi,
> then drop the forwards of these methods.

However, the changeset summary should include (API)

>
>> +    deactivate(repo)
>> +
>> +def deactivate(repo):
>> +    """
>> +    Unset the active bookmark in this reposiotry.
>> +    """
>>       wlock = repo.wlock()
>>       try:
>>           try:
>> diff --git a/mercurial/commands.py b/mercurial/commands.py
>> --- a/mercurial/commands.py
>> +++ b/mercurial/commands.py
>> @@ -980,7 +980,7 @@ def bookmark(ui, repo, *names, **opts):
>>                           raise util.Abort(_("bookmark '%s' does not exist") %
>>                                            mark)
>>                       if mark == repo._bookmarkcurrent:
>> -                        bookmarks.unsetcurrent(repo)
>> +                        bookmarks.deactivate(repo)
>>                       del marks[mark]
>>                   marks.write()
>>
>> @@ -1006,7 +1006,7 @@ def bookmark(ui, repo, *names, **opts):
>>                       if newact is None:
>>                           newact = mark
>>                       if inactive and mark == repo._bookmarkcurrent:
>> -                        bookmarks.unsetcurrent(repo)
>> +                        bookmarks.deactivate(repo)
>>                           return
>>                       tgt = cur
>>                       if rev:
>> @@ -1016,7 +1016,7 @@ def bookmark(ui, repo, *names, **opts):
>>                   if not inactive and cur == marks[newact] and not rev:
>>                       bookmarks.setcurrent(repo, newact)
>>                   elif cur != tgt and newact == repo._bookmarkcurrent:
>> -                    bookmarks.unsetcurrent(repo)
>> +                    bookmarks.deactivate(repo)
>>                   marks.write()
>>
>>               elif inactive:
>> @@ -1025,7 +1025,7 @@ def bookmark(ui, repo, *names, **opts):
>>                   elif not repo._bookmarkcurrent:
>>                       ui.status(_("no active bookmark\n"))
>>                   else:
>> -                    bookmarks.unsetcurrent(repo)
>> +                    bookmarks.deactivate(repo)
>>           finally:
>>               wlock.release()
>>       else: # show bookmarks
>> @@ -6413,7 +6413,7 @@ def update(ui, repo, node=None, rev=None
>>           if repo._bookmarkcurrent:
>>               ui.status(_("(leaving bookmark %s)\n") %
>>                         repo._bookmarkcurrent)
>> -        bookmarks.unsetcurrent(repo)
>> +        bookmarks.deactivate(repo)
>>
>>       return ret
>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list