summaryrefslogtreecommitdiff
path: root/git-p4.py
diff options
context:
space:
mode:
authorGeorge Vanburgh <gvanburgh@bloomberg.net>2016-12-17 22:11:23 +0000
committerJunio C Hamano <gitster@pobox.com>2016-12-19 10:04:21 -0800
commit9943e5b9799336460ecbbeb86e544cc4a1ad1254 (patch)
tree1c63cead3d3379f57f6a6a6fcb83f712bcb5c88a /git-p4.py
parent0202c411edc25940cc381bf317badcdf67670be4 (diff)
downloadgit-9943e5b9799336460ecbbeb86e544cc4a1ad1254.tar.gz
git-p4: fix multi-path changelist empty commitsgv/p4-multi-path-commit-fix
When importing from multiple perforce paths - we may attempt to import a changelist that contains files from two (or more) of these depot paths. Currently, this results in multiple git commits - one containing the changes, and the other(s) as empty commit(s). This behavior was introduced in commit 1f90a64891 ("git-p4: reduce number of server queries for fetches", 2015-12-19). Reproduction Steps: 1. Have a git repo cloned from a perforce repo using multiple depot paths (e.g. //depot/foo and //depot/bar). 2. Submit a single change to the perforce repo that makes changes in both //depot/foo and //depot/bar. 3. Run "git p4 sync" to sync the change from #2. Change is synced as multiple commits, one for each depot path that was affected. Using a set, instead of a list inside p4ChangesForPaths() ensures that each changelist is unique to the returned list, and therefore only a single commit is generated for each changelist. Reported-by: James Farwell <jfarwell@vmware.com> Signed-off-by: George Vanburgh <gvanburgh@bloomberg.net> Reviewed-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/git-p4.py b/git-p4.py
index b123aa2726..9c5ceed4d1 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -822,7 +822,7 @@ def p4ChangesForPaths(depotPaths, changeRange, requestedBlockSize):
die("cannot use --changes-block-size with non-numeric revisions")
block_size = None
- changes = []
+ changes = set()
# Retrieve changes a block at a time, to prevent running
# into a MaxResults/MaxScanRows error from the server.
@@ -841,7 +841,7 @@ def p4ChangesForPaths(depotPaths, changeRange, requestedBlockSize):
# Insert changes in chronological order
for line in reversed(p4_read_pipe_lines(cmd)):
- changes.append(int(line.split(" ")[1]))
+ changes.add(int(line.split(" ")[1]))
if not block_size:
break