Patchwork D8116: bookmarks: refactor in preparation for next commit

login
register
mail settings
Submitter phabricator
Date Feb. 14, 2020, 4:32 a.m.
Message ID <differential-rev-PHID-DREV-s2kxi4sj6hv6y37oio56-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45225/
State Superseded
Headers show

Comments

phabricator - Feb. 14, 2020, 4:32 a.m.
valentin.gatienbaron created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/bookmarks.py

CHANGE DETAILS




To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 21, 2020, 9:38 a.m.
pulkit added a comment.


  Amended the following in flight to `test-check-format.t` happy:
  
    diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
    --- a/mercurial/bookmarks.py
    +++ b/mercurial/bookmarks.py
    @@ -462,9 +462,11 @@ def update(repo, parents, node):
                 marks.applychanges(repo, tr, bmchanges)
         return bool(bmchanges)
     
    +
     def isdivergent(b):
         return b'@' in b and not b.endswith(b'@')
     
    +
     def listbinbookmarks(repo):
         # We may try to list bookmarks on a repo type that does not
         # support it (e.g., statichttprepository).

REPOSITORY
  rHG Mercurial

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8116/new/

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

To: valentin.gatienbaron, #hg-reviewers, pulkit
Cc: mercurial-devel
phabricator - Feb. 21, 2020, 2:13 p.m.
valentin.gatienbaron added a comment.


  Sorry, I had tried installing black, but it was not the right version. After looking some more, `pip3 install black` is what was needed I think.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8116/new/

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

To: valentin.gatienbaron, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -460,6 +460,8 @@ 
             marks.applychanges(repo, tr, bmchanges)
     return bool(bmchanges)
 
+def isdivergent(b):
+    return b'@' in b and not b.endswith(b'@')
 
 def listbinbookmarks(repo):
     # We may try to list bookmarks on a repo type that does not
@@ -469,7 +471,7 @@ 
     hasnode = repo.changelog.hasnode
     for k, v in pycompat.iteritems(marks):
         # don't expose local divergent bookmarks
-        if hasnode(v) and (b'@' not in k or k.endswith(b'@')):
+        if hasnode(v) and not isdivergent(k):
             yield k, v