Re: PATCH: git-p4 optional handling of RCS keywords

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



dhruva <dhruva@xxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux