Mercurial > hg-git-sync
changeset 1:e9f44d2deb94
Add some lame improvements to the map building.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 19 Feb 2016 16:01:24 -0800 |
parents | 6da45bb59fd0 |
children | 19156ccdc3e1 |
files | hggit_sync.py |
diffstat | 1 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit_sync.py Thu Feb 18 11:28:49 2016 -0800 +++ b/hggit_sync.py Fri Feb 19 16:01:24 2016 -0800 @@ -38,10 +38,35 @@ commits1 = sorted(commits1, key=lambda c: c.timestamp) commits2 = sorted(commits2, key=lambda c: c.timestamp) commit_map = dict(map(lambda c: (c.timestamp, (c, None)), commits1)) + orphan_commits2 = [] + print("Building commit map...") for c in commits2: entry = commit_map.get(c.timestamp, (None, None)) entry = (entry[0], c) commit_map[c.timestamp] = entry + if entry[0] is None: + orphan_commits2.append(c) + + if orphan_commits2: + print("Fixing orphaned commits...") + did_fix = True + orphan_commits1 = [e[0] for e in commit_map.values() if e[1] is None] + while did_fix: + did_fix = False + for c2 in orphan_commits2: + for c1 in orphan_commits1: + if c1.description.strip() == c2.description.strip(): + print("Mapping '%s' to '%s'" % (c1.nodeid, c2.nodeid)) + print(" Similar description: %s" % c1.description) + print(" Timestamp difference: %d" % (c2.timestamp - c1.timestamp)) + commit_map[c1.timestamp] = (c1, c2) + orphan_commits1.remove(c1) + orphan_commits2.remove(c2) + did_fix = True + break + if did_fix: + break + return commit_map @@ -57,6 +82,7 @@ parser.add_argument( 'mapfile', metavar='MAPFILE', + nargs='?', help="The path to the mapfile to generate.") res = parser.parse_args()