diff options
author | Simon Hausmann <simon@lst.de> | 2008-03-03 11:55:48 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-03-03 21:53:51 -0800 |
commit | 30b5940bcd3ed7392795f6a27563013f6f806de4 (patch) | |
tree | 28a33c4d455cfa595ed320c019275e26a5058044 /contrib | |
parent | a798b2c0f60ed7ae9161a4c4affb6127ff3b2575 (diff) | |
download | git-30b5940bcd3ed7392795f6a27563013f6f806de4.tar.gz git-30b5940bcd3ed7392795f6a27563013f6f806de4.tar.xz |
git-p4: Fix import of changesets with file deletions
Commit 3a70cdfa42199e16d2d047c286431c4274d65b1a made readP4Files abort quickly
when the changeset only contains files that are marked for deletion with an empty return
value, which caused the commit to not do anything.
This commit changes readP4Files to distinguish between files that need to be passed to p4
print and files that have no content ("deleted") and merge them in the returned
list.
Signed-off-by: Simon Hausmann <simon@lst.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/fast-import/git-p4 | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4 index be9660075..650ea3417 100755 --- a/contrib/fast-import/git-p4 +++ b/contrib/fast-import/git-p4 @@ -850,29 +850,32 @@ class P4Sync(Command): ## Should move this out, doesn't use SELF. def readP4Files(self, files): + filesForCommit = [] + filesToRead = [] + for f in files: + includeFile = True for val in self.clientSpecDirs: if f['path'].startswith(val[0]): - if val[1] > 0: - f['include'] = True - else: - f['include'] = False + if val[1] <= 0: + includeFile = False break - files = [f for f in files - if f['action'] != 'delete' and - (f.has_key('include') == False or f['include'] == True)] + if includeFile: + filesForCommit.append(f) + if f['action'] != 'delete': + filesToRead.append(f) - if not files: - return [] + filedata = [] + if len(filesToRead) > 0: + filedata = p4CmdList('-x - print', + stdin='\n'.join(['%s#%s' % (f['path'], f['rev']) + for f in filesToRead]), + stdin_mode='w+') - filedata = p4CmdList('-x - print', - stdin='\n'.join(['%s#%s' % (f['path'], f['rev']) - for f in files]), - stdin_mode='w+') - if "p4ExitCode" in filedata[0]: - die("Problems executing p4. Error: [%d]." - % (filedata[0]['p4ExitCode'])); + if "p4ExitCode" in filedata[0]: + die("Problems executing p4. Error: [%d]." + % (filedata[0]['p4ExitCode'])); j = 0; contents = {} @@ -896,10 +899,12 @@ class P4Sync(Command): contents[stat['depotFile']] = text - for f in files: - assert not f.has_key('data') - f['data'] = contents[f['path']] - return files + for f in filesForCommit: + path = f['path'] + if contents.has_key(path): + f['data'] = contents[path] + + return filesForCommit def commit(self, details, files, branch, branchPrefixes, parent = ""): epoch = details["time"] |