tests/test-rename-rev.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Sat, 25 Jul 2020 15:13:25 +0200
changeset 45249 b3040b6739ce
parent 44807 16596f5e1afa
child 45369 5178dd2233d0
permissions -rw-r--r--
commitctx: extract copy information encoding into extra into commit.py The encoding of copy information into extra has multiple subcases and become quite complicated (eg: empty list can be explicitly or implicitly stored for example). In addition, it is niche experimental feature since as it affect the hash, it is only suitable for user who don't mercurial for storage server side (ie: Google). Having this complexity part of the changelog will get in the way of further cleanup. We could have to either move more of that logic into the changelog or to move or extract more of the logic at the higher level. We take the second approach and start gather logic in dedicated function in commit.py.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12098
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
     1
  $ hg init
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
     2
  $ mkdir d1 d1/d11 d2
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
     3
  $ echo d1/a > d1/a
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
     4
  $ echo d1/ba > d1/ba
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
     5
  $ echo d1/a1 > d1/d11/a1
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
     6
  $ echo d1/b > d1/b
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
     7
  $ echo d2/b > d2/b
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
     8
  $ hg add d1/a d1/b d1/ba d1/d11/a1 d2/b
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
     9
  $ hg commit -m "intial"
12898
f2fd909053d9 test-rename: test with absolute paths
Martin Geisler <mg@aragost.com>
parents: 12897
diff changeset
    10
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    11
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    12
Test single file
1565
4bcbc126b80b fix rename --after
Robin Farine <robin.farine@terminus.org>
parents: 1515
diff changeset
    13
44806
8e47b43d665f tests: show poor error message for `hg cp -A --at-rev . non-existent dst`
Martin von Zweigbergk <martinvonz@google.com>
parents: 44805
diff changeset
    14
# One recorded copy, one copy to record after commit
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    15
  $ hg cp d1/b d1/c
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    16
  $ cp d1/b d1/d
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    17
  $ hg add d1/d
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    18
  $ hg ci -m 'copy d1/b to d1/c and d1/d'
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    19
  $ hg st -C --change .
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    20
  A d1/c
12098
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
    21
    d1/b
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    22
  A d1/d
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    23
# Errors out without --after for now
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    24
  $ hg cp --at-rev . d1/b d1/d
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    25
  abort: --at-rev requires --after
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    26
  [255]
44806
8e47b43d665f tests: show poor error message for `hg cp -A --at-rev . non-existent dst`
Martin von Zweigbergk <martinvonz@google.com>
parents: 44805
diff changeset
    27
# Errors out with non-existent source
8e47b43d665f tests: show poor error message for `hg cp -A --at-rev . non-existent dst`
Martin von Zweigbergk <martinvonz@google.com>
parents: 44805
diff changeset
    28
  $ hg cp -A --at-rev . d1/non-existent d1/d
8e47b43d665f tests: show poor error message for `hg cp -A --at-rev . non-existent dst`
Martin von Zweigbergk <martinvonz@google.com>
parents: 44805
diff changeset
    29
  d1/non-existent: no such file in rev 55d1fd85ef0a
44807
16596f5e1afa copy: give better error message when no source paths found with --at-rev
Martin von Zweigbergk <martinvonz@google.com>
parents: 44806
diff changeset
    30
  abort: no files to copy
44806
8e47b43d665f tests: show poor error message for `hg cp -A --at-rev . non-existent dst`
Martin von Zweigbergk <martinvonz@google.com>
parents: 44805
diff changeset
    31
  [255]
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    32
# Errors out with non-existent destination
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    33
  $ hg cp -A --at-rev . d1/b d1/non-existent
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    34
  abort: d1/non-existent: copy destination does not exist in 8a9d70fa20c9
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    35
  [255]
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    36
# Successful invocation
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    37
  $ hg cp -A --at-rev . d1/b d1/d
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    38
  saved backup bundle to $TESTTMP/.hg/strip-backup/8a9d70fa20c9-973ae357-copy.hg
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    39
# New copy is recorded, and previously recorded copy is also still there
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    40
  $ hg st -C --change .
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    41
  A d1/c
12098
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
    42
    d1/b
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    43
  A d1/d
12098
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
    44
    d1/b
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
    45
44804
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    46
Test moved file (not copied)
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    47
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    48
  $ hg co 0
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    49
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    50
  $ mv d1/b d1/d
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    51
  $ hg rm -A d1/b
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    52
  $ hg add d1/d
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    53
  $ hg ci -m 'move d1/b to d1/d'
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    54
  created new head
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    55
  $ hg cp -A --at-rev . d1/b d1/d
44805
02bf61bb4a70 copy: to find copy source, walk parent of revision we're marking copies in
Martin von Zweigbergk <martinvonz@google.com>
parents: 44804
diff changeset
    56
  saved backup bundle to $TESTTMP/.hg/strip-backup/519850c3ea27-153c8fbb-copy.hg
44804
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    57
  $ hg st -C --change .
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    58
  A d1/d
44805
02bf61bb4a70 copy: to find copy source, walk parent of revision we're marking copies in
Martin von Zweigbergk <martinvonz@google.com>
parents: 44804
diff changeset
    59
    d1/b
44804
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    60
  R d1/b
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    61
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    62
Test using directory as destination
1512
53ad6ee6ede4 generalize copy/rename to handle more than one source directory
Robin Farine <robin.farine@terminus.org>
parents:
diff changeset
    63
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    64
  $ hg co 0
44804
5c49a4fdb238 tests: show that `hg cp -A --at-rev .` doesn't work for renames
Martin von Zweigbergk <martinvonz@google.com>
parents: 44367
diff changeset
    65
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    66
  $ cp -R d1 d3
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    67
  $ hg add d3
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    68
  adding d3/a
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    69
  adding d3/b
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    70
  adding d3/ba
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    71
  adding d3/d11/a1
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    72
  $ hg ci -m 'copy d1/ to d3/'
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    73
  created new head
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    74
  $ hg cp -A --at-rev . d1 d3
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
    75
  abort: d3: --at-rev does not support a directory as destination
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12156
diff changeset
    76
  [255]
12098
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
    77