Patchwork [1,of,5] pushbookmark: split an ultra long line in a saner version

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 18, 2014, 11:47 p.m.
Message ID <6076552e3523a34b047d.1408405679@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5486/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 18, 2014, 11:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1408150974 25200
#      Fri Aug 15 18:02:54 2014 -0700
# Node ID 6076552e3523a34b047dba890b8ff35141175a7c
# Parent  66e2897ab70fa5a2d7ff58aa8c93419294045244
pushbookmark: split an ultra long line in a saner version

We make a temporary variable for the remote bookmark data and we do not expend
all elements from `bookmark.compare` since we are going to use only one.
Siddharth Agarwal - Aug. 18, 2014, 11:49 p.m.
On 08/18/2014 04:47 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1408150974 25200
> #      Fri Aug 15 18:02:54 2014 -0700
> # Node ID 6076552e3523a34b047dba890b8ff35141175a7c
> # Parent  66e2897ab70fa5a2d7ff58aa8c93419294045244
> pushbookmark: split an ultra long line in a saner version
>
> We make a temporary variable for the remote bookmark data and we do not expend
> all elements from `bookmark.compare` since we are going to use only one.
>
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -621,14 +621,13 @@ def _pushbookmark(pushop):
>       ui.debug("checking for updated bookmarks\n")
>       ancestors = ()
>       if pushop.revs:
>           revnums = map(repo.changelog.rev, pushop.revs)
>           ancestors = repo.changelog.ancestors(revnums, inclusive=True)
> -    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
> -     ) = bookmarks.compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
> -                           srchex=hex)
> -
> +    remotebookmark = remote.listkeys('bookmarks')
> +    comp = bookmarks.compare(repo, repo._bookmarks, remotebookmark, srchex=hex)
> +    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid) = comp

You can now drop the parentheses.

>       for b, scid, dcid in advsrc:
>           if ancestors and repo[scid].rev() not in ancestors:
>               continue
>           if remote.pushkey('bookmarks', b, dcid, scid):
>               ui.status(_("updating bookmark %s\n") % b)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Pierre-Yves David - Aug. 18, 2014, 11:56 p.m.
On 08/18/2014 04:49 PM, Siddharth Agarwal wrote:
> On 08/18/2014 04:47 PM, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1408150974 25200
>> #      Fri Aug 15 18:02:54 2014 -0700
>> # Node ID 6076552e3523a34b047dba890b8ff35141175a7c
>> # Parent  66e2897ab70fa5a2d7ff58aa8c93419294045244
>> pushbookmark: split an ultra long line in a saner version
>>
>> We make a temporary variable for the remote bookmark data and we do
>> not expend
>> all elements from `bookmark.compare` since we are going to use only one.
>>
>> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
>> --- a/mercurial/exchange.py
>> +++ b/mercurial/exchange.py
>> @@ -621,14 +621,13 @@ def _pushbookmark(pushop):
>>       ui.debug("checking for updated bookmarks\n")
>>       ancestors = ()
>>       if pushop.revs:
>>           revnums = map(repo.changelog.rev, pushop.revs)
>>           ancestors = repo.changelog.ancestors(revnums, inclusive=True)
>> -    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
>> -     ) = bookmarks.compare(repo, repo._bookmarks,
>> remote.listkeys('bookmarks'),
>> -                           srchex=hex)
>> -
>> +    remotebookmark = remote.listkeys('bookmarks')
>> +    comp = bookmarks.compare(repo, repo._bookmarks, remotebookmark,
>> srchex=hex)
>> +    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid) = comp
>
> You can now drop the parentheses.

gah. a version without parent can be pulled using

hg pull --rev 61f4e0d4c854 http://42.netv6.net/marmoute-wip/mercurial/

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -621,14 +621,13 @@  def _pushbookmark(pushop):
     ui.debug("checking for updated bookmarks\n")
     ancestors = ()
     if pushop.revs:
         revnums = map(repo.changelog.rev, pushop.revs)
         ancestors = repo.changelog.ancestors(revnums, inclusive=True)
-    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid
-     ) = bookmarks.compare(repo, repo._bookmarks, remote.listkeys('bookmarks'),
-                           srchex=hex)
-
+    remotebookmark = remote.listkeys('bookmarks')
+    comp = bookmarks.compare(repo, repo._bookmarks, remotebookmark, srchex=hex)
+    (addsrc, adddst, advsrc, advdst, diverge, differ, invalid) = comp
     for b, scid, dcid in advsrc:
         if ancestors and repo[scid].rev() not in ancestors:
             continue
         if remote.pushkey('bookmarks', b, dcid, scid):
             ui.status(_("updating bookmark %s\n") % b)