[PATCH] forget, remove: don't note on nonexistent file twice

Idan Kamara idankk86 at gmail.com
Mon Jun 13 06:56:03 CDT 2011


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1307966160 -10800
# Node ID 4d144526a58beb56d439d0192e9b9815b59e5ddf
# Parent  5f743d42591616ba5d1527fd4cdb24cd9e42e4ff
forget, remove: don't note on nonexistent file twice

before:
  $ hg forget foo
  foo: No such file or directory
  not removing foo: file is already untracked

after:
  $ hg forget foo
  foo: No such file or directory

diff -r 5f743d425916 -r 4d144526a58b mercurial/commands.py
--- a/mercurial/commands.py	Mon Jun 13 00:19:26 2011 +0300
+++ b/mercurial/commands.py	Mon Jun 13 14:56:00 2011 +0300
@@ -2272,8 +2272,9 @@
 
     for f in m.files():
         if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
-            ui.warn(_('not removing %s: file is already untracked\n')
-                    % m.rel(f))
+            if os.path.exists(m.rel(f)):
+                ui.warn(_('not removing %s: file is already untracked\n')
+                        % m.rel(f))
             errs = 1
 
     for f in forget:
@@ -3917,7 +3918,8 @@
 
     for f in m.files():
         if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
-            ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
+            if os.path.exists(m.rel(f)):
+                ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
             ret = 1
 
     if force:


More information about the Mercurial-devel mailing list