D4539: exchange: support defining narrow file patterns for pull

2018-09-12 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG130e5df346d5: exchange: support defining narrow file 
patterns for pull (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4539?vs=10916=10929

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

AFFECTED FILES
  mercurial/exchange.py
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -749,7 +749,9 @@
 overrides = {('ui', 'quietbookmarkmove'): True}
 with local.ui.configoverride(overrides, 'clone'):
 exchange.pull(local, srcpeer, revs,
-  streamclonerequested=stream)
+  streamclonerequested=stream,
+  includepats=storeincludepats,
+  excludepats=storeexcludepats)
 elif srcrepo:
 # TODO lift restriction once exchange.push() accepts narrow
 # push.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1313,7 +1313,8 @@
 """
 
 def __init__(self, repo, remote, heads=None, force=False, bookmarks=(),
- remotebookmarks=None, streamclonerequested=None):
+ remotebookmarks=None, streamclonerequested=None,
+ includepats=None, excludepats=None):
 # repo we pull into
 self.repo = repo
 # repo we pull from
@@ -1343,6 +1344,10 @@
 self.stepsdone = set()
 # Whether we attempted a clone from pre-generated bundles.
 self.clonebundleattempted = False
+# Set of file patterns to include.
+self.includepats = includepats
+# Set of file patterns to exclude.
+self.excludepats = excludepats
 
 @util.propertycache
 def pulledsubset(self):
@@ -1447,7 +1452,7 @@
 pullop.rheads = set(pullop.rheads) - pullop.common
 
 def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None,
- streamclonerequested=None):
+ streamclonerequested=None, includepats=None, excludepats=None):
 """Fetch repository data from a remote.
 
 This is the main function used to retrieve data from a remote repository.
@@ -1465,13 +1470,29 @@
 of revlogs from the server. This only works when the local repository is
 empty. The default value of ``None`` means to respect the server
 configuration for preferring stream clones.
+``includepats`` and ``excludepats`` define explicit file patterns to
+include and exclude in storage, respectively. If not defined, narrow
+patterns from the repo instance are used, if available.
 
 Returns the ``pulloperation`` created for this pull.
 """
 if opargs is None:
 opargs = {}
+
+# We allow the narrow patterns to be passed in explicitly to provide more
+# flexibility for API consumers.
+if includepats or excludepats:
+includepats = includepats or set()
+excludepats = excludepats or set()
+else:
+includepats, excludepats = repo.narrowpats
+
+narrowspec.validatepatterns(includepats)
+narrowspec.validatepatterns(excludepats)
+
 pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks,
streamclonerequested=streamclonerequested,
+   includepats=includepats, excludepats=excludepats,
**pycompat.strkwargs(opargs))
 
 peerlocal = pullop.remote.local()



To: indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4539: exchange: support defining narrow file patterns for pull

2018-09-11 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This commit teaches exchange.pull() about the desire to perform a
  narrow file pull. We simply pass include and exclude patterns to
  the function. The values are validated and stored on the pulloperation
  instance.
  
  hg.clone() has been taught to pass these arguments to exchange.pull().
  
  If the arguments are not passed to exchange.pull(), the active narrow
  patterns from the repository will automatically be used. We /could/
  always use the narrow patterns from the repo. However, allowing
  explicit values to be passed in allows us to perform data fetching
  that doesn't necessarily align with the repo configuration. This
  provides more flexibility.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/exchange.py
  mercurial/hg.py

CHANGE DETAILS

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -749,7 +749,9 @@
 overrides = {('ui', 'quietbookmarkmove'): True}
 with local.ui.configoverride(overrides, 'clone'):
 exchange.pull(local, srcpeer, revs,
-  streamclonerequested=stream)
+  streamclonerequested=stream,
+  includepats=storeincludepats,
+  excludepats=storeexcludepats)
 elif srcrepo:
 # TODO lift restriction once exchange.push() accepts narrow
 # push.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1313,7 +1313,8 @@
 """
 
 def __init__(self, repo, remote, heads=None, force=False, bookmarks=(),
- remotebookmarks=None, streamclonerequested=None):
+ remotebookmarks=None, streamclonerequested=None,
+ includepats=None, excludepats=None):
 # repo we pull into
 self.repo = repo
 # repo we pull from
@@ -1343,6 +1344,10 @@
 self.stepsdone = set()
 # Whether we attempted a clone from pre-generated bundles.
 self.clonebundleattempted = False
+# Set of file patterns to include.
+self.includepats = includepats
+# Set of file patterns to exclude.
+self.excludepats = excludepats
 
 @util.propertycache
 def pulledsubset(self):
@@ -1447,7 +1452,7 @@
 pullop.rheads = set(pullop.rheads) - pullop.common
 
 def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None,
- streamclonerequested=None):
+ streamclonerequested=None, includepats=None, excludepats=None):
 """Fetch repository data from a remote.
 
 This is the main function used to retrieve data from a remote repository.
@@ -1465,13 +1470,29 @@
 of revlogs from the server. This only works when the local repository is
 empty. The default value of ``None`` means to respect the server
 configuration for preferring stream clones.
+``includepats`` and ``excludepats`` define explicit file patterns to
+include and exclude in storage, respectively. If not defined, narrow
+patterns from the repo instance are used, if available.
 
 Returns the ``pulloperation`` created for this pull.
 """
 if opargs is None:
 opargs = {}
+
+# We allow the narrow patterns to be passed in explicitly to provide more
+# flexibility for API consumers.
+if includepats or excludepats:
+includepats = includepats or set()
+excludepats = excludepats or set()
+else:
+includepats, excludepats = repo.narrowpats
+
+narrowspec.validatepatterns(includepats)
+narrowspec.validatepatterns(excludepats)
+
 pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks,
streamclonerequested=streamclonerequested,
+   includepats=includepats, excludepats=excludepats,
**pycompat.strkwargs(opargs))
 
 peerlocal = pullop.remote.local()



To: indygreg, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel