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

login
register
mail settings
Submitter via Mercurial-devel
Date June 17, 2017, 5:18 a.m.
Message ID <123eb8b3b913585cc0a2.1497676739@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21449/
State Changes Requested
Headers show

Comments

via Mercurial-devel - June 17, 2017, 5:18 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1497657376 25200
#      Fri Jun 16 16:56:16 2017 -0700
# Node ID 123eb8b3b913585cc0a29c14c232ab6fc78978b3
# Parent  a3a36bcf122e2ea4edbbe4ac44da59446cf0ee07
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().

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1496,8 +1496,12 @@ 
         op.repo.requirements.add('treemanifest')
         op.repo._applyopenerreqs()
         op.repo._writerequirements()
-    ret = cg.apply(op.repo, 'bundle2', 'bundle2', expectedtotal=nbchangesets)
-    op.records.add('changegroup', {'return': ret})
+    ret, addednodes = cg.apply(op.repo, '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.
@@ -1565,8 +1569,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, 'bundle2', 'bundle2')
-    op.records.add('changegroup', {'return': ret})
+    ret, addednodes = cg.apply(op.repo, '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
@@ -430,9 +430,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
@@ -5337,7 +5337,8 @@ 
                           '"hg unbundle"'),
                         hint=_('use "hg debugapplystreamclonebundle"'))
             else:
-                modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
+                modheads, addednodes = gen.apply(repo, 'unbundle',
+                                                 'bundle:' + fname)
 
     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
@@ -1448,7 +1448,8 @@ 
                            "changegroupsubset."))
     else:
         cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull')
-    pullop.cgresult = cg.apply(pullop.repo, 'pull', pullop.remote.url())
+    pullop.cgresult, addednodes = cg.apply(pullop.repo, 'pull',
+                                           pullop.remote.url())
 
 def _pullphase(pullop):
     # Get remote phases data from remote
@@ -1734,7 +1735,7 @@ 
         if not util.safehasattr(cg, 'params'):
             # legacy case: bundle1 (changegroup 01)
             with repo.lock():
-                r = cg.apply(repo, source, url)
+                r, addednodes = cg.apply(repo, source, url)
         else:
             r = None
             try: