[PATCH STABLE] bundlerepo: handle empty repos to avoid requesting invalid bundles (issue2907)

timeless timeless at gmail.com
Wed Jul 27 15:45:04 CDT 2011


This has a qfold artefact

On 7/27/11, Andrew Pritchard <andrewp at fogcreek.com> wrote:
> # HG changeset patch
> # User Andrew Pritchard <andrewp at fogcreek.com>
> # Date 1311795774 14400
> # Branch stable
> # Node ID 33a3f1698e9d173dea47ff305eb6383a13c50d4e
> # Parent  56848e2bb0c5a43b580dd2ca7ce1e781d4e75b2b
> bundlerepo: handle empty repos to avoid requesting invalid bundles
> (issue2907)
>
> The server cannot sanely return a bundle with common=[] and heads=[nullid],
> so
> when findcommonincoming reports that the remote repo has only the null id as
> its heads, act as if all remote heads were known locally (because the null
> id
> is not a real head).
>
> This fixes a crash when using hg incoming --bundle with an empty remote repo
> and a non-empty local repo.
> * * *
> tests: add test case for issue2907
>
> Test that 'hg incoming' does not crash when the local repository has
> changesets
> and the remote repository is empty
>
> diff -r 56848e2bb0c5 -r 33a3f1698e9d mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py	Fri Jul 22 20:31:15 2011 -0300
> +++ b/mercurial/bundlerepo.py	Wed Jul 27 15:42:54 2011 -0400
> @@ -313,7 +313,7 @@
>      '''
>      tmp = discovery.findcommonincoming(repo, other, heads=onlyheads,
> force=force)
>      common, incoming, rheads = tmp
> -    if not incoming:
> +    if not incoming or rheads == [nullid]:
>          try:
>              os.unlink(bundlename)
>          except OSError:
> diff -r 56848e2bb0c5 -r 33a3f1698e9d tests/test-incoming-outgoing.t
> --- a/tests/test-incoming-outgoing.t	Fri Jul 22 20:31:15 2011 -0300
> +++ b/tests/test-incoming-outgoing.t	Wed Jul 27 15:42:54 2011 -0400
> @@ -465,3 +465,16 @@
>    date:        Thu Jan 01 00:00:00 1970 +0000
>    summary:     11
>
> +
> +incoming from empty remote repository
> +
> +  $ hg init r1
> +  $ hg init r2
> +  $ echo a > r1/foo
> +  $ hg -R r1 ci -Ama
> +  adding foo
> +  $ hg -R r1 incoming r2 --bundle x.hg
> +  comparing with r2
> +  searching for changes
> +  no changes found
> +  [1]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

-- 
Sent from my mobile device


More information about the Mercurial-devel mailing list