# HG changeset patch # User Yuya Nishihara # Date 2018-04-13 14:45:07 # Node ID 141017c7f7a96a44c8fabb12b5d2b30d911abb24 # Parent 03d7f885d5f2cbf25ebcb205a7ed90e6b864a892 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. diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3477,8 +3477,8 @@ def log(ui, repo, *pats, **opts): 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') diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -656,6 +656,9 @@ log copies, execute bit set 6 #endif +log copies, empty set + + $ hg log --copies -r '0 and not 0' log -p d