Patchwork [1,of,3,v2] bundle2: record changegroup data in 'op.records' (API)

login
register
mail settings
Submitter via Mercurial-devel
Date June 20, 2017, 5 p.m.
Message ID <0f77eccc602140bd4f80.1497978008@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21541/
State Accepted
Headers show

Comments

via Mercurial-devel - June 20, 2017, 5 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1497657376 25200
#      Fri Jun 16 16:56:16 2017 -0700
# Node ID 0f77eccc602140bd4f8066a196b8ae53c0f50ef9
# Parent  750c3b1bb8a32d462011449c7d983438ef756765
bundle2: record changegroup data in 'op.records' (API)

When adding support for bundling and unbundling phases, it will be
useful to have the list of added changesets. To do that, we return the
list from changegroup.apply().
Yuya Nishihara - June 22, 2017, 2:46 p.m.
On Tue, 20 Jun 2017 10:00:08 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1497657376 25200
> #      Fri Jun 16 16:56:16 2017 -0700
> # Node ID 0f77eccc602140bd4f8066a196b8ae53c0f50ef9
> # Parent  750c3b1bb8a32d462011449c7d983438ef756765
> bundle2: record changegroup data in 'op.records' (API)

I don't have expertise, but the series generally looks good.
Queued, thanks.
Pierre-Yves David - June 22, 2017, 3:26 p.m.
On 06/22/2017 04:46 PM, Yuya Nishihara wrote:
> On Tue, 20 Jun 2017 10:00:08 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
>> # HG changeset patch
>> # User Martin von Zweigbergk <martinvonz@google.com>
>> # Date 1497657376 25200
>> #      Fri Jun 16 16:56:16 2017 -0700
>> # Node ID 0f77eccc602140bd4f8066a196b8ae53c0f50ef9
>> # Parent  750c3b1bb8a32d462011449c7d983438ef756765
>> bundle2: record changegroup data in 'op.records' (API)
> 
> I don't have expertise, but the series generally looks good.
> Queued, thanks.

I think I've found a serious bug but got interrupted before finishing 
the report email. Can you drop it from hg-commited for now ?

(sorry for the delay)

Cheers,
via Mercurial-devel - June 22, 2017, 3:40 p.m.
In what scenario would you see the bug? Can you at least give us a rough
idea? Clearly not something covered by our tests.

On Jun 22, 2017 08:26, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org>
wrote:

>
>
> On 06/22/2017 04:46 PM, Yuya Nishihara wrote:
>
>> On Tue, 20 Jun 2017 10:00:08 -0700, Martin von Zweigbergk via
>> Mercurial-devel wrote:
>>
>>> # HG changeset patch
>>> # User Martin von Zweigbergk <martinvonz@google.com>
>>> # Date 1497657376 25200
>>> #      Fri Jun 16 16:56:16 2017 -0700
>>> # Node ID 0f77eccc602140bd4f8066a196b8ae53c0f50ef9
>>> # Parent  750c3b1bb8a32d462011449c7d983438ef756765
>>> bundle2: record changegroup data in 'op.records' (API)
>>>
>>
>> I don't have expertise, but the series generally looks good.
>> Queued, thanks.
>>
>
> I think I've found a serious bug but got interrupted before finishing the
> report email. Can you drop it from hg-commited for now ?
>
> (sorry for the delay)
>
> Cheers,
>
> --
> Pierre-Yves David
>
Pierre-Yves David - June 22, 2017, 3:54 p.m.
On 06/22/2017 05:40 PM, Martin von Zweigbergk wrote:
> In what scenario would you see the bug? Can you at least give us a rough 
> idea? Clearly not something covered by our tests.

See my reply to patch 2 (that I was finally able to send).

> 
> On Jun 22, 2017 08:26, "Pierre-Yves David" 
> <pierre-yves.david@ens-lyon.org <mailto:pierre-yves.david@ens-lyon.org>> 
> wrote:
> 
> 
> 
>     On 06/22/2017 04:46 PM, Yuya Nishihara wrote:
> 
>         On Tue, 20 Jun 2017 10:00:08 -0700, Martin von Zweigbergk via
>         Mercurial-devel wrote:
> 
>             # HG changeset patch
>             # User Martin von Zweigbergk <martinvonz@google.com
>             <mailto:martinvonz@google.com>>
>             # Date 1497657376 25200
>             #      Fri Jun 16 16:56:16 2017 -0700
>             # Node ID 0f77eccc602140bd4f8066a196b8ae53c0f50ef9
>             # Parent  750c3b1bb8a32d462011449c7d983438ef756765
>             bundle2: record changegroup data in 'op.records' (API)
> 
> 
>         I don't have expertise, but the series generally looks good.
>         Queued, thanks.
> 
> 
>     I think I've found a serious bug but got interrupted before
>     finishing the report email. Can you drop it from hg-commited for now ?
> 
>     (sorry for the delay)
> 
>     Cheers,
> 
>     -- 
>     Pierre-Yves David
>

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1492,9 +1492,12 @@ 
         op.repo.requirements.add('treemanifest')
         op.repo._applyopenerreqs()
         op.repo._writerequirements()
-    ret = cg.apply(op.repo, tr, 'bundle2', 'bundle2',
-                   expectedtotal=nbchangesets)
-    op.records.add('changegroup', {'return': ret})
+    ret, addednodes = cg.apply(op.repo, tr, 'bundle2', 'bundle2',
+                               expectedtotal=nbchangesets)
+    op.records.add('changegroup', {
+        'return': ret,
+        'addednodes': addednodes,
+    })
     if op.reply is not None:
         # This is definitely not the final form of this
         # return. But one need to start somewhere.
@@ -1557,8 +1560,11 @@ 
     if not isinstance(cg, changegroup.cg1unpacker):
         raise error.Abort(_('%s: not a bundle version 1.0') %
             util.hidepassword(raw_url))
-    ret = cg.apply(op.repo, tr, 'bundle2', 'bundle2')
-    op.records.add('changegroup', {'return': ret})
+    ret, addednodes = cg.apply(op.repo, tr, 'bundle2', 'bundle2')
+    op.records.add('changegroup', {
+        'return': ret,
+        'addednodes': addednodes,
+    })
     if op.reply is not None:
         # This is definitely not the final form of this
         # return. But one need to start somewhere.
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -426,9 +426,10 @@ 
             repo.ui.flush()
         # never return 0 here:
         if deltaheads < 0:
-            return deltaheads - 1
+            ret = deltaheads - 1
         else:
-            return deltaheads + 1
+            ret = deltaheads + 1
+        return ret, added
 
 class cg2unpacker(cg1unpacker):
     """Unpacker for cg2 streams.
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5340,7 +5340,7 @@ 
             else:
                 txnname = 'unbundle\n%s' % util.hidepassword(url)
                 with repo.transaction(txnname) as tr:
-                    modheads = gen.apply(repo, tr, 'unbundle', url)
+                    modheads, addednodes = gen.apply(repo, tr, 'unbundle', url)
 
     return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
 
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1449,7 +1449,8 @@ 
                            "changegroupsubset."))
     else:
         cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull')
-    pullop.cgresult = cg.apply(pullop.repo, tr, 'pull', pullop.remote.url())
+    pullop.cgresult, addednodes = cg.apply(pullop.repo, tr, 'pull',
+                                           pullop.remote.url())
 
 def _pullphase(pullop):
     # Get remote phases data from remote
@@ -1736,7 +1737,7 @@ 
             # legacy case: bundle1 (changegroup 01)
             txnname = "\n".join([source, util.hidepassword(url)])
             with repo.lock(), repo.transaction(txnname) as tr:
-                r = cg.apply(repo, tr, source, url)
+                r, addednodes = cg.apply(repo, tr, source, url)
         else:
             r = None
             try: