Created
May 10, 2017 00:34
-
-
Save JayBazuzi/f5c6d7041db3ffd142262a6f99e9db11 to your computer and use it in GitHub Desktop.
Perforce allows each file in a client to be at a different revision, making it sometimes impossible to ask the question "to which changelist is this client synced?" This script checks if all files are at the same changelist before reporting that CL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
from P4 import P4 | |
p4 = P4() | |
p4.connect() | |
def main(): | |
argparse.ArgumentParser(description="Verify that all files synced to the same changelist, and sets ERRORLEVEL to the count of unsynced files.").parse_args() | |
client = p4.fetch_client()['Client'] | |
change = next(p4.iterate_changes('-m1', "@" + client))["Change"] | |
with p4.at_exception_level(P4.RAISE_ERRORS): | |
unsynced_file_count = len(p4.run_sync('-n', '@' + change)) | |
if (unsynced_file_count): | |
print ("Client {client} is partially synced to CL{change} but some files are out of sync. Run 'p4 sync -n @{change}' to see the full list." | |
.format(client=client, change=change)) | |
else: | |
print ("Client {client} is consistently synced to CL{change}" | |
.format(client=client, change=change)) | |
return unsynced_file_count | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Depends on p4python from https://www.perforce.com/perforce/doc.current/manuals/p4script/03_python.html