[PATCH] [discovery] simplify branchmap construction again legacy server
Joshua Redstone
joshua.redstone at fb.com
Thu Jun 21 15:33:23 UTC 2012
On 6/16/12 7:16 AM, "Pierre-Yves David" <pierre-yves.david at ens-lyon.org>
wrote:
># HG changeset patch
># User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
># Date 1339845206 -7200
># Node ID 6ae00ea2cd3290a45d71e7b57b0eb4fb17affca5
># Parent 2255950e1f7663a9faa6b57040cc5c0debe7d4dd
>[discovery] simplify branchmap construction again legacy server
>
>All necessary data to fire a simple revset query are already known. No
>call to
>ancestor are needed. Such ancestor calculation was already done to compute
>outgoing.missing.
>
>This changeset add test written by Joshua Redstone
>(<joshua.redstone at fb.com>).
>
>diff --git a/mercurial/discovery.py b/mercurial/discovery.py
>--- a/mercurial/discovery.py
>+++ b/mercurial/discovery.py
>@@ -208,15 +208,8 @@
> # Construct {old,new}map with branch = None (topological branch).
> # (code based on _updatebranchcache)
> oldheads = set(h for h in remoteheads if h in cl.nodemap)
>- newheads = oldheads.union(outgoing.missing)
>- if len(newheads) > 1:
>- for latest in reversed(outgoing.missing):
>- if latest not in newheads:
>- continue
>- minhrev = min(cl.rev(h) for h in newheads)
>- reachable = cl.reachable(latest, cl.node(minhrev))
>- reachable.remove(latest)
>- newheads.difference_update(reachable)
>+ rvset = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing)
>+ newheads = set(c.node() for c in rvset)
> branches = set([None])
> newmap = {None: newheads}
> oldmap = {None: oldheads}
>diff --git a/tests/test-treediscovery-legacy.t
>b/tests/test-treediscovery-legacy.t
>--- a/tests/test-treediscovery-legacy.t
>+++ b/tests/test-treediscovery-legacy.t
>@@ -15,6 +15,13 @@
> $ cp $HGRCPATH $HGRCPATH-nocap
> $ cp $HGRCPATH-withcap $HGRCPATH
>
>+Prep for test server without branchmap support
>+
>+ $ CAP="branchmap"
>+ $ . "$TESTDIR/notcapable"
>+ $ cp $HGRCPATH $HGRCPATH-nocap-branchmap
>+ $ cp $HGRCPATH-withcap $HGRCPATH
>+
> Setup HTTP server control:
>
> $ remote=http://localhost:$HGPORT/
>@@ -314,3 +321,51 @@
>
> $ tstop
>
>+Exercise pushing to server without branchmap capability
>+
>+ $ cp $HGRCPATH-nocap-branchmap $HGRCPATH-nocap
>+ $ hg init rlocal
>+ $ cd rlocal
>+ $ echo A > A
>+ $ hg ci -Am A
>+ adding A
>+ $ cd ..
>+ $ hg clone rlocal rremote
>+ updating to branch default
>+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
>+ $ cd rlocal
>+ $ echo B > B
>+ $ hg ci -Am B
>+ adding B
>+ $ cd ..
>+ $ tstart rremote
>+
>+ $ cd rlocal
>+ $ hg incoming $remote
>+ comparing with http://localhost:$HGPORT/
>+ searching for changes
>+ no changes found
>+ [1]
>+ $ hg outgoing $remote
>+ comparing with http://localhost:$HGPORT/
>+ searching for changes
>+ 1 27547f69f254: B
>+ $ hg pull $remote
>+ pulling from http://localhost:$HGPORT/
>+ searching for changes
>+ no changes found
>+ $ hg push $remote
>+ pushing to http://localhost:$HGPORT/
>+ searching for changes
>+ remote: adding changesets
>+ remote: adding manifests
>+ remote: adding file changes
>+ remote: added 1 changesets with 1 changes to 1 files
>+ $ hg outgoing $remote
>+ comparing with http://localhost:$HGPORT/
>+ searching for changes
>+ no changes found
>+ [1]
>+ $ cd ..
>+
>+ $ tstop
>_______________________________________________
>Mercurial-devel mailing list
>Mercurial-devel at selenic.com
>http://selenic.com/mailman/listinfo/mercurial-devel
Assuming that the set of nodes in outgoing.missing has the property that
any element of missing is either a children of oldheads or a children of
missing,
then this patch looks good, and as Pierre points out in IRC, should also
be more efficient than the current code.
More information about the Mercurial-devel
mailing list