[PATCH] revert: makes interactive mode ask user if he wants to forget added files (issue4936)
Augie Fackler
raf at durin42.com
Fri Feb 5 10:47:33 EST 2016
On Fri, Feb 05, 2016 at 03:20:26PM +0100, liscju wrote:
> # HG changeset patch
> # User liscju <piotr.listkiewicz at gmail.com>
> # Date 1454681920 -3600
> # Fri Feb 05 15:18:40 2016 +0100
> # Node ID bfd4cc9096ee1b3d451e8f68c767b93644488f00
> # Parent 01a5143cd25f285f8c745a92986cd7186bb32c90
> revert: makes interactive mode ask user if he wants to forget added files (issue4936)
Queued, very nice.
>
> Before this patch revert interactive mode unconditionally forgets
> added files. This patch fixes this by asking user if he wants
> to forget added file. If user doesn't want to forget given file,
> it is added to matcher_opts exclude list, to not reviewing it
> later with other modified files.
>
> diff -r 01a5143cd25f -r bfd4cc9096ee mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py Wed Feb 03 16:24:24 2016 -0600
> +++ b/mercurial/cmdutil.py Fri Feb 05 15:18:40 2016 +0100
> @@ -3130,13 +3130,25 @@
> """
> parent, p2 = parents
> node = ctx.node()
> + excluded_files = []
> + matcher_opts = {"exclude": excluded_files}
> +
> def checkout(f):
> fc = ctx[f]
> repo.wwrite(f, fc.data(), fc.flags())
>
> audit_path = pathutil.pathauditor(repo.root)
> for f in actions['forget'][0]:
> - repo.dirstate.drop(f)
> + if interactive:
> + choice = \
> + repo.ui.promptchoice(
> + _("Would you like to forget file %s (Yn)? $$ &Yes $$ &No") % f)
> + if choice == 0:
> + repo.dirstate.drop(f)
> + else:
> + excluded_files.append(repo.wjoin(f))
> + else:
> + repo.dirstate.drop(f)
> for f in actions['remove'][0]:
> audit_path(f)
> try:
> @@ -3162,7 +3174,7 @@
> if interactive:
> # Prompt the user for changes to revert
> torevert = [repo.wjoin(f) for f in actions['revert'][0]]
> - m = scmutil.match(ctx, torevert, {})
> + m = scmutil.match(ctx, torevert, matcher_opts)
> diffopts = patch.difffeatureopts(repo.ui, whitespace=True)
> diffopts.nodates = True
> diffopts.git = True
> diff -r 01a5143cd25f -r bfd4cc9096ee tests/test-revert-interactive.t
> --- a/tests/test-revert-interactive.t Wed Feb 03 16:24:24 2016 -0600
> +++ b/tests/test-revert-interactive.t Fri Feb 05 15:18:40 2016 +0100
> @@ -15,6 +15,7 @@
> > interactive = true
> > [extensions]
> > record =
> + > purge =
> > EOF
>
>
> @@ -377,3 +378,26 @@
> 5
> d
> +lastline
> +
> + $ hg update -C .
> + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> + $ hg purge
> + $ touch newfile
> + $ hg add newfile
> + $ hg status
> + A newfile
> + $ hg revert -i <<EOF
> + > n
> + > EOF
> + forgetting newfile
> + Would you like to forget file newfile (Yn)? n
> + $ hg status
> + A newfile
> + $ hg revert -i <<EOF
> + > y
> + > EOF
> + forgetting newfile
> + Would you like to forget file newfile (Yn)? y
> + $ hg status
> + ? newfile
> +
> _______________________________________________
> 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