#!/usr/bin/env python3 ################################################################################ # # Copyright (c) 2018, Perforce Software, Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # DATE # # $Date: 2018/05/21 $ # # SYNOPSIS # # CheckMovePair.py //path/... # # DESCRIPTION # # Report move/delete revision without move/add revision and vice versa # ################################################################################ from __future__ import print_function from P4 import P4, P4Exception import sys def main(path): p4 = P4() p4.exception_level = 0 p4.connect() files = p4.run_files(path + "#move/add") for moveFile in files: change = moveFile["change"] for file in p4.run_filelog("-1", moveFile["depotFile"] + "#=" + moveFile["rev"]): for rev in file.revisions: for integ in rev.integrations: if integ.how == "moved from" and \ not p4.run_files(integ.file + "@=" + change): print("Error: missing move/delete revision for " + \ integ.file + " (change=" + change + ": move from " + \ integ.file + "#" + str(integ.erev) + " into " + \ moveFile["depotFile"] + "#" + moveFile["rev"] + ")") files = p4.run_files(path + "#move/delete") for moveFile in files: change = moveFile["change"] for file in p4.run_filelog(moveFile["depotFile"] + "#=" + str(int(moveFile["rev"]) - 1)): for rev in file.revisions: for integ in rev.integrations: if integ.how == "moved from" and \ not p4.run_files(integ.file + "@=" + change): print("Error: missing move/add revision for " + \ integ.file + " (change=" + change + ": move from " + \ moveFile["depotFile"] + "#" + moveFile["rev"] + " into " + \ integ.file + "#" + str(integ.erev) + ")") p4.disconnect() def cmdUsage(): sys.exit('Usage: checkMovePair.py //path/...') if __name__ == '__main__': if len(sys.argv) < 2: cmdUsage() main(sys.argv[1])