Show More
@@ -690,6 +690,11 b" def revsingle(repo, revspec, default='.'" | |||
|
690 | 690 | raise util.Abort(_('empty revision set')) |
|
691 | 691 | return repo[l.last()] |
|
692 | 692 | |
|
693 | def _pairspec(revspec): | |
|
694 | tree = revset.parse(revspec) | |
|
695 | tree = revset.optimize(tree, True)[1] # fix up "x^:y" -> "(x^):y" | |
|
696 | return tree and tree[0] in ('range', 'rangepre', 'rangepost', 'rangeall') | |
|
697 | ||
|
693 | 698 | def revpair(repo, revs): |
|
694 | 699 | if not revs: |
|
695 | 700 | return repo.dirstate.p1(), None |
@@ -711,13 +716,12 b' def revpair(repo, revs):' | |||
|
711 | 716 | if first is None: |
|
712 | 717 | raise util.Abort(_('empty revision range')) |
|
713 | 718 | |
|
714 | if first == second and len(revs) == 1 and _revrangesep not in revs[0]: | |
|
719 | # if top-level is range expression, the result must always be a pair | |
|
720 | if first == second and len(revs) == 1 and not _pairspec(revs[0]): | |
|
715 | 721 | return repo.lookup(first), None |
|
716 | 722 | |
|
717 | 723 | return repo.lookup(first), repo.lookup(second) |
|
718 | 724 | |
|
719 | _revrangesep = ':' | |
|
720 | ||
|
721 | 725 | def revrange(repo, revs): |
|
722 | 726 | """Yield revision as strings from a list of revision specifications.""" |
|
723 | 727 | allspecs = [] |
@@ -31,19 +31,53 b' Testing diff --change' | |||
|
31 | 31 | |
|
32 | 32 | $ cd .. |
|
33 | 33 | |
|
34 | Test dumb revspecs (issue3474) | |
|
34 | Test dumb revspecs: top-level "x:y", "x:", ":y" and ":" ranges should be handled | |
|
35 | as pairs even if x == y, but not for "f(x:y)" nor "x::y" (issue3474, issue4774) | |
|
35 | 36 | |
|
36 | 37 | $ hg clone -q a dumbspec |
|
37 | 38 | $ cd dumbspec |
|
38 | 39 | $ echo "wdir" > file.txt |
|
39 | 40 | |
|
40 | 41 | $ hg diff -r 2:2 |
|
42 | $ hg diff -r 2:. | |
|
43 | $ hg diff -r 2: | |
|
44 | $ hg diff -r :0 | |
|
45 | $ hg diff -r '2:first(2:2)' | |
|
46 | $ hg diff -r 'first(2:2)' --nodates | |
|
47 | diff -r bf5ff72eb7e0 file.txt | |
|
48 | --- a/file.txt | |
|
49 | +++ b/file.txt | |
|
50 | @@ -1,1 +1,1 @@ | |
|
51 | -third | |
|
52 | +wdir | |
|
53 | $ hg diff -r 2::2 --nodates | |
|
54 | diff -r bf5ff72eb7e0 file.txt | |
|
55 | --- a/file.txt | |
|
56 | +++ b/file.txt | |
|
57 | @@ -1,1 +1,1 @@ | |
|
58 | -third | |
|
59 | +wdir | |
|
41 | 60 |
$ |
|
42 | 61 | abort: empty revision range |
|
43 | 62 | [255] |
|
44 | 63 | |
|
45 | 64 | $ cd .. |
|
46 | 65 | |
|
66 | $ hg clone -qr0 a dumbspec-rev0 | |
|
67 | $ cd dumbspec-rev0 | |
|
68 | $ echo "wdir" > file.txt | |
|
69 | ||
|
70 | $ hg diff -r : | |
|
71 | $ hg diff -r 'first(:)' --nodates | |
|
72 | diff -r 4bb65dda5db4 file.txt | |
|
73 | --- a/file.txt | |
|
74 | +++ b/file.txt | |
|
75 | @@ -1,1 +1,1 @@ | |
|
76 | -first | |
|
77 | +wdir | |
|
78 | ||
|
79 | $ cd .. | |
|
80 | ||
|
47 | 81 | Testing diff --change when merge: |
|
48 | 82 | |
|
49 | 83 | $ cd a |
@@ -1515,10 +1515,16 b' test usage in revpair (with "+")' | |||
|
1515 | 1515 | (single rev) |
|
1516 | 1516 | |
|
1517 | 1517 | $ hg diff -r 'tip^' -r 'tip^' |
|
1518 |
$ hg diff -r 'tip^: |
|
|
1518 | $ hg diff -r 'tip^:tip^' | |
|
1519 | 1519 | |
|
1520 | 1520 | (single rev that does not looks like a range) |
|
1521 | 1521 | |
|
1522 | $ hg diff -r 'tip^::tip^ or tip^' | |
|
1523 | diff -r d5d0dcbdc4d9 .hgtags | |
|
1524 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
|
1525 | +++ b/.hgtags * (glob) | |
|
1526 | @@ -0,0 +1,1 @@ | |
|
1527 | +e0cc66ef77e8b6f711815af4e001a6594fde3ba5 1.0 | |
|
1522 | 1528 | $ hg diff -r 'tip^ or tip^' |
|
1523 | 1529 | diff -r d5d0dcbdc4d9 .hgtags |
|
1524 | 1530 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
General Comments 0
You need to be logged in to leave comments.
Login now