git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-p4: avoid syncing duplicate changes
@ 2009-01-28 16:45 Pete Wyckoff
  2009-02-05 15:24 ` Simon Hausmann
  0 siblings, 1 reply; 4+ messages in thread
From: Pete Wyckoff @ 2009-01-28 16:45 UTC (permalink / raw)
  To: git

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.

Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 contrib/fast-import/git-p4 |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index a85a7b2..63c8eca 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -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
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] git-p4: avoid syncing duplicate changes
  2009-01-28 16:45 [PATCH] git-p4: avoid syncing duplicate changes Pete Wyckoff
@ 2009-02-05 15:24 ` Simon Hausmann
  2009-02-18 18:12   ` [PATCH v2] " Pete Wyckoff
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Hausmann @ 2009-02-05 15:24 UTC (permalink / raw)
  To: Pete Wyckoff; +Cc: git

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.
> 
> Signed-off-by: Pete Wyckoff <pw@padd.com>
> ---
>  contrib/fast-import/git-p4 |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index a85a7b2..63c8eca 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] git-p4: avoid syncing duplicate changes
  2009-02-05 15:24 ` Simon Hausmann
@ 2009-02-18 18:12   ` Pete Wyckoff
  2009-02-23 17:08     ` Simon Hausmann
  0 siblings, 1 reply; 4+ messages in thread
From: Pete Wyckoff @ 2009-02-18 18:12 UTC (permalink / raw)
  To: Simon Hausmann; +Cc: git

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.

Signed-off-by: Pete Wyckoff <pw@padd.com>
---
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(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index a85a7b2..3832f60 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -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):
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] git-p4: avoid syncing duplicate changes
  2009-02-18 18:12   ` [PATCH v2] " Pete Wyckoff
@ 2009-02-23 17:08     ` Simon Hausmann
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Hausmann @ 2009-02-23 17:08 UTC (permalink / raw)
  To: Pete Wyckoff; +Cc: git

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.
> 
> Signed-off-by: Pete Wyckoff <pw@padd.com>

Acked-by: Simon Hausmann <simon@lst.de>


Nice patch, thanks :)

Simon

> 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(-)
> 
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index a85a7b2..3832f60 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -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):
> -- 
> 1.6.0.6
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-23 17:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 16:45 [PATCH] git-p4: avoid syncing duplicate changes Pete Wyckoff
2009-02-05 15:24 ` Simon Hausmann
2009-02-18 18:12   ` [PATCH v2] " Pete Wyckoff
2009-02-23 17:08     ` Simon Hausmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).