Patchwork [2,of,8,V11] bookmarks: rename `compare()` to `comparebookmarks()` (API)

login
register
mail settings
Submitter Stanislau Hlebik
Date Nov. 22, 2016, 10:17 a.m.
Message ID <20e2f13b7a1083f8d44a.1479809864@devvm957.lla2.facebook.com>
Download mbox | patch
Permalink /patch/17691/
State Superseded
Headers show

Comments

Stanislau Hlebik - Nov. 22, 2016, 10:17 a.m.
# HG changeset patch
# User Stanislau Hlebik <stash@fb.com>
# Date 1479807211 28800
#      Tue Nov 22 01:33:31 2016 -0800
# Node ID 20e2f13b7a1083f8d44a7a9e554eb3d5735b80f2
# Parent  8efced91de4d48478555d91c53e89cd1b4e3b78d
bookmarks: rename `compare()` to `comparebookmarks()` (API)

Next commit will remove optional parameters from `compare()` function.
Let's rename `compare()` to `comparebookmarks()` to avoid ambiguity from
callers from external extensions.
Gregory Szorc - Nov. 30, 2016, 4:35 a.m.
On Tue, Nov 22, 2016 at 2:17 AM, Stanislau Hlebik <stash@fb.com> wrote:

> # HG changeset patch
> # User Stanislau Hlebik <stash@fb.com>
> # Date 1479807211 28800
> #      Tue Nov 22 01:33:31 2016 -0800
> # Node ID 20e2f13b7a1083f8d44a7a9e554eb3d5735b80f2
> # Parent  8efced91de4d48478555d91c53e89cd1b4e3b78d
> bookmarks: rename `compare()` to `comparebookmarks()` (API)
>
> Next commit will remove optional parameters from `compare()` function.
> Let's rename `compare()` to `comparebookmarks()` to avoid ambiguity from
> callers from external extensions.
>

The first 2 in this series LGTM.


>
> diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
> --- a/mercurial/bookmarks.py
> +++ b/mercurial/bookmarks.py
> @@ -391,8 +391,8 @@
>      finally:
>          lockmod.release(tr, l, w)
>
> -def compare(repo, srcmarks, dstmarks,
> -            srchex=None, dsthex=None, targets=None):
> +def comparebookmarks(repo, srcmarks, dstmarks,
> +                     srchex=None, dsthex=None, targets=None):
>      '''Compare bookmarks between srcmarks and dstmarks
>
>      This returns tuple "(addsrc, adddst, advsrc, advdst, diverge,
> @@ -511,7 +511,7 @@
>      ui.debug("checking for updated bookmarks\n")
>      localmarks = repo._bookmarks
>      (addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same
> -     ) = compare(repo, remotemarks, localmarks, dsthex=hex)
> +     ) = comparebookmarks(repo, remotemarks, localmarks, dsthex=hex)
>
>      status = ui.status
>      warn = ui.warn
> @@ -573,8 +573,8 @@
>      '''
>      ui.status(_("searching for changed bookmarks\n"))
>
> -    r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
> -                dsthex=hex)
> +    r = comparebookmarks(repo, other.listkeys('bookmarks'),
> repo._bookmarks,
> +                         dsthex=hex)
>      addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
>
>      incomings = []
> @@ -615,8 +615,8 @@
>      '''
>      ui.status(_("searching for changed bookmarks\n"))
>
> -    r = compare(repo, repo._bookmarks, other.listkeys('bookmarks'),
> -                srchex=hex)
> +    r = comparebookmarks(repo, repo._bookmarks,
> other.listkeys('bookmarks'),
> +                         srchex=hex)
>      addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
>
>      outgoings = []
> @@ -660,8 +660,8 @@
>
>      This returns "(# of incoming, # of outgoing)" tuple.
>      '''
> -    r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
> -                dsthex=hex)
> +    r = comparebookmarks(repo, other.listkeys('bookmarks'),
> repo._bookmarks,
> +                         dsthex=hex)
>      addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
>      return (len(addsrc), len(adddst))
>
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -603,7 +603,8 @@
>      explicit = set([repo._bookmarks.expandname(bookmark)
>                      for bookmark in pushop.bookmarks])
>
> -    comp = bookmod.compare(repo, repo._bookmarks, remotebookmark,
> srchex=hex)
> +    comp = bookmod.comparebookmarks(repo, repo._bookmarks,
> +                                    remotebookmark, srchex=hex)
>      addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp
>      for b, scid, dcid in advsrc:
>          if b in explicit:
>

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -391,8 +391,8 @@ 
     finally:
         lockmod.release(tr, l, w)
 
-def compare(repo, srcmarks, dstmarks,
-            srchex=None, dsthex=None, targets=None):
+def comparebookmarks(repo, srcmarks, dstmarks,
+                     srchex=None, dsthex=None, targets=None):
     '''Compare bookmarks between srcmarks and dstmarks
 
     This returns tuple "(addsrc, adddst, advsrc, advdst, diverge,
@@ -511,7 +511,7 @@ 
     ui.debug("checking for updated bookmarks\n")
     localmarks = repo._bookmarks
     (addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same
-     ) = compare(repo, remotemarks, localmarks, dsthex=hex)
+     ) = comparebookmarks(repo, remotemarks, localmarks, dsthex=hex)
 
     status = ui.status
     warn = ui.warn
@@ -573,8 +573,8 @@ 
     '''
     ui.status(_("searching for changed bookmarks\n"))
 
-    r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
-                dsthex=hex)
+    r = comparebookmarks(repo, other.listkeys('bookmarks'), repo._bookmarks,
+                         dsthex=hex)
     addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
 
     incomings = []
@@ -615,8 +615,8 @@ 
     '''
     ui.status(_("searching for changed bookmarks\n"))
 
-    r = compare(repo, repo._bookmarks, other.listkeys('bookmarks'),
-                srchex=hex)
+    r = comparebookmarks(repo, repo._bookmarks, other.listkeys('bookmarks'),
+                         srchex=hex)
     addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
 
     outgoings = []
@@ -660,8 +660,8 @@ 
 
     This returns "(# of incoming, # of outgoing)" tuple.
     '''
-    r = compare(repo, other.listkeys('bookmarks'), repo._bookmarks,
-                dsthex=hex)
+    r = comparebookmarks(repo, other.listkeys('bookmarks'), repo._bookmarks,
+                         dsthex=hex)
     addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = r
     return (len(addsrc), len(adddst))
 
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -603,7 +603,8 @@ 
     explicit = set([repo._bookmarks.expandname(bookmark)
                     for bookmark in pushop.bookmarks])
 
-    comp = bookmod.compare(repo, repo._bookmarks, remotebookmark, srchex=hex)
+    comp = bookmod.comparebookmarks(repo, repo._bookmarks,
+                                    remotebookmark, srchex=hex)
     addsrc, adddst, advsrc, advdst, diverge, differ, invalid, same = comp
     for b, scid, dcid in advsrc:
         if b in explicit: