tests/test-rebuildstate.t
author Christian Delahousse <cdelahousse@fb.com>
Tue, 01 Dec 2015 11:17:14 -0800
changeset 27174 9fbe3545e4bd
parent 23840 ddc17eaf0f1b
child 27175 25a8a866eb5d
permissions -rw-r--r--
debugdirstate: add command to rebuildstate test to modify dirstate Debugging the dirstate helps if you have options to add files for normal lookup or drop them from the dirstate. This patch adds a convenience command to test-rebuilddirstate.t to modify the dirstate. It will be used in the next patch to write proper tests for debugrebuilddirstate --minimal
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27174
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
     1
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
     2
  $ cat > adddrop.py <<EOF
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
     3
  > from mercurial import cmdutil
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
     4
  > cmdtable = {}
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
     5
  > command = cmdutil.command(cmdtable)
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
     6
  > @command('debugadddrop',
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
     7
  >   [('', 'drop', False, 'drop file from dirstate', 'FILE'),
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
     8
  >    ('', 'normal-lookup', False, 'add file to dirstate', 'FILE')],
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
     9
  >     'hg debugadddrop')
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    10
  > def debugadddrop(ui, repo, *pats, **opts):
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    11
  >   '''Add or drop unnamed arguments to or from the dirstate'''
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    12
  >   drop = opts.get('drop')
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    13
  >   nl = opts.get('normal_lookup')
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    14
  >   if nl and drop:
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    15
  >       raise error.Abort('drop and normal-lookup are mutually exclusive')
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    16
  >   wlock = repo.wlock()
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    17
  >   try:
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    18
  >     for file in pats:
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    19
  >       if opts.get('normal_lookup'):
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    20
  >         repo.dirstate.normallookup(file)
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    21
  >       else:
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    22
  >         repo.dirstate.drop(file)
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    23
  > 
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    24
  >     repo.dirstate.write(repo.currenttransaction())
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    25
  >   finally:
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    26
  >     wlock.release()
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    27
  > EOF
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    28
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    29
  $ echo "[extensions]" >> $HGRCPATH
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    30
  $ echo "debugadddrop=`pwd`/adddrop.py" >> $HGRCPATH
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    31
12121
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    32
basic test for hg debugrebuildstate
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    33
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    34
  $ hg init repo
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    35
  $ cd repo
5065
b304c2496f52 dirstate: fix rebuild; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    36
12121
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    37
  $ touch foo bar
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    38
  $ hg ci -Am 'add foo bar'
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    39
  adding bar
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    40
  adding foo
5065
b304c2496f52 dirstate: fix rebuild; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    41
12121
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    42
  $ touch baz
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    43
  $ hg add baz
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    44
  $ hg rm bar
5065
b304c2496f52 dirstate: fix rebuild; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    45
12121
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    46
  $ hg debugrebuildstate
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    47
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    48
state dump after
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    49
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    50
  $ hg debugstate --nodates | sort
23840
ddc17eaf0f1b debugdirstate: don't hide date field with --nodate, just show 'set'/'unset'
Mads Kiilerich <madski@unity3d.com>
parents: 16913
diff changeset
    51
  n 644         -1 set                 bar
ddc17eaf0f1b debugdirstate: don't hide date field with --nodate, just show 'set'/'unset'
Mads Kiilerich <madski@unity3d.com>
parents: 16913
diff changeset
    52
  n 644         -1 set                 foo
5065
b304c2496f52 dirstate: fix rebuild; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    53
27174
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    54
  $ hg debugadddrop --normal-lookup file1 file2
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    55
  $ hg debugadddrop --drop bar
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    56
  $ hg debugadddrop --drop
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    57
  $ hg debugstate --nodates
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    58
  n   0         -1 unset               file1
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    59
  n   0         -1 unset               file2
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    60
  n 644         -1 set                 foo
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    61
  $ hg debugrebuildstate
9fbe3545e4bd debugdirstate: add command to rebuildstate test to modify dirstate
Christian Delahousse <cdelahousse@fb.com>
parents: 23840
diff changeset
    62
12121
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    63
status
5065
b304c2496f52 dirstate: fix rebuild; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    64
12121
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    65
  $ hg st -A
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    66
  ! bar
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    67
  ? baz
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    68
  C foo
8f258dd4ed02 tests: unify test-rebuildstate
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 6344
diff changeset
    69
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 15440
diff changeset
    70
  $ cd ..