Re: PATCH: git-p4 optional handling of RCS keywords
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 10, 2008, 05:35 UTC
- Message-ID
- <7vabegzhpl.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <201191.94038.qm@web95010.mail.in2.yahoo.com>
dhruva <dhruva@ymail.com> writes:
Show 13 quoted lines
> @@ -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.