From: Junio C Hamano <gitster@pobox.com>
To: dhruva <dhruva@ymail.com>
Cc: Simon Hausmann <simon@lst.de>, GIT SCM <git@vger.kernel.org>,
Jing Xue <jingxue@digizenstudio.com>
Subject: Re: PATCH: git-p4 optional handling of RCS keywords
Date: Tue, 09 Sep 2008 22:35:18 -0700 [thread overview]
Message-ID: <7vabegzhpl.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <201191.94038.qm@web95010.mail.in2.yahoo.com> (dhruva@ymail.com's message of "Wed, 10 Sep 2008 10:43:26 +0530 (IST)")
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.
next prev parent reply other threads:[~2008-09-10 5:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
[not found] <646617.59689.qm@web95011.mail.in2.yahoo.com>
2008-09-10 19:18 ` PATCH: git-p4 optional handling of RCS keywords Simon Hausmann
-- strict thread matches above, loose matches on Subject: below --
2008-09-11 4:06 dhruva
2008-09-11 6:33 ` Tor Arvid Lund
2008-09-11 7:13 dhruva
2008-09-11 9:18 dhruva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vabegzhpl.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=dhruva@ymail.com \
--cc=git@vger.kernel.org \
--cc=jingxue@digizenstudio.com \
--cc=simon@lst.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).