#!/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/22 $ # # 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 file in files: change = file["change"] movedFile = file["depotFile"] + "#" + file["rev"] for filelog in p4.run_filelog("-1", movedFile): for rev in filelog.revisions: movedFrom = False for integ in rev.integrations: if integ.how == "moved from": movedFrom = True if not p4.run_files(integ.file + "@=" + change): print("changelist " + change + \ ": missing move/delete revision " + \ integ.file + "#" + str(integ.erev + 1) + \ " for move/add revision " + movedFile) if not movedFrom: print("changelist " + change + \ ": missing move/delete revision for move/add revision " \ + movedFile) files = p4.run_files(path + "#move/delete") for file in files: change = file["change"] movedFile = file["depotFile"] + "#" + str(int(file["rev"]) - 1) for filelog in p4.run_filelog("-m1", movedFile): for rev in filelog.revisions: movedInto = False for integ in rev.integrations: if integ.how == "moved into": movedInto = True if not p4.run_files(integ.file + "@=" + change): print("changelist " + change + \ ": missing move/add revision " + \ integ.file + "#" + str(integ.erev) + \ " for move/delete revision " + movedFile) if not movedInto: print("changelist " + change + \ ": missing move/add revision for move/delete revision " \ + movedFile) p4.disconnect() def cmdUsage(): sys.exit('Usage: checkMovePair.py //path/...') if __name__ == '__main__': if len(sys.argv) < 2: cmdUsage() main(sys.argv[1])