# HG changeset patch # User Yuya Nishihara <y...@tcha.org> # Date 1523630707 -32400 # Fri Apr 13 23:45:07 2018 +0900 # Node ID 775ad61e04e28c49c78c7936d88826a3df024781 # Parent 8bacc09814ba5500d15fb40c472e84cb95ae2f99 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 @@ -3463,8 +3463,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 _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel