tests/test-sharing.t
changeset 979 c7b2ccd99dab
child 986 c1f8ece4182d
equal deleted inserted replaced
978:8328337d23b2 979:c7b2ccd99dab
       
     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))/hgext/evolve.py" >> $HGRCPATH
       
    13   $ hg init public
       
    14   $ hg clone -q public test-repo
       
    15   $ hg clone -q test-repo dev-repo
       
    16   $ cat >> test-repo/.hg/hgrc <<EOF
       
    17   > [phases]
       
    18   > publish = false
       
    19   > EOF
       
    20 
       
    21 To start things off, let's make one public, immutable changeset::
       
    22 
       
    23   $ cd test-repo
       
    24   $ echo 'my new project' > file1
       
    25   $ hg add file1
       
    26   $ hg commit -m'create new project'
       
    27   $ hg push -q
       
    28 
       
    29 and pull that into the development repository::
       
    30 
       
    31   $ cd ../dev-repo
       
    32   $ hg pull -q -u
       
    33 
       
    34 Let's commit a preliminary change and push it to ``test-repo`` for
       
    35 testing. ::
       
    36 
       
    37   $ echo 'fix fix fix' > file1
       
    38   $ hg commit -m'prelim change'
       
    39   $ hg push -q ../test-repo
       
    40 
       
    41 Figure SG01 (roughly)
       
    42   $ hg shortlog -G
       
    43   @  1:f6490818a721  draft  prelim change
       
    44   |
       
    45   o  0:0dc9c9f6ab91  public  create new project
       
    46   
       
    47 Now let's switch to test-repo to test our change and amend::
       
    48   $ cd ../test-repo
       
    49   $ hg update -q
       
    50   $ echo 'Fix fix fix.' > file1
       
    51   $ hg amend -m'fix bug 37'
       
    52 
       
    53 Figure SG02
       
    54   $ hg shortlog --hidden -G
       
    55   @  3:60ffde5765c5  draft  fix bug 37
       
    56   |
       
    57   | x  2:2a039763c0f4  draft  temporary amend commit for f6490818a721
       
    58   | |
       
    59   | x  1:f6490818a721  draft  prelim change
       
    60   |/
       
    61   o  0:0dc9c9f6ab91  public  create new project
       
    62   
       
    63 Pull into dev-repo: obsolescence markers are transferred, but not
       
    64 the new obsolete changeset.
       
    65   $ cd ../dev-repo
       
    66   $ hg pull -q -u
       
    67 
       
    68 Figure SG03
       
    69   $ hg shortlog --hidden -G
       
    70   @  2:60ffde5765c5  draft  fix bug 37
       
    71   |
       
    72   | x  1:f6490818a721  draft  prelim change
       
    73   |/
       
    74   o  0:0dc9c9f6ab91  public  create new project
       
    75   
       
    76 Amend again in dev-repo
       
    77   $ echo 'Fix, fix, and fix.' > file1
       
    78   $ hg amend
       
    79   $ hg push -q
       
    80 
       
    81 Figure SG04 (dev-repo)
       
    82   $ hg shortlog --hidden -G
       
    83   @  4:de6151c48e1c  draft  fix bug 37
       
    84   |
       
    85   | x  3:ad19d3570adb  draft  temporary amend commit for 60ffde5765c5
       
    86   | |
       
    87   | x  2:60ffde5765c5  draft  fix bug 37
       
    88   |/
       
    89   | x  1:f6490818a721  draft  prelim change
       
    90   |/
       
    91   o  0:0dc9c9f6ab91  public  create new project
       
    92   
       
    93 Figure SG04 (test-repo)
       
    94   $ cd ../test-repo
       
    95   $ hg update -q
       
    96   $ hg shortlog --hidden -G
       
    97   @  4:de6151c48e1c  draft  fix bug 37
       
    98   |
       
    99   | x  3:60ffde5765c5  draft  fix bug 37
       
   100   |/
       
   101   | x  2:2a039763c0f4  draft  temporary amend commit for f6490818a721
       
   102   | |
       
   103   | x  1:f6490818a721  draft  prelim change
       
   104   |/
       
   105   o  0:0dc9c9f6ab91  public  create new project
       
   106   
       
   107 This bug fix is finished. We can push it to the public repository.
       
   108   $ hg push
       
   109   pushing to $TESTTMP/public
       
   110   searching for changes
       
   111   adding changesets
       
   112   adding manifests
       
   113   adding file changes
       
   114   added 1 changesets with 1 changes to 1 files
       
   115   OBSEXC: computing relevant nodes
       
   116   OBSEXC: computing markers relevant to 2 nodes
       
   117   OBSEXC: pushing 4 markers (341 bytes)
       
   118   OBSEXC: DONE
       
   119 
       
   120 Figure SG05
       
   121   $ hg -R ../public shortlog -G
       
   122   o  1:de6151c48e1c  public  fix bug 37
       
   123   |
       
   124   o  0:0dc9c9f6ab91  public  create new project
       
   125   
       
   126 Oops, still have draft changesets in dev-repo.
       
   127   $ cd ../dev-repo
       
   128   $ hg shortlog -r 'draft()'
       
   129   4:de6151c48e1c  draft  fix bug 37
       
   130   $ hg pull -q -u
       
   131   $ hg shortlog -r 'draft()'
       
   132 
       
   133 Sharing by Alice and Bob to demonstrate bumped and divergent changesets.
       
   134 First, setup repos for them.
       
   135 
       
   136   $ cd ..
       
   137   $ hg clone -q public alice
       
   138   $ hg clone -q public bob
       
   139   $ cat >> alice/.hg/hgrc <<EOF
       
   140   > [phases]
       
   141   > publish = false
       
   142   > EOF
       
   143   $ cp alice/.hg/hgrc bob/.hg/hgrc
       
   144 
       
   145 Alice commits a bug fix.
       
   146   $ cd alice
       
   147   $ echo 'fix' > file2
       
   148   $ hg commit -q -A -u alice -m 'fix bug 15'
       
   149 
       
   150 Bob pulls and amends Alice's fix.
       
   151   $ cd ../bob
       
   152   $ hg pull -q -u ../alice
       
   153   $ echo 'Fix.' > file2
       
   154   $ hg amend -q -A -u bob -m 'fix bug 15 (amended)'
       
   155 
       
   156 Figure SG06: Bob's repository after amending Alice's fix.
       
   157 (Nothing new here; we could have seen this in the user guide.
       
   158   $ hg --hidden shortlog -G
       
   159   @  4:fe884dfac355  draft  fix bug 15 (amended)
       
   160   |
       
   161   | x  3:0376cac226f8  draft  temporary amend commit for e011baf925da
       
   162   | |
       
   163   | x  2:e011baf925da  draft  fix bug 15
       
   164   |/
       
   165   o  1:de6151c48e1c  public  fix bug 37
       
   166   |
       
   167   o  0:0dc9c9f6ab91  public  create new project
       
   168   
       
   169 
       
   170 But in the meantime, Alice decides the fix is just fine and publishes it.
       
   171   $ cd ../alice
       
   172   $ hg push -q
       
   173 
       
   174 Which means that Bob now has an formerly obsolete changeset that is
       
   175 also public (2:6e83). As soon as he pulls its phase change, he's got
       
   176 trouble: the successors of that formerly obsolete changeset are
       
   177 bumped.
       
   178 
       
   179   $ cd ../bob
       
   180   $ hg --hidden shortlog -r 'obsolete()'
       
   181   2:e011baf925da  draft  fix bug 15
       
   182   3:0376cac226f8  draft  temporary amend commit for e011baf925da
       
   183   $ hg pull -q -u
       
   184   1 new bumped changesets
       
   185   $ hg --hidden shortlog -r 'obsolete()'
       
   186   3:0376cac226f8  draft  temporary amend commit for e011baf925da
       
   187   $ hg shortlog -r 'bumped()'
       
   188   4:fe884dfac355  draft  fix bug 15 (amended)
       
   189 
       
   190 Figure SG07: Bob's repo with one bumped changeset (rev 4:c02d)
       
   191   $ hg --hidden shortlog -G
       
   192   @  4:fe884dfac355  draft  fix bug 15 (amended)
       
   193   |
       
   194   | x  3:0376cac226f8  draft  temporary amend commit for e011baf925da
       
   195   | |
       
   196   | o  2:e011baf925da  public  fix bug 15
       
   197   |/
       
   198   o  1:de6151c48e1c  public  fix bug 37
       
   199   |
       
   200   o  0:0dc9c9f6ab91  public  create new project
       
   201   
       
   202 
       
   203 Bob gets out of trouble by evolving the repository.
       
   204   $ hg evolve --all
       
   205   recreate:[4] fix bug 15 (amended)
       
   206   atop:[2] fix bug 15
       
   207   computing new diff
       
   208   committed as 227d860d9ad0
       
   209 
       
   210 Figure SG08
       
   211   $ hg --hidden shortlog -G
       
   212   @  5:227d860d9ad0  draft  bumped update to e011baf925da:
       
   213   |
       
   214   | x  4:fe884dfac355  draft  fix bug 15 (amended)
       
   215   | |
       
   216   +---x  3:0376cac226f8  draft  temporary amend commit for e011baf925da
       
   217   | |
       
   218   o |  2:e011baf925da  public  fix bug 15
       
   219   |/
       
   220   o  1:de6151c48e1c  public  fix bug 37
       
   221   |
       
   222   o  0:0dc9c9f6ab91  public  create new project
       
   223   
       
   224 
       
   225 Throw away Bob's messy repo and start over.
       
   226   $ cd ..
       
   227   $ rm -rf bob
       
   228   $ cp -rp alice bob
       
   229 
       
   230 Bob commits a pretty good fix that both he and Alice will amend,
       
   231 leading to divergence.
       
   232   $ cd bob
       
   233   $ echo 'pretty good fix' >> file1
       
   234   $ hg commit -u bob -m 'fix bug 24 (v1)'
       
   235 
       
   236 Alice pulls Bob's fix and improves it.
       
   237   $ cd ../alice
       
   238   $ hg pull -q -u ../bob
       
   239   $ echo 'better (alice)' >> file1
       
   240   $ hg amend -u alice -m 'fix bug 24 (v2 by alice)'
       
   241 
       
   242 Likewise, Bob amends his own fix. Now we have an obsolete changeset
       
   243 with two successors, although the successors are in different repos.
       
   244   $ cd ../bob
       
   245   $ echo 'better (bob)' >> file1
       
   246   $ hg amend -u bob -m 'fix bug 24 (v2 by bob)'
       
   247 
       
   248 Bob pulls from Alice's repo and discovers the trouble: divergent changesets!
       
   249   $ hg pull -q -u ../alice
       
   250   not updating: not a linear update
       
   251   (merge or update --check to force update)
       
   252   2 new divergent changesets
       
   253   $ hg shortlog -r 'divergent()'
       
   254   5:fc16901f4d7a  draft  fix bug 24 (v2 by bob)
       
   255   6:694fd0f6b503  draft  fix bug 24 (v2 by alice)
       
   256 
       
   257 Figure SG09
       
   258   $ hg --hidden shortlog -G
       
   259   o  6:694fd0f6b503  draft  fix bug 24 (v2 by alice)
       
   260   |
       
   261   | @  5:fc16901f4d7a  draft  fix bug 24 (v2 by bob)
       
   262   |/
       
   263   | x  4:162612d3335b  draft  temporary amend commit for fe81d904ed08
       
   264   | |
       
   265   | x  3:fe81d904ed08  draft  fix bug 24 (v1)
       
   266   |/
       
   267   o  2:e011baf925da  public  fix bug 15
       
   268   |
       
   269   o  1:de6151c48e1c  public  fix bug 37
       
   270   |
       
   271   o  0:0dc9c9f6ab91  public  create new project
       
   272   
       
   273 Merge the trouble away.
       
   274   $ HGMERGE=internal:local hg merge
       
   275   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
       
   276   (branch merge, don't forget to commit)
       
   277   $ hg commit -m merge
       
   278   $ hg shortlog -G
       
   279   @    7:b1d30ba26e44  draft  merge
       
   280   |\
       
   281   | o  6:694fd0f6b503  draft  fix bug 24 (v2 by alice)
       
   282   | |
       
   283   o |  5:fc16901f4d7a  draft  fix bug 24 (v2 by bob)
       
   284   |/
       
   285   o  2:e011baf925da  public  fix bug 15
       
   286   |
       
   287   o  1:de6151c48e1c  public  fix bug 37
       
   288   |
       
   289   o  0:0dc9c9f6ab91  public  create new project
       
   290   
       
   291   $ hg log -q -r 'divergent()'
       
   292   5:fc16901f4d7a
       
   293   6:694fd0f6b503
       
   294 
       
   295 # XXX hg evolve does not solve this trouble! bug in evolve?
       
   296 #Evolve the trouble away.
       
   297 #  $ HGMERGE=internal:local hg evolve --all
       
   298 #  merge:[5] fix bug 24 (v2 by bob)
       
   299 #  with: [6] fix bug 24 (v2 by alice)
       
   300 #  base: [3] fix bug 24 (v1)
       
   301 #  0 files updated, 1 files merged, 0 files removed, 0 files unresolved
       
   302 #  $ hg status
       
   303 #  $ hg shortlog -G
       
   304 #  o  6:694fd0f6b503  draft  fix bug 24 (v2 by alice)
       
   305 #  |
       
   306 #  | @  5:fc16901f4d7a  draft  fix bug 24 (v2 by bob)
       
   307 #  |/
       
   308 #  o  2:e011baf925da  public  fix bug 15
       
   309 #  |
       
   310 #  o  1:de6151c48e1c  public  fix bug 37
       
   311 #  |
       
   312 #  o  0:0dc9c9f6ab91  public  create new project
       
   313 #  
       
   314 #  $ hg --hidden shortlog -G