Mercurial > hg
comparison tests/test-log-linerange.t @ 43740:d1b9d2c6ec96 stable
log: map None rev to wdirrev when filtering revisions with --line-range
When 'hg log -f --line-range <file>,<range>' is invoked with <range>
containing uncommitted changes, the command crashes on Python 3 as
follows:
[...]
File "/usr/lib/python3/dist-packages/mercurial/commands.py", line 4725, in log
revs, differ = logcmdutil.getlinerangerevs(repo, revs, opts)
File "/usr/lib/python3/dist-packages/mercurial/logcmdutil.py", line 933, in getlinerangerevs
if rev not in userrevs:
File "/usr/lib/python3/dist-packages/mercurial/smartset.py", line 969, in __contains__
if l < x:
TypeError: '<' not supported between instances of 'int' and 'NoneType'
The None value is because requested line range has uncommitted changes,
so 'rev' is the working directory revision. This only occurs in Python 3
as Python 2 allows comparing None with int.
As suggested by Yuya Nishihara, mapping None to node.wdirrev resolves
the issue and also make the '--line-range' option properly work with -r
'wdir()'. We add extra tests for non-regression and to illustrate
handling of 'wdir()'.
author | Denis Laxalde <denis@laxalde.org> |
---|---|
date | Fri, 29 Nov 2019 21:43:13 +0100 |
parents | 66d5c8c3afed |
children | 29adf0a087a1 |
comparison
equal
deleted
inserted
replaced
43739:66d5c8c3afed | 43740:d1b9d2c6ec96 |
---|---|
896 changeset: 0:5ae1f82b9a00 | 896 changeset: 0:5ae1f82b9a00 |
897 user: test | 897 user: test |
898 date: Thu Jan 01 00:00:00 1970 +0000 | 898 date: Thu Jan 01 00:00:00 1970 +0000 |
899 summary: init | 899 summary: init |
900 | 900 |
901 | |
902 Uncommitted changes in requested line range | |
903 | |
904 $ sed 's/2/ /' bazn > bazn.new | |
905 $ mv bazn.new bazn | |
906 $ hg diff | |
907 diff --git a/dir/baz b/dir/bazn | |
908 rename from dir/baz | |
909 rename to dir/bazn | |
910 --- a/dir/baz | |
911 +++ b/dir/bazn | |
912 @@ -3,7 +3,7 @@ | |
913 0 | |
914 0 | |
915 1+ | |
916 -2+ | |
917 + + | |
918 3+ | |
919 4 | |
920 5 | |
921 $ hg log -f -L bazn,5:7 | |
922 changeset: 9:6af29c3a778f | |
923 tag: tip | |
924 user: test | |
925 date: Thu Jan 01 00:00:00 1970 +0000 | |
926 summary: foo -> dir/baz; 1-1+ | |
927 | |
928 changeset: 5:cfdf972b3971 | |
929 user: test | |
930 date: Thu Jan 01 00:00:00 1970 +0000 | |
931 summary: foo: 3 -> 3+ and 11+ -> 11-; bar: a -> a+ | |
932 | |
933 changeset: 4:eaec41c1a0c9 | |
934 user: test | |
935 date: Thu Jan 01 00:00:00 1970 +0000 | |
936 summary: 11 -> 11+; leading space before "1" | |
937 | |
938 changeset: 2:63a884426fd0 | |
939 user: test | |
940 date: Thu Jan 01 00:00:00 1970 +0000 | |
941 summary: 2 -> 2+; added bar | |
942 | |
943 changeset: 0:5ae1f82b9a00 | |
944 user: test | |
945 date: Thu Jan 01 00:00:00 1970 +0000 | |
946 summary: init | |
947 | |
948 | |
949 Uncommitted changes in line-range + wdir() | |
950 | |
951 $ hg log -r 'wdir()' -f -L bazn,5:7 --limit 2 -p | |
952 changeset: 2147483647:ffffffffffff | |
953 parent: 9:6af29c3a778f | |
954 user: test | |
955 date: Thu Jan 01 00:00:00 1970 +0000 | |
956 | |
957 diff --git a/dir/baz b/dir/bazn | |
958 copy from dir/baz | |
959 copy to dir/bazn | |
960 --- a/dir/baz | |
961 +++ b/dir/bazn | |
962 @@ -3,7 +3,7 @@ | |
963 0 | |
964 0 | |
965 1+ | |
966 -2+ | |
967 + + | |
968 3+ | |
969 4 | |
970 5 | |
971 | |
972 changeset: 9:6af29c3a778f | |
973 tag: tip | |
974 user: test | |
975 date: Thu Jan 01 00:00:00 1970 +0000 | |
976 summary: foo -> dir/baz; 1-1+ | |
977 | |
978 diff --git a/foo b/dir/baz | |
979 copy from foo | |
980 copy to dir/baz | |
981 --- a/foo | |
982 +++ b/dir/baz | |
983 @@ -2,7 +2,7 @@ | |
984 0 | |
985 0 | |
986 0 | |
987 - 1 | |
988 + 1+ | |
989 2+ | |
990 3+ | |
991 4 | |
992 | |
993 | |
901 $ hg revert -a -C -q | 994 $ hg revert -a -C -q |
902 | 995 |
903 Binary files work but without diff hunks filtering. | 996 Binary files work but without diff hunks filtering. |
904 (Checking w/ and w/o diff.git option.) | 997 (Checking w/ and w/o diff.git option.) |
905 | 998 |