Patchwork D6435: narrow: factor out logic to build ellipses related b2parts in separate fn

login
register
mail settings
Submitter phabricator
Date May 22, 2019, 9:47 p.m.
Message ID <differential-rev-PHID-DREV-lpuvjka3e2myyshxacae-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/40197/
State Superseded
Headers show

Comments

phabricator - May 22, 2019, 9:47 p.m.
pulkit created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This will help us switch more cleanly to using wireprotocol commands instead of
  using exchange.pull() which exchanges more things then required.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/narrow/narrowbundle2.py

CHANGE DETAILS




To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - May 23, 2019, 4:42 p.m.
martinvonz added inline comments.

INLINE COMMENTS

> narrowbundle2.py:69
> +def generateellipsesbundle2(bundler, repo, oldinclude, oldexclude, newinclude,
> +                            newexclude, version, common, known, depth, heads):
> +    newmatch = narrowspec.match(repo.root, include=newinclude,

nit: `common` and `heads` are a closely related, so I'd put `heads` right after `common` here

> narrowbundle2.py:79
>      common = set(common or [nullid])
> -    oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', [])))
> -    oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
> -    known = {bin(n) for n in kwargs.get(r'known', [])}
> -    if known and (oldinclude != include or oldexclude != exclude):
> +    known = {bin(n) for n in known}
> +    if known and (oldinclude != newinclude or oldexclude != newexclude):

nit: we generally work with binary nodeids, so I'd expect this new function to get the nodeids in binary form already

REPOSITORY
  rHG Mercurial

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

To: pulkit, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/narrow/narrowbundle2.py b/hgext/narrow/narrowbundle2.py
--- a/hgext/narrow/narrowbundle2.py
+++ b/hgext/narrow/narrowbundle2.py
@@ -57,22 +57,27 @@ 
         raise ValueError(_('no common changegroup version'))
     version = max(cgversions)
 
-    include = sorted(filter(bool, kwargs.get(r'includepats', [])))
-    exclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
-    newmatch = narrowspec.match(repo.root, include=include, exclude=exclude)
+    oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', [])))
+    oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
+    newinclude = sorted(filter(bool, kwargs.get(r'includepats', [])))
+    newexclude = sorted(filter(bool, kwargs.get(r'excludepats', [])))
+    generateellipsesbundle2(bundler, repo, oldinclude, oldexclude, newinclude,
+            newexclude, version, common, kwargs.get('known', []),
+            kwargs.get(r'depth', None), heads)
 
-    depth = kwargs.get(r'depth', None)
+def generateellipsesbundle2(bundler, repo, oldinclude, oldexclude, newinclude,
+                            newexclude, version, common, known, depth, heads):
+    newmatch = narrowspec.match(repo.root, include=newinclude,
+                                exclude=newexclude)
     if depth is not None:
         depth = int(depth)
         if depth < 1:
             raise error.Abort(_('depth must be positive, got %d') % depth)
 
     heads = set(heads or repo.heads())
     common = set(common or [nullid])
-    oldinclude = sorted(filter(bool, kwargs.get(r'oldincludepats', [])))
-    oldexclude = sorted(filter(bool, kwargs.get(r'oldexcludepats', [])))
-    known = {bin(n) for n in kwargs.get(r'known', [])}
-    if known and (oldinclude != include or oldexclude != exclude):
+    known = {bin(n) for n in known}
+    if known and (oldinclude != newinclude or oldexclude != newexclude):
         # Steps:
         # 1. Send kill for "$known & ::common"
         #