Show More
@@ -29,6 +29,7 b' wdirnodes = {newnodeid, addednodeid, mod' | |||||
29 | # (they are experimental, so don't add too many dependencies on them) |
|
29 | # (they are experimental, so don't add too many dependencies on them) | |
30 | wdirrev = 0x7fffffff |
|
30 | wdirrev = 0x7fffffff | |
31 | wdirid = b"\xff" * 20 |
|
31 | wdirid = b"\xff" * 20 | |
|
32 | wdirhex = hex(wdirid) | |||
32 |
|
33 | |||
33 | def short(node): |
|
34 | def short(node): | |
34 | return hex(node[:6]) |
|
35 | return hex(node[:6]) |
@@ -26,6 +26,7 b' from .node import (' | |||||
26 | hex, |
|
26 | hex, | |
27 | nullid, |
|
27 | nullid, | |
28 | nullrev, |
|
28 | nullrev, | |
|
29 | wdirhex, | |||
29 | wdirid, |
|
30 | wdirid, | |
30 | wdirrev, |
|
31 | wdirrev, | |
31 | ) |
|
32 | ) | |
@@ -1038,10 +1039,17 b' class revlog(object):' | |||||
1038 | pass |
|
1039 | pass | |
1039 |
|
1040 | |||
1040 | def _partialmatch(self, id): |
|
1041 | def _partialmatch(self, id): | |
|
1042 | maybewdir = wdirhex.startswith(id) | |||
1041 | try: |
|
1043 | try: | |
1042 | partial = self.index.partialmatch(id) |
|
1044 | partial = self.index.partialmatch(id) | |
1043 | if partial and self.hasnode(partial): |
|
1045 | if partial and self.hasnode(partial): | |
|
1046 | if maybewdir: | |||
|
1047 | # single 'ff...' match in radix tree, ambiguous with wdir | |||
|
1048 | raise RevlogError | |||
1044 | return partial |
|
1049 | return partial | |
|
1050 | if maybewdir: | |||
|
1051 | # no 'ff...' match in radix tree, wdir identified | |||
|
1052 | raise error.WdirUnsupported | |||
1045 | return None |
|
1053 | return None | |
1046 | except RevlogError: |
|
1054 | except RevlogError: | |
1047 | # parsers.c radix tree lookup gave multiple matches |
|
1055 | # parsers.c radix tree lookup gave multiple matches | |
@@ -1066,11 +1074,13 b' class revlog(object):' | |||||
1066 | nl = [n for n in nl if hex(n).startswith(id) and |
|
1074 | nl = [n for n in nl if hex(n).startswith(id) and | |
1067 | self.hasnode(n)] |
|
1075 | self.hasnode(n)] | |
1068 | if len(nl) > 0: |
|
1076 | if len(nl) > 0: | |
1069 | if len(nl) == 1: |
|
1077 | if len(nl) == 1 and not maybewdir: | |
1070 | self._pcache[id] = nl[0] |
|
1078 | self._pcache[id] = nl[0] | |
1071 | return nl[0] |
|
1079 | return nl[0] | |
1072 | raise LookupError(id, self.indexfile, |
|
1080 | raise LookupError(id, self.indexfile, | |
1073 | _('ambiguous identifier')) |
|
1081 | _('ambiguous identifier')) | |
|
1082 | if maybewdir: | |||
|
1083 | raise error.WdirUnsupported | |||
1074 | return None |
|
1084 | return None | |
1075 | except TypeError: |
|
1085 | except TypeError: | |
1076 | pass |
|
1086 | pass |
@@ -1309,12 +1309,12 b' def node_(repo, subset, x):' | |||||
1309 | rn = None |
|
1309 | rn = None | |
1310 | else: |
|
1310 | else: | |
1311 | rn = None |
|
1311 | rn = None | |
1312 | pm = repo.changelog._partialmatch(n) |
|
1312 | try: | |
1313 | if pm is not None: |
|
1313 | pm = repo.changelog._partialmatch(n) | |
1314 |
|
|
1314 | if pm is not None: | |
1315 | rn = repo.changelog.rev(pm) |
|
1315 | rn = repo.changelog.rev(pm) | |
1316 |
|
|
1316 | except error.WdirUnsupported: | |
1317 |
|
|
1317 | rn = node.wdirrev | |
1318 |
|
1318 | |||
1319 | if rn is None: |
|
1319 | if rn is None: | |
1320 | return baseset() |
|
1320 | return baseset() |
@@ -960,6 +960,9 b' def shortest(context, mapping, args):' | |||||
960 | return True |
|
960 | return True | |
961 | except error.RevlogError: |
|
961 | except error.RevlogError: | |
962 | return False |
|
962 | return False | |
|
963 | except error.WdirUnsupported: | |||
|
964 | # single 'ff...' match | |||
|
965 | return True | |||
963 |
|
966 | |||
964 | shortest = node |
|
967 | shortest = node | |
965 | startlength = max(6, minlength) |
|
968 | startlength = max(6, minlength) |
@@ -3503,6 +3503,9 b' Test shortest(node) function:' | |||||
3503 | hg: parse error: shortest() expects an integer minlength |
|
3503 | hg: parse error: shortest() expects an integer minlength | |
3504 | [255] |
|
3504 | [255] | |
3505 |
|
3505 | |||
|
3506 | $ hg log -r 'wdir()' -T '{node|shortest}\n' | |||
|
3507 | ffff | |||
|
3508 | ||||
3506 | $ cd .. |
|
3509 | $ cd .. | |
3507 |
|
3510 | |||
3508 | Test shortest(node) with the repo having short hash collision: |
|
3511 | Test shortest(node) with the repo having short hash collision: |
@@ -1289,13 +1289,64 b' Test working-directory integer revision ' | |||||
1289 | 2147483647 |
|
1289 | 2147483647 | |
1290 | $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff' |
|
1290 | $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff' | |
1291 | 2147483647 |
|
1291 | 2147483647 | |
|
1292 | $ hg debugrevspec '0:wdir() & ffffffffffff' | |||
|
1293 | 2147483647 | |||
1292 | $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)' |
|
1294 | $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)' | |
1293 | 2147483647 |
|
1295 | 2147483647 | |
1294 | $ hg debugrevspec '0:wdir() & id(ffffffffffff)' |
|
1296 | $ hg debugrevspec '0:wdir() & id(ffffffffffff)' | |
1295 | BROKEN: should be '2147483647' |
|
1297 | 2147483647 | |
|
1298 | ||||
|
1299 | $ cd .. | |||
|
1300 | ||||
|
1301 | Test short 'ff...' hash collision | |||
|
1302 | (BUG: '0:wdir()' is still needed to populate wdir revision) | |||
|
1303 | ||||
|
1304 | $ hg init wdir-hashcollision | |||
|
1305 | $ cd wdir-hashcollision | |||
|
1306 | $ cat <<EOF >> .hg/hgrc | |||
|
1307 | > [experimental] | |||
|
1308 | > evolution = createmarkers | |||
|
1309 | > EOF | |||
|
1310 | $ echo 0 > a | |||
|
1311 | $ hg ci -qAm 0 | |||
|
1312 | $ for i in 2463 2961 6726 78127; do | |||
|
1313 | > hg up -q 0 | |||
|
1314 | > echo $i > a | |||
|
1315 | > hg ci -qm $i | |||
|
1316 | > done | |||
|
1317 | $ hg up -q null | |||
|
1318 | $ hg log -r '0:wdir()' -T '{rev}:{node} {shortest(node, 3)}\n' | |||
|
1319 | 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a b4e | |||
|
1320 | 1:fffbae3886c8fbb2114296380d276fd37715d571 fffba | |||
|
1321 | 2:fffb6093b00943f91034b9bdad069402c834e572 fffb6 | |||
|
1322 | 3:fff48a9b9de34a4d64120c29548214c67980ade3 fff4 | |||
|
1323 | 4:ffff85cff0ff78504fcdc3c0bc10de0c65379249 ffff8 | |||
|
1324 | 2147483647:ffffffffffffffffffffffffffffffffffffffff fffff | |||
|
1325 | $ hg debugobsolete fffbae3886c8fbb2114296380d276fd37715d571 | |||
|
1326 | ||||
|
1327 | $ hg debugrevspec '0:wdir() & fff' | |||
|
1328 | abort: 00changelog.i@fff: ambiguous identifier! | |||
|
1329 | [255] | |||
|
1330 | $ hg debugrevspec '0:wdir() & ffff' | |||
|
1331 | abort: 00changelog.i@ffff: ambiguous identifier! | |||
|
1332 | [255] | |||
|
1333 | $ hg debugrevspec '0:wdir() & fffb' | |||
|
1334 | abort: 00changelog.i@fffb: ambiguous identifier! | |||
|
1335 | [255] | |||
|
1336 | BROKEN should be '2' (node lookup uses unfiltered repo since dc25ed84bee8) | |||
|
1337 | $ hg debugrevspec '0:wdir() & id(fffb)' | |||
|
1338 | 2 | |||
|
1339 | $ hg debugrevspec '0:wdir() & ffff8' | |||
|
1340 | 4 | |||
|
1341 | $ hg debugrevspec '0:wdir() & fffff' | |||
|
1342 | 2147483647 | |||
|
1343 | ||||
|
1344 | $ cd .. | |||
1296 |
|
1345 | |||
1297 | Test branch() with wdir() |
|
1346 | Test branch() with wdir() | |
1298 |
|
1347 | |||
|
1348 | $ cd repo | |||
|
1349 | ||||
1299 | $ log '0:wdir() & branch("literal:é")' |
|
1350 | $ log '0:wdir() & branch("literal:é")' | |
1300 | 8 |
|
1351 | 8 | |
1301 | 9 |
|
1352 | 9 |
General Comments 0
You need to be logged in to leave comments.
Login now