Skip to contentSkip to conversation

git-p4: avoid syncing duplicate changes

PATCH Superseded Pete Wyckoff 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-p4: avoid syncing duplicate changes

When a particular changeset affects multiple depot paths, it will appear multiple times in the output of "p4 changes". Filter out the duplicates to avoid the extra empty commits that this would otherwise create.

---
 contrib/fast-import/git-p4 |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
contrib/fast-import/git-p4 +3 -2
index a85a7b2..63c8eca 100755
@@ -444,8 +444,9 @@ def p4ChangesForPaths(depotPaths, changeRange):
 
     changes = []
     for line in output:
-        changeNum = line.split(" ")[1]
-        changes.append(int(changeNum))
+	changeNum = int(line.split(" ")[1])
+	if changeNum not in changes:
+	    changes.append(changeNum)
 
     changes.sort()
     return changes
Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 15 lines · On Wednesday 28 January 2009 Pete Wyckoff, wrote:

When a particular changeset affects multiple depot paths, it will appear multiple times in the output of "p4 changes". Filter out the duplicates to avoid the extra empty commits that this would otherwise create.

---
 contrib/fast-import/git-p4 |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
contrib/fast-import/git-p4 +0 -0
index a85a7b2..63c8eca 100755

contrib/fast-import/git-p4 def p4ChangesForPaths(depotPaths, changeRange): · line 449

Quoted 8 lines
contrib/fast-import/git-p4 +3 -2
@@ -444,8 +444,9 @@ def p4ChangesForPaths(depotPaths, changeRange):
 
     changes = []
     for line in output:
-        changeNum = line.split(" ")[1]
-        changes.append(int(changeNum))
+	changeNum = int(line.split(" ")[1])
+	if changeNum not in changes:
+	    changes.append(changeNum)

Hmm, isn't this a potentially quadratic operation?

I agree about the problem in general though.

Simon

#2 lore raw

PATCH v2 1/1 git-p4: avoid syncing duplicate changes

When a particular changeset affects multiple depot paths, it will appear multiple times in the output of "p4 changes". Filter out the duplicates to avoid the extra empty commits that this otherwise would create.

---
Switched to a dictionary to avoid the quadratic behavior, as pointed out by Simon.

 contrib/fast-import/git-p4 |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
contrib/fast-import/git-p4 +6 -5
index a85a7b2..3832f60 100755
@@ -442,13 +442,14 @@ def p4ChangesForPaths(depotPaths, changeRange):
     output = p4_read_pipe_lines("changes " + ' '.join (["%s...%s" % (p, changeRange)
                                                         for p in depotPaths]))
 
-    changes = []
+    changes = {}
     for line in output:
-        changeNum = line.split(" ")[1]
-        changes.append(int(changeNum))
+	changeNum = int(line.split(" ")[1])
+	changes[changeNum] = True
 
-    changes.sort()
-    return changes
+    changelist = changes.keys()
+    changelist.sort()
+    return changelist
 
 class Command:
     def __init__(self):
Signature · 1 line
1.6.0.6
Acked-by on v2 1/1
#3 lore raw
Quoted 6 lines · On Wednesday 18 February 2009 Pete Wyckoff, wrote:

When a particular changeset affects multiple depot paths, it will appear multiple times in the output of "p4 changes". Filter out the duplicates to avoid the extra empty commits that this otherwise would create.

Nice patch, thanks :)

Simon

contrib/fast-import/git-p4 def p4ChangesForPaths(depotPaths, changeRange): · line 442

Quoted 12 lines

Switched to a dictionary to avoid the quadratic behavior, as pointed out by Simon.

 contrib/fast-import/git-p4 |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
contrib/fast-import/git-p4 +0 -0
index a85a7b2..3832f60 100755
@@ -442,13 +442,14 @@ def p4ChangesForPaths(depotPaths, changeRange):
     output = p4_read_pipe_lines("changes " + ' '.join (["%s...%s" % (p, 

changeRange)

contrib/fast-import/git-p4 def p4ChangesForPaths(depotPaths, changeRange): · line 443

Quoted 1 line
contrib/fast-import/git-p4 +0 -0
                                                         for p in 

depotPaths]))

Quoted 21 lines
contrib/fast-import/git-p4 +6 -5
-    changes = []
+    changes = {}
     for line in output:
-        changeNum = line.split(" ")[1]
-        changes.append(int(changeNum))
+	changeNum = int(line.split(" ")[1])
+	changes[changeNum] = True
 
-    changes.sort()
-    return changes
+    changelist = changes.keys()
+    changelist.sort()
+    return changelist
 
 class Command:
     def __init__(self):
Signature · 1 line
1.6.0.6