All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] Support threshold in copy/rename detection
@ 2011-08-22  8:33 Vitor Antunes
  2011-08-22  8:33 ` [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold Vitor Antunes
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Vitor Antunes @ 2011-08-22  8:33 UTC (permalink / raw)
  To: git; +Cc: Pete Wyckoff, Tor Arvid Lund, Vitor Antunes

Make detectCopiesHarder use "git config --bool".
Include Pete Wyckoff's patches to test cases.

Vitor Antunes (5):
  git-p4: Allow setting rename/copy detection threshold
  git-p4: Add description of rename/copy detection options
  git-p4: Add test case for rename detection
  git-p4: Add test case for copy detection
  git-p4: Process detectCopiesHarder with --bool

 contrib/fast-import/git-p4     |   15 +++--
 contrib/fast-import/git-p4.txt |   25 +++++++
 t/t9800-git-p4.sh              |  136 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+), 5 deletions(-)

-- 
1.7.5.4

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

* [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold
  2011-08-22  8:33 [PATCH v3 0/5] Support threshold in copy/rename detection Vitor Antunes
@ 2011-08-22  8:33 ` Vitor Antunes
  2011-08-22 12:18   ` Pete Wyckoff
  2011-08-22  8:33 ` [PATCH v3 2/5] git-p4: Add description of rename/copy detection options Vitor Antunes
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Vitor Antunes @ 2011-08-22  8:33 UTC (permalink / raw)
  To: git; +Cc: Pete Wyckoff, Tor Arvid Lund, Vitor Antunes

Copy and rename detection arguments (-C and -M) allow setting a threshold value
for the similarity ratio. If the similarity is below this threshold the rename
or copy is ignored and the file is added as new.
This patch allows setting git-p4.detectRenames and git-p4.detectCopies options
to an integer value to set the respective threshold.

Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
---
 contrib/fast-import/git-p4 |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 6b9de9e..29a5390f 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -774,15 +774,20 @@ class P4Submit(Command, P4UserMap):
 
         if not self.detectRenames:
             # If not explicitly set check the config variable
-            self.detectRenames = gitConfig("git-p4.detectRenames").lower() == "true"
+            self.detectRenames = gitConfig("git-p4.detectRenames")
 
-        if self.detectRenames:
+        if self.detectRenames.lower() == "false" or self.detectRenames == "":
+            diffOpts = ""
+        elif self.detectRenames.lower() == "true":
             diffOpts = "-M"
         else:
-            diffOpts = ""
+            diffOpts = "-M%s" % self.detectRenames
 
-        if gitConfig("git-p4.detectCopies").lower() == "true":
+        detectCopies = gitConfig("git-p4.detectCopies")
+        if detectCopies.lower() == "true":
             diffOpts += " -C"
+        elif detectCopies != "" and detectCopies.lower() != "false":
+            diffOpts += " -C%s" % detectCopies
 
         if gitConfig("git-p4.detectCopiesHarder").lower() == "true":
             diffOpts += " --find-copies-harder"
-- 
1.7.5.4

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

* [PATCH v3 2/5] git-p4: Add description of rename/copy detection options
  2011-08-22  8:33 [PATCH v3 0/5] Support threshold in copy/rename detection Vitor Antunes
  2011-08-22  8:33 ` [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold Vitor Antunes
@ 2011-08-22  8:33 ` Vitor Antunes
  2011-08-22  8:33 ` [PATCH v3 3/5] git-p4: Add test case for rename detection Vitor Antunes
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Vitor Antunes @ 2011-08-22  8:33 UTC (permalink / raw)
  To: git; +Cc: Pete Wyckoff, Tor Arvid Lund, Vitor Antunes

Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
---
 contrib/fast-import/git-p4.txt |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/contrib/fast-import/git-p4.txt b/contrib/fast-import/git-p4.txt
index caa4bb3..2ffbccc 100644
--- a/contrib/fast-import/git-p4.txt
+++ b/contrib/fast-import/git-p4.txt
@@ -232,6 +232,31 @@ git-p4.skipUserNameCheck
 When submitting, git-p4 checks that the git commits are authored by the current
 p4 user, and warns if they are not. This disables the check.
 
+git-p4.detectRenames
+
+Detect renames when submitting changes to Perforce server. Will enable -M git
+argument. Can be optionally set to a number representing the threshold
+percentage value of the rename detection.
+
+  git config [--global] git-p4.detectRenames true
+  git config [--global] git-p4.detectRenames 50
+
+git-p4.detectCopies
+
+Detect copies when submitting changes to Perforce server. Will enable -C git
+argument. Can be optionally set to a number representing the threshold
+percentage value of the copy detection.
+
+  git config [--global] git-p4.detectCopies true
+  git config [--global] git-p4.detectCopies 80
+
+git-p4.detectCopiesHarder
+
+Detect copies even between files that did not change when submitting changes to
+Perforce server. Will enable --find-copies-harder git argument.
+
+  git config [--global] git-p4.detectCopies true
+
 Implementation Details...
 =========================
 
-- 
1.7.5.4

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

* [PATCH v3 3/5] git-p4: Add test case for rename detection
  2011-08-22  8:33 [PATCH v3 0/5] Support threshold in copy/rename detection Vitor Antunes
  2011-08-22  8:33 ` [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold Vitor Antunes
  2011-08-22  8:33 ` [PATCH v3 2/5] git-p4: Add description of rename/copy detection options Vitor Antunes
@ 2011-08-22  8:33 ` Vitor Antunes
  2011-08-22  8:33 ` [PATCH v3 4/5] git-p4: Add test case for copy detection Vitor Antunes
  2011-08-22  8:33 ` [PATCH v3 5/5] git-p4: Process detectCopiesHarder with --bool Vitor Antunes
  4 siblings, 0 replies; 8+ messages in thread
From: Vitor Antunes @ 2011-08-22  8:33 UTC (permalink / raw)
  To: git; +Cc: Pete Wyckoff, Tor Arvid Lund, Vitor Antunes

Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 t/t9800-git-p4.sh |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh
index 97ec975..5a5fd0f 100755
--- a/t/t9800-git-p4.sh
+++ b/t/t9800-git-p4.sh
@@ -269,6 +269,59 @@ test_expect_success 'initial import time from top change time' '
 	test $p4time = $gittime
 '
 
+# Rename a file and confirm that rename is not detected in P4.
+# Rename the new file again with detectRenames option enabled and confirm that
+# this is detected in P4.
+# Rename the new file again adding an extra line, configure a big threshold in
+# detectRenames and confirm that rename is not detected in P4.
+# Repeat, this time with a smaller threshold and confirm that the rename is
+# detected in P4.
+test_expect_success 'detect renames' '
+	"$GITP4" clone --dest="$git" //depot@all &&
+	test_when_finished cleanup_git &&
+	cd "$git" &&
+	git config git-p4.skipSubmitEditCheck true &&
+
+	git mv file1 file4 &&
+	git commit -a -m "Rename file1 to file4" &&
+	git diff-tree -r -M HEAD &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file4 &&
+	! p4 filelog //depot/file4 | grep -q "branch from" &&
+
+	git mv file4 file5 &&
+	git commit -a -m "Rename file4 to file5" &&
+	git diff-tree -r -M HEAD &&
+	git config git-p4.detectRenames true &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file5 &&
+	p4 filelog //depot/file5 | grep -q "branch from //depot/file4" &&
+
+	git mv file5 file6 &&
+	echo update >>file6 &&
+	git add file6 &&
+	git commit -a -m "Rename file5 to file6 with changes" &&
+	git diff-tree -r -M HEAD &&
+	level=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&
+	test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
+	git config git-p4.detectRenames $((level + 2)) &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file6 &&
+	! p4 filelog //depot/file6 | grep -q "branch from" &&
+
+	git mv file6 file7 &&
+	echo update >>file7 &&
+	git add file7 &&
+	git commit -a -m "Rename file6 to file7 with changes" &&
+	git diff-tree -r -M HEAD &&
+	level=$(git diff-tree -r -M HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/R0*//") &&
+	test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
+	git config git-p4.detectRenames $((level - 2)) &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file7 &&
+	p4 filelog //depot/file7 | grep -q "branch from //depot/file6"
+'
+
 test_expect_success 'shutdown' '
 	pid=`pgrep -f p4d` &&
 	test -n "$pid" &&
-- 
1.7.5.4

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

* [PATCH v3 4/5] git-p4: Add test case for copy detection
  2011-08-22  8:33 [PATCH v3 0/5] Support threshold in copy/rename detection Vitor Antunes
                   ` (2 preceding siblings ...)
  2011-08-22  8:33 ` [PATCH v3 3/5] git-p4: Add test case for rename detection Vitor Antunes
@ 2011-08-22  8:33 ` Vitor Antunes
  2011-08-22  8:33 ` [PATCH v3 5/5] git-p4: Process detectCopiesHarder with --bool Vitor Antunes
  4 siblings, 0 replies; 8+ messages in thread
From: Vitor Antunes @ 2011-08-22  8:33 UTC (permalink / raw)
  To: git; +Cc: Pete Wyckoff, Tor Arvid Lund, Vitor Antunes

Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 t/t9800-git-p4.sh |   83 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh
index 5a5fd0f..9d4d4bf 100755
--- a/t/t9800-git-p4.sh
+++ b/t/t9800-git-p4.sh
@@ -322,6 +322,89 @@ test_expect_success 'detect renames' '
 	p4 filelog //depot/file7 | grep -q "branch from //depot/file6"
 '
 
+# Copy a file and confirm that copy is not detected in P4.
+# Copy a file with detectCopies option enabled and confirm that copy is not
+# detected in P4.
+# Modify and copy a file with detectCopies option enabled and confirm that copy
+# is detected in P4.
+# Copy a file with detectCopies and detectCopiesHarder options enabled and
+# confirm that copy is detected in P4.
+# Modify and copy a file, configure a bigger threshold in detectCopies and
+# confirm that copy is not detected in P4.
+# Modify and copy a file, configure a smaller threshold in detectCopies and
+# confirm that copy is detected in P4.
+test_expect_success 'detect copies' '
+	"$GITP4" clone --dest="$git" //depot@all &&
+	test_when_finished cleanup_git &&
+	cd "$git" &&
+	git config git-p4.skipSubmitEditCheck true &&
+
+	cp file2 file8 &&
+	git add file8 &&
+	git commit -a -m "Copy file2 to file8" &&
+	git diff-tree -r -C HEAD &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file8 &&
+	! p4 filelog //depot/file8 | grep -q "branch from" &&
+
+	cp file2 file9 &&
+	git add file9 &&
+	git commit -a -m "Copy file2 to file9" &&
+	git diff-tree -r -C HEAD &&
+	git config git-p4.detectCopies true &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file9 &&
+	! p4 filelog //depot/file9 | grep -q "branch from" &&
+
+	echo "file2" >>file2 &&
+	cp file2 file10 &&
+	git add file2 file10 &&
+	git commit -a -m "Modify and copy file2 to file10" &&
+	git diff-tree -r -C HEAD &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file10 &&
+	p4 filelog //depot/file10 | grep -q "branch from //depot/file" &&
+
+	cp file2 file11 &&
+	git add file11 &&
+	git commit -a -m "Copy file2 to file11" &&
+	git diff-tree -r -C --find-copies-harder HEAD &&
+	src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
+	test "$src" = file10 &&
+	git config git-p4.detectCopiesHarder true &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file11 &&
+	p4 filelog //depot/file11 | grep -q "branch from //depot/file" &&
+
+	cp file2 file12 &&
+	echo "some text" >>file12 &&
+	git add file12 &&
+	git commit -a -m "Copy file2 to file12 with changes" &&
+	git diff-tree -r -C --find-copies-harder HEAD &&
+	level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
+	test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
+	src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
+	test "$src" = file10 &&
+	git config git-p4.detectCopies $((level + 2)) &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file12 &&
+	! p4 filelog //depot/file12 | grep -q "branch from" &&
+
+	cp file2 file13 &&
+	echo "different text" >>file13 &&
+	git add file13 &&
+	git commit -a -m "Copy file2 to file13 with changes" &&
+	git diff-tree -r -C --find-copies-harder HEAD &&
+	level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
+	test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
+	src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
+	test "$src" = file10 &&
+	git config git-p4.detectCopies $((level - 2)) &&
+	"$GITP4" submit &&
+	p4 filelog //depot/file13 &&
+	p4 filelog //depot/file13 | grep -q "branch from //depot/file"
+'
+
 test_expect_success 'shutdown' '
 	pid=`pgrep -f p4d` &&
 	test -n "$pid" &&
-- 
1.7.5.4

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

* [PATCH v3 5/5] git-p4: Process detectCopiesHarder with --bool
  2011-08-22  8:33 [PATCH v3 0/5] Support threshold in copy/rename detection Vitor Antunes
                   ` (3 preceding siblings ...)
  2011-08-22  8:33 ` [PATCH v3 4/5] git-p4: Add test case for copy detection Vitor Antunes
@ 2011-08-22  8:33 ` Vitor Antunes
  4 siblings, 0 replies; 8+ messages in thread
From: Vitor Antunes @ 2011-08-22  8:33 UTC (permalink / raw)
  To: git; +Cc: Pete Wyckoff, Tor Arvid Lund, Vitor Antunes

Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
---
 contrib/fast-import/git-p4 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 29a5390f..0db3e72 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -789,7 +789,7 @@ class P4Submit(Command, P4UserMap):
         elif detectCopies != "" and detectCopies.lower() != "false":
             diffOpts += " -C%s" % detectCopies
 
-        if gitConfig("git-p4.detectCopiesHarder").lower() == "true":
+        if gitConfig("git-p4.detectCopiesHarder", "--bool") == "true":
             diffOpts += " --find-copies-harder"
 
         diff = read_pipe_lines("git diff-tree -r %s \"%s^\" \"%s\"" % (diffOpts, id, id))
-- 
1.7.5.4

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

* Re: [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold
  2011-08-22  8:33 ` [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold Vitor Antunes
@ 2011-08-22 12:18   ` Pete Wyckoff
  2011-08-22 12:44     ` Vitor Antunes
  0 siblings, 1 reply; 8+ messages in thread
From: Pete Wyckoff @ 2011-08-22 12:18 UTC (permalink / raw)
  To: Vitor Antunes; +Cc: git, Tor Arvid Lund

vitor.hda@gmail.com wrote on Mon, 22 Aug 2011 09:33 +0100:
> Copy and rename detection arguments (-C and -M) allow setting a threshold value
> for the similarity ratio. If the similarity is below this threshold the rename
> or copy is ignored and the file is added as new.
> This patch allows setting git-p4.detectRenames and git-p4.detectCopies options
> to an integer value to set the respective threshold.
> 
> Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>

This series looks great.  Thanks for fixing the --bool issue and
the tests.

Acked-by: Pete Wyckoff <pw@padd.com>

		-- Pete

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

* Re: [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold
  2011-08-22 12:18   ` Pete Wyckoff
@ 2011-08-22 12:44     ` Vitor Antunes
  0 siblings, 0 replies; 8+ messages in thread
From: Vitor Antunes @ 2011-08-22 12:44 UTC (permalink / raw)
  To: Pete Wyckoff; +Cc: git, Tor Arvid Lund

On Mon, Aug 22, 2011 at 1:18 PM, Pete Wyckoff <pw@padd.com> wrote:
> This series looks great.  Thanks for fixing the --bool issue and
> the tests.

Thank *you* for the help and suggestions.
-- 
Vitor Antunes

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

end of thread, other threads:[~2011-08-22 12:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-22  8:33 [PATCH v3 0/5] Support threshold in copy/rename detection Vitor Antunes
2011-08-22  8:33 ` [PATCH v3 1/5] git-p4: Allow setting rename/copy detection threshold Vitor Antunes
2011-08-22 12:18   ` Pete Wyckoff
2011-08-22 12:44     ` Vitor Antunes
2011-08-22  8:33 ` [PATCH v3 2/5] git-p4: Add description of rename/copy detection options Vitor Antunes
2011-08-22  8:33 ` [PATCH v3 3/5] git-p4: Add test case for rename detection Vitor Antunes
2011-08-22  8:33 ` [PATCH v3 4/5] git-p4: Add test case for copy detection Vitor Antunes
2011-08-22  8:33 ` [PATCH v3 5/5] git-p4: Process detectCopiesHarder with --bool Vitor Antunes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.