Mercurial > public > mercurial-scm > hg
comparison mercurial/branchmap.py @ 35831:a011e4140435
branchmap: make error messages consistent between Python 2 and 3
Differential Revision: https://phab.mercurial-scm.org/D1890
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 17 Jan 2018 20:38:10 -0500 |
parents | 07fdac1d5c66 |
children | fa4d333cac58 |
comparison
equal
deleted
inserted
replaced
35830:e689d8b22728 | 35831:a011e4140435 |
---|---|
16 nullrev, | 16 nullrev, |
17 ) | 17 ) |
18 from . import ( | 18 from . import ( |
19 encoding, | 19 encoding, |
20 error, | 20 error, |
21 pycompat, | |
21 scmutil, | 22 scmutil, |
22 util, | 23 util, |
23 ) | 24 ) |
24 | 25 |
25 calcsize = struct.calcsize | 26 calcsize = struct.calcsize |
50 filteredhash = bin(cachekey[2]) | 51 filteredhash = bin(cachekey[2]) |
51 partial = branchcache(tipnode=last, tiprev=lrev, | 52 partial = branchcache(tipnode=last, tiprev=lrev, |
52 filteredhash=filteredhash) | 53 filteredhash=filteredhash) |
53 if not partial.validfor(repo): | 54 if not partial.validfor(repo): |
54 # invalidate the cache | 55 # invalidate the cache |
55 raise ValueError('tip differs') | 56 raise ValueError(r'tip differs') |
56 cl = repo.changelog | 57 cl = repo.changelog |
57 for l in lines: | 58 for l in lines: |
58 if not l: | 59 if not l: |
59 continue | 60 continue |
60 node, state, label = l.split(" ", 2) | 61 node, state, label = l.split(" ", 2) |
61 if state not in 'oc': | 62 if state not in 'oc': |
62 raise ValueError('invalid branch state') | 63 raise ValueError(r'invalid branch state') |
63 label = encoding.tolocal(label.strip()) | 64 label = encoding.tolocal(label.strip()) |
64 node = bin(node) | 65 node = bin(node) |
65 if not cl.hasnode(node): | 66 if not cl.hasnode(node): |
66 raise ValueError('node %s does not exist' % hex(node)) | 67 raise ValueError( |
68 r'node %s does not exist' % pycompat.sysstr(hex(node))) | |
67 partial.setdefault(label, []).append(node) | 69 partial.setdefault(label, []).append(node) |
68 if state == 'c': | 70 if state == 'c': |
69 partial._closednodes.add(node) | 71 partial._closednodes.add(node) |
70 except Exception as inst: | 72 except Exception as inst: |
71 if repo.ui.debugflag: | 73 if repo.ui.debugflag: |
72 msg = 'invalid branchheads cache' | 74 msg = 'invalid branchheads cache' |
73 if repo.filtername is not None: | 75 if repo.filtername is not None: |
74 msg += ' (%s)' % repo.filtername | 76 msg += ' (%s)' % repo.filtername |
75 msg += ': %s\n' | 77 msg += ': %s\n' |
76 repo.ui.debug(msg % inst) | 78 repo.ui.debug(msg % pycompat.bytestr(inst)) |
77 partial = None | 79 partial = None |
78 return partial | 80 return partial |
79 | 81 |
80 ### Nearest subset relation | 82 ### Nearest subset relation |
81 # Nearest subset of filter X is a filter Y so that: | 83 # Nearest subset of filter X is a filter Y so that: |