From 531fa9b3a2ac4ed302cea66058a26c4ce615129f Mon Sep 17 00:00:00 2001 From: Felipe Contreras Date: Thu, 9 Mar 2023 15:48:54 -0600 Subject: [PATCH] Simplify split_dict There's no need to keep track of the left side: if it's modified it's modified. Signed-off-by: Felipe Contreras --- hg-fast-export.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hg-fast-export.py b/hg-fast-export.py index 40bc52d..b72fc10 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -74,35 +74,34 @@ def file_mismatch(f1,f2): """See if two revisions of a file are not equal.""" return node.hex(f1)!=node.hex(f2) -def split_dict(dleft,dright,l=[],c=[],r=[],match=file_mismatch): +def split_dict(dleft,dright,c=[],r=[],match=file_mismatch): """Loop over our repository and find all changed and missing files.""" for left in dleft.keys(): right=dright.get(left,None) if right==None: - # we have the file but our parent hasn't: add to left set - l.append(left) + # we have the file but our parent hasn't: add + c.append(left) elif match(dleft[left],right) or gitmode(dleft.flags(left))!=gitmode(dright.flags(left)): - # we have it but checksums mismatch: add to center set + # we have it but checksums mismatch: add c.append(left) for right in dright.keys(): left=dleft.get(right,None) if left==None: - # if parent has file but we don't: add to right set + # if parent has file but we don't: remove r.append(right) # change is already handled when comparing child against parent - return l,c,r + return c,r def get_filechanges(repo,revision,parents,mleft): """Given some repository and revision, find all changed/deleted files.""" - l,c,r=[],[],[] + c,r=[],[] for p in parents: if p<0: continue mright=repo[p].manifest() - l,c,r=split_dict(mleft,mright,l,c,r) - l.sort() + c,r=split_dict(mleft,mright,c,r) c.sort() r.sort() - return c+l,r + return c,r def get_author(logmessage,committer,authors): """As git distincts between author and committer of a patch, try to