git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-p4: Allow unshelving of branched files
@ 2019-05-21 22:50 Simon Williams
  2019-05-22  5:49 ` Luke Diamand
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Williams @ 2019-05-21 22:50 UTC (permalink / raw)
  To: git; +Cc: Luke Diamand, Junio C Hamano

When unshelving a changelist, git-p4 tries to work out the appropriate
parent commit in a given branch (default: HEAD).  To do this, it looks
at the state of any pre-existing files in the target Perforce branch,
omiting files added in the shelved changelist.  Currently, only files
added (or move targets) are classed as new.  However, files integrated
from other branches (i.e. a 'branch' action) also need to be considered
as added, for this purpose.

Signed-off-by: Simon Williams <simon@no-dns-yet.org.uk>
---
 git-p4.py           | 2 +-
 t/t9832-unshelve.sh | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/git-p4.py b/git-p4.py
index 5b79920f46..81a525858b 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1309,7 +1309,7 @@ def processContent(self, git_mode, relPath, contents):
 
 class Command:
     delete_actions = ( "delete", "move/delete", "purge" )
-    add_actions = ( "add", "move/add" )
+    add_actions = ( "add", "branch", "move/add" )
 
     def __init__(self):
         self.usage = "usage: %prog [options]"
diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
index 41c09f11f4..cde9f86cd6 100755
--- a/t/t9832-unshelve.sh
+++ b/t/t9832-unshelve.sh
@@ -22,7 +22,10 @@ test_expect_success 'init depot' '
 		: >file_to_move &&
 		p4 add file_to_delete &&
 		p4 add file_to_move &&
-		p4 submit -d "add files to delete"
+		p4 submit -d "add files to delete" &&
+		echo file_to_integrate >file_to_integrate &&
+		p4 add file_to_integrate &&
+		p4 submit -d "add file to integrate"
 	)
 '
 
@@ -40,6 +43,7 @@ test_expect_success 'create shelved changelist' '
 		p4 delete file_to_delete &&
 		p4 edit file_to_move &&
 		p4 move file_to_move moved_file &&
+		p4 integrate file_to_integrate integrated_file &&
 		p4 opened &&
 		p4 shelve -i <<EOF
 Change: new
@@ -53,6 +57,7 @@ Files:
 	//depot/file_to_delete
 	//depot/file_to_move
 	//depot/moved_file
+	//depot/integrated_file
 EOF
 
 	) &&
@@ -65,6 +70,7 @@ EOF
 		test_path_is_file file2 &&
 		test_cmp file1 "$cli"/file1 &&
 		test_cmp file2 "$cli"/file2 &&
+		test_cmp file_to_integrate "$cli"/integrated_file &&
 		test_path_is_missing file_to_delete &&
 		test_path_is_missing file_to_move &&
 		test_path_is_file moved_file
-- 
2.17.1


-- 
Simon Williams <simon@no-dns-yet.org.uk>
PGP Key ID: 0xF4A23C69


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

* Re: [PATCH] git-p4: Allow unshelving of branched files
  2019-05-21 22:50 [PATCH] git-p4: Allow unshelving of branched files Simon Williams
@ 2019-05-22  5:49 ` Luke Diamand
  2019-05-22  6:19   ` Simon Williams
  0 siblings, 1 reply; 3+ messages in thread
From: Luke Diamand @ 2019-05-22  5:49 UTC (permalink / raw)
  To: Simon Williams; +Cc: Git Users, Junio C Hamano

On Tue, 21 May 2019 at 23:50, Simon Williams <simon@no-dns-yet.org.uk> wrote:
>
> When unshelving a changelist, git-p4 tries to work out the appropriate
> parent commit in a given branch (default: HEAD).  To do this, it looks
> at the state of any pre-existing files in the target Perforce branch,
> omiting files added in the shelved changelist.  Currently, only files
> added (or move targets) are classed as new.  However, files integrated
> from other branches (i.e. a 'branch' action) also need to be considered
> as added, for this purpose.

Looks good to me!

"omiting" in the comment should perhaps be "omitting".

>
> Signed-off-by: Simon Williams <simon@no-dns-yet.org.uk>
> ---
>  git-p4.py           | 2 +-
>  t/t9832-unshelve.sh | 8 +++++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index 5b79920f46..81a525858b 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -1309,7 +1309,7 @@ def processContent(self, git_mode, relPath, contents):
>
>  class Command:
>      delete_actions = ( "delete", "move/delete", "purge" )
> -    add_actions = ( "add", "move/add" )
> +    add_actions = ( "add", "branch", "move/add" )
>
>      def __init__(self):
>          self.usage = "usage: %prog [options]"
> diff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh
> index 41c09f11f4..cde9f86cd6 100755
> --- a/t/t9832-unshelve.sh
> +++ b/t/t9832-unshelve.sh
> @@ -22,7 +22,10 @@ test_expect_success 'init depot' '
>                 : >file_to_move &&
>                 p4 add file_to_delete &&
>                 p4 add file_to_move &&
> -               p4 submit -d "add files to delete"
> +               p4 submit -d "add files to delete" &&
> +               echo file_to_integrate >file_to_integrate &&
> +               p4 add file_to_integrate &&
> +               p4 submit -d "add file to integrate"
>         )
>  '
>
> @@ -40,6 +43,7 @@ test_expect_success 'create shelved changelist' '
>                 p4 delete file_to_delete &&
>                 p4 edit file_to_move &&
>                 p4 move file_to_move moved_file &&
> +               p4 integrate file_to_integrate integrated_file &&
>                 p4 opened &&
>                 p4 shelve -i <<EOF
>  Change: new
> @@ -53,6 +57,7 @@ Files:
>         //depot/file_to_delete
>         //depot/file_to_move
>         //depot/moved_file
> +       //depot/integrated_file
>  EOF
>
>         ) &&
> @@ -65,6 +70,7 @@ EOF
>                 test_path_is_file file2 &&
>                 test_cmp file1 "$cli"/file1 &&
>                 test_cmp file2 "$cli"/file2 &&
> +               test_cmp file_to_integrate "$cli"/integrated_file &&
>                 test_path_is_missing file_to_delete &&
>                 test_path_is_missing file_to_move &&
>                 test_path_is_file moved_file
> --
> 2.17.1
>
>
> --
> Simon Williams <simon@no-dns-yet.org.uk>
> PGP Key ID: 0xF4A23C69
>

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

* Re: [PATCH] git-p4: Allow unshelving of branched files
  2019-05-22  5:49 ` Luke Diamand
@ 2019-05-22  6:19   ` Simon Williams
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Williams @ 2019-05-22  6:19 UTC (permalink / raw)
  To: Luke Diamand; +Cc: Git Users, Junio C Hamano

On Wed, May 22, 2019 at 06:49:38AM +0100, Luke Diamand wrote:
> On Tue, 21 May 2019 at 23:50, Simon Williams <simon@no-dns-yet.org.uk> wrote:
> >
> > When unshelving a changelist, git-p4 tries to work out the appropriate
> > parent commit in a given branch (default: HEAD).  To do this, it looks
> > at the state of any pre-existing files in the target Perforce branch,
> > omiting files added in the shelved changelist.  Currently, only files
> > added (or move targets) are classed as new.  However, files integrated
> > from other branches (i.e. a 'branch' action) also need to be considered
> > as added, for this purpose.
> 
> Looks good to me!
> 
> "omiting" in the comment should perhaps be "omitting".

Thanks and good point.  I'll send the revised patch.


Regards,
-- 
Simon Williams <simon@no-dns-yet.org.uk>
PGP Key ID: 0xF4A23C69


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

end of thread, other threads:[~2019-05-22  6:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21 22:50 [PATCH] git-p4: Allow unshelving of branched files Simon Williams
2019-05-22  5:49 ` Luke Diamand
2019-05-22  6:19   ` Simon Williams

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).