tests/test-sharing.t
changeset 2020 143c8e4dc22d
parent 1806 9f42f819267b
child 2110 f1ffd093ef30
child 2566 f6821f6bf73c
equal deleted inserted replaced
2019:996a562b6c9f 2020:143c8e4dc22d
       
     1 Test script based on sharing.rst: ensure that all scenarios in that
       
     2 document work as advertised.
       
     3 
       
     4 Setting things up
       
     5 
       
     6   $ cat >> $HGRCPATH <<EOF
       
     7   > [alias]
       
     8   > shortlog = log --template '{rev}:{node|short}  {phase}  {desc|firstline}\n'
       
     9   > [extensions]
       
    10   > rebase =
       
    11   > EOF
       
    12   $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
       
    13   $ hg init public
       
    14   $ hg clone public test-repo
       
    15   updating to branch default
       
    16   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
    17   $ hg clone test-repo dev-repo
       
    18   updating to branch default
       
    19   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
    20   $ cat >> test-repo/.hg/hgrc <<EOF
       
    21   > [phases]
       
    22   > publish = false
       
    23   > EOF
       
    24 
       
    25 To start things off, let's make one public, immutable changeset::
       
    26 
       
    27   $ cd test-repo
       
    28   $ echo 'my new project' > file1
       
    29   $ hg add file1
       
    30   $ hg commit -m'create new project'
       
    31   $ hg push
       
    32   pushing to $TESTTMP/public (glob)
       
    33   searching for changes
       
    34   adding changesets
       
    35   adding manifests
       
    36   adding file changes
       
    37   added 1 changesets with 1 changes to 1 files
       
    38 
       
    39 and pull that into the development repository::
       
    40 
       
    41   $ cd ../dev-repo
       
    42   $ hg pull -u
       
    43   pulling from $TESTTMP/test-repo (glob)
       
    44   requesting all changes
       
    45   adding changesets
       
    46   adding manifests
       
    47   adding file changes
       
    48   added 1 changesets with 1 changes to 1 files
       
    49   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
    50 
       
    51 Let's commit a preliminary change and push it to ``test-repo`` for
       
    52 testing. ::
       
    53 
       
    54   $ echo 'fix fix fix' > file1
       
    55   $ hg commit -m'prelim change'
       
    56   $ hg push -q ../test-repo
       
    57 
       
    58 Figure SG01 (roughly)
       
    59   $ hg shortlog -G
       
    60   @  1:f6490818a721  draft  prelim change
       
    61   |
       
    62   o  0:0dc9c9f6ab91  public  create new project
       
    63   
       
    64 Now let's switch to test-repo to test our change and amend::
       
    65   $ cd ../test-repo
       
    66   $ hg update -q
       
    67   $ echo 'Fix fix fix.' > file1
       
    68   $ hg amend -m'fix bug 37'
       
    69 
       
    70 Figure SG02
       
    71   $ hg shortlog --hidden -G
       
    72   @  3:60ffde5765c5  draft  fix bug 37
       
    73   |
       
    74   | x  2:2a039763c0f4  draft  temporary amend commit for f6490818a721
       
    75   | |
       
    76   | x  1:f6490818a721  draft  prelim change
       
    77   |/
       
    78   o  0:0dc9c9f6ab91  public  create new project
       
    79   
       
    80 Pull into dev-repo: obsolescence markers are transferred, but not
       
    81 the new obsolete changeset.
       
    82   $ cd ../dev-repo
       
    83   $ hg pull -u
       
    84   pulling from $TESTTMP/test-repo (glob)
       
    85   searching for changes
       
    86   adding changesets
       
    87   adding manifests
       
    88   adding file changes
       
    89   added 1 changesets with 1 changes to 1 files (+1 heads)
       
    90   2 new obsolescence markers
       
    91   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
    92   1 other heads for branch "default"
       
    93 
       
    94 Figure SG03
       
    95   $ hg shortlog --hidden -G
       
    96   @  2:60ffde5765c5  draft  fix bug 37
       
    97   |
       
    98   | x  1:f6490818a721  draft  prelim change
       
    99   |/
       
   100   o  0:0dc9c9f6ab91  public  create new project
       
   101   
       
   102 Amend again in dev-repo
       
   103   $ echo 'Fix, fix, and fix.' > file1
       
   104   $ hg amend
       
   105   $ hg push -q
       
   106 
       
   107 Figure SG04 (dev-repo)
       
   108   $ hg shortlog --hidden -G
       
   109   @  4:de6151c48e1c  draft  fix bug 37
       
   110   |
       
   111   | x  3:ad19d3570adb  draft  temporary amend commit for 60ffde5765c5
       
   112   | |
       
   113   | x  2:60ffde5765c5  draft  fix bug 37
       
   114   |/
       
   115   | x  1:f6490818a721  draft  prelim change
       
   116   |/
       
   117   o  0:0dc9c9f6ab91  public  create new project
       
   118   
       
   119 Figure SG04 (test-repo)
       
   120   $ cd ../test-repo
       
   121   $ hg update
       
   122   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   123   1 other heads for branch "default"
       
   124   $ hg shortlog --hidden -G
       
   125   @  4:de6151c48e1c  draft  fix bug 37
       
   126   |
       
   127   | x  3:60ffde5765c5  draft  fix bug 37
       
   128   |/
       
   129   | x  2:2a039763c0f4  draft  temporary amend commit for f6490818a721
       
   130   | |
       
   131   | x  1:f6490818a721  draft  prelim change
       
   132   |/
       
   133   o  0:0dc9c9f6ab91  public  create new project
       
   134   
       
   135 This bug fix is finished. We can push it to the public repository.
       
   136   $ hg push
       
   137   pushing to $TESTTMP/public (glob)
       
   138   searching for changes
       
   139   adding changesets
       
   140   adding manifests
       
   141   adding file changes
       
   142   added 1 changesets with 1 changes to 1 files
       
   143   4 new obsolescence markers
       
   144 
       
   145 Now that the fix is public, we cannot amend it any more.
       
   146   $ hg amend -m 'fix bug 37'
       
   147   abort: cannot amend public changesets
       
   148   [255]
       
   149 
       
   150 Figure SG05
       
   151   $ hg -R ../public shortlog -G
       
   152   o  1:de6151c48e1c  public  fix bug 37
       
   153   |
       
   154   o  0:0dc9c9f6ab91  public  create new project
       
   155   
       
   156 Oops, still have draft changesets in dev-repo: push the phase change there.
       
   157   $ hg -R ../dev-repo shortlog -r 'draft()'
       
   158   4:de6151c48e1c  draft  fix bug 37
       
   159   $ hg push ../dev-repo
       
   160   pushing to ../dev-repo
       
   161   searching for changes
       
   162   no changes found
       
   163   [1]
       
   164   $ hg -R ../dev-repo shortlog -r 'draft()'
       
   165 
       
   166 Sharing with multiple developers: code review
       
   167 
       
   168   $ cd ..
       
   169   $ hg clone public review
       
   170   updating to branch default
       
   171   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   172   $ hg clone review alice
       
   173   updating to branch default
       
   174   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   175   $ hg clone review bob
       
   176   updating to branch default
       
   177   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   178   $ cat >> review/.hg/hgrc <<EOF
       
   179   > [phases]
       
   180   > publish = false
       
   181   > EOF
       
   182 
       
   183 Alice commits a draft bug fix, pushes to review repo.
       
   184   $ cd alice
       
   185   $ hg bookmark bug15
       
   186   $ echo 'fix' > file2
       
   187   $ hg commit -A -u alice -m 'fix bug 15 (v1)'
       
   188   adding file2
       
   189   $ hg push -B bug15
       
   190   pushing to $TESTTMP/review (glob)
       
   191   searching for changes
       
   192   adding changesets
       
   193   adding manifests
       
   194   adding file changes
       
   195   added 1 changesets with 1 changes to 1 files
       
   196   exporting bookmark bug15
       
   197   $ hg -R ../review bookmarks
       
   198      bug15                     2:f91e97234c2b
       
   199 
       
   200 Alice receives code review, amends her fix, and goes out to lunch to
       
   201 await second review.
       
   202   $ echo 'Fix.' > file2
       
   203   $ hg amend -m 'fix bug 15 (v2)'
       
   204   $ hg push
       
   205   pushing to $TESTTMP/review (glob)
       
   206   searching for changes
       
   207   adding changesets
       
   208   adding manifests
       
   209   adding file changes
       
   210   added 1 changesets with 1 changes to 1 files (+1 heads)
       
   211   2 new obsolescence markers
       
   212   updating bookmark bug15
       
   213   $ hg -R ../review bookmarks
       
   214      bug15                     3:cbdfbd5a5db2
       
   215 
       
   216 Figure SG06: review repository after Alice pushes her amended changeset.
       
   217   $ hg --hidden -R ../review shortlog -G -r 1::
       
   218   o  3:cbdfbd5a5db2  draft  fix bug 15 (v2)
       
   219   |
       
   220   | x  2:f91e97234c2b  draft  fix bug 15 (v1)
       
   221   |/
       
   222   @  1:de6151c48e1c  public  fix bug 37
       
   223   |
       
   224   ~
       
   225 
       
   226 Bob commits a draft changeset, pushes to review repo.
       
   227   $ cd ../bob
       
   228   $ echo 'stuff' > file1
       
   229   $ hg bookmark featureX
       
   230   $ hg commit -u bob -m 'implement feature X (v1)'
       
   231   $ hg push -B featureX
       
   232   pushing to $TESTTMP/review (glob)
       
   233   searching for changes
       
   234   remote has heads on branch 'default' that are not known locally: cbdfbd5a5db2
       
   235   adding changesets
       
   236   adding manifests
       
   237   adding file changes
       
   238   added 1 changesets with 1 changes to 1 files (+1 heads)
       
   239   exporting bookmark featureX
       
   240   $ hg -R ../review bookmarks
       
   241      bug15                     3:cbdfbd5a5db2
       
   242      featureX                  4:193657d1e852
       
   243 
       
   244 Bob receives first review, amends and pushes.
       
   245   $ echo 'do stuff' > file1
       
   246   $ hg amend -m 'implement feature X (v2)'
       
   247   $ hg push
       
   248   pushing to $TESTTMP/review (glob)
       
   249   searching for changes
       
   250   remote has heads on branch 'default' that are not known locally: cbdfbd5a5db2
       
   251   adding changesets
       
   252   adding manifests
       
   253   adding file changes
       
   254   added 1 changesets with 1 changes to 1 files (+1 heads)
       
   255   2 new obsolescence markers
       
   256   updating bookmark featureX
       
   257 
       
   258 Bob receives second review, amends, and pushes to public:
       
   259 this time, he's sure he got it right!
       
   260   $ echo 'Do stuff.' > file1
       
   261   $ hg amend -m 'implement feature X (v3)'
       
   262   $ hg push ../public
       
   263   pushing to ../public
       
   264   searching for changes
       
   265   adding changesets
       
   266   adding manifests
       
   267   adding file changes
       
   268   added 1 changesets with 1 changes to 1 files
       
   269   4 new obsolescence markers
       
   270   $ hg -R ../public bookmarks
       
   271   no bookmarks set
       
   272   $ hg push ../review
       
   273   pushing to ../review
       
   274   searching for changes
       
   275   remote has heads on branch 'default' that are not known locally: cbdfbd5a5db2
       
   276   adding changesets
       
   277   adding manifests
       
   278   adding file changes
       
   279   added 1 changesets with 1 changes to 1 files (+1 heads)
       
   280   2 new obsolescence markers
       
   281   updating bookmark featureX
       
   282   $ hg -R ../review bookmarks
       
   283      bug15                     3:cbdfbd5a5db2
       
   284      featureX                  6:540ba8f317e6
       
   285 
       
   286 Figure SG07: review and public repos after Bob implements feature X.
       
   287   $ hg --hidden -R ../review shortlog -G -r 1::
       
   288   o  6:540ba8f317e6  public  implement feature X (v3)
       
   289   |
       
   290   | x  5:0eb74a7b6698  draft  implement feature X (v2)
       
   291   |/
       
   292   | x  4:193657d1e852  draft  implement feature X (v1)
       
   293   |/
       
   294   | o  3:cbdfbd5a5db2  draft  fix bug 15 (v2)
       
   295   |/
       
   296   | x  2:f91e97234c2b  draft  fix bug 15 (v1)
       
   297   |/
       
   298   @  1:de6151c48e1c  public  fix bug 37
       
   299   |
       
   300   ~
       
   301   $ hg --hidden -R ../public shortlog -G -r 1::
       
   302   o  2:540ba8f317e6  public  implement feature X (v3)
       
   303   |
       
   304   o  1:de6151c48e1c  public  fix bug 37
       
   305   |
       
   306   ~
       
   307 
       
   308 How do things look in the review repo?
       
   309   $ cd ../review
       
   310   $ hg --hidden shortlog -G -r 1::
       
   311   o  6:540ba8f317e6  public  implement feature X (v3)
       
   312   |
       
   313   | x  5:0eb74a7b6698  draft  implement feature X (v2)
       
   314   |/
       
   315   | x  4:193657d1e852  draft  implement feature X (v1)
       
   316   |/
       
   317   | o  3:cbdfbd5a5db2  draft  fix bug 15 (v2)
       
   318   |/
       
   319   | x  2:f91e97234c2b  draft  fix bug 15 (v1)
       
   320   |/
       
   321   @  1:de6151c48e1c  public  fix bug 37
       
   322   |
       
   323   ~
       
   324 
       
   325 Meantime, Alice is back from lunch. While she was away, Bob approved
       
   326 her change, so now she can publish it.
       
   327   $ cd ../alice
       
   328   $ hg --hidden shortlog -G -r 1::
       
   329   @  4:cbdfbd5a5db2  draft  fix bug 15 (v2)
       
   330   |
       
   331   | x  3:55dd95168a35  draft  temporary amend commit for f91e97234c2b
       
   332   | |
       
   333   | x  2:f91e97234c2b  draft  fix bug 15 (v1)
       
   334   |/
       
   335   o  1:de6151c48e1c  public  fix bug 37
       
   336   |
       
   337   ~
       
   338   $ hg outgoing -q ../public
       
   339   4:cbdfbd5a5db2
       
   340   $ hg push ../public
       
   341   pushing to ../public
       
   342   searching for changes
       
   343   remote has heads on branch 'default' that are not known locally: 540ba8f317e6
       
   344   abort: push creates new remote head cbdfbd5a5db2 with bookmark 'bug15'!
       
   345   (pull and merge or see 'hg help push' for details about pushing new heads)
       
   346   [255]
       
   347   $ hg pull ../public
       
   348   pulling from ../public
       
   349   searching for changes
       
   350   adding changesets
       
   351   adding manifests
       
   352   adding file changes
       
   353   added 1 changesets with 1 changes to 1 files (+1 heads)
       
   354   4 new obsolescence markers
       
   355   (run 'hg heads' to see heads, 'hg merge' to merge)
       
   356   $ hg log -G -q -r 'head()'
       
   357   o  5:540ba8f317e6
       
   358   |
       
   359   ~
       
   360   @  4:cbdfbd5a5db2
       
   361   |
       
   362   ~
       
   363   $ hg --hidden shortlog -G -r 1::
       
   364   o  5:540ba8f317e6  public  implement feature X (v3)
       
   365   |
       
   366   | @  4:cbdfbd5a5db2  draft  fix bug 15 (v2)
       
   367   |/
       
   368   | x  3:55dd95168a35  draft  temporary amend commit for f91e97234c2b
       
   369   | |
       
   370   | x  2:f91e97234c2b  draft  fix bug 15 (v1)
       
   371   |/
       
   372   o  1:de6151c48e1c  public  fix bug 37
       
   373   |
       
   374   ~
       
   375 
       
   376 Alice rebases her draft changeset on top of Bob's public changeset and
       
   377 publishes the result.
       
   378   $ hg rebase -d 5
       
   379   rebasing 4:cbdfbd5a5db2 "fix bug 15 (v2)" (bug15)
       
   380   $ hg push ../public
       
   381   pushing to ../public
       
   382   searching for changes
       
   383   adding changesets
       
   384   adding manifests
       
   385   adding file changes
       
   386   added 1 changesets with 1 changes to 1 files
       
   387   3 new obsolescence markers
       
   388   $ hg push ../review
       
   389   pushing to ../review
       
   390   searching for changes
       
   391   adding changesets
       
   392   adding manifests
       
   393   adding file changes
       
   394   added 1 changesets with 0 changes to 1 files
       
   395   1 new obsolescence markers
       
   396   updating bookmark bug15
       
   397 
       
   398 Figure SG08: review and public changesets after Alice pushes.
       
   399   $ hg --hidden -R ../review shortlog -G -r 1::
       
   400   o  7:a06ec1bf97bd  public  fix bug 15 (v2)
       
   401   |
       
   402   o  6:540ba8f317e6  public  implement feature X (v3)
       
   403   |
       
   404   | x  5:0eb74a7b6698  draft  implement feature X (v2)
       
   405   |/
       
   406   | x  4:193657d1e852  draft  implement feature X (v1)
       
   407   |/
       
   408   | x  3:cbdfbd5a5db2  draft  fix bug 15 (v2)
       
   409   |/
       
   410   | x  2:f91e97234c2b  draft  fix bug 15 (v1)
       
   411   |/
       
   412   @  1:de6151c48e1c  public  fix bug 37
       
   413   |
       
   414   ~
       
   415   $ hg --hidden -R ../public shortlog -G -r 1::
       
   416   o  3:a06ec1bf97bd  public  fix bug 15 (v2)
       
   417   |
       
   418   o  2:540ba8f317e6  public  implement feature X (v3)
       
   419   |
       
   420   o  1:de6151c48e1c  public  fix bug 37
       
   421   |
       
   422   ~
       
   423   $ cd ..
       
   424 
       
   425 Setup for "cowboy mode" shared mutable history (to illustrate divergent
       
   426 and bumped changesets).
       
   427   $ rm -rf review alice bob
       
   428   $ hg clone public alice
       
   429   updating to branch default
       
   430   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   431   $ hg clone public bob
       
   432   updating to branch default
       
   433   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   434   $ cat >> alice/.hg/hgrc <<EOF
       
   435   > [phases]
       
   436   > publish = false
       
   437   > EOF
       
   438   $ cp alice/.hg/hgrc bob/.hg/hgrc
       
   439 
       
   440 Now we'll have Bob commit a bug fix that could still be improved::
       
   441 
       
   442   $ cd bob
       
   443   $ echo 'pretty good fix' >> file1
       
   444   $ hg commit -u bob -m 'fix bug 24 (v1)'
       
   445   $ hg shortlog -r .
       
   446   4:2fe6c4bd32d0  draft  fix bug 24 (v1)
       
   447 
       
   448 Since Alice and Bob are now in cowboy mode, Alice pulls Bob's draft
       
   449 changeset and amends it herself. ::
       
   450 
       
   451   $ cd ../alice
       
   452   $ hg pull -u ../bob
       
   453   pulling from ../bob
       
   454   searching for changes
       
   455   adding changesets
       
   456   adding manifests
       
   457   adding file changes
       
   458   added 1 changesets with 1 changes to 1 files
       
   459   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
       
   460   $ echo 'better fix (alice)' >> file1
       
   461   $ hg amend -u alice -m 'fix bug 24 (v2 by alice)'
       
   462 
       
   463 Bob implements a better fix of his own::
       
   464 
       
   465   $ cd ../bob
       
   466   $ echo 'better fix (bob)' >> file1
       
   467   $ hg amend -u bob -m 'fix bug 24 (v2 by bob)'
       
   468   $ hg --hidden shortlog -G -r 3::
       
   469   @  6:a360947f6faf  draft  fix bug 24 (v2 by bob)
       
   470   |
       
   471   | x  5:3466c7f5a149  draft  temporary amend commit for 2fe6c4bd32d0
       
   472   | |
       
   473   | x  4:2fe6c4bd32d0  draft  fix bug 24 (v1)
       
   474   |/
       
   475   o  3:a06ec1bf97bd  public  fix bug 15 (v2)
       
   476   |
       
   477   ~
       
   478 
       
   479 Bob discovers the divergence.
       
   480   $ hg pull ../alice
       
   481   pulling from ../alice
       
   482   searching for changes
       
   483   adding changesets
       
   484   adding manifests
       
   485   adding file changes
       
   486   added 1 changesets with 1 changes to 1 files (+1 heads)
       
   487   2 new obsolescence markers
       
   488   (run 'hg heads' to see heads, 'hg merge' to merge)
       
   489   2 new divergent changesets
       
   490 
       
   491 Figure SG09: multiple heads! divergence! oh my!
       
   492   $ hg --hidden shortlog -G -r 3::
       
   493   o  7:e3f99ce9d9cd  draft  fix bug 24 (v2 by alice)
       
   494   |
       
   495   | @  6:a360947f6faf  draft  fix bug 24 (v2 by bob)
       
   496   |/
       
   497   | x  5:3466c7f5a149  draft  temporary amend commit for 2fe6c4bd32d0
       
   498   | |
       
   499   | x  4:2fe6c4bd32d0  draft  fix bug 24 (v1)
       
   500   |/
       
   501   o  3:a06ec1bf97bd  public  fix bug 15 (v2)
       
   502   |
       
   503   ~
       
   504   $ hg --hidden shortlog -r 'successors(2fe6)'
       
   505   6:a360947f6faf  draft  fix bug 24 (v2 by bob)
       
   506   7:e3f99ce9d9cd  draft  fix bug 24 (v2 by alice)
       
   507 
       
   508 Use evolve to fix the divergence.
       
   509   $ HGMERGE=internal:other hg evolve --divergent
       
   510   merge:[6] fix bug 24 (v2 by bob)
       
   511   with: [7] fix bug 24 (v2 by alice)
       
   512   base: [4] fix bug 24 (v1)
       
   513   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
       
   514   working directory is now at 5ad6037c046c
       
   515   $ hg log -q -r 'divergent()'
       
   516 
       
   517 Figure SG10: Bob's repository after fixing divergence.
       
   518   $ hg --hidden shortlog -G -r 3::
       
   519   @  9:5ad6037c046c  draft  fix bug 24 (v2 by bob)
       
   520   |
       
   521   | x  8:bcfc9a755ac3  draft  temporary amend commit for a360947f6faf
       
   522   | |
       
   523   +---x  7:e3f99ce9d9cd  draft  fix bug 24 (v2 by alice)
       
   524   | |
       
   525   | x  6:a360947f6faf  draft  fix bug 24 (v2 by bob)
       
   526   |/
       
   527   | x  5:3466c7f5a149  draft  temporary amend commit for 2fe6c4bd32d0
       
   528   | |
       
   529   | x  4:2fe6c4bd32d0  draft  fix bug 24 (v1)
       
   530   |/
       
   531   o  3:a06ec1bf97bd  public  fix bug 15 (v2)
       
   532   |
       
   533   ~
       
   534   $ hg --hidden shortlog -r 'precursors(9)'
       
   535   6:a360947f6faf  draft  fix bug 24 (v2 by bob)
       
   536   7:e3f99ce9d9cd  draft  fix bug 24 (v2 by alice)
       
   537   $ cat file1
       
   538   Do stuff.
       
   539   pretty good fix
       
   540   better fix (alice)