@@ -2639,7 +2639,7 @@ class RepoFilter(object):
2639
2639
assert new_hash is not None
2640
2640
return new_hash [0 :orig_len ]
2641
2641
2642
- def trim_extra_parents (self , orig_parents , parents ):
2642
+ def _trim_extra_parents (self , orig_parents , parents ):
2643
2643
'''Due to pruning of empty commits, some parents could be non-existent
2644
2644
(None) or otherwise redundant. Remove the non-existent parents, and
2645
2645
remove redundant parents so long as that doesn't transform a merge
@@ -2722,7 +2722,7 @@ class RepoFilter(object):
2722
2722
2723
2723
return parents , None
2724
2724
2725
- def prunable (self , commit , new_1st_parent , had_file_changes , orig_parents ):
2725
+ def _prunable (self , commit , new_1st_parent , had_file_changes , orig_parents ):
2726
2726
parents = commit .parents
2727
2727
2728
2728
if self ._args .empty_pruning == 'never' :
@@ -2810,7 +2810,7 @@ class RepoFilter(object):
2810
2810
2811
2811
return True
2812
2812
2813
- def record_remapping (self , commit , orig_parents ):
2813
+ def _record_remapping (self , commit , orig_parents ):
2814
2814
new_id = None
2815
2815
# Record the mapping of old commit hash to new one
2816
2816
if commit .original_id and self ._import_pipes :
@@ -2828,7 +2828,7 @@ class RepoFilter(object):
2828
2828
if len (orig_parents ) >= 2 and len (commit .parents ) < 2 :
2829
2829
self ._commits_no_longer_merges .append ((commit .original_id , new_id ))
2830
2830
2831
- def tweak_blob (self , blob ):
2831
+ def _tweak_blob (self , blob ):
2832
2832
if self ._args .replace_text :
2833
2833
for literal , replacement in self ._args .replace_text ['literals' ]:
2834
2834
blob .data = blob .data .replace (literal , replacement )
@@ -2838,7 +2838,7 @@ class RepoFilter(object):
2838
2838
if self ._blob_callback :
2839
2839
self ._blob_callback (blob )
2840
2840
2841
- def tweak_commit (self , commit , aux_info ):
2841
+ def _tweak_commit (self , commit , aux_info ):
2842
2842
def filename_matches (path_expression , pathname ):
2843
2843
''' Returns whether path_expression matches pathname or a leading
2844
2844
directory thereof, allowing path_expression to not have a trailing
@@ -2904,7 +2904,7 @@ class RepoFilter(object):
2904
2904
# Sometimes the 'branch' given is a tag; if so, rename it as requested so
2905
2905
# we don't get any old tagnames
2906
2906
if self ._args .tag_rename :
2907
- commit .branch = RepoFilter .do_tag_rename (args .tag_rename , commit .branch )
2907
+ commit .branch = RepoFilter ._do_tag_rename (args .tag_rename , commit .branch )
2908
2908
if self ._refname_callback :
2909
2909
commit .branch = self ._refname_callback (commit .branch )
2910
2910
@@ -2977,7 +2977,7 @@ class RepoFilter(object):
2977
2977
self ._orig_graph .add_commit_and_parents (commit .old_id , orig_parents )
2978
2978
2979
2979
# Prune parents (due to pruning of empty commits) if relevant
2980
- parents , new_1st_parent = self .trim_extra_parents (orig_parents , parents )
2980
+ parents , new_1st_parent = self ._trim_extra_parents (orig_parents , parents )
2981
2981
commit .parents = parents
2982
2982
2983
2983
# Call the user-defined callback, if any
@@ -2986,11 +2986,11 @@ class RepoFilter(object):
2986
2986
2987
2987
# Now print the resulting commit, or if prunable skip it
2988
2988
if not commit .dumped :
2989
- if not self .prunable (commit , new_1st_parent , aux_info [ 'had_file_changes' ] ,
2990
- orig_parents ):
2989
+ if not self ._prunable (commit , new_1st_parent ,
2990
+ aux_info [ 'had_file_changes' ], orig_parents ):
2991
2991
self ._seen_refs [commit .branch ] = None # was seen, doesn't need reset
2992
2992
commit .dump (self ._output )
2993
- self .record_remapping (commit , orig_parents )
2993
+ self ._record_remapping (commit , orig_parents )
2994
2994
else :
2995
2995
rewrite_to = new_1st_parent or commit .first_parent ()
2996
2996
# We skip empty commits, but want to keep track to make sure our branch
@@ -3006,23 +3006,23 @@ class RepoFilter(object):
3006
3006
self ._progress_writer .show (self ._parsed_message % self ._num_commits )
3007
3007
3008
3008
@staticmethod
3009
- def do_tag_rename (rename_pair , tagname ):
3009
+ def _do_tag_rename (rename_pair , tagname ):
3010
3010
old , new = rename_pair .split (b':' , 1 )
3011
3011
old , new = b'refs/tags/' + old , b'refs/tags/' + new
3012
3012
if tagname .startswith (old ):
3013
3013
return tagname .replace (old , new , 1 )
3014
3014
return tagname
3015
3015
3016
- def handle_tag (self , tag ):
3016
+ def _tweak_tag (self , tag ):
3017
3017
# Tweak the tag message according to callbacks
3018
3018
if self ._message_callback :
3019
3019
tag .message = self ._message_callback (tag .message )
3020
3020
3021
- # Tweak the tag name according to callbacks
3021
+ # Tweak the tag name according to tag-name-related callbacks
3022
3022
tag_prefix = b'refs/tags/'
3023
3023
fullref = tag_prefix + tag .ref
3024
3024
if self ._args .tag_rename :
3025
- fullref = RepoFilter .do_tag_rename (self ._args .tag_rename , fullref )
3025
+ fullref = RepoFilter ._do_tag_rename (self ._args .tag_rename , fullref )
3026
3026
if self ._refname_callback :
3027
3027
fullref = self ._refname_callback (fullref )
3028
3028
if not fullref .startswith (tag_prefix ):
@@ -3045,13 +3045,13 @@ class RepoFilter(object):
3045
3045
if tag .from_ref :
3046
3046
self ._seen_refs [fullref ] = None
3047
3047
3048
- # Tweak all aspects of the tag according to callback
3048
+ # Call general purpose tag callback
3049
3049
if self ._tag_callback :
3050
3050
self ._tag_callback (tag )
3051
3051
3052
- def handle_reset (self , reset ):
3052
+ def _tweak_reset (self , reset ):
3053
3053
if self ._args .tag_rename :
3054
- reset .ref = RepoFilter .do_tag_rename (self ._args .tag_rename , reset .ref )
3054
+ reset .ref = RepoFilter ._do_tag_rename (self ._args .tag_rename , reset .ref )
3055
3055
if self ._refname_callback :
3056
3056
reset .ref = self ._refname_callback (reset .ref )
3057
3057
if self ._reset_callback :
@@ -3344,10 +3344,10 @@ class RepoFilter(object):
3344
3344
if self ._input :
3345
3345
# Create and run the filter
3346
3346
self ._repo_working_dir = self ._args .source or b'.'
3347
- fef = FastExportParser (blob_callback = self .tweak_blob ,
3348
- commit_callback = self .tweak_commit ,
3349
- tag_callback = self .handle_tag ,
3350
- reset_callback = self .handle_reset ,
3347
+ fef = FastExportParser (blob_callback = self ._tweak_blob ,
3348
+ commit_callback = self ._tweak_commit ,
3349
+ tag_callback = self ._tweak_tag ,
3350
+ reset_callback = self ._tweak_reset ,
3351
3351
done_callback = self ._handle_final_commands )
3352
3352
fef .run (self ._input , self ._output )
3353
3353
if not self ._finalize_handled :
0 commit comments