[PATCH 2 of 4] Move commands.forget over to using new walk code

Bryan O'Sullivan bos at serpentine.com
Fri Jul 29 20:24:14 UTC 2005


With no names, it now recursively forgets everything, as is the default
behaviour of other commands.  And prints the names of all files it
hasn't specifically been told to forget.

# HG changeset patch
# User Bryan O'Sullivan <bos at serpentine.com>
# Node ID 790a0ff306f2f43d96c1aa2f8254e1a49dcd8d2b
# Parent  d0fb9efa2b2d972c2ca5357acdbad0414c8def0c
Move commands.forget over to using new walk code.

With no names, it now recursively forgets everything, as is the default
behaviour of other commands.  And prints the names of all files it
hasn't specifically been told to forget.

diff -r d0fb9efa2b2d -r 790a0ff306f2 doc/hg.1.txt
--- a/doc/hg.1.txt	Fri Jul 29 16:42:28 2005
+++ b/doc/hg.1.txt	Fri Jul 29 16:49:01 2005
@@ -161,8 +161,12 @@
 
     -o, --output <filespec>   print output to file with formatted named
 
-forget [files]::
+forget [options] [files]::
     Undo an 'hg add' scheduled for the next commit.
+
+    options:
+    -I, --include <pat>  include directories matching the given patterns
+    -X, --exclude <pat>  exclude directories matching the given patterns
 
 heads::
     Show all repository head changesets.
diff -r d0fb9efa2b2d -r 790a0ff306f2 mercurial/commands.py
--- a/mercurial/commands.py	Fri Jul 29 16:42:28 2005
+++ b/mercurial/commands.py	Fri Jul 29 16:49:01 2005
@@ -601,9 +601,15 @@
         seqno += 1
         doexport(ui, repo, cset, seqno, total, revwidth, opts)
 
-def forget(ui, repo, file1, *files):
+def forget(ui, repo, *pats, **opts):
     """don't add the specified files on the next commit"""
-    repo.forget(relpath(repo, (file1,) + files))
+    q = dict(zip(pats, pats))
+    forget = []
+    for src, abs, rel in walk(repo, pats, opts):
+        if repo.dirstate.state(abs) == 'a':
+            forget.append(abs)
+            if rel not in q: ui.status('forgetting ', rel, '\n')
+    repo.forget(forget)
 
 def heads(ui, repo):
     """show current repository heads"""
@@ -1153,7 +1159,10 @@
         (export,
          [('o', 'output', "", 'output to file')],
          "hg export [-o OUTFILE] REV..."),
-    "forget": (forget, [], "hg forget FILE..."),
+    "forget": (forget,
+               [('I', 'include', [], 'include path in search'),
+                ('X', 'exclude', [], 'exclude path from search')],
+               "hg forget FILE..."),
     "heads": (heads, [], 'hg heads'),
     "help": (help_, [], 'hg help [COMMAND]'),
     "identify|id": (identify, [], 'hg identify'),





More information about the Mercurial mailing list