tests/test-topic-tutorial.t
branchstable
changeset 2827 498409c72dd2
parent 2826 93588d219f2f
child 2829 1c529afd3fef
equal deleted inserted replaced
2826:93588d219f2f 2827:498409c72dd2
    64 Much like a named branch, our topic is active but it does not contain any
    64 Much like a named branch, our topic is active but it does not contain any
    65 changesets yet:
    65 changesets yet:
    66 
    66 
    67   $ hg topic
    67   $ hg topic
    68    * food
    68    * food
       
    69 
    69   $ hg summary
    70   $ hg summary
    70   parent: 0:38da43f0a2ea tip
    71   parent: 0:38da43f0a2ea tip
    71    Shopping list
    72    Shopping list
    72   branch: default
    73   branch: default
    73   commit: (clean)
    74   commit: (clean)
    74   update: (current)
    75   update: (current)
    75   topic:  food
    76   topic:  food
       
    77 
    76   $ hg log --graph
    78   $ hg log --graph
    77   @  changeset:   0:38da43f0a2ea
    79   @  changeset:   0:38da43f0a2ea
    78      tag:         tip
    80      tag:         tip
    79      user:        test
    81      user:        test
    80      date:        Thu Jan 01 00:00:00 1970 +0000
    82      date:        Thu Jan 01 00:00:00 1970 +0000
    87   > Egg
    89   > Egg
    88   > Suggar
    90   > Suggar
    89   > Vinegar
    91   > Vinegar
    90   > Oil
    92   > Oil
    91   > EOF
    93   > EOF
       
    94 
    92   $ hg commit -m "adding condiments"
    95   $ hg commit -m "adding condiments"
       
    96 
    93   $ hg log --graph --rev 'topic("food")'
    97   $ hg log --graph --rev 'topic("food")'
    94   @  changeset:   1:13900241408b
    98   @  changeset:   1:13900241408b
    95   |  tag:         tip
    99   |  tag:         tip
    96   ~  topic:       food
   100   ~  topic:       food
    97      user:        test
   101      user:        test
   104   $ cat >> shopping << EOF
   108   $ cat >> shopping << EOF
   105   > Bananas
   109   > Bananas
   106   > Pear
   110   > Pear
   107   > Apple
   111   > Apple
   108   > EOF
   112   > EOF
       
   113 
   109   $ hg commit -m "adding fruits"
   114   $ hg commit -m "adding fruits"
       
   115 
   110   $ hg log --graph --rev 'topic("food")'
   116   $ hg log --graph --rev 'topic("food")'
   111   @  changeset:   2:287de11b401f
   117   @  changeset:   2:287de11b401f
   112   |  tag:         tip
   118   |  tag:         tip
   113   |  topic:       food
   119   |  topic:       food
   114   |  user:        test
   120   |  user:        test
   132   t1: adding condiments
   138   t1: adding condiments
   133   t0^ Shopping list (base)
   139   t0^ Shopping list (base)
   134 
   140 
   135 The topic deactivates when we update away from it:
   141 The topic deactivates when we update away from it:
   136 
   142 
   137   $ hg up default
   143   $ hg update default
   138   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   144   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   145 
   139   $ hg topic
   146   $ hg topic
   140      food
   147      food
   141 
   148 
   142 Note that ``default`` (name of the branch) now refers to the tipmost
   149 Note that ``default`` (name of the branch) now refers to the tipmost
   143 changeset of default without a topic:
   150 changeset of default without a topic:
   161      date:        Thu Jan 01 00:00:00 1970 +0000
   168      date:        Thu Jan 01 00:00:00 1970 +0000
   162      summary:     Shopping list
   169      summary:     Shopping list
   163   
   170   
   164 And updating back to the topic reactivates it:
   171 And updating back to the topic reactivates it:
   165 
   172 
   166   $ hg up food
   173   $ hg update food
   167   switching to topic food
   174   switching to topic food
   168   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   175   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   176 
   169   $ hg topic
   177   $ hg topic
   170    * food
   178    * food
   171 
   179 
   172 Updating to any changeset that is part of a topic activates the topic
   180 Updating to any changeset that is part of a topic activates the topic
   173 regardless of how the revision was specified:
   181 regardless of how the revision was specified:
   174 
   182 
   175   $ hg up default
   183   $ hg update default
   176   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   184   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   177   $ hg up --rev 'desc("condiments")'
   185 
       
   186   $ hg update --rev 'desc("condiments")'
   178   switching to topic food
   187   switching to topic food
   179   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   188   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   189 
   180   $ hg topic
   190   $ hg topic
   181    * food
   191    * food
   182 
   192 
   183 .. server side activity:
   193 .. Server side activity:
   184 
   194 
   185   $ cd ../server/
   195   $ cd ../server/
   186   $ cat > shopping << EOF
   196   $ cat > shopping << EOF
   187   > T-Shirt
   197   > T-Shirt
   188   > Trousers
   198   > Trousers
   192   > Rat (rather a lot)
   202   > Rat (rather a lot)
   193   > Jugged fish
   203   > Jugged fish
   194   > Blancmange
   204   > Blancmange
   195   > Salmon mousse
   205   > Salmon mousse
   196   > EOF
   206   > EOF
       
   207 
   197   $ hg commit -A -m "Adding clothes"
   208   $ hg commit -A -m "Adding clothes"
       
   209 
   198   $ cd ../client
   210   $ cd ../client
   199 
   211 
   200 The topic will also affect the rebase and the merge destinations. Let's pull
   212 The topic will also affect the rebase and the merge destinations. Let's pull
   201 the latest update from the main server:
   213 the latest update from the main server:
   202 
   214 
   206   adding changesets
   218   adding changesets
   207   adding manifests
   219   adding manifests
   208   adding file changes
   220   adding file changes
   209   added 1 changesets with 1 changes to 1 files (+1 heads)
   221   added 1 changesets with 1 changes to 1 files (+1 heads)
   210   (run 'hg heads' to see heads)
   222   (run 'hg heads' to see heads)
       
   223 
   211   $ hg log -G
   224   $ hg log -G
   212   o  changeset:   3:6104862e8b84
   225   o  changeset:   3:6104862e8b84
   213   |  tag:         tip
   226   |  tag:         tip
   214   |  parent:      0:38da43f0a2ea
   227   |  parent:      0:38da43f0a2ea
   215   |  user:        test
   228   |  user:        test
   235   
   248   
   236 
   249 
   237 The topic head will not be considered when merging from the new head of the
   250 The topic head will not be considered when merging from the new head of the
   238 branch:
   251 branch:
   239 
   252 
   240   $ hg up default
   253   $ hg update default
   241   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   254   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   255 
   242   $ hg merge
   256   $ hg merge
   243   abort: branch 'default' has one head - please merge with an explicit rev
   257   abort: branch 'default' has one head - please merge with an explicit rev
   244   (run 'hg heads' to see all heads)
   258   (run 'hg heads' to see all heads)
   245   [255]
   259   [255]
   246 
   260 
   247 But the topic will see that branch head as a valid destination:
   261 But the topic will see that branch head as a valid destination:
   248 
   262 
   249   $ hg up food
   263   $ hg update food
   250   switching to topic food
   264   switching to topic food
   251   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   265   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   266 
   252   $ hg rebase
   267   $ hg rebase
   253   rebasing 1:13900241408b "adding condiments"
   268   rebasing 1:13900241408b "adding condiments"
   254   merging shopping
   269   merging shopping
   255   switching to topic food
   270   switching to topic food
   256   rebasing 2:287de11b401f "adding fruits"
   271   rebasing 2:287de11b401f "adding fruits"
   257   merging shopping
   272   merging shopping
       
   273 
   258   $ hg log --graph
   274   $ hg log --graph
   259   @  changeset:   5:2d50db8b5b4c
   275   @  changeset:   5:2d50db8b5b4c
   260   |  tag:         tip
   276   |  tag:         tip
   261   |  topic:       food
   277   |  topic:       food
   262   |  user:        test
   278   |  user:        test
   283 
   299 
   284 The topic information will disappear when we publish the changesets:
   300 The topic information will disappear when we publish the changesets:
   285 
   301 
   286   $ hg topic
   302   $ hg topic
   287    * food
   303    * food
       
   304 
   288   $ hg push
   305   $ hg push
   289   pushing to $TESTTMP/server (glob)
   306   pushing to $TESTTMP/server (glob)
   290   searching for changes
   307   searching for changes
   291   adding changesets
   308   adding changesets
   292   adding manifests
   309   adding manifests
   293   adding file changes
   310   adding file changes
   294   added 2 changesets with 2 changes to 1 files
   311   added 2 changesets with 2 changes to 1 files
   295   2 new obsolescence markers
   312   2 new obsolescence markers
       
   313 
   296   $ hg topic
   314   $ hg topic
   297    * food
   315    * food
       
   316 
   298   $ hg log --graph
   317   $ hg log --graph
   299   @  changeset:   5:2d50db8b5b4c
   318   @  changeset:   5:2d50db8b5b4c
   300   |  tag:         tip
   319   |  tag:         tip
   301   |  user:        test
   320   |  user:        test
   302   |  date:        Thu Jan 01 00:00:00 1970 +0000
   321   |  date:        Thu Jan 01 00:00:00 1970 +0000
   316   o  changeset:   0:38da43f0a2ea
   335   o  changeset:   0:38da43f0a2ea
   317      user:        test
   336      user:        test
   318      date:        Thu Jan 01 00:00:00 1970 +0000
   337      date:        Thu Jan 01 00:00:00 1970 +0000
   319      summary:     Shopping list
   338      summary:     Shopping list
   320   
   339   
   321   $ hg up default
   340   $ hg update default
   322   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   341   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   323 
   342 
   324 Working with Multiple Topics
   343 Working with Multiple Topics
   325 ============================
   344 ============================
   326 
   345 
   331 We might go shopping in a hardware store in the same go, so let's add some
   350 We might go shopping in a hardware store in the same go, so let's add some
   332 tools to the shopping list within a new topic:
   351 tools to the shopping list within a new topic:
   333 
   352 
   334   $ hg topic tools
   353   $ hg topic tools
   335   $ echo hammer >> shopping
   354   $ echo hammer >> shopping
   336   $ hg ci -m 'Adding hammer'
   355   $ hg commit -m 'Adding hammer'
       
   356 
   337   $ echo saw >> shopping
   357   $ echo saw >> shopping
   338   $ hg ci -m 'Adding saw'
   358   $ hg commit -m 'Adding saw'
       
   359 
   339   $ echo drill >> shopping
   360   $ echo drill >> shopping
   340   $ hg ci -m 'Adding drill'
   361   $ hg commit -m 'Adding drill'
   341 
   362 
   342 But we are not sure we will actually go to the hardware store, so in the
   363 But we are not sure we will actually go to the hardware store, so in the
   343 meantime, we want to extend the list with drinks. We go back to the official
   364 meantime, we want to extend the list with drinks. We go back to the official
   344 default branch and start a new topic:
   365 default branch and start a new topic:
   345 
   366 
   346   $ hg up default
   367   $ hg update default
   347   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   368   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   369 
   348   $ hg topic drinks
   370   $ hg topic drinks
   349   $ echo 'apple juice' >> shopping
   371   $ echo 'apple juice' >> shopping
   350   $ hg ci -m 'Adding apple juice'
   372   $ hg commit -m 'Adding apple juice'
       
   373 
   351   $ echo 'orange juice' >> shopping
   374   $ echo 'orange juice' >> shopping
   352   $ hg ci -m 'Adding orange juice'
   375   $ hg commit -m 'Adding orange juice'
   353 
   376 
   354 We now have two topics:
   377 We now have two topics:
   355 
   378 
   356   $ hg topic
   379   $ hg topic
   357    * drinks
   380    * drinks
   363   ### topic: drinks
   386   ### topic: drinks
   364   ### branch: default
   387   ### branch: default
   365   t2@ Adding orange juice (current)
   388   t2@ Adding orange juice (current)
   366   t1: Adding apple juice
   389   t1: Adding apple juice
   367   t0^ adding fruits (base)
   390   t0^ adding fruits (base)
   368   $ hg up tools
   391 
       
   392   $ hg update tools
   369   switching to topic tools
   393   switching to topic tools
   370   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   394   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   395 
   371   $ hg stack
   396   $ hg stack
   372   ### topic: tools
   397   ### topic: tools
   373   ### branch: default
   398   ### branch: default
   374   t3@ Adding drill (current)
   399   t3@ Adding drill (current)
   375   t2: Adding saw
   400   t2: Adding saw
   381 
   406 
   382   $ hg rebase
   407   $ hg rebase
   383   nothing to rebase
   408   nothing to rebase
   384   [1]
   409   [1]
   385 
   410 
   386 .. server activity:
   411 Server activity:
   387 
   412 
   388   $ cd ../server
   413   $ cd ../server
   389   $ hg up
   414   $ hg update
   390   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   415   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   391   $ mv shopping foo
   416   $ mv shopping foo
   392   $ echo 'Coat' > shopping
   417   $ echo 'Coat' > shopping
   393   $ cat foo >> shopping
   418   $ cat foo >> shopping
   394   $ hg ci -m 'add a coat'
   419   $ hg commit -m 'add a coat'
   395   $ echo 'Coat' > shopping
   420   $ echo 'Coat' > shopping
   396   $ echo 'Shoes' >> shopping
   421   $ echo 'Shoes' >> shopping
   397   $ cat foo >> shopping
   422   $ cat foo >> shopping
   398   $ rm foo
   423   $ rm foo
   399   $ hg ci -m 'add a pair of shoes'
   424   $ hg commit -m 'add a pair of shoes'
   400   $ cd ../client
   425   $ cd ../client
   401 
   426 
   402 Let's see what other people did in the meantime:
   427 Let's see what other people did in the meantime:
   403 
   428 
   404   $ hg pull
   429   $ hg pull
   411   (run 'hg heads' to see heads)
   436   (run 'hg heads' to see heads)
   412 
   437 
   413 There are new changes! We can simply use ``hg rebase`` to update our
   438 There are new changes! We can simply use ``hg rebase`` to update our
   414 changeset on top of the latest:
   439 changeset on top of the latest:
   415 
   440 
       
   441   $ hg log -G
       
   442   o  changeset:   12:fbff9bc37a43
       
   443   |  tag:         tip
       
   444   |  user:        test
       
   445   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   446   |  summary:     add a pair of shoes
       
   447   |
       
   448   o  changeset:   11:f2d6cacc6115
       
   449   |  parent:      5:2d50db8b5b4c
       
   450   |  user:        test
       
   451   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   452   |  summary:     add a coat
       
   453   |
       
   454   | o  changeset:   10:70dfa201ed73
       
   455   | |  topic:       drinks
       
   456   | |  user:        test
       
   457   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   458   | |  summary:     Adding orange juice
       
   459   | |
       
   460   | o  changeset:   9:8dfa45bd5e0c
       
   461   |/   topic:       drinks
       
   462   |    parent:      5:2d50db8b5b4c
       
   463   |    user:        test
       
   464   |    date:        Thu Jan 01 00:00:00 1970 +0000
       
   465   |    summary:     Adding apple juice
       
   466   |
       
   467   | @  changeset:   8:34255b455dac
       
   468   | |  topic:       tools
       
   469   | |  user:        test
       
   470   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   471   | |  summary:     Adding drill
       
   472   | |
       
   473   | o  changeset:   7:cffff85af537
       
   474   | |  topic:       tools
       
   475   | |  user:        test
       
   476   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   477   | |  summary:     Adding saw
       
   478   | |
       
   479   | o  changeset:   6:183984ef46d1
       
   480   |/   topic:       tools
       
   481   |    user:        test
       
   482   |    date:        Thu Jan 01 00:00:00 1970 +0000
       
   483   |    summary:     Adding hammer
       
   484   |
       
   485   o  changeset:   5:2d50db8b5b4c
       
   486   |  user:        test
       
   487   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   488   |  summary:     adding fruits
       
   489   |
       
   490   o  changeset:   4:4011b46eeb33
       
   491   |  user:        test
       
   492   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   493   |  summary:     adding condiments
       
   494   |
       
   495   o  changeset:   3:6104862e8b84
       
   496   |  parent:      0:38da43f0a2ea
       
   497   |  user:        test
       
   498   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   499   |  summary:     Adding clothes
       
   500   |
       
   501   o  changeset:   0:38da43f0a2ea
       
   502      user:        test
       
   503      date:        Thu Jan 01 00:00:00 1970 +0000
       
   504      summary:     Shopping list
       
   505   
   416   $ hg rebase
   506   $ hg rebase
   417   rebasing 6:183984ef46d1 "Adding hammer"
   507   rebasing 6:183984ef46d1 "Adding hammer"
   418   merging shopping
   508   merging shopping
   419   switching to topic tools
   509   switching to topic tools
   420   rebasing 7:cffff85af537 "Adding saw"
   510   rebasing 7:cffff85af537 "Adding saw"
   450   merging shopping
   540   merging shopping
   451   switching to topic drinks
   541   switching to topic drinks
   452   rebasing 10:70dfa201ed73 "Adding orange juice"
   542   rebasing 10:70dfa201ed73 "Adding orange juice"
   453   merging shopping
   543   merging shopping
   454   switching to topic tools
   544   switching to topic tools
       
   545 
   455   $ hg push
   546   $ hg push
   456   pushing to $TESTTMP/server (glob)
   547   pushing to $TESTTMP/server (glob)
   457   searching for changes
   548   searching for changes
   458   abort: push creates new remote head 4cd7c1591a67!
   549   abort: push creates new remote head 4cd7c1591a67!
   459   (merge or see 'hg help push' for details about pushing new heads)
   550   (merge or see 'hg help push' for details about pushing new heads)
   474 The published topic has now disappeared, and the other is now marked as
   565 The published topic has now disappeared, and the other is now marked as
   475 "behind":
   566 "behind":
   476 
   567 
   477   $ hg topic --verbose
   568   $ hg topic --verbose
   478    * tools (on branch: default, 3 changesets, 2 behind)
   569    * tools (on branch: default, 3 changesets, 2 behind)
       
   570 
   479   $ hg stack
   571   $ hg stack
   480   ### topic: tools
   572   ### topic: tools
   481   ### branch: default, 2 behind
   573   ### branch: default, 2 behind
   482   t3@ Adding drill (current)
   574   t3@ Adding drill (current)
   483   t2: Adding saw
   575   t2: Adding saw