Patchwork [STABLE] forget: cleanup the output for an inexact case match on icasefs

login
register
mail settings
Submitter Matt Harbison
Date March 31, 2015, 10:20 p.m.
Message ID <7bc88b9b004f32490ca9.1427840423@MATT7H-PC.attotech.com>
Download mbox | patch
Permalink /patch/8398/
State Accepted
Headers show

Comments

Matt Harbison - March 31, 2015, 10:20 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1427838166 14400
#      Tue Mar 31 17:42:46 2015 -0400
# Branch stable
# Node ID 7bc88b9b004f32490ca9983ca5db72b0813537eb
# Parent  2bb13f2b778c0675811171c932762a381b022443
forget: cleanup the output for an inexact case match on icasefs

Previously, specifying a file name but not matching the dirstate case yielded
the following, even though the file was actually removed:

  $ hg forget capsdir1/capsdir/abc.txt
  not removing capsdir\a.txt: file is already untracked
  removing CapsDir\A.txt
  [1]

This change doesn't appear to cause any extra filesystem accesses, even if a
nonexistant file is specified.

If a directory is specified without a case match, it is (and was previously)
still silently ignored.
Matt Mackall - March 31, 2015, 10:23 p.m.
On Tue, 2015-03-31 at 18:20 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1427838166 14400
> #      Tue Mar 31 17:42:46 2015 -0400
> # Branch stable
> # Node ID 7bc88b9b004f32490ca9983ca5db72b0813537eb
> # Parent  2bb13f2b778c0675811171c932762a381b022443
> forget: cleanup the output for an inexact case match on icasefs

Queued for stable, thanks for tidying this up.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2044,6 +2044,12 @@  def forget(ui, repo, match, prefix, expl
             if f not in repo.dirstate and not repo.wvfs.isdir(f):
                 if f not in forgot:
                     if repo.wvfs.exists(f):
+                        # Don't complain if the exact case match wasn't given.
+                        # But don't do this until after checking 'forgot', so
+                        # that subrepo files aren't normalized, and this op is
+                        # purely from data cached by the status walk above.
+                        if repo.dirstate.normalize(f) in repo.dirstate:
+                            continue
                         ui.warn(_('not removing %s: '
                                   'file is already untracked\n')
                                 % match.rel(f))
diff --git a/tests/test-add.t b/tests/test-add.t
--- a/tests/test-add.t
+++ b/tests/test-add.t
@@ -179,6 +179,9 @@  Test that adding a directory doesn't req
   $ hg add -v capsdir1/capsdir
   adding CapsDir1/CapsDir/AbC.txt (glob)
   adding CapsDir1/CapsDir/SubDir/Def.txt (glob)
+
+  $ hg forget capsdir1/capsdir/abc.txt
+  removing CapsDir1/CapsDir/AbC.txt (glob)
 #endif
 
   $ cd ..