Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 | |
| 6 def IsSameFilePath(path1, path2): | |
| 7 """Determines if two paths represent same path. | |
| 8 | |
| 9 Compares the name of the folders in the path (by split('/')), and checks | |
| 10 if they match either more than 3 or min of path lengths. | |
|
Martin Barbella
2016/04/18 21:01:18
I'm not fully convinced that this is right, but it
Sharu Jiang
2016/04/19 20:38:37
Not a reliable way either but an alternative is to
stgao
2016/04/20 17:41:26
Have you explored the different change types Gitil
Sharu Jiang
2016/04/21 02:06:01
Yes, the copy/rename change type can help me detec
stgao
2016/04/21 17:31:53
If we plan to make this change, a bug should be cr
| |
| 11 | |
| 12 Args: | |
| 13 path1 (str): First path. | |
| 14 path2 (str): Second path to compare. | |
| 15 | |
| 16 Returns: | |
| 17 Boolean, True if it they are thought to be a same path, False otherwise. | |
| 18 """ | |
| 19 path_parts_1 = path1.lower().split('/') | |
| 20 path_parts_2 = path2.lower().split('/') | |
| 21 | |
| 22 if path_parts_1[-1] != path_parts_2[-1]: | |
| 23 return False | |
| 24 | |
| 25 intersection = set(path_parts_1).intersection(set(path_parts_2)) | |
|
Martin Barbella
2016/04/18 21:01:18
Set intersection might not be ideal here. I didn't
Sharu Jiang
2016/04/19 20:38:37
Done.
| |
| 26 return len(intersection) >= (min(3, min(len(path_parts_1), | |
| 27 len(path_parts_2)))) | |
| OLD | NEW |