Patchwork [01,of,10] changegroup: move source check to top of addchangegroup

login
register
mail settings
Submitter Augie Fackler
Date Oct. 14, 2015, 5:34 p.m.
Message ID <57a54add8a79b24d5f47.1444844066@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/11052/
State Accepted
Headers show

Comments

Augie Fackler - Oct. 14, 2015, 5:34 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1444766045 14400
#      Tue Oct 13 15:54:05 2015 -0400
# Node ID 57a54add8a79b24d5f47484d214493aff68713ab
# Parent  335b06e9a9cab0bebb527718e1c80daf1560141d
changegroup: move source check to top of addchangegroup

This is preparation for some refactoring.
Gregory Szorc - Oct. 14, 2015, 11:45 p.m.
On Wed, Oct 14, 2015 at 10:34 AM, Augie Fackler <raf@durin42.com> wrote:

> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1444766045 14400
> #      Tue Oct 13 15:54:05 2015 -0400
> # Node ID 57a54add8a79b24d5f47484d214493aff68713ab
> # Parent  335b06e9a9cab0bebb527718e1c80daf1560141d
> changegroup: move source check to top of addchangegroup
>
>
This entire series LGTM. Some parts will need additional refactoring to
support bundle2. But that is scope bloat. This is a step towards a unified
.apply() interface, which I wholeheartedly support.

Patch

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -730,6 +730,9 @@  def addchangegroup(repo, source, srctype
     - fewer heads than before: -1-removed heads (-2..-n)
     - number of heads stays the same: 1
     """
+    if not source:
+        return 0
+
     repo = repo.unfiltered()
     def csmap(x):
         repo.ui.debug("add changeset %s\n" % short(x))
@@ -738,9 +741,6 @@  def addchangegroup(repo, source, srctype
     def revmap(x):
         return cl.rev(x)
 
-    if not source:
-        return 0
-
     changesets = files = revisions = 0
 
     tr = repo.transaction("\n".join([srctype, util.hidepassword(url)]))