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