1311 A new should be created at the beginning of each pull and discarded |
1311 A new should be created at the beginning of each pull and discarded |
1312 afterward. |
1312 afterward. |
1313 """ |
1313 """ |
1314 |
1314 |
1315 def __init__(self, repo, remote, heads=None, force=False, bookmarks=(), |
1315 def __init__(self, repo, remote, heads=None, force=False, bookmarks=(), |
1316 remotebookmarks=None, streamclonerequested=None): |
1316 remotebookmarks=None, streamclonerequested=None, |
|
1317 includepats=None, excludepats=None): |
1317 # repo we pull into |
1318 # repo we pull into |
1318 self.repo = repo |
1319 self.repo = repo |
1319 # repo we pull from |
1320 # repo we pull from |
1320 self.remote = remote |
1321 self.remote = remote |
1321 # revision we try to pull (None is "all") |
1322 # revision we try to pull (None is "all") |
1341 self.cgresult = None |
1342 self.cgresult = None |
1342 # list of step already done |
1343 # list of step already done |
1343 self.stepsdone = set() |
1344 self.stepsdone = set() |
1344 # Whether we attempted a clone from pre-generated bundles. |
1345 # Whether we attempted a clone from pre-generated bundles. |
1345 self.clonebundleattempted = False |
1346 self.clonebundleattempted = False |
|
1347 # Set of file patterns to include. |
|
1348 self.includepats = includepats |
|
1349 # Set of file patterns to exclude. |
|
1350 self.excludepats = excludepats |
1346 |
1351 |
1347 @util.propertycache |
1352 @util.propertycache |
1348 def pulledsubset(self): |
1353 def pulledsubset(self): |
1349 """heads of the set of changeset target by the pull""" |
1354 """heads of the set of changeset target by the pull""" |
1350 # compute target subset |
1355 # compute target subset |
1445 new_heads = headsofdiff(unficl.heads(), old_heads) |
1450 new_heads = headsofdiff(unficl.heads(), old_heads) |
1446 pullop.common = headsofunion(new_heads, pullop.common) |
1451 pullop.common = headsofunion(new_heads, pullop.common) |
1447 pullop.rheads = set(pullop.rheads) - pullop.common |
1452 pullop.rheads = set(pullop.rheads) - pullop.common |
1448 |
1453 |
1449 def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None, |
1454 def pull(repo, remote, heads=None, force=False, bookmarks=(), opargs=None, |
1450 streamclonerequested=None): |
1455 streamclonerequested=None, includepats=None, excludepats=None): |
1451 """Fetch repository data from a remote. |
1456 """Fetch repository data from a remote. |
1452 |
1457 |
1453 This is the main function used to retrieve data from a remote repository. |
1458 This is the main function used to retrieve data from a remote repository. |
1454 |
1459 |
1455 ``repo`` is the local repository to clone into. |
1460 ``repo`` is the local repository to clone into. |
1463 ``streamclonerequested`` is a boolean indicating whether a "streaming |
1468 ``streamclonerequested`` is a boolean indicating whether a "streaming |
1464 clone" is requested. A "streaming clone" is essentially a raw file copy |
1469 clone" is requested. A "streaming clone" is essentially a raw file copy |
1465 of revlogs from the server. This only works when the local repository is |
1470 of revlogs from the server. This only works when the local repository is |
1466 empty. The default value of ``None`` means to respect the server |
1471 empty. The default value of ``None`` means to respect the server |
1467 configuration for preferring stream clones. |
1472 configuration for preferring stream clones. |
|
1473 ``includepats`` and ``excludepats`` define explicit file patterns to |
|
1474 include and exclude in storage, respectively. If not defined, narrow |
|
1475 patterns from the repo instance are used, if available. |
1468 |
1476 |
1469 Returns the ``pulloperation`` created for this pull. |
1477 Returns the ``pulloperation`` created for this pull. |
1470 """ |
1478 """ |
1471 if opargs is None: |
1479 if opargs is None: |
1472 opargs = {} |
1480 opargs = {} |
|
1481 |
|
1482 # We allow the narrow patterns to be passed in explicitly to provide more |
|
1483 # flexibility for API consumers. |
|
1484 if includepats or excludepats: |
|
1485 includepats = includepats or set() |
|
1486 excludepats = excludepats or set() |
|
1487 else: |
|
1488 includepats, excludepats = repo.narrowpats |
|
1489 |
|
1490 narrowspec.validatepatterns(includepats) |
|
1491 narrowspec.validatepatterns(excludepats) |
|
1492 |
1473 pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks, |
1493 pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks, |
1474 streamclonerequested=streamclonerequested, |
1494 streamclonerequested=streamclonerequested, |
|
1495 includepats=includepats, excludepats=excludepats, |
1475 **pycompat.strkwargs(opargs)) |
1496 **pycompat.strkwargs(opargs)) |
1476 |
1497 |
1477 peerlocal = pullop.remote.local() |
1498 peerlocal = pullop.remote.local() |
1478 if peerlocal: |
1499 if peerlocal: |
1479 missing = set(peerlocal.requirements) - pullop.repo.supported |
1500 missing = set(peerlocal.requirements) - pullop.repo.supported |