##// END OF EJS Templates
rewriteutil: relax the sha1 hash references to handle future hash types...
Matt Harbison -
r45996:78861610 default
parent child Browse files
Show More
@@ -21,7 +21,7 b' from . import ('
21 21 )
22 22
23 23
24 sha1re = re.compile(br'\b[0-9a-f]{6,40}\b')
24 NODE_RE = re.compile(br'\b[0-9a-f]{6,64}\b')
25 25
26 26
27 27 def precheck(repo, revs, action=b'rewrite'):
@@ -92,10 +92,10 b' def update_hash_refs(repo, commitmsg, pe'
92 92 if not pending:
93 93 pending = {}
94 94 cache = {}
95 sha1s = re.findall(sha1re, commitmsg)
95 hashes = re.findall(NODE_RE, commitmsg)
96 96 unfi = repo.unfiltered()
97 for sha1 in sha1s:
98 fullnode = scmutil.resolvehexnodeidprefix(unfi, sha1)
97 for h in hashes:
98 fullnode = scmutil.resolvehexnodeidprefix(unfi, h)
99 99 if fullnode is None:
100 100 continue
101 101 ctx = unfi[fullnode]
@@ -111,15 +111,15 b' def update_hash_refs(repo, commitmsg, pe'
111 111 # We can't make any assumptions about how to update the hash if the
112 112 # cset in question was split or diverged.
113 113 if len(successors) == 1 and len(successors[0]) == 1:
114 newsha1 = node.hex(successors[0][0])
115 commitmsg = commitmsg.replace(sha1, newsha1[: len(sha1)])
114 newhash = node.hex(successors[0][0])
115 commitmsg = commitmsg.replace(h, newhash[: len(h)])
116 116 else:
117 117 repo.ui.note(
118 118 _(
119 119 b'The stale commit message reference to %s could '
120 120 b'not be updated\n'
121 121 )
122 % sha1
122 % h
123 123 )
124 124
125 125 return commitmsg
General Comments 0
You need to be logged in to leave comments. Login now