git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Git-p4: Add "git p4 change" command.
@ 2011-10-17 22:16 Andrei Warkentin
  2011-10-17 22:20 ` Andrei Warkentin
  0 siblings, 1 reply; 4+ messages in thread
From: Andrei Warkentin @ 2011-10-17 22:16 UTC (permalink / raw)
  To: git, gitster; +Cc: Andrei Warkentin

Many users of p4/sd use changelists for review, regression
tests and batch builds.

"p4 change" is almost equivalent to "p4 submit", yet will
just create the changelist and not submit it.

Signed-off-by: Andrei Warkentin <andreiw@vmware.com>
---
 contrib/fast-import/git-p4     |   16 ++++++++++++----
 contrib/fast-import/git-p4.txt |   10 ++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2f7b270..19c295b 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -959,7 +959,10 @@ class P4Submit(Command, P4UserMap):
                 submitTemplate = message[:message.index(separatorLine)]
                 if self.isWindows:
                     submitTemplate = submitTemplate.replace("\r\n", "\n")
-                p4_write_pipe("submit -i", submitTemplate)
+                if gitConfig("git-p4.changeOnSubmit"):
+                    p4_write_pipe("change -i", submitTemplate)
+                else:
+                    p4_write_pipe("subadasdmit -i", submitTemplate)
 
                 if self.preserveUser:
                     if p4User:
@@ -981,9 +984,14 @@ class P4Submit(Command, P4UserMap):
             file = open(fileName, "w+")
             file.write(self.prepareLogMessage(template, logMessage))
             file.close()
-            print ("Perforce submit template written as %s. "
-                   + "Please review/edit and then use p4 submit -i < %s to submit directly!"
-                   % (fileName, fileName))
+            if gitConfig("git-p4.changeOnSubmit"):
+                print ("Perforce submit template written as %s. "
+                       + "Please review/edit and then use p4 change -i < %s to create changelist!"
+                       % (fileName, fileName))
+            else:
+                print ("Perforce submit template written as %s. "
+                       + "Please review/edit and then use p4 submit -i < %s to submit directly!"
+                       % (fileName, fileName))
 
     def run(self, args):
         if len(args) == 0:
diff --git a/contrib/fast-import/git-p4.txt b/contrib/fast-import/git-p4.txt
index 52003ae..3a3a815 100644
--- a/contrib/fast-import/git-p4.txt
+++ b/contrib/fast-import/git-p4.txt
@@ -180,6 +180,16 @@ git-p4.allowSubmit
 
   git config [--global] git-p4.allowSubmit false
 
+git-p4.changeOnSubmit
+
+  git config [--global] git-p4.changeOnSubmit false
+
+Most places using p4/sourcedepot don't actually want you submit
+changes directly, and changelists are used to do regression testing,
+batch builds and review, hence, by setting this parameter to
+true you acknowledge you end up creating a changelist which you
+must then manually commit.
+
 git-p4.syncFromOrigin
 
 A useful setup may be that you have a periodically updated git repository
-- 
1.7.4.1

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

* [PATCH] Git-p4: Add "git p4 change" command.
@ 2011-10-17 22:18 Andrei Warkentin
  2011-10-17 22:21 ` Andrei Warkentin
  0 siblings, 1 reply; 4+ messages in thread
From: Andrei Warkentin @ 2011-10-17 22:18 UTC (permalink / raw)
  To: git, gitster; +Cc: Andrei Warkentin

Many users of p4/sd use changelists for review, regression
tests and batch builds.

"p4 change" is almost equivalent to "p4 submit", yet will
just create the changelist and not submit it.

Signed-off-by: Andrei Warkentin <andreiw@vmware.com>
---
 contrib/fast-import/git-p4 |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2f7b270..dd084b9 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -950,7 +950,10 @@ class P4Submit(Command, P4UserMap):
             if checkModTime and (os.stat(fileName).st_mtime <= mtime):
                 response = "x"
                 while response != "y" and response != "n":
-                    response = raw_input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ")
+                    if (self.cmdname == "change"):
+                        response = raw_input("Change template unchanged. Create changelist anyway? [y]es, [n]o (skip this patch) ")
+                    else:
+                        response = raw_input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ")
 
             if response == "y":
                 tmpFile = open(fileName, "rb")
@@ -959,7 +962,10 @@ class P4Submit(Command, P4UserMap):
                 submitTemplate = message[:message.index(separatorLine)]
                 if self.isWindows:
                     submitTemplate = submitTemplate.replace("\r\n", "\n")
-                p4_write_pipe("submit -i", submitTemplate)
+                if (self.cmdname == "change"):
+                    p4_write_pipe("change -i", submitTemplate)
+                else:
+                    p4_write_pipe("submit -i", submitTemplate)
 
                 if self.preserveUser:
                     if p4User:
@@ -981,9 +987,14 @@ class P4Submit(Command, P4UserMap):
             file = open(fileName, "w+")
             file.write(self.prepareLogMessage(template, logMessage))
             file.close()
-            print ("Perforce submit template written as %s. "
-                   + "Please review/edit and then use p4 submit -i < %s to submit directly!"
-                   % (fileName, fileName))
+            if (self.cmdname == "change"):
+                print ("Perforce change template written as %s. "
+                       + "Please review/edit and then use p4 change -i < %s to submit directly!"
+                       % (fileName, fileName))
+            else:
+                print ("Perforce submit template written as %s. "
+                       + "Please review/edit and then use p4 submit -i < %s to submit directly!"
+                       % (fileName, fileName))
 
     def run(self, args):
         if len(args) == 0:
@@ -2177,6 +2188,7 @@ commands = {
     "debug" : P4Debug,
     "submit" : P4Submit,
     "commit" : P4Submit,
+    "change" : P4Submit,
     "sync" : P4Sync,
     "rebase" : P4Rebase,
     "clone" : P4Clone,
@@ -2202,6 +2214,7 @@ def main():
         sys.exit(2)
 
     options = cmd.options
+    cmd.cmdname = cmdName
     cmd.gitdir = os.environ.get("GIT_DIR", None)
 
     args = sys.argv[2:]
-- 
1.7.4.1

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

* Re: [PATCH] Git-p4: Add "git p4 change" command.
  2011-10-17 22:16 Andrei Warkentin
@ 2011-10-17 22:20 ` Andrei Warkentin
  0 siblings, 0 replies; 4+ messages in thread
From: Andrei Warkentin @ 2011-10-17 22:20 UTC (permalink / raw)
  To: Andrei Warkentin; +Cc: git, gitster

----- Original Message -----
> From: "Andrei Warkentin" <andreiw@vmware.com>
> To: git@vger.kernel.org, gitster@pobox.com
> Cc: "Andrei Warkentin" <andreiw@vmware.com>
> Sent: Monday, October 17, 2011 6:16:38 PM
> Subject: [PATCH] Git-p4: Add "git p4 change" command.
> 
> Many users of p4/sd use changelists for review, regression
> tests and batch builds.
> 
> "p4 change" is almost equivalent to "p4 submit", yet will
> just create the changelist and not submit it.
> 
> Signed-off-by: Andrei Warkentin <andreiw@vmware.com>
> ---

Sorry for the spam, this is the wrong patch :-(.

A

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

* Re: [PATCH] Git-p4: Add "git p4 change" command.
  2011-10-17 22:18 [PATCH] Git-p4: Add "git p4 change" command Andrei Warkentin
@ 2011-10-17 22:21 ` Andrei Warkentin
  0 siblings, 0 replies; 4+ messages in thread
From: Andrei Warkentin @ 2011-10-17 22:21 UTC (permalink / raw)
  To: Andrei Warkentin; +Cc: git, gitster

----- Original Message -----
> From: "Andrei Warkentin" <andreiw@vmware.com>
> To: git@vger.kernel.org, gitster@pobox.com
> Cc: "Andrei Warkentin" <andreiw@vmware.com>
> Sent: Monday, October 17, 2011 6:18:57 PM
> Subject: [PATCH] Git-p4: Add "git p4 change" command.
> 
> Many users of p4/sd use changelists for review, regression
> tests and batch builds.
> 
> "p4 change" is almost equivalent to "p4 submit", yet will
> just create the changelist and not submit it.
> 
> Signed-off-by: Andrei Warkentin <andreiw@vmware.com>
> ---
>  contrib/fast-import/git-p4 |   23 ++++++++++++++++++-----
>  1 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index 2f7b270..dd084b9 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -950,7 +950,10 @@ class P4Submit(Command, P4UserMap):
>              if checkModTime and (os.stat(fileName).st_mtime <=
>              mtime):
>                  response = "x"
>                  while response != "y" and response != "n":
> -                    response = raw_input("Submit template unchanged.
> Submit anyway? [y]es, [n]o (skip this patch) ")
> +                    if (self.cmdname == "change"):
> +                        response = raw_input("Change template
> unchanged. Create changelist anyway? [y]es, [n]o (skip this patch)
> ")
> +                    else:
> +                        response = raw_input("Submit template
> unchanged. Submit anyway? [y]es, [n]o (skip this patch) ")
>  
>              if response == "y":
>                  tmpFile = open(fileName, "rb")
> @@ -959,7 +962,10 @@ class P4Submit(Command, P4UserMap):
>                  submitTemplate =
>                  message[:message.index(separatorLine)]
>                  if self.isWindows:
>                      submitTemplate = submitTemplate.replace("\r\n",
>                      "\n")
> -                p4_write_pipe("submit -i", submitTemplate)
> +                if (self.cmdname == "change"):
> +                    p4_write_pipe("change -i", submitTemplate)
> +                else:
> +                    p4_write_pipe("submit -i", submitTemplate)
>  
>                  if self.preserveUser:
>                      if p4User:
> @@ -981,9 +987,14 @@ class P4Submit(Command, P4UserMap):
>              file = open(fileName, "w+")
>              file.write(self.prepareLogMessage(template, logMessage))
>              file.close()
> -            print ("Perforce submit template written as %s. "
> -                   + "Please review/edit and then use p4 submit -i <
> %s to submit directly!"
> -                   % (fileName, fileName))
> +            if (self.cmdname == "change"):
> +                print ("Perforce change template written as %s. "
> +                       + "Please review/edit and then use p4 change
> -i < %s to submit directly!"
> +                       % (fileName, fileName))
> +            else:
> +                print ("Perforce submit template written as %s. "
> +                       + "Please review/edit and then use p4 submit
> -i < %s to submit directly!"
> +                       % (fileName, fileName))
>  
>      def run(self, args):
>          if len(args) == 0:
> @@ -2177,6 +2188,7 @@ commands = {
>      "debug" : P4Debug,
>      "submit" : P4Submit,
>      "commit" : P4Submit,
> +    "change" : P4Submit,
>      "sync" : P4Sync,
>      "rebase" : P4Rebase,
>      "clone" : P4Clone,
> @@ -2202,6 +2214,7 @@ def main():
>          sys.exit(2)
>  
>      options = cmd.options
> +    cmd.cmdname = cmdName
>      cmd.gitdir = os.environ.get("GIT_DIR", None)
>  
>      args = sys.argv[2:]
> --
> 1.7.4.1
> 

This is the change I would like to have reviewed.

Sorry again for the spam.

A

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

end of thread, other threads:[~2011-10-17 22:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-17 22:18 [PATCH] Git-p4: Add "git p4 change" command Andrei Warkentin
2011-10-17 22:21 ` Andrei Warkentin
  -- strict thread matches above, loose matches on Subject: below --
2011-10-17 22:16 Andrei Warkentin
2011-10-17 22:20 ` Andrei Warkentin

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).