bholley and I have a script for doing this in git.  With thanks to
glandium for telling us how to do it:

0. Fetch the prtypes change, and merge it into your local master branch.

1. Let your git checkout be directory |src|.

2. Save the script at the end of this message as src/../convert.sh.

3. For each branch B that you want to rebase over this change, do:

a. $ git checkout B.  Maybe make a note of the hash, so you can
reset --hard in case something goes wrong.

b. Let P be the parent changeset of B.  This is the result of |git
qparent|, if you have moz-git-tools [1] installed.  Otherwise it's
|git merge-base B origin/master|, assuming that your branch is
upstream from origin/master.

c. $ git filter-branch --tree-filter /absolute/path/to/convert.sh P^..

Note that it's "P^.." and not "P..".  This is because we want to
convert P and also all of the commits in B (and the rev range P.. does
not include P).  We're effectively applying the pr-types change to P
and all changesets in B.

d. Let P' be the new parent changeset of B.  (The hash has changed,
since we rewrote this commit.)

e. $ git rebase --onto master P'

Note that |git rebase master| will not do what you want, because
that will try to move P' onto master.  But P' is already in master!
If in doubt, do rebase --interactive, so you can see what git is going
to try to do.


The git apologist in me feels compelled to admit that this is, in
fact, much more complicated than the equivalent task in hg.  :)

Good luck!

[1] https://github.com/jlebar/moz-git-tools

== convert.sh ==

#!/bin/bash
# This could be faster, but maybe it's good enough.

function convert() {
  git ls-files | grep '\.cpp$\|\.idl$\|\.h$' | xargs grep -l $1 |
xargs -n1 sed -i '' -e "s/$1/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t
convert PRIntn int32_t
convert PRUintn uint32_t
convert PRSize size_t
convert PROffset32 int32_t
convert PROffset64 int64_t
convert PRPtrdiff ptrdiff_t
convert PRFloat64 double

On Wed, Aug 22, 2012 at 12:25 PM, Ehsan Akhgari <ehsan.akhg...@gmail.com> wrote:
> On 12-08-22 3:18 PM, Jonathan Kew wrote:
>>
>> On 22/8/12 17:35, Ehsan Akhgari wrote:
>>>
>>> I just landed the patches in bug 579517 which switch all of the code in
>>> mozilla-central and comm-central [1] to use the standard integer types
>>> as opposed to NSPR integer types.  Here's what this means to you:
>>>
>>> * If you're a developer, this will most likely bitrot your patches.  You
>>> can use this script [2] in order to unbitrot your patches if you use
>>> mercurial queues.
>>
>>
>>> [2] https://bugzilla.mozilla.org/attachment.cgi?id=650572
>>
>>
>> Beware that this script is slightly obsolete, inasmuch as it converts
>> PRIntn/PRUintn to int32_t/uint32_t (should be int/unsigned).
>
>
> Good point.  But you should've called the cops if anyone used those types in
> their patches in the first place.  ;-)
>
> Ehsan
>
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to