[PATCH 2 of 2 V8] update: fix bare --clean to work on new branch (issue5003) (BC)
Simon Farnsworth
simonfar at fb.com
Wed Apr 13 07:49:32 EDT 2016
On 13/04/2016 12:32, Piotr Listkiewicz wrote:
> Again, "this commit" is implied; you can reword this in a simpler
> fashion with something like "bare update --clean on a newly created
> branch updates to the parent commit, even if there are later commits
> on the parent commit's branch. Update to the latest head on the
> parent commit's branch instead".
> Otherwise, this looks good to me.
>
>
> Right, changed it in V9. I need some english writing classes :P
Writing good commit messages is difficult, even if you naturally write
perfect English - it's *so* tempting to say what you're doing (which
repeats the commit contents) rather than why you're doing it.
The goal of the commit message is to tell me (as a reader of your
commit) why you wrote this code. I can read your code and see what it
does, but sometimes it's not obvious why you did that.
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-March/080690.html
has a great commit message, IMO - it tells me why Yuya thought this code
was worth writing, and what his goal was in writing the code.
>
> 2016-04-13 12:31 GMT+02:00 Simon Farnsworth <simonfar at fb.com
> <mailto:simonfar at fb.com>>:
>
> On 13/04/2016 09:48, liscju wrote:
>
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com
> <mailto:piotr.listkiewicz at gmail.com>>
> # Date 1459834201 -7200
> # Tue Apr 05 07:30:01 2016 +0200
> # Node ID dece0d6bc1442e50db920cd6ee04bebf786cddd1
> # Parent cabc4e5224db4d4f02e4460f4349df2e7ffd2e52
> update: fix bare --clean to work on new branch (issue5003) (BC)
>
> Before this commit bare update --clean on newly created branch
> resulted in updating to the parent. After applying this commit bare
> update --clean results in updating to the max head of the parents
> branch.
>
>
> Again, "this commit" is implied; you can reword this in a simpler
> fashion with something like "bare update --clean on a newly created
> branch updates to the parent commit, even if there are later commits
> on the parent commit's branch. Update to the latest head on the
> parent commit's branch instead".
>
> Otherwise, this looks good to me.
>
> This seems reasonable as clean should discard uncommited changes,
> branch is one of them.
>
> diff -r cabc4e5224db -r dece0d6bc144 mercurial/destutil.py
> --- a/mercurial/destutil.py Tue Apr 05 06:53:33 2016 +0200
> +++ b/mercurial/destutil.py Tue Apr 05 07:30:01 2016 +0200
> @@ -95,14 +95,24 @@ def _destupdatebranch(repo, clean, check
> wc = repo[None]
> movemark = node = None
> currentbranch = wc.branch()
> - if currentbranch in repo.branchmap():
> - heads = repo.branchheads(currentbranch)
> +
> + if clean:
> + heads = repo.branchheads(repo['.'].branch())
> if heads:
> node = repo.revs('max(.::(%ln))', heads).first()
> - if bookmarks.isactivewdirparent(repo):
> - movemark = repo['.'].node()
> + if currentbranch not in repo.branchmap():
> + repo.ui.warn(_('uncommitted branch %s does not
> exist, '
> + 'updating to the head of parent
> branch\n')
> + % currentbranch)
> else:
> - node = repo['.'].node()
> + if currentbranch in repo.branchmap():
> + heads = repo.branchheads(currentbranch)
> + if heads:
> + node = repo.revs('max(.::(%ln))', heads).first()
> + if bookmarks.isactivewdirparent(repo):
> + movemark = repo['.'].node()
> + else:
> + node = repo['.'].node()
> return node, movemark, None
>
> def _destupdatebranchfallback(repo, clean, check):
> diff -r cabc4e5224db -r dece0d6bc144 tests/test-newbranch.t
> --- a/tests/test-newbranch.t Tue Apr 05 06:53:33 2016 +0200
> +++ b/tests/test-newbranch.t Tue Apr 05 07:30:01 2016 +0200
> @@ -391,3 +391,58 @@ We expect that bare update on new branch
> commit: (new branch)
> update: (current)
> phases: 3 draft
> +
> + $ cd ..
> +
> +We expect that update --clean discard changes in working directory,
> +and updates to the head of parent branch.
> +
> + $ hg init updatebareclean
> + $ cd updatebareclean
> + $ hg update --clean
> + 0 files updated, 0 files merged, 0 files removed, 0 files
> unresolved
> + $ touch a
> + $ hg commit -A -m "a"
> + adding a
> + $ touch b
> + $ hg commit -A -m "b"
> + adding b
> + $ touch c
> + $ hg commit -A -m "c"
> + adding c
> + $ hg log
> + changeset: 2:991a3460af53
> + tag: tip
> + user: test
> + date: Thu Jan 01 00:00:00 1970 +0000
> + summary: c
> +
> + changeset: 1:0e067c57feba
> + user: test
> + date: Thu Jan 01 00:00:00 1970 +0000
> + summary: b
> +
> + changeset: 0:3903775176ed
> + user: test
> + date: Thu Jan 01 00:00:00 1970 +0000
> + summary: a
> +
> + $ hg update -r 1
> + 0 files updated, 0 files merged, 1 files removed, 0 files
> unresolved
> + $ hg branch new-branch
> + marked working directory as branch new-branch
> + (branches are permanent and global, did you want a bookmark?)
> + $ echo "aa" >> a
> + $ hg update --clean
> + uncommitted branch new-branch does not exist, updating to the
> head of parent branch
> + 2 files updated, 0 files merged, 0 files removed, 0 files
> unresolved
> + $ hg status
> + $ hg branch
> + default
> + $ hg parent
> + changeset: 2:991a3460af53
> + tag: tip
> + user: test
> + date: Thu Jan 01 00:00:00 1970 +0000
> + summary: c
> +
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> <mailto:Mercurial-devel at mercurial-scm.org>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=CwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=mEgSWILcY4c4W3zjApBQLA&m=0CfCsgbAHYSJuudfZETgD37V8iW7OcgWbJlLm-esIw8&s=8f-McLAsJIV4rTria6XwDa_05Mwhp52IY0DG9vca3HE&e=
>
>
> --
> Simon Farnsworth
>
>
--
Simon Farnsworth
More information about the Mercurial-devel
mailing list