* Re: PATCH: git-p4 optional handling of RCS keywords
@ 2008-09-11 4:06 dhruva
2008-09-11 6:33 ` Tor Arvid Lund
0 siblings, 1 reply; 6+ messages in thread
From: dhruva @ 2008-09-11 4:06 UTC (permalink / raw)
To: Simon Hausmann; +Cc: Junio C Hamano, GIT SCM, Jing Xue
Hello,
Commit message: Modifying RCS keywords prevents submitting to p4 from git due to missing hunks. Optional shrinking of RCS keywords in git-p4. New option git-p4.kwstrip set to true or false controls the behavior..
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2216cac..ac8b7f7 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -16,6 +16,9 @@ from sets import Set;
verbose = False
+# Handling of RCS keyowrds. To ensure backward compatibility, the default
+# is to strip keywords. Default behavior is controlled here
+kwstrip = True
def p4_build_cmd(cmd):
"""Build a suitable p4 command line.
@@ -975,7 +978,9 @@ class P4Sync(Command):
sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
continue
- if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
+ if not kwstrip:
+ pass
+ elif stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
@@ -1850,6 +1855,16 @@ def main():
(cmd, args) = parser.parse_args(sys.argv[2:], cmd);
global verbose
verbose = cmd.verbose
+
+ global kwstrip
+ kwval = gitConfig("git-p4.kwstrip")
+ if len(kwval) > 0:
+ kwval = kwval.lower();
+ if kwval == "false":
+ kwstrip = False
+ elif kwval == "true":
+ kwstrip = True
+
if cmd.needsGit:
if cmd.gitdir == None:
cmd.gitdir = os..path.abspath(".git")
-dhruva
----- Original Message ----
> From: Simon Hausmann <simon@lst.de>
> > + kwval = kwval.lower();
> > + if "false" == kwval:
> > + kwstrip = False
> > + elif "true" == kwval:
> > + kwstrip = True
>
> I have another style nitpick, sorry :). Please use "kwval == "false" instead
> of the other way around.
There was a reason for keeping the constant as lvalue to avoid typos like '=' instead from '==' from 'C' school, I realize that python throws an error when such things happen. Must say that programming languages are becoming smarter and taking away the charm of programming...
> Otherwise your patch looks good to me, I think it's a very good option to add.
> Please resend with commit message so that Junio can include it.
Add more friends to your messenger and enjoy! Go to http://in.messenger.yahoo.com/invite/
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: PATCH: git-p4 optional handling of RCS keywords
2008-09-11 4:06 PATCH: git-p4 optional handling of RCS keywords dhruva
@ 2008-09-11 6:33 ` Tor Arvid Lund
0 siblings, 0 replies; 6+ messages in thread
From: Tor Arvid Lund @ 2008-09-11 6:33 UTC (permalink / raw)
To: dhruva; +Cc: Simon Hausmann, Junio C Hamano, GIT SCM, Jing Xue
On Thu, Sep 11, 2008 at 6:06 AM, dhruva <dhruva@ymail.com> wrote:
> Hello,
>
>
> Commit message: Modifying RCS keywords prevents submitting to p4 from git due to missing hunks. Optional shrinking of RCS keywords in git-p4. New option git-p4.kwstrip set to true or false controls the behavior..
<snip away the diff>
Me guesses that Junio (who gets loads of patches) would be happy if you do:
1) Squash these changes down to one single commit
2) Run git format-patch -1
3) Send it to the list either with git send-email, or otherwise send
the 0001-<your-commit-summary>.patch to the list directly if your
mailer supports it.
The reason is simply that the maintainer can simply use git am
<your-raw-mail-message-file> to commit it, instead of having to
manually sift through the emails.
Otherwise, this is nice work. Thanks.
-Tor Arvid-
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PATCH: git-p4 optional handling of RCS keywords
@ 2008-09-11 9:18 dhruva
0 siblings, 0 replies; 6+ messages in thread
From: dhruva @ 2008-09-11 9:18 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Simon Hausmann, Tor Arvid Lund, GIT SCM, Jing Xue
>From aa822b35925b893de049b6cc4d1531dc476ade56 Mon Sep 17 00:00:00 2001
From: Dhruva Krishnamurthy <dhruva@siml6.eng.btc.netapp.in>
Date: Thu, 11 Sep 2008 14:36:32 +0530
Subject: [PATCH] Modifying RCS keywords prevents submitting to p4 from git due to missing hunks. Optional shrinking of RCS keywords in git-p4. New option git-p4.kwstrip set to true or false controls the behavior
Signed-off-by: Dhruva Krishnamurthy <dhruva@ymail.com>
---
contrib/fast-import/git-p4 | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2216cac..ac8b7f7 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -16,6 +16,9 @@ from sets import Set;
verbose = False
+# Handling of RCS keyowrds. To ensure backward compatibility, the default
+# is to strip keywords. Default behavior is controlled here
+kwstrip = True
def p4_build_cmd(cmd):
"""Build a suitable p4 command line.
@@ -975,7 +978,9 @@ class P4Sync(Command):
sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
continue
- if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
+ if not kwstrip:
+ pass
+ elif stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
@@ -1850,6 +1855,16 @@ def main():
(cmd, args) = parser.parse_args(sys.argv[2:], cmd);
global verbose
verbose = cmd.verbose
+
+ global kwstrip
+ kwval = gitConfig("git-p4.kwstrip")
+ if len(kwval) > 0:
+ kwval = kwval.lower();
+ if kwval == "false":
+ kwstrip = False
+ elif kwval == "true":
+ kwstrip = True
+
if cmd.needsGit:
if cmd.gitdir == None:
cmd.gitdir = os.path.abspath(".git")
--
1.6.0.1.442.g17b2f
-dhruva
Get an email ID as yourname@ymail.com or yourname@rocketmail.com. Click here http://in.promos.yahoo.com/address
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: PATCH: git-p4 optional handling of RCS keywords
@ 2008-09-11 7:13 dhruva
0 siblings, 0 replies; 6+ messages in thread
From: dhruva @ 2008-09-11 7:13 UTC (permalink / raw)
To: Tor Arvid Lund; +Cc: Simon Hausmann, Junio C Hamano, GIT SCM, Jing Xue
Hi,
The patch I have sent is 1 single patch.
----- Original Message ----
> From: Tor Arvid Lund <torarvid@gmail.com>
> To: dhruva <dhruva@ymail.com>
> Me guesses that Junio (who gets loads of patches) would be happy if you do:
>
> 1) Squash these changes down to one single commit
> 2) Run git format-patch -1
> 3) Send it to the list either with git send-email, or otherwise send
> the 0001-.patch to the list directly if your
> mailer supports it.
Let me start learning that now. I have added my own extensions on top of what I have submitted, I need to figure out a way to do all these stuff (I am still a newbie to git ;)
-dhruva
Get an email ID as yourname@ymail.com or yourname@rocketmail.com. Click here http://in.promos.yahoo.com/address
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <646617.59689.qm@web95011.mail.in2.yahoo.com>]
* Re: PATCH: git-p4 optional handling of RCS keywords
[not found] <646617.59689.qm@web95011.mail.in2.yahoo.com>
@ 2008-09-10 19:18 ` Simon Hausmann
0 siblings, 0 replies; 6+ messages in thread
From: Simon Hausmann @ 2008-09-10 19:18 UTC (permalink / raw)
To: dhruva; +Cc: Junio C Hamano, GIT SCM, Jing Xue
[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]
On Wednesday 10 September 2008 08:29:56 dhruva wrote:
> Hi,
> Incorporated the style tip, sure makes it look cleaner.
>
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index 2216cac..3e72e43 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -16,6 +16,9 @@ from sets import Set;
>
> verbose = False
>
> +# Handling of RCS keyowrds. To ensure backward compatibility, the default
> +# is to strip keywords. Default behavior is controlled here
> +kwstrip = True
>
> def p4_build_cmd(cmd):
> """Build a suitable p4 command line.
> @@ -975,7 +978,9 @@ class P4Sync(Command):
> sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
> continue
>
> - if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
> + if not kwstrip:
> + pass
> + elif stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
> text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
> elif stat['type'] in ('text+k', 'ktext', 'kxtext',
> 'unicode+k', 'binary+k'): text =
> re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r
>'$\1$', text) @@ -1850,6 +1855,16 @@ def main():
> (cmd, args) = parser.parse_args(sys.argv[2:], cmd);
> global verbose
> verbose = cmd.verbose
> +
> + global kwstrip
> + kwval = gitConfig("git-p4.kwstrip")
> + if len(kwval) > 0:
> + kwval = kwval.lower();
> + if "false" == kwval:
> + kwstrip = False
> + elif "true" == kwval:
> + kwstrip = True
I have another style nitpick, sorry :). Please use "kwval == "false" instead
of the other way around.
Otherwise your patch looks good to me, I think it's a very good option to add.
Please resend with commit message so that Junio can include it.
Simon
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and keyword expansion]
@ 2008-09-10 5:13 dhruva
2008-09-10 5:35 ` PATCH: git-p4 optional handling of RCS keywords Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: dhruva @ 2008-09-10 5:13 UTC (permalink / raw)
To: Simon Hausmann; +Cc: GIT SCM, Jing Xue
Hello,
I would like to submit my first patch to the git community.
I have introduced a new configuration option to 'git-p4' "kwstrip". If enabled, the RCS keywords gets unexpanded like it is done with out the patch and disabling it explicitly retains the RCS keywords as in the original p4 source. The default (in the absence) is 'false' to ensure backward compatibility. To override, you can put the following lines in your '.gitconfig' file..
[git-p4]
kwstrip = false
The patch to git-p4 (based on origin/next branch):
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2216cac..ad37d0b 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -16,6 +16,9 @@ from sets import Set;
verbose = False
+# Handling of RCS keyowrds. To ensure backward compatibility, the default
+# is to strip keywords. Default behavior is controlled here
+kwstrip = True
def p4_build_cmd(cmd):
"""Build a suitable p4 command line.
@@ -975,10 +978,11 @@ class P4Sync(Command):
sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
continue
- if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
- text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
- elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
- text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
+ if kwstrip:
+ if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
+ text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
+ elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
+ text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
contents[stat['depotFile']] = text
@@ -1850,6 +1854,16 @@ def main():
(cmd, args) = parser.parse_args(sys..argv[2:], cmd);
global verbose
verbose = cmd.verbose
+
+ global kwstrip
+ kwval = gitConfig("git-p4.kwstrip")
+ if len(kwval) > 0:
+ kwval = kwval.lower();
+ if "false" == kwval:
+ kwstrip = False
+ else if "true" == kwval:
+ kwstrip = True
+
if cmd.needsGit:
if cmd.gitdir == None:
cmd.gitdir = os.path.abspath(".git")
----- Original Message ----
> From: Jing Xue <jingxue@digizenstudio.com>
> To: dhruva <dhruva@ymail.com>
> Cc: GIT SCM <git@vger.kernel.org>
> Sent: Tuesday, 9 September, 2008 11:08:48 PM
> Subject: Re: git-p4 and keyword expansion
>
> On Tue, Sep 09, 2008 at 04:44:11PM +0530, dhruva wrote:
> > Hello,
>
> Hi,
>
> > I feel the configuration must be set the first time only, when you
> > clone using 'git-p4 clone'. Altering it in between will be very
> > confusing!
> > Ideally, the setting must be transferred when the git repo
> > (cloned from git-p4) is cloned using standard git. Is it something
> > possible (well, I am new to git and am exploring. Any extra
> > information would help).
> >
> > My proposal is as follows:
> > 1. Add an extra command line argument to 'git-p4 clone' to either
> > enable/disable keyword expansion
> > 2. Store that information under the .git folder in a file that is
> > copied when someone clones that repo
> > 3. Use the stored information in future 'git-p4 sync/rebase'
>
> Any way to make it optional would be welcome by me.
Done
> If you do come up with a "formal" patch, you might want to
> explicitly add Simon Hausmann to the To list, for he's the git-p4
> author.
Done
-dhruva
Add more friends to your messenger and enjoy! Go to http://in.messenger.yahoo.com/invite/
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: PATCH: git-p4 optional handling of RCS keywords
2008-09-10 5:13 PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and keyword expansion] dhruva
@ 2008-09-10 5:35 ` Junio C Hamano
0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2008-09-10 5:35 UTC (permalink / raw)
To: dhruva; +Cc: Simon Hausmann, GIT SCM, Jing Xue
dhruva <dhruva@ymail.com> writes:
> @@ -975,10 +978,11 @@ class P4Sync(Command):
> sys.stderr.write("p4 print fails with: %s\n" % repr(stat))
> continue
>
> - if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
> - text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
> - elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
> - text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
> + if kwstrip:
> + if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
> + text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
> + elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
> + text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|File|Revision):[^$]*\$',r'$\1$', text)
A style tip.
It makes it easier to convince others that you didn't screw up in the
conversion if you cascade the code this way instead:
- if stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
+ if not kwstrip:
+ pass
+ elif stat['type'] in ('text+ko', 'unicode+ko', 'binary+ko'):
text = re.sub(r'(?i)\$(Id|Header):[^$]*\$',r'$\1$', text)
elif stat['type'] in ('text+k', 'ktext', 'kxtext', 'unicode+k', 'binary+k'):
text = re.sub(r'\$(Id|Header|Author|Date|DateTime|Change|...
This technique not just only makes the patch smaller and easier to review,
it also makes the result less deeply nested and easier to read as well.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-09-11 9:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-11 4:06 PATCH: git-p4 optional handling of RCS keywords dhruva
2008-09-11 6:33 ` Tor Arvid Lund
-- strict thread matches above, loose matches on Subject: below --
2008-09-11 9:18 dhruva
2008-09-11 7:13 dhruva
[not found] <646617.59689.qm@web95011.mail.in2.yahoo.com>
2008-09-10 19:18 ` Simon Hausmann
2008-09-10 5:13 PATCH: git-p4 optional handling of RCS keywords [was: Re: git-p4 and keyword expansion] dhruva
2008-09-10 5:35 ` PATCH: git-p4 optional handling of RCS keywords Junio C Hamano
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).