[PATCH 3 of 3] simplemerge: rewrite flag merging loop as expression
Yuya Nishihara
yuya at tcha.org
Sat Jun 6 03:04:15 UTC 2020
On Fri, 5 Jun 2020 16:24:17 +0200, Pierre-Yves David wrote:
> On 6/4/20 4:15 PM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya at tcha.org>
> > # Date 1591101897 -32400
> > # Tue Jun 02 21:44:57 2020 +0900
> > # Node ID 970abb8ea2a2d6a086ebfdd9a1130b2fb777640e
> > # Parent dba0ac9b68381e9610f25d9991bd623f85cbdefd
> > simplemerge: rewrite flag merging loop as expression
> >
> > I feel binary operations are more readable.
>
> The fact also merge "flag removal" become implicit and might be less
> clear to reader. I like the use of binary operation, but can we add a
> comment about the removed flag ?
What do you mean with the "flag removal"?
The logic is unchanged, which is to take the common flags and
then add changes from the base.
> > - flags = localflags & otherflags
> > - for f in localflags.symmetric_difference(otherflags):
> > - if f not in baseflags:
> > - flags.add(f)
> > - flags = b''.join(sorted(flags))
> > + commonflags = localflags & otherflags
> > + addedflags = (localflags ^ otherflags) - baseflags
> > + flags = b''.join(sorted(commonflags | addedflags))
More information about the Mercurial-devel
mailing list