[PATCH 2 of 2 V2] switch: add a switch extension to easily move between branches (issue4420)
yuya at tcha.org
Sat Mar 5 00:38:28 EST 2016
On Tue, 01 Mar 2016 21:10:32 +0100, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1456130672 -3600
> # Mon Feb 22 09:44:32 2016 +0100
> # Node ID faf19a7078eddcb14a4272908c53990f88fa096a
> # Parent 46461ba496c9fd763f6e47217ba8b6de8b8ca1d1
> switch: add a switch extension to easily move between branches (issue4420)
I read the issue, but I couldn't get the point why we need new command. If
it's possible to get back (or recover) from miserable merge of "hg update",
I think "hg update another-branch" can be allowed.
> Without argument switch command shows possible switch destination -
> other branches. With one argument it shelves current changes, updates
> to given branch and try to unshelve changes.
Hmm, but you can switch to any revisions that aren't listed by "hg switch",
which seems awkward.
> +def switch(ui, repo, *branch, **opts):
> + """switches to given branch or show possible switch destination
> + With no argument show possible switch destination. With one
> + argument saves changes made to the working directory, updates to
> + given branch and restores saved changes. Before switching to other
> + branch it marks new/missing files as added/removed respectively.
> + """
> + with repo.wlock():
> + _doswitch(ui, repo, *branch, **opts)
wlock won't be necessary for _showbranches().
> + elif len(destbranch) > 1:
> + raise error.Abort(_('can only switch to one branch at a time'))
> + else:
> + destbranch = destbranch
scmutil.revsingle() can accept an revset.
More information about the Mercurial-devel