changeset 37776:141017c7f7a9

log: fix crash on empty revision with --copies switch If a revset is empty, .max() raises ValueError. I don't see any reason to recompute the revs, so I made it reuse the one returned by logcmdutil.getrevs(). If no revs specified by command line, the endrev will be smartset.spanset(repo) + 1, which is basically the same as len(repo), the default of getrenamedfn(). If --follow specified, revs.max() points to the working parent, which seems more correct.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 13 Apr 2018 23:45:07 +0900
parents 03d7f885d5f2
children a4cac7b0ea4f
files mercurial/commands.py tests/test-log.t
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Apr 17 21:59:58 2018 +0900
+++ b/mercurial/commands.py	Fri Apr 13 23:45:07 2018 +0900
@@ -3477,8 +3477,8 @@
     getrenamed = None
     if opts.get('copies'):
         endrev = None
-        if opts.get('rev'):
-            endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
+        if revs:
+            endrev = revs.max() + 1
         getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
 
     ui.pager('log')
--- a/tests/test-log.t	Tue Apr 17 21:59:58 2018 +0900
+++ b/tests/test-log.t	Fri Apr 13 23:45:07 2018 +0900
@@ -656,6 +656,9 @@
   6 
 #endif
 
+log copies, empty set
+
+  $ hg log --copies -r '0 and not 0'
 
 log -p d