tests/test-oldconvert.t
author Anton Shestakov <av6@dwimlabs.net>
Fri, 07 Jun 2019 18:14:48 +0800
branchstable
changeset 4687 313565dd75e3
parent 2776 4dd84054ebbb
permissions -rw-r--r--
pick: remove transaction on the whole command (issue6037) At its core, pick is a pretty straightforward and well-behaving command, it uses functions already in core hg, it checks that wdir is clean and that changeset to pick is not public, it checks if there happen to be merge conflicts and can be --continue'd later, etc. It is very similar to graft in core (it also uses mergemod.graft function), but it obsoletes the original changeset. However, graft does not experience this incorrect behavior from issue 6037. What happens in the test case for this issue when we pick a revision that touches both "a" and "b": mergemod.graft() takes the original changeset and tries to apply it to the wdir, which results in "b" being marked as newly added and ready to be committed, "a" updated with the new content and being marked as modified, but "a" also has conflicts. Pick correctly notices this and saves its state before asking for user intervention. So far so good. However, when the command raises InterventionRequired to print a user-facing message and exit while being wrapped in repo.transaction() context manager, the latter partially undoes what mergemod.graft() did: it unmarks "b" as added. And when user continues pick, "b" is therefore not tracked and is not included in the resulting commit. The transaction is not useful here, because it doesn't touch wdir (it's still dirty), it doesn't remove pickstate (and other commands will refuse to work until pick --abort or --continue), it just makes "b" untracked. The solution is to use repo.transaction() only to wrap code that writes data to hg store in the final stages of the command after all checks have passed and is not expected to fail on trivial cases like merge conflicts. For example, committing the picked changeset. But since pick uses repo.commit() for that, and because that function already uses a transaction, wrapping it in another transaction doesn't make sense.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
     1
  $ cat >> $HGRCPATH <<EOF
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
     2
  > [web]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
     3
  > push_ssl = false
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
     4
  > allow_push = *
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
     5
  > [phases]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
     6
  > publish=False
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
     7
  > [alias]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
     8
  > odiff=diff --rev 'limit(obsparents(.),1)' --rev .
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
     9
  > [extensions]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    10
  > EOF
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    11
  $ mkcommit() {
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    12
  >    echo "$1" > "$1"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    13
  >    hg add "$1"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    14
  >    hg ci -m "add $1"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    15
  > }
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    16
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    17
create commit
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    18
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    19
  $ hg init repo
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    20
  $ cd repo
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    21
  $ mkcommit a
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    22
  $ mkcommit b
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    23
  $ hg up -q 0
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    24
  $ mkcommit c
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    25
  created new head
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    26
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    27
forge old style relation files
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    28
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    29
  $ hg log -r 2 --template='{node} ' > .hg/obsolete-relations
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    30
  $ hg log -r 1 --template='{node}' >> .hg/obsolete-relations
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    31
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    32
enable the extensions
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    33
1810
ce4018f03520 hgext3rd: move 'obsolete' as 'evolve.legacy'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 1065
diff changeset
    34
  $ echo "obsolete=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/legacy.py" >> $HGRCPATH
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    35
2776
4dd84054ebbb test: remove reference to the graphlog extension
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 1810
diff changeset
    36
  $ hg log -G
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    37
  abort: old format of obsolete marker detected!
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    38
  run `hg debugconvertobsolete` once.
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    39
  [255]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    40
  $ hg debugconvertobsolete --traceback
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    41
  1 obsolete marker converted
2776
4dd84054ebbb test: remove reference to the graphlog extension
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 1810
diff changeset
    42
  $ hg log -G
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    43
  @  changeset:   2:d67cd0334eee
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    44
  |  tag:         tip
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    45
  |  parent:      0:1f0dee641bb7
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    46
  |  user:        test
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    47
  |  date:        Thu Jan 01 00:00:00 1970 +0000
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    48
  |  summary:     add c
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    49
  |
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    50
  o  changeset:   0:1f0dee641bb7
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    51
     user:        test
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    52
     date:        Thu Jan 01 00:00:00 1970 +0000
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    53
     summary:     add a
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    54
  
441
d702f0d26c6a obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 350
diff changeset
    55
  $ hg debugobsolete
1065
f355bbc124fc test: update test to new date formatting in debuobsolete output
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 441
diff changeset
    56
  7c3bad9141dcb46ff89abf5f61856facd56e476c d67cd0334eeecfded222fed9009f0db4beb57585 0 (*) {'user': 'test'} (glob)
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    57
  $ hg debugconvertobsolete
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    58
  nothing to do
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents:
diff changeset
    59
  0 obsolete marker converted
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    60
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    61
Convert json
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    62
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    63
  $ cat > .hg/store/obsoletemarkers << EOF
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    64
  > [
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    65
  >     {
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    66
  >         "reason": "import from older format.", 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    67
  >         "subjects": [
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    68
  >             "3218406b50ed13480765e7c260669620f37fba6e"
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    69
  >         ], 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    70
  >         "user": "Pierre-Yves David <pierre-yves.david@ens-lyon.org>", 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    71
  >         "date": [
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    72
  >             1336503323.9768269, 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    73
  >             -7200
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    74
  >         ], 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    75
  >         "object": "3e03d82708d4da97a92158558dd13386d8f09ad5", 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    76
  >         "id": "4743f676eaf3923cb98c921ee06b2e91052c365b"
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    77
  >     }, 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    78
  >     {
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    79
  >         "reason": "import from older format.", 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    80
  >         "user": "Pierre-Yves David <pierre-yves.david@logilab.fr>", 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    81
  >         "date": [
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    82
  >             1336557472.7875929, 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    83
  >             -7200
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    84
  >         ], 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    85
  >         "object": "5c722672795c3a2cb94d0cc9a821c394c1475f87", 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    86
  >         "id": "1fd90a84b7225d2e3062b7e1b3100aa2e060fc72"
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    87
  >     }, 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    88
  >     {
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    89
  >         "reason": "import from older format.", 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    90
  >         "subjects": [
350
b836862d48b4 [convert] properly exclude null successors from convertion
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 334
diff changeset
    91
  >             "0000000000000000000000000000000000000000"
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    92
  >         ], 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    93
  >         "user": "Pierre-Yves David <pierre-yves.david@logilab.fr>", 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    94
  >         "date": [
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    95
  >             1336557472.784307, 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    96
  >             -7200
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    97
  >         ], 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    98
  >         "object": "2c3784e102bb34ccc93862af5bd6d609ee30c577", 
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
    99
  >         "id": "7d940c5ee1f886c8a6c0d805b43e522cb3ef7a15"
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
   100
  >     }
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
   101
  > ]
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
   102
  > EOF
2776
4dd84054ebbb test: remove reference to the graphlog extension
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 1810
diff changeset
   103
  $ hg log -G
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
   104
  abort: old format of obsolete marker detected!
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
   105
  run `hg debugconvertobsolete` once.
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
   106
  [255]
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
   107
  $ hg debugconvertobsolete --traceback
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
   108
  3 obsolete marker converted
441
d702f0d26c6a obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 350
diff changeset
   109
  $ hg debugobsolete
1065
f355bbc124fc test: update test to new date formatting in debuobsolete output
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 441
diff changeset
   110
  7c3bad9141dcb46ff89abf5f61856facd56e476c d67cd0334eeecfded222fed9009f0db4beb57585 0 (*) {'user': 'test'} (glob)
f355bbc124fc test: update test to new date formatting in debuobsolete output
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 441
diff changeset
   111
  3e03d82708d4da97a92158558dd13386d8f09ad5 3218406b50ed13480765e7c260669620f37fba6e 0 (Tue May 08 20:55:23 2012 +0200) {'user': 'Pierre-Yves David <pierre-yves.david@ens-lyon.org>'}
f355bbc124fc test: update test to new date formatting in debuobsolete output
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 441
diff changeset
   112
  5c722672795c3a2cb94d0cc9a821c394c1475f87 0 (Wed May 09 11:57:52 2012 +0200) {'user': 'Pierre-Yves David <pierre-yves.david@logilab.fr>'}
f355bbc124fc test: update test to new date formatting in debuobsolete output
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 441
diff changeset
   113
  2c3784e102bb34ccc93862af5bd6d609ee30c577 0 (Wed May 09 11:57:52 2012 +0200) {'user': 'Pierre-Yves David <pierre-yves.david@logilab.fr>'}