-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow partial sync with multiple paths #182
Changes from all commits
da8ec25
1e86681
10e571f
7061a6b
2ae09e0
3f200a0
d8fa0bf
c42522f
cf58885
1f3f891
ab7ac56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,11 +21,15 @@ def __init__(self, root=None, view=None, stream=None, | |
root: Directory in which to create the client workspace | ||
view: Client workspace mapping | ||
stream: Client workspace stream. Overrides view parameter. | ||
sync: List of paths to sync. Defaults to entire view. | ||
client_opts: Additional options to add to client. (e.g. allwrite) | ||
parallel: How many threads to use for parallel sync. | ||
Comment on lines
+24
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Driveby, document undocumented params |
||
""" | ||
self.root = os.path.abspath(root or '') | ||
self.stream = stream | ||
self.view = self._localize_view(view or []) | ||
self.sync_paths = sync or '//...' | ||
self.sync_paths = sync or ['//...'] | ||
assert isinstance(self.sync_paths, list) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will never fail other than when authoring unit tests which pass the wrong type - avoids confusion when making this mistake. Ideally we would add some types to this class instead |
||
self.client_opts = client_opts or '' | ||
self.parallel = parallel | ||
|
||
|
@@ -176,9 +180,10 @@ def sync(self, revision=None): | |
"""Sync the workspace""" | ||
self._setup_client() | ||
self.revert() | ||
sync_files = ['%s%s' % (path, revision or '') for path in self.sync_paths] | ||
result = self.perforce.run_sync( | ||
'--parallel=threads=%s' % self.parallel, | ||
'%s%s' % (self.sync_paths, revision or ''), | ||
*sync_files, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expands list into params, e.g.:
|
||
handler=SyncOutput(self.perforce.logger), | ||
) | ||
if result: | ||
|
@@ -248,14 +253,14 @@ def p4print_unshelve(self, changelist): | |
|
||
# Turn sync spec info a prefix to filter out unwanted files | ||
# e.g. //my-depot/dir/... => //my-depot/dir/ | ||
sync_prefix = self.sync_paths.rstrip('.') | ||
sync_prefixes = [prefix.rstrip('.') for prefix in self.sync_paths] | ||
|
||
cmds = [] | ||
for depotfile, localfile in depot_to_local.items(): | ||
if os.path.isfile(localfile): | ||
os.chmod(localfile, stat.S_IWRITE) | ||
os.unlink(localfile) | ||
if depotfile.startswith(sync_prefix): | ||
if any(depotfile.startswith(prefix) for prefix in sync_prefixes): | ||
cmds.append(('print', '-o', localfile, '%s@=%s' % (depotfile, changelist))) | ||
|
||
self.run_parallel_cmds(cmds) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesnt have any actual functional effect afaik - I think buildkite have some plans to auto-generate docs from this file