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