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

Augie Fackler raf at durin42.com
Wed Oct 14 17:34:26 UTC 2015


# HG changeset patch
# User Augie Fackler <augie at 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.

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)]))


More information about the Mercurial-devel mailing list