Skip to content

Commit

Permalink
Handle add after purge
Browse files Browse the repository at this point in the history
  • Loading branch information
rcowham committed Nov 8, 2024
1 parent 7c7f7b2 commit 48edb6a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion P4Transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,10 @@ def processChangeRevs(self, fileRevs, specialMoveRevs, srcFileLogs):
self.replicateBranch(f, dirty=True)
else:
self.logger.debug('processing:0020 add')
self.p4cmd('add', '-ft', f.type, f.fixedLocalFile)
output = self.p4cmd('add', '-ft', f.type, f.fixedLocalFile)
if len(output) > 0 and self.re_cant_add_existing_file.search(str(output[-1])):
self.p4cmd('sync', '-k', f.fixedLocalFile)
self.p4cmd('edit', '-t', f.type, f.fixedLocalFile)
elif f.action == 'delete':
if f.hasIntegrations() and not f.hasOnlyMovedFromIntegrations():
self.replicateIntegration(f)
Expand Down
32 changes: 32 additions & 0 deletions test/TestP4Transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4982,6 +4982,38 @@ def testTempobjFiletype(self):
self.assertEqual(filelog[0].revisions[0].action, 'integrate')
self.assertEqual(filelog[0].revisions[1].action, 'purge')

def testAddAfterPurge(self):
"""Tests for files added after being purged"""
self.setupTransfer()

inside = localDirectory(self.source.client_root, "inside")
inside_file1 = os.path.join(inside, "inside_file1")

create_file(inside_file1, "Test content")
self.source.p4cmd('add', '-t', 'text', inside_file1)
self.source.p4cmd('submit', '-d', 'files added')

self.source.p4cmd('sync', '@0')
self.source.p4cmd('obliterate', '-yp', inside_file1)

self.source.p4cmd('add', inside_file1)
append_to_file(inside_file1, 'New text')
self.source.p4cmd('submit', '-d', 'version 2')

self.run_P4Transfer()
self.assertCounters(5, 5)

filelog = self.target.p4.run_filelog('//depot/import/inside_file1')
revisions = filelog[0].revisions
self.logger.debug('test:', revisions)
self.assertEqual(len(revisions), 3)
for rev in revisions:
self.logger.debug('test:', rev.rev, rev.action, rev.digest)
self.logger.debug(self.target.p4.run_print('//depot/import/inside_file1#%s' % rev.rev))
filelog = self.target.p4.run_filelog('//depot/import/inside_file4')
self.assertEqual(filelog[0].revisions[0].action, 'integrate')
self.assertEqual(filelog[0].revisions[1].action, 'purge')

def testBranchPerformance(self):
"Branch lots of files and test performance"
self.setupTransfer()
Expand Down

0 comments on commit 48edb6a

Please sign in to comment.