# HG changeset patch # User Peter Arrenbrecht # Date 2011-05-05 10:53:33 # Node ID e3dd3dcd6059d008f466ea31a2a0b43de9e8d47f # Parent 8f11fd321014d3dd555fe9eb4de01dc81e9e4f1b treediscovery: fix regression when run against older repos (issue2793) I ran the entire test suite with "known" and "getbundle" disabled in localrepository. This generated failures because the old findoutgoing had always queried remote's heads explicitly and thus always got them back in the returned heads. treediscovery.findcommonincoming now correctly returns remote's heads in all cases. Also adds a dedicated test for running treediscovery against a pre-getbundle HTTP server. diff --git a/mercurial/treediscovery.py b/mercurial/treediscovery.py --- a/mercurial/treediscovery.py +++ b/mercurial/treediscovery.py @@ -33,7 +33,7 @@ def findcommonincoming(repo, remote, hea base.add(nullid) if heads != [nullid]: return [nullid], [nullid], list(heads) - return [nullid], [], [] + return [nullid], [], heads # assume we're closer to the tip than the root # and start by examining the heads @@ -46,10 +46,10 @@ def findcommonincoming(repo, remote, hea else: base.add(h) + if not unknown: + return list(base), [], list(heads) + heads = unknown - if not unknown: - return list(base), [], [] - req = set(unknown) reqcnt = 0 diff --git a/tests/test-treediscovery.t b/tests/test-treediscovery.t new file mode 100644 --- /dev/null +++ b/tests/test-treediscovery.t @@ -0,0 +1,278 @@ +Tests discovery against servers without getbundle support: + + $ CAP=getbundle + $ . "$TESTDIR/notcapable" + $ echo '[ui]' >>$HGRCPATH + $ echo 'logtemplate="{rev} {node|short}: {desc} {branches}\\n"' >>$HGRCPATH + $ echo '[extensions]' >>$HGRCPATH + $ echo 'graphlog=' >>$HGRCPATH + +Setup HTTP server control: + + $ export remote=http://localhost:$HGPORT/ + $ start() { + > echo '[web]' > $1/.hg/hgrc + > echo 'push_ssl = false' >> $1/.hg/hgrc + > echo 'allow_push = *' >> $1/.hg/hgrc + > hg serve -R $1 -p $HGPORT -d --pid-file=hg.pid -E errors.log + > cat hg.pid >> $DAEMON_PIDS + > } + $ stop() { + > "$TESTDIR/killdaemons.py" + > } + +Both are empty: + + $ hg init empty1 + $ hg init empty2 + $ start empty2 + $ hg incoming -R empty1 $remote + comparing with http://localhost:$HGPORT/ + no changes found + [1] + $ hg outgoing -R empty1 $remote + comparing with http://localhost:$HGPORT/ + no changes found + [1] + $ hg pull -R empty1 $remote + pulling from http://localhost:$HGPORT/ + no changes found + $ hg push -R empty1 $remote + pushing to http://localhost:$HGPORT/ + no changes found + $ stop + +Base repo: + + $ hg init main + $ cd main + $ hg debugbuilddag -mo '+2:tbase @name1 +3:thead1