Finding Merges in the Wrong Direction

Matt Mackall mpm at selenic.com
Tue Nov 12 04:40:20 UTC 2013


On Tue, 2013-11-12 at 00:45 +0000, Jensen, Aaron wrote:
> Avoiding `branch(X)` gives a *huge* speedup.  This query:
> 
>     limit(children(p2(merge() and ::X) and branch(default)) and reverse(ancestors(X)))
> 
> takes about 6 seconds.  If I put the `-2000:` clause in, it takes less than a second:
> 
>     limit(children(p2(-2000 and merge() and ::X) and branch(default)) and reverse(ancestors(X)))
> 
> However, there are no guarantees that an offending changeset could be within the last 2000 changesets.  I'd like to replace it with a clause that gives me the parent of the first changeset in a branch.  Is there a quicker way than
> 
>     descendants(parents(min(branch(X)))) 

If this is a push hook, you can probably replace -2000 with the first
rev in the bundle, since you'll be looking for new bad merges.

In general, there is no way to isolate named branches quickly. Consider
this valid history graph with branches X and Y:

X-Y-X-Y-X-Y-X-Y

We only cache the locations of the heads of X and Y (ie the last two
here). The only way to find the first Y.. might involve visiting a lot
of changesets.

If you have additional knowledge about the topological structure of your
branches (like "they are connected and always branch off default"), then
you can probably do something like:

first(::X - ::default)

-- 
Mathematics is the supreme nostalgia of our time.





More information about the Mercurial mailing list