Patchwork [STABLE] bundle: exit early when there are no commits to bundle

login
register
mail settings
Submitter Durham Goode
Date Jan. 19, 2016, 11:23 p.m.
Message ID <65decdaf0e60d76e615d.1453245835@dev8486.prn1.facebook.com>
Download mbox | patch
Permalink /patch/12838/
State Accepted
Headers show

Comments

Durham Goode - Jan. 19, 2016, 11:23 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1453239830 28800
#      Tue Jan 19 13:43:50 2016 -0800
# Branch stable
# Node ID 65decdaf0e60d76e615d599205ad9fc45ec37693
# Parent  d2c5ad3deccb5a504e2553652b66a4110db68afb
bundle: exit early when there are no commits to bundle

Previously, if you passed a revset that resolved to no nodes, it would get
interpreted by the changegroup discovery logic as 'bundle all my heads', which
is not what the user asked.

Let's exit early when we notice this case.

It could be argued that the changeset discovery logic should be smarter and only
assume 'all heads' if the incoming heads parameter is None, but that's a much
riskier change.
Matt Mackall - Jan. 20, 2016, 6:36 p.m.
On Tue, 2016-01-19 at 15:23 -0800, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1453239830 28800
> #      Tue Jan 19 13:43:50 2016 -0800
> # Branch stable
> # Node ID 65decdaf0e60d76e615d599205ad9fc45ec37693
> # Parent  d2c5ad3deccb5a504e2553652b66a4110db68afb
> bundle: exit early when there are no commits to bundle

Queued for stable, thanks.

-- 
Mathematics is the supreme nostalgia of our time.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1328,7 +1328,10 @@  def bundle(ui, repo, fname, dest=None, *
     """
     revs = None
     if 'rev' in opts:
-        revs = scmutil.revrange(repo, opts['rev'])
+        revstrings = opts['rev']
+        revs = scmutil.revrange(repo, revstrings)
+        if revstrings and not revs:
+            raise error.Abort(_('no commits to bundle'))
 
     bundletype = opts.get('type', 'bzip2').lower()
     try:
diff --git a/tests/test-bundle.t b/tests/test-bundle.t
--- a/tests/test-bundle.t
+++ b/tests/test-bundle.t
@@ -728,4 +728,8 @@  bundle single branch
   checking files
   4 files, 3 changesets, 5 total revisions
 
-  $ cd ..
+== Test bundling no commits
+
+  $ hg bundle -r 'public()' no-output.hg
+  abort: no commits to bundle
+  [255]