Show More
@@ -312,6 +312,7 EFFECTFLAGFIELD = "ef1" | |||
|
312 | 312 | |
|
313 | 313 | DESCCHANGED = 1 << 0 # action changed the description |
|
314 | 314 | METACHANGED = 1 << 1 # action change the meta |
|
315 | DIFFCHANGED = 1 << 3 # action change diff introduced by the changeset | |
|
315 | 316 | PARENTCHANGED = 1 << 2 # action change the parent |
|
316 | 317 | USERCHANGED = 1 << 4 # the user changed |
|
317 | 318 | DATECHANGED = 1 << 5 # the date changed |
@@ -332,6 +333,47 def metanotblacklisted(metaitem): | |||
|
332 | 333 | |
|
333 | 334 | return not any(pattern.match(metakey) for pattern in METABLACKLIST) |
|
334 | 335 | |
|
336 | def _prepare_hunk(hunk): | |
|
337 | """Drop all information but the username and patch""" | |
|
338 | cleanhunk = [] | |
|
339 | for line in hunk.splitlines(): | |
|
340 | if line.startswith(b'# User') or not line.startswith(b'#'): | |
|
341 | if line.startswith(b'@@'): | |
|
342 | line = b'@@\n' | |
|
343 | cleanhunk.append(line) | |
|
344 | return cleanhunk | |
|
345 | ||
|
346 | def _getdifflines(iterdiff): | |
|
347 | """return a cleaned up lines""" | |
|
348 | lines = next(iterdiff, None) | |
|
349 | ||
|
350 | if lines is None: | |
|
351 | return lines | |
|
352 | ||
|
353 | return _prepare_hunk(lines) | |
|
354 | ||
|
355 | def _cmpdiff(leftctx, rightctx): | |
|
356 | """return True if both ctx introduce the "same diff" | |
|
357 | ||
|
358 | This is a first and basic implementation, with many shortcoming. | |
|
359 | """ | |
|
360 | ||
|
361 | # Leftctx or right ctx might be filtered, so we need to use the contexts | |
|
362 | # with an unfiltered repository to safely compute the diff | |
|
363 | leftunfi = leftctx._repo.unfiltered()[leftctx.rev()] | |
|
364 | leftdiff = leftunfi.diff(git=1) | |
|
365 | rightunfi = rightctx._repo.unfiltered()[rightctx.rev()] | |
|
366 | rightdiff = rightunfi.diff(git=1) | |
|
367 | ||
|
368 | left, right = (0, 0) | |
|
369 | while None not in (left, right): | |
|
370 | left = _getdifflines(leftdiff) | |
|
371 | right = _getdifflines(rightdiff) | |
|
372 | ||
|
373 | if left != right: | |
|
374 | return False | |
|
375 | return True | |
|
376 | ||
|
335 | 377 | def geteffectflag(relation): |
|
336 | 378 | """ From an obs-marker relation, compute what changed between the |
|
337 | 379 | predecessor and the successor. |
@@ -371,6 +413,10 def geteffectflag(relation): | |||
|
371 | 413 | if ctxmeta != srcmeta: |
|
372 | 414 | effects |= METACHANGED |
|
373 | 415 | |
|
416 | # Check if the diff has changed | |
|
417 | if not _cmpdiff(source, changectx): | |
|
418 | effects |= DIFFCHANGED | |
|
419 | ||
|
374 | 420 | return effects |
|
375 | 421 | |
|
376 | 422 | def getobsoleted(repo, tr): |
@@ -93,7 +93,7 amend touching the diff | |||
|
93 | 93 | check result |
|
94 | 94 | |
|
95 | 95 | $ hg debugobsolete --rev . |
|
96 |
ebfe0333e0d96f68a917afd97c0a0af87f1c3b5f 75781fdbdbf58a987516b00c980bccda1e9ae588 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': ' |
|
|
96 | ebfe0333e0d96f68a917afd97c0a0af87f1c3b5f 75781fdbdbf58a987516b00c980bccda1e9ae588 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'} | |
|
97 | 97 | |
|
98 | 98 | amend with multiple effect (desc and meta) |
|
99 | 99 | ------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now