Mercurial > hg-git
changeset 839:83a0e6c0e82c
git_handler: add a way to get a rename detector
This will be used to detect renames in upcoming patches.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 02 Dec 2014 14:53:11 -0800 |
parents | f6f84d51a154 |
children | edcdb7620f4d |
files | hggit/git_handler.py |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git_handler.py Mon Dec 01 23:25:25 2014 -0800 +++ b/hggit/git_handler.py Tue Dec 02 14:53:11 2014 -0800 @@ -1334,6 +1334,28 @@ return files, gitlinks + @hgutil.propertycache + def _rename_detector(self): + # disabled by default to avoid surprises + similarity = self.ui.configint('git', 'similarity', default=0) + if similarity < 0 or similarity > 100: + raise util.Abort(_('git.similarity must be between 0 and 100')) + if similarity == 0: + return None + + # default is borrowed from Git + max_files = self.ui.configint('git', 'renamelimit', default=400) + if similarity < 0: + raise util.Abort(_('git.renamelimit must be non-negative')) + if max_files == 0: + max_files = None + + find_copies_harder = self.ui.configbool('git', 'findcopiesharder', + default=False) + return diff_tree.RenameDetector( + rename_threshold=similarity, max_files=max_files, + find_copies_harder=find_copies_harder) + def parse_gitmodules(self, tree_obj): """Parse .gitmodules from a git tree specified by tree_obj