Re: [PATCHv2 0/6] git-p4: some small fixes updated

2018-06-12 Thread Luke Diamand
On 12 June 2018 at 22:53, Eric Sunshine  wrote:
> On Tue, Jun 12, 2018 at 5:49 PM, Luke Diamand  wrote:
>> Thanks. While on the subject of git-p4, I thought I should mention
>> that I've been looking at getting git-p4 to work with Python3.
>>
>> I've got some low risk easy (mostly automated) changes which get it to
>> the point where it compiles. After that I have to figure out how to
>> fix the byte-vs-string unicode problem that Python3 brings. [...]
>
> See how reposurgeon handles the problem[1]. It defines polystr() and
> polybytes() functions which coerce strings and byte sequences as
> needed. It's not pretty, but it works.
>
> [1]: https://gitlab.com/esr/reposurgeon/blob/master/reposurgeon#L100

Thanks, that's got some useful tips!


Re: [PATCHv2 0/6] git-p4: some small fixes updated

2018-06-12 Thread Eric Sunshine
On Tue, Jun 12, 2018 at 5:49 PM, Luke Diamand  wrote:
> Thanks. While on the subject of git-p4, I thought I should mention
> that I've been looking at getting git-p4 to work with Python3.
>
> I've got some low risk easy (mostly automated) changes which get it to
> the point where it compiles. After that I have to figure out how to
> fix the byte-vs-string unicode problem that Python3 brings. [...]

See how reposurgeon handles the problem[1]. It defines polystr() and
polybytes() functions which coerce strings and byte sequences as
needed. It's not pretty, but it works.

[1]: https://gitlab.com/esr/reposurgeon/blob/master/reposurgeon#L100


Re: [PATCHv2 0/6] git-p4: some small fixes updated

2018-06-12 Thread Luke Diamand
On 12 June 2018 at 22:35, Junio C Hamano  wrote:
> Luke Diamand  writes:
>
>> On 12 June 2018 at 18:10, Junio C Hamano  wrote:
>>> Luke Diamand  writes:
>>>
 This is an updated version of the set of changes I posted recently,
 following comments on the list:

 disable automatic sync after git-p4 submit:
 https://marc.info/?l=git=152818734814838=2

 better handling of being logged out by Perforce:
https://marc.info/?l=git=152818893815326=2

 adapt the block size automatically on git-p4 submit:
https://marc.info/?l=git=152819004315688=2

 - Spelling corrections (Eric)
 - Improved comments (Eric)
 - Exception class hierarchy fix (Merland)
 - test simplification (Eric)

>>>
>>> That reminds me of one thing.
>>>
>>> This 6-patch series depends on the rm/p4-submit-with-commit-option
>>> that came without and still waiting for a sign-off by the original
>>> author.  Also I do not think the original patch reached the public
>>> list, so I'm attaching the patch to make sure people know which
>>> patch I am talking about.
>>>
>>> Romain, can we get your sign-off on the patch you sent earlier?
>>
>> Wasn't it already sent in this message:
>>
>> https://marc.info/?l=git=152783923418317=2
>>
>> Luke
>
>
> Thanks for a pointer.  Will replace and requeue.

Thanks. While on the subject of git-p4, I thought I should mention
that I've been looking at getting git-p4 to work with Python3.

I've got some low risk easy (mostly automated) changes which get it to
the point where it compiles. After that I have to figure out how to
fix the byte-vs-string unicode problem that Python3 brings. Having
been playing around with it, I think it should be possible to make the
same git-p4.py script work with 2.7, 3.6 and probably 2.6, although
I'm still some way from making this last bit work.

Luke


Re: [PATCHv2 0/6] git-p4: some small fixes updated

2018-06-12 Thread Junio C Hamano
Luke Diamand  writes:

> On 12 June 2018 at 18:10, Junio C Hamano  wrote:
>> Luke Diamand  writes:
>>
>>> This is an updated version of the set of changes I posted recently,
>>> following comments on the list:
>>>
>>> disable automatic sync after git-p4 submit:
>>> https://marc.info/?l=git=152818734814838=2
>>>
>>> better handling of being logged out by Perforce:
>>>https://marc.info/?l=git=152818893815326=2
>>>
>>> adapt the block size automatically on git-p4 submit:
>>>https://marc.info/?l=git=152819004315688=2
>>>
>>> - Spelling corrections (Eric)
>>> - Improved comments (Eric)
>>> - Exception class hierarchy fix (Merland)
>>> - test simplification (Eric)
>>>
>>
>> That reminds me of one thing.
>>
>> This 6-patch series depends on the rm/p4-submit-with-commit-option
>> that came without and still waiting for a sign-off by the original
>> author.  Also I do not think the original patch reached the public
>> list, so I'm attaching the patch to make sure people know which
>> patch I am talking about.
>>
>> Romain, can we get your sign-off on the patch you sent earlier?
>
> Wasn't it already sent in this message:
>
> https://marc.info/?l=git=152783923418317=2
>
> Luke


Thanks for a pointer.  Will replace and requeue.



Re: [PATCHv2 0/6] git-p4: some small fixes updated

2018-06-12 Thread Luke Diamand
On 12 June 2018 at 18:10, Junio C Hamano  wrote:
> Luke Diamand  writes:
>
>> This is an updated version of the set of changes I posted recently,
>> following comments on the list:
>>
>> disable automatic sync after git-p4 submit:
>> https://marc.info/?l=git=152818734814838=2
>>
>> better handling of being logged out by Perforce:
>>https://marc.info/?l=git=152818893815326=2
>>
>> adapt the block size automatically on git-p4 submit:
>>https://marc.info/?l=git=152819004315688=2
>>
>> - Spelling corrections (Eric)
>> - Improved comments (Eric)
>> - Exception class hierarchy fix (Merland)
>> - test simplification (Eric)
>>
>
> That reminds me of one thing.
>
> This 6-patch series depends on the rm/p4-submit-with-commit-option
> that came without and still waiting for a sign-off by the original
> author.  Also I do not think the original patch reached the public
> list, so I'm attaching the patch to make sure people know which
> patch I am talking about.
>
> Romain, can we get your sign-off on the patch you sent earlier?

Wasn't it already sent in this message:

https://marc.info/?l=git=152783923418317=2

Luke


>
> Thanks.
>
> -- >8 --
> From: Romain Merland 
> Date: Wed, 9 May 2018 17:32:12 +0200
> Subject: [PATCH] git-p4: add options --commit and --disable-rebase
>
> On a daily work with multiple local git branches, the usual way to
> submit only a specified commit was to cherry-pick the commit on
> master then run git-p4 submit.  It can be very annoying to switch
> between local branches and master, only to submit one commit.  The
> proposed new way is to select directly the commit you want to
> submit.
>
> Add option --commit to command 'git-p4 submit' in order to submit
> only specified commit(s) in p4.
>
> On a daily work developping software with big compilation time, one
> may not want to rebase on his local git tree, in order to avoid long
> recompilation.
>
> Add option --disable-rebase to command 'git-p4 submit' in order to
> disable rebase after submission.
>
> Reviewed-by: Luke Diamand 
> Signed-off-by: Junio C Hamano 
> ---
>  Documentation/git-p4.txt | 14 ++
>  git-p4.py| 29 +++--
>  t/t9807-git-p4-submit.sh | 40 
>  3 files changed, 77 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
> index d8c8f11c9f..88d109debb 100644
> --- a/Documentation/git-p4.txt
> +++ b/Documentation/git-p4.txt
> @@ -149,6 +149,12 @@ To specify a branch other than the current one, use:
>  $ git p4 submit topicbranch
>  
>
> +To specify a single commit or a range of commits, use:
> +
> +$ git p4 submit --commit 
> +$ git p4 submit --commit 
> +
> +
>  The upstream reference is generally 'refs/remotes/p4/master', but can
>  be overridden using the `--origin=` command-line option.
>
> @@ -330,6 +336,14 @@ These options can be used to modify 'git p4 submit' 
> behavior.
> p4/master.  See the "Sync options" section above for more
> information.
>
> +--commit |::
> +Submit only the specified commit or range of commits, instead of the full
> +list of changes that are in the current Git branch.
> +
> +--disable-rebase::
> +Disable the automatic rebase after all commits have been successfully
> +submitted.
> +
>  Rebase options
>  ~~
>  These options can be used to modify 'git p4 rebase' behavior.
> diff --git a/git-p4.py b/git-p4.py
> index 7bb9cadc69..f4a6f3b4c3 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -1352,7 +1352,12 @@ def __init__(self):
>  optparse.make_option("--update-shelve", 
> dest="update_shelve", action="append", type="int",
>   metavar="CHANGELIST",
>   help="update an existing shelved 
> changelist, implies --shelve, "
> -   "repeat in-order for multiple 
> shelved changelists")
> +   "repeat in-order for multiple 
> shelved changelists"),
> +optparse.make_option("--commit", dest="commit", 
> metavar="COMMIT",
> + help="submit only the specified 
> commit(s), one commit or xxx..xxx"),
> +optparse.make_option("--disable-rebase", 
> dest="disable_rebase", action="store_true",
> + help="Disable rebase after submit is 
> completed. Can be useful if you "
> + "work from a local git branch that is 
> not master")
>  ]
>  self.description = "Submit changes from git to the perforce depot."
>  self.usage += " [name of git branch to submit into perforce depot]"
> @@ -1362,6 +1367,8 @@ def __init__(self):
>  self.dry_run = False
>  self.shelve = False
>  self.update_shelve = list()
> +self.commit = ""
> +

Re: [PATCHv2 0/6] git-p4: some small fixes updated

2018-06-12 Thread Junio C Hamano
Luke Diamand  writes:

> This is an updated version of the set of changes I posted recently,
> following comments on the list:
>
> disable automatic sync after git-p4 submit:
> https://marc.info/?l=git=152818734814838=2
>
> better handling of being logged out by Perforce:
>https://marc.info/?l=git=152818893815326=2
>
> adapt the block size automatically on git-p4 submit:
>https://marc.info/?l=git=152819004315688=2
>
> - Spelling corrections (Eric)
> - Improved comments (Eric)
> - Exception class hierarchy fix (Merland)
> - test simplification (Eric)
>

That reminds me of one thing.  

This 6-patch series depends on the rm/p4-submit-with-commit-option
that came without and still waiting for a sign-off by the original
author.  Also I do not think the original patch reached the public
list, so I'm attaching the patch to make sure people know which
patch I am talking about.

Romain, can we get your sign-off on the patch you sent earlier?

Thanks.

-- >8 --
From: Romain Merland 
Date: Wed, 9 May 2018 17:32:12 +0200
Subject: [PATCH] git-p4: add options --commit and --disable-rebase

On a daily work with multiple local git branches, the usual way to
submit only a specified commit was to cherry-pick the commit on
master then run git-p4 submit.  It can be very annoying to switch
between local branches and master, only to submit one commit.  The
proposed new way is to select directly the commit you want to
submit.

Add option --commit to command 'git-p4 submit' in order to submit
only specified commit(s) in p4.

On a daily work developping software with big compilation time, one
may not want to rebase on his local git tree, in order to avoid long
recompilation.

Add option --disable-rebase to command 'git-p4 submit' in order to
disable rebase after submission.

Reviewed-by: Luke Diamand 
Signed-off-by: Junio C Hamano 
---
 Documentation/git-p4.txt | 14 ++
 git-p4.py| 29 +++--
 t/t9807-git-p4-submit.sh | 40 
 3 files changed, 77 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index d8c8f11c9f..88d109debb 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -149,6 +149,12 @@ To specify a branch other than the current one, use:
 $ git p4 submit topicbranch
 
 
+To specify a single commit or a range of commits, use:
+
+$ git p4 submit --commit 
+$ git p4 submit --commit 
+
+
 The upstream reference is generally 'refs/remotes/p4/master', but can
 be overridden using the `--origin=` command-line option.
 
@@ -330,6 +336,14 @@ These options can be used to modify 'git p4 submit' 
behavior.
p4/master.  See the "Sync options" section above for more
information.
 
+--commit |::
+Submit only the specified commit or range of commits, instead of the full
+list of changes that are in the current Git branch.
+
+--disable-rebase::
+Disable the automatic rebase after all commits have been successfully
+submitted.
+
 Rebase options
 ~~
 These options can be used to modify 'git p4 rebase' behavior.
diff --git a/git-p4.py b/git-p4.py
index 7bb9cadc69..f4a6f3b4c3 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1352,7 +1352,12 @@ def __init__(self):
 optparse.make_option("--update-shelve", dest="update_shelve", 
action="append", type="int",
  metavar="CHANGELIST",
  help="update an existing shelved 
changelist, implies --shelve, "
-   "repeat in-order for multiple 
shelved changelists")
+   "repeat in-order for multiple 
shelved changelists"),
+optparse.make_option("--commit", dest="commit", 
metavar="COMMIT",
+ help="submit only the specified 
commit(s), one commit or xxx..xxx"),
+optparse.make_option("--disable-rebase", 
dest="disable_rebase", action="store_true",
+ help="Disable rebase after submit is 
completed. Can be useful if you "
+ "work from a local git branch that is not 
master")
 ]
 self.description = "Submit changes from git to the perforce depot."
 self.usage += " [name of git branch to submit into perforce depot]"
@@ -1362,6 +1367,8 @@ def __init__(self):
 self.dry_run = False
 self.shelve = False
 self.update_shelve = list()
+self.commit = ""
+self.disable_rebase = False
 self.prepare_p4_only = False
 self.conflict_behavior = None
 self.isWindows = (platform.system() == "Windows")
@@ -2103,9 +2110,18 @@ def run(self, args):
 else:
 commitish = 'HEAD'
 
-for line in read_pipe_lines(["git", "rev-list", "--no-merges", 
"%s..%s" % (self.origin, commitish)]):
- 

[PATCHv2 0/6] git-p4: some small fixes updated

2018-06-08 Thread Luke Diamand
This is an updated version of the set of changes I posted recently,
following comments on the list:

disable automatic sync after git-p4 submit:
https://marc.info/?l=git=152818734814838=2

better handling of being logged out by Perforce:
   https://marc.info/?l=git=152818893815326=2

adapt the block size automatically on git-p4 submit:
   https://marc.info/?l=git=152819004315688=2

- Spelling corrections (Eric)
- Improved comments (Eric)
- Exception class hierarchy fix (Merland)
- test simplification (Eric)


Luke Diamand (6):
  git-p4: disable-rebase: allow setting this via configuration
  git-p4: add option to disable syncing of p4/master with p4
  git-p4: better error reporting when p4 fails
  git-p4: raise exceptions from p4CmdList based on error from p4 server
  git-p4: narrow the scope of exceptions caught when parsing an int
  git-p4: auto-size the block

 Documentation/git-p4.txt |  13 +++-
 git-p4.py| 161 +--
 t/t9818-git-p4-block.sh  |   8 ++
 t/t9833-errors.sh|  78 +++
 4 files changed, 236 insertions(+), 24 deletions(-)
 create mode 100755 t/t9833-errors.sh

-- 
2.17.0.392.gdeb1a6e9b7