Patchwork [3,of,3] changegroup: don't fail on empty changegroup (API)

login
register
mail settings
Submitter via Mercurial-devel
Date July 5, 2017, 10:12 p.m.
Message ID <d4e1f3ac5a45534203ca.1499292754@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/22023/
State Accepted
Headers show

Comments

via Mercurial-devel - July 5, 2017, 10:12 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1498892339 25200
#      Fri Jun 30 23:58:59 2017 -0700
# Node ID d4e1f3ac5a45534203caafe5bd7bd66f3b54c4e0
# Parent  748b0ea7aa3b88ef8ccdd236339d9a2daba18f54
changegroup: don't fail on empty changegroup (API)

I don't know why applying an empty changegroup should be an error. It
seems harmless. I suspect the check was there to find code that
creates empty changegroups just because that would be wasteful. Let's
use develwarn() for that instead, so we catch any such cases that run
with our test runner, but we still allow others to generate empty
changegroups if they want to.

We have run into this check at Google once or twice and had to work
around it, but I'm changing this not so much because of that, but
because it seems like it shouldn't be an error.

I also changed the message slightly to be more modern ("changelog
group" -> "changegroup") and more generic ("received" -> "applied").
Sean Farley - July 6, 2017, 10:34 p.m.
Martin von Zweigbergk via Mercurial-devel <mercurial-devel@mercurial-scm.org> writes:

> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1498892339 25200
> #      Fri Jun 30 23:58:59 2017 -0700
> # Node ID d4e1f3ac5a45534203caafe5bd7bd66f3b54c4e0
> # Parent  748b0ea7aa3b88ef8ccdd236339d9a2daba18f54
> changegroup: don't fail on empty changegroup (API)
>
> I don't know why applying an empty changegroup should be an error. It
> seems harmless. I suspect the check was there to find code that
> creates empty changegroups just because that would be wasteful. Let's
> use develwarn() for that instead, so we catch any such cases that run
> with our test runner, but we still allow others to generate empty
> changegroups if they want to.
>
> We have run into this check at Google once or twice and had to work
> around it, but I'm changing this not so much because of that, but
> because it seems like it shouldn't be an error.
>
> I also changed the message slightly to be more modern ("changelog
> group" -> "changegroup") and more generic ("received" -> "applied").

Makes sense to me. Queued!

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -298,7 +298,8 @@ 
             efiles = len(efiles)
 
             if not cgnodes:
-                raise error.Abort(_("received changelog group is empty"))
+                repo.ui.develwarn('applied empty changegroup',
+                                  config='empty-changegroup')
             clend = len(cl)
             changesets = clend - clstart
             repo.ui.progress(_('changesets'), None)