Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 39890:1c3f1491965f
scmutil: expand long "one-liner"
When a one-liner gets 3 lines longs, it loses its expressivity benefits. We
expand it into a simple for loop. This makes future changes of the code in
that area clearer.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 27 Sep 2018 13:54:37 -0700 |
parents | f1d6021453c2 |
children | b99903534e06 |
comparison
equal
deleted
inserted
replaced
39889:d9ba836fc234 | 39890:1c3f1491965f |
---|---|
966 # some obsstore logic. | 966 # some obsstore logic. |
967 # NOTE: the filtering and sorting might belong to createmarkers. | 967 # NOTE: the filtering and sorting might belong to createmarkers. |
968 isobs = unfi.obsstore.successors.__contains__ | 968 isobs = unfi.obsstore.successors.__contains__ |
969 torev = unfi.changelog.rev | 969 torev = unfi.changelog.rev |
970 sortfunc = lambda ns: torev(ns[0]) | 970 sortfunc = lambda ns: torev(ns[0]) |
971 rels = [(unfi[n], tuple(unfi[m] for m in s)) | 971 rels = [] |
972 for n, s in sorted(replacements.items(), key=sortfunc) | 972 for n, s in sorted(replacements.items(), key=sortfunc): |
973 if s or not isobs(n)] | 973 if s or not isobs(n): |
974 rel = (unfi[n], tuple(unfi[m] for m in s)) | |
975 rels.append(rel) | |
974 if rels: | 976 if rels: |
975 obsolete.createmarkers(repo, rels, operation=operation, | 977 obsolete.createmarkers(repo, rels, operation=operation, |
976 metadata=metadata) | 978 metadata=metadata) |
977 else: | 979 else: |
978 from . import repair # avoid import cycle | 980 from . import repair # avoid import cycle |