[Python-Dev] Generating patch files

"Martin v. Löwis" martin at v.loewis.de
Wed Mar 16 18:49:42 CET 2011


I think I figured out how to generate a single patch for
a clone that has all its changes on the default branch,
comparing it with cpython's default branch. The command to generate
the patch is

hg diff -r'max(p1(min(outgoing())) or p2(max(merge() and 
branch(default))))' -r default

If it's a branch different from default, replace 'default' in both 
places with the branch name.

I'd be curious for people to try this out and report whether it works 
correctly. You'll need a Mercurial release supporting revsets.

Here is the theory of operation: The diff needs to be either from
the oldest of the commits (in case no merges have been made from 
cpython), or from cpython's code in that was last merged. So:

- merge() gives all changesets that are merges
- branch(default) gives all changesets on the default branch
- 'merge() and branch(default)' gives all merges to the default
   branch
- max(merge() and branch(default)) gives the most recent merge
   to the default branch
- p2(max(merge() and branch(default))) is the second parent,
   which will be the upstream version of cpython that got last
   merged
- outgoing() gives all changes in the local repository not
   in cpython
- min(outgoing()) gives the first local change made
- p1(min(outgoing())) gives revision that was the starting
   point for the local modifications
- max(p1(...) or p2(...)) determines which of the two is
   later.

Having the revision of cpython to compare against is the
difficult part; the other revision must be default's head,
which is always called 'default'.

Enjoy,
Martin


More information about the Python-Dev mailing list