changeset 27911:645e78845383 stable

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.
author Durham Goode <durham@fb.com>
date Tue, 19 Jan 2016 13:43:50 -0800
parents d2c5ad3deccb
children ae4e6b80f084
files mercurial/commands.py tests/test-bundle.t
diffstat 2 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Jan 17 20:37:29 2016 -0800
+++ b/mercurial/commands.py	Tue Jan 19 13:43:50 2016 -0800
@@ -1328,7 +1328,10 @@
     """
     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:
--- a/tests/test-bundle.t	Sun Jan 17 20:37:29 2016 -0800
+++ b/tests/test-bundle.t	Tue Jan 19 13:43:50 2016 -0800
@@ -728,4 +728,8 @@
   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]