annotate tests/test-rename-rev.t @ 44367:9dab3fa64325

copy: add experimental support for marking committed copies The simplest way I'm aware of to mark a file as copied/moved after committing is this: hg uncommit --keep <src> <dest> # <src> needed for move, but not copy hg mv --after <src> <dest> hg amend This patch teaches `hg copy` a `--at-rev` argument to simplify that into: hg copy --after --at-rev . <src> <dest> In addition to being simpler, it doesn't touch the working copy, so it can easily be used even if the destination file has been modified in the working copy. Differential Revision: https://phab.mercurial-scm.org/D8035
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 20 Dec 2019 13:24:46 -0800
parents tests/test-rename.t@5b92a717bfc1
children 5c49a4fdb238
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
14 # One recoded copy, one copy to record after commit
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]
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
27 # 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
28 $ 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
29 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
30 [255]
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
31 # Successful invocation
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
32 $ 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
33 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
34 # 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
35 $ hg st -C --change .
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
36 A d1/c
12098
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
37 d1/b
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
38 A d1/d
12098
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
39 d1/b
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
40
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
41 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
42
44367
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
43 $ hg co 0
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
44 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
45 $ cp -R d1 d3
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
46 $ hg add d3
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
47 adding d3/a
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
48 adding d3/b
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
49 adding d3/ba
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
50 adding d3/d11/a1
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
51 $ 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
52 created new head
9dab3fa64325 copy: add experimental support for marking committed copies
Martin von Zweigbergk <martinvonz@google.com>
parents: 39350
diff changeset
53 $ 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
54 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
55 [255]
12098
12108d7f2ce1 tests: unify test-rename
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 11551
diff changeset
56