tests/test-topic-tutorial.t
changeset 2831 eda8eb561134
parent 2830 499b2dd69107
child 2833 08a64770ed24
equal deleted inserted replaced
2820:fb795bdaa06c 2831:eda8eb561134
     1 ==============
     1 ==============
     2 Topic Tutorial
     2 Topic Tutorial
     3 ==============
     3 ==============
     4 
     4 
     5 .. This test file is also supposed to be able to compile as a rest file.
     5 This Mercurial configuration example is used for testing.
     6 
     6 
     7 
     7 .. Various setup
     8 .. Some Setup::
       
     9 
     8 
    10   $ . "$TESTDIR/testlib/topic_setup.sh"
     9   $ . "$TESTDIR/testlib/topic_setup.sh"
       
    10   $ cat >> $HGRCPATH << EOF
       
    11   > [experimental]
       
    12   > evolution=all
       
    13   > [extensions]
       
    14   > evolve=
       
    15   > EOF
       
    16 
    11   $ hg init server
    17   $ hg init server
       
    18 
    12   $ cd server
    19   $ cd server
       
    20 
    13   $ cat >> .hg/hgrc << EOF
    21   $ cat >> .hg/hgrc << EOF
    14   > [ui]
    22   > [ui]
    15   > user= Shopping Master
    23   > user= Shopping Master
    16   > EOF
    24   > EOF
       
    25 
    17   $ cat >> shopping << EOF
    26   $ cat >> shopping << EOF
    18   > Spam
    27   > Spam
    19   > Whizzo butter
    28   > Whizzo butter
    20   > Albatross
    29   > Albatross
    21   > Rat (rather a lot)
    30   > Rat (rather a lot)
    22   > Jugged fish
    31   > Jugged fish
    23   > Blancmange
    32   > Blancmange
    24   > Salmon mousse
    33   > Salmon mousse
    25   > EOF
    34   > EOF
       
    35 
    26   $ hg commit -A -m "Shopping list"
    36   $ hg commit -A -m "Shopping list"
    27   adding shopping
    37   adding shopping
       
    38 
    28   $ cd ..
    39   $ cd ..
    29   $ hg clone server client
    40   $ hg clone server client
    30   updating to branch default
    41   updating to branch default
    31   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    42   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    32   $ cd client
    43   $ cd client
    34   > [ui]
    45   > [ui]
    35   > user= Tutorial User
    46   > user= Tutorial User
    36   > EOF
    47   > EOF
    37 
    48 
    38 Topic branches are lightweight branches which disappear when changes are
    49 Topic branches are lightweight branches which disappear when changes are
    39 finalized (move to the public phase). They can help users to organise and share
    50 finalized (move to the public phase). They can help users to organize and share
    40 their unfinished work.
    51 their unfinished work.
    41 
    52 
    42 Topic Basics
    53 Topic Basics
    43 ============
    54 ============
    44 
    55 
    45 Let's say we use Mercurial to manage our shopping list::
    56 Let's say we use Mercurial to manage our shopping list:
    46 
    57 
    47   $ hg log --graph
    58   $ hg log --graph
    48   @  changeset:   0:38da43f0a2ea
    59   @  changeset:   0:38da43f0a2ea
    49      tag:         tip
    60      tag:         tip
    50      user:        test
    61      user:        test
    51      date:        Thu Jan 01 00:00:00 1970 +0000
    62      date:        Thu Jan 01 00:00:00 1970 +0000
    52      summary:     Shopping list
    63      summary:     Shopping list
    53   
    64   
    54 
    65 
    55 We are about to make some additions to this list and would like to do them
    66 We are about to make some additions to this list and would like to do them 
    56 within a topic. Creating a new topic is done using the ``topic`` command::
    67 within a topic. Creating a new topic is done using the ``topic`` command:
    57 
    68 
    58   $ hg topic food
    69   $ hg topic food
    59 
    70 
    60 Much like a named branch, our topic is active but it does not contain any
    71 Much like a named branch, our topic is active but it does not contain any
    61 changesets yet::
    72 changesets yet:
    62 
    73 
    63   $ hg topic
    74   $ hg topic
    64    * food
    75    * food
       
    76 
    65   $ hg summary
    77   $ hg summary
    66   parent: 0:38da43f0a2ea tip
    78   parent: 0:38da43f0a2ea tip
    67    Shopping list
    79    Shopping list
    68   branch: default
    80   branch: default
    69   commit: (clean)
    81   commit: (clean)
    70   update: (current)
    82   update: (current)
    71   topic:  food
    83   topic:  food
       
    84 
    72   $ hg log --graph
    85   $ hg log --graph
    73   @  changeset:   0:38da43f0a2ea
    86   @  changeset:   0:38da43f0a2ea
    74      tag:         tip
    87      tag:         tip
    75      user:        test
    88      user:        test
    76      date:        Thu Jan 01 00:00:00 1970 +0000
    89      date:        Thu Jan 01 00:00:00 1970 +0000
    77      summary:     Shopping list
    90      summary:     Shopping list
    78   
    91   
    79 
    92 
    80 Our next commit will be part of the active topic::
    93 Our next commit will be part of the active topic:
    81 
    94 
    82   $ cat >> shopping << EOF
    95   $ cat >> shopping << EOF
    83   > Egg
    96   > Egg
    84   > Suggar
    97   > Suggar
    85   > Vinegar
    98   > Vinegar
    86   > Oil
    99   > Oil
    87   > EOF
   100   > EOF
       
   101 
    88   $ hg commit -m "adding condiments"
   102   $ hg commit -m "adding condiments"
       
   103 
    89   $ hg log --graph --rev 'topic("food")'
   104   $ hg log --graph --rev 'topic("food")'
    90   @  changeset:   1:13900241408b
   105   @  changeset:   1:13900241408b
    91   |  tag:         tip
   106   |  tag:         tip
    92   ~  topic:       food
   107   ~  topic:       food
    93      user:        test
   108      user:        test
    94      date:        Thu Jan 01 00:00:00 1970 +0000
   109      date:        Thu Jan 01 00:00:00 1970 +0000
    95      summary:     adding condiments
   110      summary:     adding condiments
    96   
   111   
    97 
   112 
    98 And future commits will be part of that topic too::
   113 And future commits will be part of that topic too:
    99 
   114 
   100   $ cat >> shopping << EOF
   115   $ cat >> shopping << EOF
   101   > Bananas
   116   > Bananas
   102   > Pear
   117   > Pear
   103   > Apple
   118   > Apple
   104   > EOF
   119   > EOF
       
   120 
   105   $ hg commit -m "adding fruits"
   121   $ hg commit -m "adding fruits"
       
   122 
   106   $ hg log --graph --rev 'topic("food")'
   123   $ hg log --graph --rev 'topic("food")'
   107   @  changeset:   2:287de11b401f
   124   @  changeset:   2:287de11b401f
   108   |  tag:         tip
   125   |  tag:         tip
   109   |  topic:       food
   126   |  topic:       food
   110   |  user:        test
   127   |  user:        test
   117      date:        Thu Jan 01 00:00:00 1970 +0000
   134      date:        Thu Jan 01 00:00:00 1970 +0000
   118      summary:     adding condiments
   135      summary:     adding condiments
   119   
   136   
   120 
   137 
   121 We can get a compact view of the content of our topic using the ``stack``
   138 We can get a compact view of the content of our topic using the ``stack``
   122 command::
   139 command:
   123 
   140 
   124   $ hg stack
   141   $ hg stack
   125   ### topic: food
   142   ### topic: food
   126   ### branch: default
   143   ### branch: default
   127   t2@ adding fruits (current)
   144   t2@ adding fruits (current)
   128   t1: adding condiments
   145   t1: adding condiments
   129   t0^ Shopping list (base)
   146   t0^ Shopping list (base)
   130 
   147 
   131 The topic deactivates when we update away from it::
   148 The topic deactivates when we update away from it:
   132 
   149 
   133   $ hg up default
   150   $ hg update default
   134   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   151   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   152 
   135   $ hg topic
   153   $ hg topic
   136      food
   154      food
   137 
   155 
   138 Note that ``default`` (name of the branch) now refers to the tipmost
   156 Note that ``default`` (name of the branch) now refers to the tipmost
   139 changeset of default without a topic::
   157 changeset of default without a topic:
   140 
   158 
   141   $ hg log --graph
   159   $ hg log --graph
   142   o  changeset:   2:287de11b401f
   160   o  changeset:   2:287de11b401f
   143   |  tag:         tip
   161   |  tag:         tip
   144   |  topic:       food
   162   |  topic:       food
   155   @  changeset:   0:38da43f0a2ea
   173   @  changeset:   0:38da43f0a2ea
   156      user:        test
   174      user:        test
   157      date:        Thu Jan 01 00:00:00 1970 +0000
   175      date:        Thu Jan 01 00:00:00 1970 +0000
   158      summary:     Shopping list
   176      summary:     Shopping list
   159   
   177   
   160 
   178 And updating back to the topic reactivates it:
   161 And updating back to the topic reactivates it::
   179 
   162 
   180   $ hg update food
   163   $ hg up food
       
   164   switching to topic food
   181   switching to topic food
   165   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   182   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   183 
   166   $ hg topic
   184   $ hg topic
   167    * food
   185    * food
   168 
   186 
   169 Updating to any changeset that is part of a topic activates the topic
   187 Updating to any changeset that is part of a topic activates the topic
   170 regardless of how the revision was specified::
   188 regardless of how the revision was specified:
   171 
   189 
   172   $ hg up default
   190   $ hg update default
   173   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   191   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   174   $ hg up --rev 'desc("condiments")'
   192 
       
   193   $ hg update --rev 'desc("condiments")'
   175   switching to topic food
   194   switching to topic food
   176   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   195   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   196 
   177   $ hg topic
   197   $ hg topic
   178    * food
   198    * food
   179 
   199 
   180 .. server side activity::
   200 .. Server side activity:
   181 
   201 
   182   $ cd ../server/
   202   $ cd ../server/
   183   $ cat > shopping << EOF
   203   $ cat > shopping << EOF
   184   > T-Shirt
   204   > T-Shirt
   185   > Trousers
   205   > Trousers
   189   > Rat (rather a lot)
   209   > Rat (rather a lot)
   190   > Jugged fish
   210   > Jugged fish
   191   > Blancmange
   211   > Blancmange
   192   > Salmon mousse
   212   > Salmon mousse
   193   > EOF
   213   > EOF
       
   214 
   194   $ hg commit -A -m "Adding clothes"
   215   $ hg commit -A -m "Adding clothes"
       
   216 
   195   $ cd ../client
   217   $ cd ../client
   196 
   218 
   197 The topic will also affect the rebase and the merge destinations. Let's pull
   219 The topic will also affect the rebase and the merge destinations. Let's pull
   198 the latest update from the main server::
   220 the latest update from the main server:
   199 
   221 
   200   $ hg pull
   222   $ hg pull
   201   pulling from $TESTTMP/server (glob)
   223   pulling from $TESTTMP/server (glob)
   202   searching for changes
   224   searching for changes
   203   adding changesets
   225   adding changesets
   204   adding manifests
   226   adding manifests
   205   adding file changes
   227   adding file changes
   206   added 1 changesets with 1 changes to 1 files (+1 heads)
   228   added 1 changesets with 1 changes to 1 files (+1 heads)
   207   (run 'hg heads' to see heads)
   229   (run 'hg heads' to see heads)
       
   230 
   208   $ hg log -G
   231   $ hg log -G
   209   o  changeset:   3:6104862e8b84
   232   o  changeset:   3:6104862e8b84
   210   |  tag:         tip
   233   |  tag:         tip
   211   |  parent:      0:38da43f0a2ea
   234   |  parent:      0:38da43f0a2ea
   212   |  user:        test
   235   |  user:        test
   230      date:        Thu Jan 01 00:00:00 1970 +0000
   253      date:        Thu Jan 01 00:00:00 1970 +0000
   231      summary:     Shopping list
   254      summary:     Shopping list
   232   
   255   
   233 
   256 
   234 The topic head will not be considered when merging from the new head of the
   257 The topic head will not be considered when merging from the new head of the
   235 branch::
   258 branch:
   236 
   259 
   237   $ hg up default
   260   $ hg update default
   238   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   261   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   262 
   239   $ hg merge
   263   $ hg merge
   240   abort: branch 'default' has one head - please merge with an explicit rev
   264   abort: branch 'default' has one head - please merge with an explicit rev
   241   (run 'hg heads' to see all heads)
   265   (run 'hg heads' to see all heads)
   242   [255]
   266   [255]
   243 
   267 
   244 But the topic will see that branch head as a valid destination::
   268 But the topic will see that branch head as a valid destination:
   245 
   269 
   246   $ hg up food
   270   $ hg update food
   247   switching to topic food
   271   switching to topic food
   248   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   272   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   273 
   249   $ hg rebase
   274   $ hg rebase
   250   rebasing 1:13900241408b "adding condiments"
   275   rebasing 1:13900241408b "adding condiments"
   251   merging shopping
   276   merging shopping
   252   switching to topic food
   277   switching to topic food
   253   rebasing 2:287de11b401f "adding fruits"
   278   rebasing 2:287de11b401f "adding fruits"
   254   merging shopping
   279   merging shopping
       
   280 
   255   $ hg log --graph
   281   $ hg log --graph
   256   @  changeset:   5:2d50db8b5b4c
   282   @  changeset:   5:2d50db8b5b4c
   257   |  tag:         tip
   283   |  tag:         tip
   258   |  topic:       food
   284   |  topic:       food
   259   |  user:        test
   285   |  user:        test
   276      user:        test
   302      user:        test
   277      date:        Thu Jan 01 00:00:00 1970 +0000
   303      date:        Thu Jan 01 00:00:00 1970 +0000
   278      summary:     Shopping list
   304      summary:     Shopping list
   279   
   305   
   280 
   306 
   281 The topic information will disappear when we publish the changesets::
   307 The topic information will disappear when we publish the changesets:
   282 
   308 
   283   $ hg topic
   309   $ hg topic
   284    * food
   310    * food
       
   311 
   285   $ hg push
   312   $ hg push
   286   pushing to $TESTTMP/server (glob)
   313   pushing to $TESTTMP/server (glob)
   287   searching for changes
   314   searching for changes
   288   adding changesets
   315   adding changesets
   289   adding manifests
   316   adding manifests
   290   adding file changes
   317   adding file changes
   291   added 2 changesets with 2 changes to 1 files
   318   added 2 changesets with 2 changes to 1 files
   292   2 new obsolescence markers
   319   2 new obsolescence markers
       
   320 
   293   $ hg topic
   321   $ hg topic
   294    * food
   322    * food
       
   323 
   295   $ hg log --graph
   324   $ hg log --graph
   296   @  changeset:   5:2d50db8b5b4c
   325   @  changeset:   5:2d50db8b5b4c
   297   |  tag:         tip
   326   |  tag:         tip
   298   |  user:        test
   327   |  user:        test
   299   |  date:        Thu Jan 01 00:00:00 1970 +0000
   328   |  date:        Thu Jan 01 00:00:00 1970 +0000
   313   o  changeset:   0:38da43f0a2ea
   342   o  changeset:   0:38da43f0a2ea
   314      user:        test
   343      user:        test
   315      date:        Thu Jan 01 00:00:00 1970 +0000
   344      date:        Thu Jan 01 00:00:00 1970 +0000
   316      summary:     Shopping list
   345      summary:     Shopping list
   317   
   346   
   318   $ hg up default
   347   $ hg update default
   319   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   348   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   320 
   349 
   321 Working with Multiple Topics
   350 Working with Multiple Topics
   322 ============================
   351 ============================
   323 
   352 
   324 In the above example, topics do not bring much benefit since you only have one
   353 In the above example, topics do not bring much benefit since you only have one
   325 line of development. Topics start to be more useful when you have to work on
   354 line of development. Topics start to be more useful when you have to work on
   326 multiple features at the same time.
   355 multiple features at the same time.
   327 
   356 
   328 We might go shopping in a hardware store in the same go, so let's add some
   357 We might go shopping in a hardware store in the same go, so let's add some
   329 tools to the shopping list within a new topic::
   358 tools to the shopping list within a new topic:
   330 
   359 
   331   $ hg topic tools
   360   $ hg topic tools
   332   $ echo hammer >> shopping
   361   $ echo hammer >> shopping
   333   $ hg ci -m 'Adding hammer'
   362   $ hg commit -m 'Adding hammer'
       
   363 
   334   $ echo saw >> shopping
   364   $ echo saw >> shopping
   335   $ hg ci -m 'Adding saw'
   365   $ hg commit -m 'Adding saw'
       
   366 
   336   $ echo drill >> shopping
   367   $ echo drill >> shopping
   337   $ hg ci -m 'Adding drill'
   368   $ hg commit -m 'Adding drill'
   338 
   369 
   339 But we are not sure we will actually go to the hardware store, so in the
   370 But we are not sure we will actually go to the hardware store, so in the
   340 meantime, we want to extend the list with drinks. We go back to the official
   371 meantime, we want to extend the list with drinks. We go back to the official
   341 default branch and start a new topic::
   372 default branch and start a new topic:
   342 
   373 
   343   $ hg up default
   374   $ hg update default
   344   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   375   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   376 
   345   $ hg topic drinks
   377   $ hg topic drinks
   346   $ echo 'apple juice' >> shopping
   378   $ echo 'apple juice' >> shopping
   347   $ hg ci -m 'Adding apple juice'
   379   $ hg commit -m 'Adding apple juice'
       
   380 
   348   $ echo 'orange juice' >> shopping
   381   $ echo 'orange juice' >> shopping
   349   $ hg ci -m 'Adding orange juice'
   382   $ hg commit -m 'Adding orange juice'
   350 
   383 
   351 We now have two topics::
   384 We now have two topics:
   352 
   385 
   353   $ hg topic
   386   $ hg topic
   354    * drinks
   387    * drinks
   355      tools
   388      tools
   356 
   389 
   357 The information displayed by ``hg stack`` adapts to the active topic::
   390 The information displayed by ``hg stack`` adapts to the active topic:
   358 
   391 
   359   $ hg stack
   392   $ hg stack
   360   ### topic: drinks
   393   ### topic: drinks
   361   ### branch: default
   394   ### branch: default
   362   t2@ Adding orange juice (current)
   395   t2@ Adding orange juice (current)
   363   t1: Adding apple juice
   396   t1: Adding apple juice
   364   t0^ adding fruits (base)
   397   t0^ adding fruits (base)
   365   $ hg up tools
   398 
       
   399   $ hg update tools
   366   switching to topic tools
   400   switching to topic tools
   367   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   401   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   402 
   368   $ hg stack
   403   $ hg stack
   369   ### topic: tools
   404   ### topic: tools
   370   ### branch: default
   405   ### branch: default
   371   t3@ Adding drill (current)
   406   t3@ Adding drill (current)
   372   t2: Adding saw
   407   t2: Adding saw
   373   t1: Adding hammer
   408   t1: Adding hammer
   374   t0^ adding fruits (base)
   409   t0^ adding fruits (base)
   375 
   410 
   376 They are seen as independent branches by Mercurial. No rebase or merge
   411 They are seen as independent branches by Mercurial. No rebase or merge
   377 between them will be attempted by default::
   412 between them will be attempted by default:
   378 
   413 
   379   $ hg rebase
   414   $ hg rebase
   380   nothing to rebase
   415   nothing to rebase
   381   [1]
   416   [1]
   382 
   417 
   383 .. server activity::
   418 Server activity:
   384 
   419 
   385   $ cd ../server
   420   $ cd ../server
   386   $ hg up
   421   $ hg update
   387   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   422   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   388   $ mv shopping foo
   423   $ mv shopping foo
   389   $ echo 'Coat' > shopping
   424   $ echo 'Coat' > shopping
   390   $ cat foo >> shopping
   425   $ cat foo >> shopping
   391   $ hg ci -m 'add a coat'
   426   $ hg commit -m 'add a coat'
   392   $ echo 'Coat' > shopping
   427   $ echo 'Coat' > shopping
   393   $ echo 'Shoes' >> shopping
   428   $ echo 'Shoes' >> shopping
   394   $ cat foo >> shopping
   429   $ cat foo >> shopping
   395   $ rm foo
   430   $ rm foo
   396   $ hg ci -m 'add a pair of shoes'
   431   $ hg commit -m 'add a pair of shoes'
   397   $ cd ../client
   432   $ cd ../client
   398 
   433 
   399 Let's see what other people did in the meantime::
   434 Let's see what other people did in the meantime:
   400 
   435 
   401   $ hg pull
   436   $ hg pull
   402   pulling from $TESTTMP/server (glob)
   437   pulling from $TESTTMP/server (glob)
   403   searching for changes
   438   searching for changes
   404   adding changesets
   439   adding changesets
   406   adding file changes
   441   adding file changes
   407   added 2 changesets with 2 changes to 1 files (+1 heads)
   442   added 2 changesets with 2 changes to 1 files (+1 heads)
   408   (run 'hg heads' to see heads)
   443   (run 'hg heads' to see heads)
   409 
   444 
   410 There are new changes! We can simply use ``hg rebase`` to update our
   445 There are new changes! We can simply use ``hg rebase`` to update our
   411 changeset on top of the latest::
   446 changeset on top of the latest:
   412 
   447 
       
   448   $ hg log -G
       
   449   o  changeset:   12:fbff9bc37a43
       
   450   |  tag:         tip
       
   451   |  user:        test
       
   452   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   453   |  summary:     add a pair of shoes
       
   454   |
       
   455   o  changeset:   11:f2d6cacc6115
       
   456   |  parent:      5:2d50db8b5b4c
       
   457   |  user:        test
       
   458   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   459   |  summary:     add a coat
       
   460   |
       
   461   | o  changeset:   10:70dfa201ed73
       
   462   | |  topic:       drinks
       
   463   | |  user:        test
       
   464   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   465   | |  summary:     Adding orange juice
       
   466   | |
       
   467   | o  changeset:   9:8dfa45bd5e0c
       
   468   |/   topic:       drinks
       
   469   |    parent:      5:2d50db8b5b4c
       
   470   |    user:        test
       
   471   |    date:        Thu Jan 01 00:00:00 1970 +0000
       
   472   |    summary:     Adding apple juice
       
   473   |
       
   474   | @  changeset:   8:34255b455dac
       
   475   | |  topic:       tools
       
   476   | |  user:        test
       
   477   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   478   | |  summary:     Adding drill
       
   479   | |
       
   480   | o  changeset:   7:cffff85af537
       
   481   | |  topic:       tools
       
   482   | |  user:        test
       
   483   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   484   | |  summary:     Adding saw
       
   485   | |
       
   486   | o  changeset:   6:183984ef46d1
       
   487   |/   topic:       tools
       
   488   |    user:        test
       
   489   |    date:        Thu Jan 01 00:00:00 1970 +0000
       
   490   |    summary:     Adding hammer
       
   491   |
       
   492   o  changeset:   5:2d50db8b5b4c
       
   493   |  user:        test
       
   494   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   495   |  summary:     adding fruits
       
   496   |
       
   497   o  changeset:   4:4011b46eeb33
       
   498   |  user:        test
       
   499   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   500   |  summary:     adding condiments
       
   501   |
       
   502   o  changeset:   3:6104862e8b84
       
   503   |  parent:      0:38da43f0a2ea
       
   504   |  user:        test
       
   505   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   506   |  summary:     Adding clothes
       
   507   |
       
   508   o  changeset:   0:38da43f0a2ea
       
   509      user:        test
       
   510      date:        Thu Jan 01 00:00:00 1970 +0000
       
   511      summary:     Shopping list
       
   512   
   413   $ hg rebase
   513   $ hg rebase
   414   rebasing 6:183984ef46d1 "Adding hammer"
   514   rebasing 6:183984ef46d1 "Adding hammer"
   415   merging shopping
   515   merging shopping
   416   switching to topic tools
   516   switching to topic tools
   417   rebasing 7:cffff85af537 "Adding saw"
   517   rebasing 7:cffff85af537 "Adding saw"
   418   merging shopping
   518   merging shopping
   419   rebasing 8:34255b455dac "Adding drill"
   519   rebasing 8:34255b455dac "Adding drill"
   420   merging shopping
   520   merging shopping
   421 
   521 
   422 But what about the other topic? You can use 'hg topic --verbose' to see
   522 But what about the other topic? You can use 'hg topic --verbose' to see
   423 information about all the topics::
   523 information about all the topics:
   424 
   524 
   425   $ hg topic --verbose
   525   $ hg topic --verbose
   426      drinks (on branch: default, 2 changesets, 2 behind)
   526      drinks (on branch: default, 2 changesets, 2 behind)
   427    * tools  (on branch: default, 3 changesets)
   527    * tools  (on branch: default, 3 changesets)
   428 
   528 
   429 The "2 behind" is telling you that there are 2 new changesets on the named
   529 The "2 behind" is telling you that there are 2 new changesets on the named
   430 branch of the topic. You need to merge or rebase to incorporate them.
   530 branch of the topic. You need to merge or rebase to incorporate them.
   431 
   531 
   432 Pushing that topic would create a new head, and therefore will be prevented::
   532 Pushing that topic would create a new head, and therefore will be prevented:
   433 
   533 
   434   $ hg push --rev drinks
   534   $ hg push --rev drinks
   435   pushing to $TESTTMP/server (glob)
   535   pushing to $TESTTMP/server (glob)
   436   searching for changes
   536   searching for changes
   437   abort: push creates new remote head 70dfa201ed73!
   537   abort: push creates new remote head 70dfa201ed73!
   438   (merge or see 'hg help push' for details about pushing new heads)
   538   (merge or see 'hg help push' for details about pushing new heads)
   439   [255]
   539   [255]
   440 
   540 
   441 
   541 
   442 Even after a rebase, pushing all active topics at the same time will complain
   542 Even after a rebase, pushing all active topics at the same time will complain
   443 about the multiple heads it would create on that branch::
   543 about the multiple heads it would create on that branch:
   444 
   544 
   445   $ hg rebase -b drinks
   545   $ hg rebase -b drinks
   446   rebasing 9:8dfa45bd5e0c "Adding apple juice"
   546   rebasing 9:8dfa45bd5e0c "Adding apple juice"
   447   merging shopping
   547   merging shopping
   448   switching to topic drinks
   548   switching to topic drinks
   449   rebasing 10:70dfa201ed73 "Adding orange juice"
   549   rebasing 10:70dfa201ed73 "Adding orange juice"
   450   merging shopping
   550   merging shopping
   451   switching to topic tools
   551   switching to topic tools
       
   552 
   452   $ hg push
   553   $ hg push
   453   pushing to $TESTTMP/server (glob)
   554   pushing to $TESTTMP/server (glob)
   454   searching for changes
   555   searching for changes
   455   abort: push creates new remote head 4cd7c1591a67!
   556   abort: push creates new remote head 4cd7c1591a67!
   456   (merge or see 'hg help push' for details about pushing new heads)
   557   (merge or see 'hg help push' for details about pushing new heads)
   457   [255]
   558   [255]
   458 
   559 
   459 Publishing only one of them is allowed (as long as it does not create a new
   560 Publishing only one of them is allowed (as long as it does not create a new
   460 branch head as we just saw in the previous case)::
   561 branch head as we just saw in the previous case):
   461 
   562 
   462   $ hg push -r drinks
   563   $ hg push -r drinks
   463   pushing to $TESTTMP/server (glob)
   564   pushing to $TESTTMP/server (glob)
   464   searching for changes
   565   searching for changes
   465   adding changesets
   566   adding changesets
   467   adding file changes
   568   adding file changes
   468   added 2 changesets with 2 changes to 1 files
   569   added 2 changesets with 2 changes to 1 files
   469   2 new obsolescence markers
   570   2 new obsolescence markers
   470 
   571 
   471 The published topic has now disappeared, and the other is now marked as
   572 The published topic has now disappeared, and the other is now marked as
   472 "behind"::
   573 "behind":
   473 
   574 
   474   $ hg topic --verbose
   575   $ hg topic --verbose
   475    * tools (on branch: default, 3 changesets, 2 behind)
   576    * tools (on branch: default, 3 changesets, 2 behind)
       
   577 
   476   $ hg stack
   578   $ hg stack
   477   ### topic: tools
   579   ### topic: tools
   478   ### branch: default, 2 behind
   580   ### branch: default, 2 behind
   479   t3@ Adding drill (current)
   581   t3@ Adding drill (current)
   480   t2: Adding saw
   582   t2: Adding saw
   481   t1: Adding hammer
   583   t1: Adding hammer
   482   t0^ add a pair of shoes (base)
   584   t0^ add a pair of shoes (base)
   483 
   585 
       
   586 Working Within Your Stack
       
   587 ===========================
       
   588 
       
   589 Navigating within your stack
       
   590 ----------------------------
       
   591 
       
   592 As we saw before `stack` display changesets on your current topic in a clean way:
       
   593 
       
   594   $ hg topics --verbose
       
   595    * tools (on branch: default, 3 changesets, 2 behind)
       
   596 
       
   597   $ hg stack
       
   598   ### topic: tools
       
   599   ### branch: default, 2 behind
       
   600   t3@ Adding drill (current)
       
   601   t2: Adding saw
       
   602   t1: Adding hammer
       
   603   t0^ add a pair of shoes (base)
       
   604 
       
   605 You can navigate in your current stack with `previous` and `next`.
       
   606 
       
   607 `previous` will takes you to the parent of your working directory parent on the same topic.
       
   608 
       
   609   $ hg previous
       
   610   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   611   [14] Adding saw
       
   612 
       
   613   $ hg stack
       
   614   ### topic: tools
       
   615   ### branch: default, 2 behind
       
   616   t3: Adding drill
       
   617   t2@ Adding saw (current)
       
   618   t1: Adding hammer
       
   619   t0^ add a pair of shoes (base)
       
   620 
       
   621 `next` will moves take you to the children of your working directory parent on the same topic.
       
   622 
       
   623   $ hg next
       
   624   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   625   [15] Adding drill
       
   626 
       
   627   $ hg stack
       
   628   ### topic: tools
       
   629   ### branch: default, 2 behind
       
   630   t3@ Adding drill (current)
       
   631   t2: Adding saw
       
   632   t1: Adding hammer
       
   633   t0^ add a pair of shoes (base)
       
   634 
       
   635 You can also directly access changesets within your stack with the revset `t#`.
       
   636 
       
   637   $ hg update t1
       
   638   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   639 
       
   640   $ hg stack
       
   641   ### topic: tools
       
   642   ### branch: default, 2 behind
       
   643   t3: Adding drill
       
   644   t2: Adding saw
       
   645   t1@ Adding hammer (current)
       
   646   t0^ add a pair of shoes (base)
       
   647 
       
   648 Editing your work mid-stack
       
   649 ---------------------------
       
   650 
       
   651 It's easy to edit your work inside your stack:
       
   652 
       
   653   $ hg stack
       
   654   ### topic: tools
       
   655   ### branch: default, 2 behind
       
   656   t3: Adding drill
       
   657   t2: Adding saw
       
   658   t1@ Adding hammer (current)
       
   659   t0^ add a pair of shoes (base)
       
   660 
       
   661   $ hg amend -m "Adding hammer to the shopping list"
       
   662   2 new unstable changesets
       
   663 
       
   664 Understanding the current situation with hg log is not so easy:
       
   665 
       
   666   $ hg log -G -r "t0::"
       
   667   @  changeset:   18:b7509bd417f8
       
   668   |  tag:         tip
       
   669   |  topic:       tools
       
   670   |  parent:      12:fbff9bc37a43
       
   671   |  user:        test
       
   672   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   673   |  summary:     Adding hammer to the shopping list
       
   674   |
       
   675   | o  changeset:   17:4cd7c1591a67
       
   676   | |  user:        test
       
   677   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   678   | |  summary:     Adding orange juice
       
   679   | |
       
   680   | o  changeset:   16:20759cb47ff8
       
   681   |/   parent:      12:fbff9bc37a43
       
   682   |    user:        test
       
   683   |    date:        Thu Jan 01 00:00:00 1970 +0000
       
   684   |    summary:     Adding apple juice
       
   685   |
       
   686   | o  changeset:   15:bb1e6254f532
       
   687   | |  topic:       tools
       
   688   | |  user:        test
       
   689   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   690   | |  trouble:     unstable
       
   691   | |  summary:     Adding drill
       
   692   | |
       
   693   | o  changeset:   14:d4f97f32f8a1
       
   694   | |  topic:       tools
       
   695   | |  user:        test
       
   696   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   697   | |  trouble:     unstable
       
   698   | |  summary:     Adding saw
       
   699   | |
       
   700   | x  changeset:   13:a8ab3599d53d
       
   701   |/   topic:       tools
       
   702   |    user:        test
       
   703   |    date:        Thu Jan 01 00:00:00 1970 +0000
       
   704   |    obsolete:    rewritten as b7509bd417f8
       
   705   |    summary:     Adding hammer
       
   706   |
       
   707   o  changeset:   12:fbff9bc37a43
       
   708   |  user:        test
       
   709   ~  date:        Thu Jan 01 00:00:00 1970 +0000
       
   710      summary:     add a pair of shoes
       
   711   
       
   712 Fortunately stack show you a better visualization:
       
   713 
       
   714   $ hg stack
       
   715   ### topic: tools
       
   716   ### branch: default, 2 behind
       
   717   t3$ Adding drill (unstable)
       
   718   t2$ Adding saw (unstable)
       
   719   t1@ Adding hammer to the shopping list (current)
       
   720   t0^ add a pair of shoes (base)
       
   721 
       
   722 It's easy to stabilize the situation, `next` has an `--evolve` option:
       
   723 
       
   724   $ hg next --evolve
       
   725   move:[14] Adding saw
       
   726   atop:[18] Adding hammer to the shopping list
       
   727   working directory now at d5c51ee5762a
       
   728 
       
   729   $ hg stack
       
   730   ### topic: tools
       
   731   ### branch: default, 2 behind
       
   732   t3$ Adding drill (unstable)
       
   733   t2@ Adding saw (current)
       
   734   t1: Adding hammer to the shopping list
       
   735   t0^ add a pair of shoes (base)
       
   736 
       
   737 One more to go:
       
   738 
       
   739   $ hg next --evolve
       
   740   move:[15] Adding drill
       
   741   atop:[19] Adding saw
       
   742   working directory now at bae3758e46bf
       
   743 
       
   744   $ hg stack
       
   745   ### topic: tools
       
   746   ### branch: default, 2 behind
       
   747   t3@ Adding drill (current)
       
   748   t2: Adding saw
       
   749   t1: Adding hammer to the shopping list
       
   750   t0^ add a pair of shoes (base)
       
   751 
       
   752 Let's take a look at `hg log` once again:
       
   753 
       
   754   $ hg log -G -r "t0::"
       
   755   @  changeset:   20:bae3758e46bf
       
   756   |  tag:         tip
       
   757   |  topic:       tools
       
   758   |  user:        test
       
   759   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   760   |  summary:     Adding drill
       
   761   |
       
   762   o  changeset:   19:d5c51ee5762a
       
   763   |  topic:       tools
       
   764   |  user:        test
       
   765   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   766   |  summary:     Adding saw
       
   767   |
       
   768   o  changeset:   18:b7509bd417f8
       
   769   |  topic:       tools
       
   770   |  parent:      12:fbff9bc37a43
       
   771   |  user:        test
       
   772   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   773   |  summary:     Adding hammer to the shopping list
       
   774   |
       
   775   | o  changeset:   17:4cd7c1591a67
       
   776   | |  user:        test
       
   777   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   778   | |  summary:     Adding orange juice
       
   779   | |
       
   780   | o  changeset:   16:20759cb47ff8
       
   781   |/   parent:      12:fbff9bc37a43
       
   782   |    user:        test
       
   783   |    date:        Thu Jan 01 00:00:00 1970 +0000
       
   784   |    summary:     Adding apple juice
       
   785   |
       
   786   o  changeset:   12:fbff9bc37a43
       
   787   |  user:        test
       
   788   ~  date:        Thu Jan 01 00:00:00 1970 +0000
       
   789      summary:     add a pair of shoes
       
   790   
       
   791 Multi-headed stack
       
   792 ------------------
       
   793 
       
   794 Stack is also very helpful when you have a multi-headed stack:
       
   795 
       
   796   $ hg up t1
       
   797   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   798 
       
   799   $ echo "nails" > new_shopping
       
   800   $ cat shopping >> new_shopping
       
   801   $ mv new_shopping shopping
       
   802 
       
   803   $ hg commit -m 'Adding nails'
       
   804 
       
   805   $ hg stack
       
   806   ### topic: tools (2 heads)
       
   807   ### branch: default, 2 behind
       
   808   t4: Adding drill
       
   809   t3: Adding saw
       
   810   t1^ Adding hammer to the shopping list (base)
       
   811   t2@ Adding nails (current)
       
   812   t1: Adding hammer to the shopping list
       
   813   t0^ add a pair of shoes (base)
       
   814 
       
   815 Solving this situation is easy with a topic, use merge or rebase.
       
   816 Merge within a multi-headed stack will use the other topic head as
       
   817 redestination if the topic has multiple heads.
       
   818 
       
   819   $ hg log -G
       
   820   @  changeset:   21:f936c6da9d61
       
   821   |  tag:         tip
       
   822   |  topic:       tools
       
   823   |  parent:      18:b7509bd417f8
       
   824   |  user:        test
       
   825   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   826   |  summary:     Adding nails
       
   827   |
       
   828   | o  changeset:   20:bae3758e46bf
       
   829   | |  topic:       tools
       
   830   | |  user:        test
       
   831   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   832   | |  summary:     Adding drill
       
   833   | |
       
   834   | o  changeset:   19:d5c51ee5762a
       
   835   |/   topic:       tools
       
   836   |    user:        test
       
   837   |    date:        Thu Jan 01 00:00:00 1970 +0000
       
   838   |    summary:     Adding saw
       
   839   |
       
   840   o  changeset:   18:b7509bd417f8
       
   841   |  topic:       tools
       
   842   |  parent:      12:fbff9bc37a43
       
   843   |  user:        test
       
   844   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   845   |  summary:     Adding hammer to the shopping list
       
   846   |
       
   847   | o  changeset:   17:4cd7c1591a67
       
   848   | |  user:        test
       
   849   | |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   850   | |  summary:     Adding orange juice
       
   851   | |
       
   852   | o  changeset:   16:20759cb47ff8
       
   853   |/   parent:      12:fbff9bc37a43
       
   854   |    user:        test
       
   855   |    date:        Thu Jan 01 00:00:00 1970 +0000
       
   856   |    summary:     Adding apple juice
       
   857   |
       
   858   o  changeset:   12:fbff9bc37a43
       
   859   |  user:        test
       
   860   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   861   |  summary:     add a pair of shoes
       
   862   |
       
   863   o  changeset:   11:f2d6cacc6115
       
   864   |  parent:      5:2d50db8b5b4c
       
   865   |  user:        test
       
   866   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   867   |  summary:     add a coat
       
   868   |
       
   869   o  changeset:   5:2d50db8b5b4c
       
   870   |  user:        test
       
   871   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   872   |  summary:     adding fruits
       
   873   |
       
   874   o  changeset:   4:4011b46eeb33
       
   875   |  user:        test
       
   876   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   877   |  summary:     adding condiments
       
   878   |
       
   879   o  changeset:   3:6104862e8b84
       
   880   |  parent:      0:38da43f0a2ea
       
   881   |  user:        test
       
   882   |  date:        Thu Jan 01 00:00:00 1970 +0000
       
   883   |  summary:     Adding clothes
       
   884   |
       
   885   o  changeset:   0:38da43f0a2ea
       
   886      user:        test
       
   887      date:        Thu Jan 01 00:00:00 1970 +0000
       
   888      summary:     Shopping list
       
   889   
       
   890 
       
   891   $ hg up t4
       
   892   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   893 
       
   894   $ hg rebase
       
   895   rebasing 19:d5c51ee5762a "Adding saw"
       
   896   merging shopping
       
   897   rebasing 20:bae3758e46bf "Adding drill"
       
   898   merging shopping
       
   899 
       
   900   $ hg commit -m "Merge tools"
       
   901   nothing changed
       
   902   [1]
       
   903 
       
   904   $ hg stack
       
   905   ### topic: tools
       
   906   ### branch: default, 2 behind
       
   907   t4@ Adding drill (current)
       
   908   t3: Adding saw
       
   909   t2: Adding nails
       
   910   t1: Adding hammer to the shopping list
       
   911   t0^ add a pair of shoes (base)
       
   912 
       
   913 Collaborating through non-publishing server
       
   914 ===========================================
       
   915 
       
   916 .. setup:
       
   917 
       
   918 .. Let's create a non-publishing server:
       
   919 
       
   920   $ cd ..
       
   921 
       
   922   $ hg clone server non-publishing-server
       
   923   updating to branch default
       
   924   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   925 
       
   926   $ cd non-publishing-server
       
   927   $ cat >> .hg/hgrc << EOF
       
   928   > [phases]
       
   929   > publish = false
       
   930   > EOF
       
   931 
       
   932 .. And another client:
       
   933 
       
   934   $ cd ..
       
   935 
       
   936   $ hg clone server other-client
       
   937   updating to branch default
       
   938   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   939 
       
   940   $ cd client
       
   941 
       
   942 We can now share theses drafts changesets:
       
   943 
       
   944   $ hg push ../non-publishing-server -r tools
       
   945   pushing to ../non-publishing-server
       
   946   searching for changes
       
   947   adding changesets
       
   948   adding manifests
       
   949   adding file changes
       
   950   added 4 changesets with 4 changes to 1 files (+1 heads)
       
   951   8 new obsolescence markers
       
   952 
       
   953 Pushing the new topic branch to a non publishing server did not required
       
   954 --force. As long as new heads are on their own topic, Mercurial will not
       
   955 complains about them.
       
   956 
       
   957 From another client, we will gets them with their topic:
       
   958 
       
   959   $ cd ../other-client
       
   960 
       
   961   $ hg pull ../non-publishing-server
       
   962   pulling from ../non-publishing-server
       
   963   searching for changes
       
   964   adding changesets
       
   965   adding manifests
       
   966   adding file changes
       
   967   added 4 changesets with 4 changes to 1 files (+1 heads)
       
   968   8 new obsolescence markers
       
   969   (run 'hg heads' to see heads)
       
   970 
       
   971   $ hg topics --verbose
       
   972      tools (on branch: default, 4 changesets, 2 behind)
       
   973 
       
   974   $ hg up tools
       
   975   switching to topic tools
       
   976   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   977 
       
   978   $ hg stack
       
   979   ### topic: tools
       
   980   ### branch: default, 2 behind
       
   981   t4@ Adding drill (current)
       
   982   t3: Adding saw
       
   983   t2: Adding nails
       
   984   t1: Adding hammer to the shopping list
       
   985   t0^ add a pair of shoes (base)
       
   986 
       
   987 We can also add new changesets and share them:
       
   988 
       
   989   $ echo screws >> shopping
       
   990 
       
   991   $ hg commit -A -m "Adding screws"
       
   992 
       
   993   $ hg push ../non-publishing-server
       
   994   pushing to ../non-publishing-server
       
   995   searching for changes
       
   996   adding changesets
       
   997   adding manifests
       
   998   adding file changes
       
   999   added 1 changesets with 1 changes to 1 files
       
  1000 
       
  1001 And retrieve them on the first client:
       
  1002 
       
  1003   $ cd ../client
       
  1004 
       
  1005   $ hg pull ../non-publishing-server
       
  1006   pulling from ../non-publishing-server
       
  1007   searching for changes
       
  1008   adding changesets
       
  1009   adding manifests
       
  1010   adding file changes
       
  1011   added 1 changesets with 1 changes to 1 files
       
  1012   (run 'hg update' to get a working copy)
       
  1013 
       
  1014   $ hg update
       
  1015   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
  1016 
       
  1017   $ hg stack
       
  1018   ### topic: tools
       
  1019   ### branch: default, 2 behind
       
  1020   t5@ Adding screws (current)
       
  1021   t4: Adding drill
       
  1022   t3: Adding saw
       
  1023   t2: Adding nails
       
  1024   t1: Adding hammer to the shopping list
       
  1025   t0^ add a pair of shoes (base)