[PATCH] localrepo: prevent executable-bit only changes from being lost on amend

Augie Fackler raf at durin42.com
Mon May 23 15:25:23 EDT 2016


On Thu, May 19, 2016 at 10:53:54PM +0000, Mateusz Kwapich wrote:
> I think it should be good to go on stable – it doesn’t look risky to me.

It's not a regression though. I'm conflicted. It's small enough I've
gone ahead and taken it for stable this time.

>
> On 5/19/16, 3:52 PM, "Pierre-Yves David" <pierre-yves.david at ens-lyon.org> wrote:
>
> >
> >
> >On 05/19/2016 11:39 PM, Mateusz Kwapich wrote:
> >> # HG changeset patch
> >> # User Mateusz Kwapich <mitrandir at fb.com>
> >> # Date 1463693722 25200
> >> #      Thu May 19 14:35:22 2016 -0700
> >> # Node ID ccd61c869f63297fbae2662314afcb7b3dce5224
> >> # Parent  f00f1de16454dfd31ee5e3fe301ab3225df76698
> >> localrepo: prevent executable-bit only changes from being lost on amend
> >>
> >> If you have just executable-bit change and amend it twice it will vanish:
> >>
> >>  * After the first amend the commit will have the proper executable bit set
> >>    in manifest but it won't have the the file on the list of files in
> >>    changelog.
> >>
> >>  * The second amend will read the wrong list of files from changelog and it
> >>    will copy the manifest entry from parent for this file.
> >>
> >>  * Voila! The change is lost.
> >>
> >> This change repairs the bug in localrepo causing this and adds a test for it.
> >
> >Nice catch, any reason it should not go on stable?
> >
> >>
> >> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> >> --- a/mercurial/localrepo.py
> >> +++ b/mercurial/localrepo.py
> >> @@ -1397,6 +1397,8 @@ class localrepository(object):
> >>              node = fctx.filenode()
> >>              if node in [fparent1, fparent2]:
> >>                  self.ui.debug('reusing %s filelog entry\n' % fname)
> >> +                if manifest1.flags(fname) != fctx.flags():
> >> +                    changelist.append(fname)
> >>                  return node
> >>
> >>          flog = self.file(fname)
> >> diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
> >> --- a/tests/test-commit-amend.t
> >> +++ b/tests/test-commit-amend.t
> >> @@ -1156,3 +1156,21 @@ directory)
> >>       rev    offset  length  delta linkrev nodeid       p1           p2
> >>         0         0      88     -1       3 34a4d536c0c0 000000000000 000000000000
> >>
> >> +Test if amend preserves executable bit changes
> >> +  $ chmod +x newdirname/commonfile.py
> >> +  $ hg ci -m chmod
> >> +  $ hg ci --amend -m "chmod amended"
> >> +  $ hg ci --amend -m "chmod amended second time"
> >> +  $ hg log -p --git -r .
> >> +  changeset:   8:b1326f52dddf
> >> +  branch:      newdirname
> >> +  tag:         tip
> >> +  parent:      5:7fd235f7cb2f
> >> +  user:        test
> >> +  date:        Thu Jan 01 00:00:00 1970 +0000
> >> +  summary:     chmod amended second time
> >> +
> >> +  diff --git a/newdirname/commonfile.py b/newdirname/commonfile.py
> >> +  old mode 100644
> >> +  new mode 100755
> >> +
> >> _______________________________________________
> >> Mercurial-devel mailing list
> >> Mercurial-devel at mercurial-scm.org
> >> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwICaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=dK7q_6fOymlfdGMBe3wUaA&m=Lp90uJ9CaUSnUn146a7iNvVvGEVRm3zsPVdRU_1Oi0M&s=84KV8WaboS9RD451fzTQLuZO5-2r0YN600wDCF-zVhc&e=
> >
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list