Patchwork [7,of,7] bundle: factor the 'getchangegroup' out

login
register
mail settings
Submitter Pierre-Yves David
Date May 5, 2017, 6:26 a.m.
Message ID <c37d9a61b50c2175926b.1493965617@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20454/
State Accepted
Headers show

Comments

Pierre-Yves David - May 5, 2017, 6:26 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1493894925 -7200
#      Thu May 04 12:48:45 2017 +0200
# Node ID c37d9a61b50c2175926b533ae3eea8277b230c04
# Parent  5ff659101e17aa1e2b63ddd0efd5e2b0bcb7b226
# EXP-Topic bundle.cleanup
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r c37d9a61b50c
bundle: factor the 'getchangegroup' out

The call in the two branches is identical, so we can just issue it outside of
the conditional.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1357,8 +1357,6 @@  def bundle(ui, repo, fname, dest=None, *
         common = [repo.lookup(rev) for rev in base]
         heads = revs and map(repo.lookup, revs) or None
         outgoing = discovery.outgoing(repo, common, heads)
-        cg = changegroup.getchangegroup(repo, 'bundle', outgoing,
-                                        version=cgversion)
     else:
         dest = ui.expandpath(dest or 'default-push', dest or 'default')
         dest, branches = hg.parseurl(dest, opts.get('branch'))
@@ -1369,8 +1367,7 @@  def bundle(ui, repo, fname, dest=None, *
                                                 onlyheads=heads,
                                                 force=opts.get('force'),
                                                 portable=True)
-        cg = changegroup.getchangegroup(repo, 'bundle', outgoing,
-                                             version=cgversion)
+    cg = changegroup.getchangegroup(repo, 'bundle', outgoing, version=cgversion)
     if not cg:
         scmutil.nochangesfound(ui, repo, not base and outgoing.excluded)
         return 1