bundle: exit early when there are no commits to bundle stable
authorDurham Goode <durham@fb.com>
Tue, 19 Jan 2016 13:43:50 -0800
branchstable
changeset 27911 645e78845383
parent 27910 d2c5ad3deccb
child 27912 ae4e6b80f084
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.
mercurial/commands.py
tests/test-bundle.t
--- 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]