Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayBazuzi/f5c6d7041db3ffd142262a6f99e9db11 to your computer and use it in GitHub Desktop.
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.
#!/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())
@JayBazuzi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment