tests/test-rebuildstate.t
changeset 27174 9fbe3545e4bd
parent 23840 ddc17eaf0f1b
child 27175 25a8a866eb5d
equal deleted inserted replaced
27173:8a8f5d71a49a 27174:9fbe3545e4bd
       
     1 
       
     2   $ cat > adddrop.py <<EOF
       
     3   > from mercurial import cmdutil
       
     4   > cmdtable = {}
       
     5   > command = cmdutil.command(cmdtable)
       
     6   > @command('debugadddrop',
       
     7   >   [('', 'drop', False, 'drop file from dirstate', 'FILE'),
       
     8   >    ('', 'normal-lookup', False, 'add file to dirstate', 'FILE')],
       
     9   >     'hg debugadddrop')
       
    10   > def debugadddrop(ui, repo, *pats, **opts):
       
    11   >   '''Add or drop unnamed arguments to or from the dirstate'''
       
    12   >   drop = opts.get('drop')
       
    13   >   nl = opts.get('normal_lookup')
       
    14   >   if nl and drop:
       
    15   >       raise error.Abort('drop and normal-lookup are mutually exclusive')
       
    16   >   wlock = repo.wlock()
       
    17   >   try:
       
    18   >     for file in pats:
       
    19   >       if opts.get('normal_lookup'):
       
    20   >         repo.dirstate.normallookup(file)
       
    21   >       else:
       
    22   >         repo.dirstate.drop(file)
       
    23   > 
       
    24   >     repo.dirstate.write(repo.currenttransaction())
       
    25   >   finally:
       
    26   >     wlock.release()
       
    27   > EOF
       
    28 
       
    29   $ echo "[extensions]" >> $HGRCPATH
       
    30   $ echo "debugadddrop=`pwd`/adddrop.py" >> $HGRCPATH
       
    31 
     1 basic test for hg debugrebuildstate
    32 basic test for hg debugrebuildstate
     2 
    33 
     3   $ hg init repo
    34   $ hg init repo
     4   $ cd repo
    35   $ cd repo
     5 
    36 
    18 
    49 
    19   $ hg debugstate --nodates | sort
    50   $ hg debugstate --nodates | sort
    20   n 644         -1 set                 bar
    51   n 644         -1 set                 bar
    21   n 644         -1 set                 foo
    52   n 644         -1 set                 foo
    22 
    53 
       
    54   $ hg debugadddrop --normal-lookup file1 file2
       
    55   $ hg debugadddrop --drop bar
       
    56   $ hg debugadddrop --drop
       
    57   $ hg debugstate --nodates
       
    58   n   0         -1 unset               file1
       
    59   n   0         -1 unset               file2
       
    60   n 644         -1 set                 foo
       
    61   $ hg debugrebuildstate
       
    62 
    23 status
    63 status
    24 
    64 
    25   $ hg st -A
    65   $ hg st -A
    26   ! bar
    66   ! bar
    27   ? baz
    67   ? baz