tests/test-rebuildstate.t
changeset 27174 9fbe3545e4bd
parent 23840 ddc17eaf0f1b
child 27175 25a8a866eb5d
--- a/tests/test-rebuildstate.t	Wed Dec 02 06:33:52 2015 +0000
+++ b/tests/test-rebuildstate.t	Tue Dec 01 11:17:14 2015 -0800
@@ -1,3 +1,34 @@
+
+  $ cat > adddrop.py <<EOF
+  > from mercurial import cmdutil
+  > cmdtable = {}
+  > command = cmdutil.command(cmdtable)
+  > @command('debugadddrop',
+  >   [('', 'drop', False, 'drop file from dirstate', 'FILE'),
+  >    ('', 'normal-lookup', False, 'add file to dirstate', 'FILE')],
+  >     'hg debugadddrop')
+  > def debugadddrop(ui, repo, *pats, **opts):
+  >   '''Add or drop unnamed arguments to or from the dirstate'''
+  >   drop = opts.get('drop')
+  >   nl = opts.get('normal_lookup')
+  >   if nl and drop:
+  >       raise error.Abort('drop and normal-lookup are mutually exclusive')
+  >   wlock = repo.wlock()
+  >   try:
+  >     for file in pats:
+  >       if opts.get('normal_lookup'):
+  >         repo.dirstate.normallookup(file)
+  >       else:
+  >         repo.dirstate.drop(file)
+  > 
+  >     repo.dirstate.write(repo.currenttransaction())
+  >   finally:
+  >     wlock.release()
+  > EOF
+
+  $ echo "[extensions]" >> $HGRCPATH
+  $ echo "debugadddrop=`pwd`/adddrop.py" >> $HGRCPATH
+
 basic test for hg debugrebuildstate
 
   $ hg init repo
@@ -20,6 +51,15 @@
   n 644         -1 set                 bar
   n 644         -1 set                 foo
 
+  $ hg debugadddrop --normal-lookup file1 file2
+  $ hg debugadddrop --drop bar
+  $ hg debugadddrop --drop
+  $ hg debugstate --nodates
+  n   0         -1 unset               file1
+  n   0         -1 unset               file2
+  n 644         -1 set                 foo
+  $ hg debugrebuildstate
+
 status
 
   $ hg st -A