tests/test-copies-in-changeset.t
changeset 43141 52781d57313d
parent 42861 57ea0a81a65c
child 43142 beed7ce61681
equal deleted inserted replaced
43140:12b8a2ef8d04 43141:52781d57313d
     1 
     1 #testcases extra sidedata
       
     2 
       
     3 #if extra
     2   $ cat >> $HGRCPATH << EOF
     4   $ cat >> $HGRCPATH << EOF
     3   > [experimental]
     5   > [experimental]
     4   > copies.write-to=changeset-only
     6   > copies.write-to=changeset-only
     5   > copies.read-from=changeset-only
     7   > copies.read-from=changeset-only
     6   > [alias]
     8   > [alias]
     7   > changesetcopies = log -r . -T 'files: {files}
     9   > changesetcopies = log -r . -T 'files: {files}
     8   >   {extras % "{ifcontains("files", key, "{key}: {value}\n")}"}
    10   >   {extras % "{ifcontains("files", key, "{key}: {value}\n")}"}
     9   >   {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}'
    11   >   {extras % "{ifcontains("copies", key, "{key}: {value}\n")}"}'
       
    12   > EOF
       
    13 #endif
       
    14 
       
    15 #if sidedata
       
    16   $ cat >> $HGRCPATH << EOF
       
    17   > [format]
       
    18   > exp-use-copies-side-data-changeset = yes
       
    19   > EOF
       
    20 #endif
       
    21 
       
    22   $ cat >> $HGRCPATH << EOF
       
    23   > [alias]
    10   > showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}'
    24   > showcopies = log -r . -T '{file_copies % "{source} -> {name}\n"}'
    11   > [extensions]
    25   > [extensions]
    12   > rebase =
    26   > rebase =
    13   > split =
    27   > split =
    14   > EOF
    28   > EOF
    15 
    29 
    16 Check that copies are recorded correctly
    30 Check that copies are recorded correctly
    17 
    31 
    18   $ hg init repo
    32   $ hg init repo
    19   $ cd repo
    33   $ cd repo
       
    34 #if sidedata
       
    35   $ hg debugformat -v
       
    36   format-variant    repo config default
       
    37   fncache:           yes    yes     yes
       
    38   dotencode:         yes    yes     yes
       
    39   generaldelta:      yes    yes     yes
       
    40   sparserevlog:      yes    yes     yes
       
    41   sidedata:          yes    yes      no
       
    42   copies-sdc:        yes    yes      no
       
    43   plain-cl-delta:    yes    yes     yes
       
    44   compression:       zlib   zlib    zlib
       
    45   compression-level: default default default
       
    46 #else
       
    47   $ hg debugformat -v
       
    48   format-variant    repo config default
       
    49   fncache:           yes    yes     yes
       
    50   dotencode:         yes    yes     yes
       
    51   generaldelta:      yes    yes     yes
       
    52   sparserevlog:      yes    yes     yes
       
    53   sidedata:           no     no      no
       
    54   copies-sdc:         no     no      no
       
    55   plain-cl-delta:    yes    yes     yes
       
    56   compression:       zlib   zlib    zlib
       
    57   compression-level: default default default
       
    58 #endif
    20   $ echo a > a
    59   $ echo a > a
    21   $ hg add a
    60   $ hg add a
    22   $ hg ci -m initial
    61   $ hg ci -m initial
    23   $ hg cp a b
    62   $ hg cp a b
    24   $ hg cp a c
    63   $ hg cp a c
    25   $ hg cp a d
    64   $ hg cp a d
    26   $ hg ci -m 'copy a to b, c, and d'
    65   $ hg ci -m 'copy a to b, c, and d'
       
    66 
       
    67 #if extra
       
    68 
    27   $ hg changesetcopies
    69   $ hg changesetcopies
    28   files: b c d
    70   files: b c d
    29   filesadded: 0
    71   filesadded: 0
    30   1
    72   1
    31   2
    73   2
    32   
    74   
    33   p1copies: 0\x00a (esc)
    75   p1copies: 0\x00a (esc)
    34   1\x00a (esc)
    76   1\x00a (esc)
    35   2\x00a (esc)
    77   2\x00a (esc)
       
    78 
       
    79 #endif
       
    80 
    36   $ hg showcopies
    81   $ hg showcopies
    37   a -> b
    82   a -> b
    38   a -> c
    83   a -> c
    39   a -> d
    84   a -> d
       
    85 
       
    86 #if extra
       
    87 
    40   $ hg showcopies --config experimental.copies.read-from=compatibility
    88   $ hg showcopies --config experimental.copies.read-from=compatibility
    41   a -> b
    89   a -> b
    42   a -> c
    90   a -> c
    43   a -> d
    91   a -> d
    44   $ hg showcopies --config experimental.copies.read-from=filelog-only
    92   $ hg showcopies --config experimental.copies.read-from=filelog-only
    45 
    93 
       
    94 #endif
       
    95 
    46 Check that renames are recorded correctly
    96 Check that renames are recorded correctly
    47 
    97 
    48   $ hg mv b b2
    98   $ hg mv b b2
    49   $ hg ci -m 'rename b to b2'
    99   $ hg ci -m 'rename b to b2'
       
   100 
       
   101 #if extra
       
   102 
    50   $ hg changesetcopies
   103   $ hg changesetcopies
    51   files: b b2
   104   files: b b2
    52   filesadded: 1
   105   filesadded: 1
    53   filesremoved: 0
   106   filesremoved: 0
    54   
   107   
    55   p1copies: 1\x00b (esc)
   108   p1copies: 1\x00b (esc)
       
   109 
       
   110 #endif
       
   111 
    56   $ hg showcopies
   112   $ hg showcopies
    57   b -> b2
   113   b -> b2
       
   114 
    58 
   115 
    59 Rename onto existing file. This should get recorded in the changeset files list and in the extras,
   116 Rename onto existing file. This should get recorded in the changeset files list and in the extras,
    60 even though there is no filelog entry.
   117 even though there is no filelog entry.
    61 
   118 
    62   $ hg cp b2 c --force
   119   $ hg cp b2 c --force
    63   $ hg st --copies
   120   $ hg st --copies
    64   M c
   121   M c
    65     b2
   122     b2
       
   123 
       
   124 #if extra
       
   125 
    66   $ hg debugindex c
   126   $ hg debugindex c
    67      rev linkrev nodeid       p1           p2
   127      rev linkrev nodeid       p1           p2
    68        0       1 b789fdd96dc2 000000000000 000000000000
   128        0       1 b789fdd96dc2 000000000000 000000000000
       
   129 
       
   130 #else
       
   131 
       
   132   $ hg debugindex c
       
   133      rev linkrev nodeid       p1           p2
       
   134        0       1 37d9b5d994ea 000000000000 000000000000
       
   135 
       
   136 #endif
       
   137 
       
   138 
    69   $ hg ci -m 'move b onto d'
   139   $ hg ci -m 'move b onto d'
       
   140 
       
   141 #if extra
       
   142 
    70   $ hg changesetcopies
   143   $ hg changesetcopies
    71   files: c
   144   files: c
    72   
   145   
    73   p1copies: 0\x00b2 (esc)
   146   p1copies: 0\x00b2 (esc)
       
   147 
       
   148 #endif
       
   149 
    74   $ hg showcopies
   150   $ hg showcopies
    75   b2 -> c
   151   b2 -> c
       
   152 
       
   153 #if extra
       
   154 
    76   $ hg debugindex c
   155   $ hg debugindex c
    77      rev linkrev nodeid       p1           p2
   156      rev linkrev nodeid       p1           p2
    78        0       1 b789fdd96dc2 000000000000 000000000000
   157        0       1 b789fdd96dc2 000000000000 000000000000
       
   158 
       
   159 #else
       
   160 
       
   161   $ hg debugindex c
       
   162      rev linkrev nodeid       p1           p2
       
   163        0       1 37d9b5d994ea 000000000000 000000000000
       
   164        1       3 029625640347 000000000000 000000000000
       
   165 
       
   166 #endif
    79 
   167 
    80 Create a merge commit with copying done during merge.
   168 Create a merge commit with copying done during merge.
    81 
   169 
    82   $ hg co 0
   170   $ hg co 0
    83   0 files updated, 0 files merged, 3 files removed, 0 files unresolved
   171   0 files updated, 0 files merged, 3 files removed, 0 files unresolved
    94 File 'd' exists only in p2, so 'h' should be from p2
   182 File 'd' exists only in p2, so 'h' should be from p2
    95   $ hg cp d h
   183   $ hg cp d h
    96 File 'f' exists only in p1, so 'i' should be from p1
   184 File 'f' exists only in p1, so 'i' should be from p1
    97   $ hg cp f i
   185   $ hg cp f i
    98   $ hg ci -m 'merge'
   186   $ hg ci -m 'merge'
       
   187 
       
   188 #if extra
       
   189 
    99   $ hg changesetcopies
   190   $ hg changesetcopies
   100   files: g h i
   191   files: g h i
   101   filesadded: 0
   192   filesadded: 0
   102   1
   193   1
   103   2
   194   2
   104   
   195   
   105   p1copies: 0\x00a (esc)
   196   p1copies: 0\x00a (esc)
   106   2\x00f (esc)
   197   2\x00f (esc)
   107   p2copies: 1\x00d (esc)
   198   p2copies: 1\x00d (esc)
       
   199 
       
   200 #endif
       
   201 
   108   $ hg showcopies
   202   $ hg showcopies
   109   a -> g
   203   a -> g
   110   d -> h
   204   d -> h
   111   f -> i
   205   f -> i
   112 
   206 
   113 Test writing to both changeset and filelog
   207 Test writing to both changeset and filelog
   114 
   208 
   115   $ hg cp a j
   209   $ hg cp a j
       
   210 #if extra
   116   $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility
   211   $ hg ci -m 'copy a to j' --config experimental.copies.write-to=compatibility
   117   $ hg changesetcopies
   212   $ hg changesetcopies
   118   files: j
   213   files: j
   119   filesadded: 0
   214   filesadded: 0
   120   filesremoved: 
   215   filesremoved: 
   121   
   216   
   122   p1copies: 0\x00a (esc)
   217   p1copies: 0\x00a (esc)
   123   p2copies: 
   218   p2copies: 
       
   219 #else
       
   220   $ hg ci -m 'copy a to j'
       
   221 #endif
   124   $ hg debugdata j 0
   222   $ hg debugdata j 0
   125   \x01 (esc)
   223   \x01 (esc)
   126   copy: a
   224   copy: a
   127   copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
   225   copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
   128   \x01 (esc)
   226   \x01 (esc)
   133   a -> j
   231   a -> j
   134   $ hg showcopies --config experimental.copies.read-from=filelog-only
   232   $ hg showcopies --config experimental.copies.read-from=filelog-only
   135   a -> j
   233   a -> j
   136 Existing copy information in the changeset gets removed on amend and writing
   234 Existing copy information in the changeset gets removed on amend and writing
   137 copy information on to the filelog
   235 copy information on to the filelog
       
   236 #if extra
   138   $ hg ci --amend -m 'copy a to j, v2' \
   237   $ hg ci --amend -m 'copy a to j, v2' \
   139   > --config experimental.copies.write-to=filelog-only
   238   > --config experimental.copies.write-to=filelog-only
   140   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/dd7bb9581359-a6e6b6d2-amend.hg
   239   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
   141   $ hg changesetcopies
   240   $ hg changesetcopies
   142   files: j
   241   files: j
   143   
   242   
       
   243 #else
       
   244   $ hg ci --amend -m 'copy a to j, v2'
       
   245   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
       
   246 #endif
   144   $ hg showcopies --config experimental.copies.read-from=filelog-only
   247   $ hg showcopies --config experimental.copies.read-from=filelog-only
   145   a -> j
   248   a -> j
   146 The entries should be written to extras even if they're empty (so the client
   249 The entries should be written to extras even if they're empty (so the client
   147 won't have to fall back to reading from filelogs)
   250 won't have to fall back to reading from filelogs)
   148   $ echo x >> j
   251   $ echo x >> j
       
   252 #if extra
   149   $ hg ci -m 'modify j' --config experimental.copies.write-to=compatibility
   253   $ hg ci -m 'modify j' --config experimental.copies.write-to=compatibility
   150   $ hg changesetcopies
   254   $ hg changesetcopies
   151   files: j
   255   files: j
   152   filesadded: 
   256   filesadded: 
   153   filesremoved: 
   257   filesremoved: 
   154   
   258   
   155   p1copies: 
   259   p1copies: 
   156   p2copies: 
   260   p2copies: 
       
   261 #else
       
   262   $ hg ci -m 'modify j'
       
   263 #endif
   157 
   264 
   158 Test writing only to filelog
   265 Test writing only to filelog
   159 
   266 
   160   $ hg cp a k
   267   $ hg cp a k
       
   268 #if extra
   161   $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only
   269   $ hg ci -m 'copy a to k' --config experimental.copies.write-to=filelog-only
       
   270 
   162   $ hg changesetcopies
   271   $ hg changesetcopies
   163   files: k
   272   files: k
   164   
   273   
       
   274 #else
       
   275   $ hg ci -m 'copy a to k'
       
   276 #endif
       
   277 
   165   $ hg debugdata k 0
   278   $ hg debugdata k 0
   166   \x01 (esc)
   279   \x01 (esc)
   167   copy: a
   280   copy: a
   168   copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
   281   copyrev: b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
   169   \x01 (esc)
   282   \x01 (esc)
   170   a
   283   a
   171   $ hg showcopies
   284 #if extra
       
   285   $ hg showcopies
       
   286 
   172   $ hg showcopies --config experimental.copies.read-from=compatibility
   287   $ hg showcopies --config experimental.copies.read-from=compatibility
   173   a -> k
   288   a -> k
   174   $ hg showcopies --config experimental.copies.read-from=filelog-only
   289   $ hg showcopies --config experimental.copies.read-from=filelog-only
   175   a -> k
   290   a -> k
       
   291 #else
       
   292   $ hg showcopies
       
   293   a -> k
       
   294 #endif
   176 
   295 
   177   $ cd ..
   296   $ cd ..
   178 
   297 
   179 Test rebasing a commit with copy information
   298 Test rebasing a commit with copy information
   180 
   299 
   186   $ hg ci -m 'modify a'
   305   $ hg ci -m 'modify a'
   187   $ hg co -q 0
   306   $ hg co -q 0
   188   $ hg mv a b
   307   $ hg mv a b
   189   $ hg ci -qm 'rename a to b'
   308   $ hg ci -qm 'rename a to b'
   190   $ hg rebase -d 1 --config rebase.experimental.inmemory=yes
   309   $ hg rebase -d 1 --config rebase.experimental.inmemory=yes
   191   rebasing 2:fc7287ac5b9b "rename a to b" (tip)
   310   rebasing 2:* "rename a to b" (tip) (glob)
   192   merging a and b to b
   311   merging a and b to b
   193   saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/fc7287ac5b9b-8f2a95ec-rebase.hg
   312   saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/*-*-rebase.hg (glob)
   194   $ hg st --change . --copies
   313   $ hg st --change . --copies
   195   A b
   314   A b
   196     a
   315     a
   197   R a
   316   R a
   198   $ cd ..
   317   $ cd ..
   235   rename from b
   354   rename from b
   236   rename to c
   355   rename to c
   237   examine changes to 'b' and 'c'?
   356   examine changes to 'b' and 'c'?
   238   (enter ? for help) [Ynesfdaq?] y
   357   (enter ? for help) [Ynesfdaq?] y
   239   
   358   
   240   saved backup bundle to $TESTTMP/split/.hg/strip-backup/9a396d463e04-2d9e6864-split.hg
   359   saved backup bundle to $TESTTMP/split/.hg/strip-backup/*-*-split.hg (glob)
   241   $ cd ..
   360   $ cd ..
   242 
   361 
   243 Test committing half a rename
   362 Test committing half a rename
   244 
   363 
   245   $ hg init partial
   364   $ hg init partial