docs/sharing.rst
branchstable
changeset 4937 0d1893c1044c
parent 4936 deec516b6e34
child 4973 f3faafa1e064
equal deleted inserted replaced
4936:deec516b6e34 4937:0d1893c1044c
   158   $ hg push ../test-repo
   158   $ hg push ../test-repo
   159 
   159 
   160 At this point, ``dev-repo`` and ``test-repo`` have the same changesets
   160 At this point, ``dev-repo`` and ``test-repo`` have the same changesets
   161 in the same phases:
   161 in the same phases:
   162 
   162 
   163   [figure SG01: rev 0:0dc9 public, rev 1:f649 draft, same on both repos]
   163 .. figure:: figures/figure-sg01-ab.svg
       
   164 
       
   165    Figure 1 a: ``dev-repo`` has rev 0:0dc9 public, rev 1:f649 draft
       
   166 
       
   167 .. figure:: figures/figure-sg01-ab.svg
       
   168 
       
   169    Figure 1 b: the same exact picture in ``test-repo``
   164 
   170 
   165 (You may notice a change in notation from the user guide: now
   171 (You may notice a change in notation from the user guide: now
   166 changesets are labelled with their revision number and the first four
   172 changesets are labelled with their revision number and the first four
   167 digits of the 40-digit hexadecimal changeset ID. Mercurial revision
   173 digits of the 40-digit hexadecimal changeset ID. Mercurial revision
   168 numbers are not consistent when working across repositories, especially
   174 numbers are not consistent when working across repositories, especially
   196 
   202 
   197 Now we're in a funny intermediate state (figure 2): revision 1:f649 is
   203 Now we're in a funny intermediate state (figure 2): revision 1:f649 is
   198 obsolete in ``test-repo``, having been replaced by revision 2:96d8 and then by
   204 obsolete in ``test-repo``, having been replaced by revision 2:96d8 and then by
   199 3:522d—but ``dev-repo`` knows nothing of these recent developments.
   205 3:522d—but ``dev-repo`` knows nothing of these recent developments.
   200 
   206 
   201   [figure SG02: test-repo has rev 0:0dc9 public, rev 1:f649 and 2:96d8 obsolete, rev 3:522d draft; dev-repo same as in SG01]
   207 .. figure:: figures/figure-sg01-ab.svg
       
   208 
       
   209    Figure 2 a: ``dev-repo`` same as in Figure 01 a
       
   210 
       
   211 .. figure:: figures/figure-sg02-b.svg
       
   212 
       
   213    Figure 2 b: ``test-repo`` has rev 0:0dc9 public, revs 1:f649 and 2:96d8
       
   214    obsolete, rev 3:522d draft
   202 
   215 
   203 Let's resynchronize::
   216 Let's resynchronize::
   204 
   217 
   205   $ cd ../dev-repo
   218   $ cd ../dev-repo
   206   $ hg pull -u
   219   $ hg pull -u
   216 As seen in figure 3, this transfers the new changeset *and* the
   229 As seen in figure 3, this transfers the new changeset *and* the
   217 obsolescence marker for revision 1. However, it does *not* transfer
   230 obsolescence marker for revision 1. However, it does *not* transfer
   218 2:96d8, because it is hidden. Push and pull transfer obsolescence
   231 2:96d8, because it is hidden. Push and pull transfer obsolescence
   219 markers between repositories, but they do not transfer hidden changesets.
   232 markers between repositories, but they do not transfer hidden changesets.
   220 
   233 
   221   [figure SG03: dev-repo grows new rev 2:522d, marks 1:f649 obsolete]
   234 .. figure:: figures/figure-sg03.svg
       
   235 
       
   236    Figure 3: ``dev-repo`` receives rev 2:522d, 1:f649 is now obsolete like in
       
   237    ``test-repo``
   222 
   238 
   223 Because of this deliberately incomplete synchronization, revision
   239 Because of this deliberately incomplete synchronization, revision
   224 numbers in ``test-repo`` and ``dev-repo`` are no longer consistent. We
   240 numbers in ``test-repo`` and ``dev-repo`` are no longer consistent. We
   225 *must* use changeset IDs.
   241 *must* use changeset IDs.
   226 
   242 
   241 This time around, the first amend commit stays in ``dev-repo``, and
   257 This time around, the first amend commit stays in ``dev-repo``, and
   242 it is not transferred to ``test-repo``—the same as before, just in the
   258 it is not transferred to ``test-repo``—the same as before, just in the
   243 opposite direction. Figure 4 shows the two repositories after amending
   259 opposite direction. Figure 4 shows the two repositories after amending
   244 in ``dev-repo`` and pushing to ``test-repo``.
   260 in ``dev-repo`` and pushing to ``test-repo``.
   245 
   261 
   246   [figure SG04: each repo has one temporary amend commit, but they're different in each one]
   262 .. figure:: figures/figure-sg04-a.svg
       
   263 
       
   264    Figure 4 a: in ``dev-repo`` the extra amend commit is 3:e42b
       
   265 
       
   266 .. figure:: figures/figure-sg04-b.svg
       
   267 
       
   268    Figure 4 b: and in ``test-repo`` it is 2:96d8
   247 
   269 
   248 Let's hop over to ``test-repo`` to test the more elegant fix::
   270 Let's hop over to ``test-repo`` to test the more elegant fix::
   249 
   271 
   250   $ cd ../test-repo
   272   $ cd ../test-repo
   251   $ hg update
   273   $ hg update
   267 
   289 
   268 So the picture in ``public`` is much simpler than in either
   290 So the picture in ``public`` is much simpler than in either
   269 ``dev-repo`` or ``test-repo``. Neither of our missteps nor our amendments
   291 ``dev-repo`` or ``test-repo``. Neither of our missteps nor our amendments
   270 are publicly visible, just the final, beautifully polished changeset:
   292 are publicly visible, just the final, beautifully polished changeset:
   271 
   293 
   272   [figure SG05: public repo with rev 0:0dc9, 1:7b49, both public]
   294 .. figure:: figures/figure-sg05.svg
       
   295 
       
   296    Figure 5: in ``public`` repo with revs 0:0dc9 and 1:7b49, both public
   273 
   297 
   274 There is one important step left to do. Because we pushed from
   298 There is one important step left to do. Because we pushed from
   275 ``test-repo`` to ``public``, the pushed changeset is in *public* phase
   299 ``test-repo`` to ``public``, the pushed changeset is in *public* phase
   276 in those two repositories. But ``dev-repo`` has been out-of-the-loop;
   300 in those two repositories. But ``dev-repo`` has been out-of-the-loop;
   277 changeset 7b49 is still *draft* there. If we're not careful, we might
   301 changeset 7b49 is still *draft* there. If we're not careful, we might
   400   obsoleted 1 changesets
   424   obsoleted 1 changesets
   401   updating bookmark bug15
   425   updating bookmark bug15
   402 
   426 
   403 Figure 6 shows the state of the ``review`` repository at this point.
   427 Figure 6 shows the state of the ``review`` repository at this point.
   404 
   428 
   405   [figure SG06: rev 2:4e96 is Alice's obsolete v1, rev 3:3363 is her v2; both children of rev 1:7b49]
   429 .. figure:: figures/figure-sg06.svg
       
   430 
       
   431    Figure 6: rev 2:4e96 is Alice's obsolete v1, rev 3:3363 is her v2; both
       
   432    children of rev 1:7b49
   406 
   433 
   407 After a busy morning of bug fixing, Alice stops for lunch. Let's see
   434 After a busy morning of bug fixing, Alice stops for lunch. Let's see
   408 what Bob has been up to.
   435 what Bob has been up to.
   409 
   436 
   410 Example 4: Bob implements and publishes a new feature
   437 Example 4: Bob implements and publishes a new feature
   464   updating bookmark featureX
   491   updating bookmark featureX
   465 
   492 
   466 Figure 7 shows the result of Bob's work in both ``review`` and
   493 Figure 7 shows the result of Bob's work in both ``review`` and
   467 ``public``.
   494 ``public``.
   468 
   495 
   469   [figure SG07: review includes Alice's draft work on bug 15, as well as Bob's v1, v2, and v3 changes for feature X: v1 and v2 obsolete, v3 public. public contains only the final, public implementation of feature X]
   496 .. figure:: figures/figure-sg07-a.svg
       
   497 
       
   498    Figure 7 a: ``review`` includes Alice's draft work on bug 15, as well as
       
   499    Bob's v1, v2, and v3 changes for feature X: v1 and v2 obsolete, v3 public
       
   500 
       
   501 .. figure:: figures/figure-sg07-b.svg
       
   502 
       
   503    Figure 7 b: ``public`` contains only the final, public implementation of
       
   504    feature X
   470 
   505 
   471 Incidentally, it's important that Bob push to ``public`` *before*
   506 Incidentally, it's important that Bob push to ``public`` *before*
   472 ``review``. If he pushed to ``review`` first, then revision 6:540b
   507 ``review``. If he pushed to ``review`` first, then revision 6:540b
   473 would still be in *draft* phase in ``review``, but it would be
   508 would still be in *draft* phase in ``review``, but it would be
   474 *public* in both Bob's local repository and the ``public`` repository.
   509 *public* in both Bob's local repository and the ``public`` repository.
   521   updating bookmark bug15
   556   updating bookmark bug15
   522 
   557 
   523 The result, in both ``review`` and ``public`` repositories, is shown
   558 The result, in both ``review`` and ``public`` repositories, is shown
   524 in figure 8.
   559 in figure 8.
   525 
   560 
   526   [figure SG08: review shows v1 and v2 of Alice's fix, then v1, v2, v3 of Bob's feature, finally Alice's fix rebased onto Bob's. public just shows the final public version of each changeset]
   561 .. figure:: figures/figure-sg08-a.svg
       
   562 
       
   563    Figure 8 a: ``review`` shows v1 and v2 of Alice's fix, then v1, v2, v3 of
       
   564    Bob's feature, finally Alice's fix rebased onto Bob's
       
   565 
       
   566 .. figure:: figures/figure-sg08-b.svg
       
   567 
       
   568    Figure 8 b: ``public`` just shows the final public version of each changeset
   527 
   569 
   528 Getting into trouble with shared mutable history
   570 Getting into trouble with shared mutable history
   529 ------------------------------------------------
   571 ------------------------------------------------
   530 
   572 
   531 Mercurial with ``evolve`` is a powerful tool, and using powerful tools
   573 Mercurial with ``evolve`` is a powerful tool, and using powerful tools
   625   new changesets e3a586fd2377 (1 drafts)
   667   new changesets e3a586fd2377 (1 drafts)
   626   (run 'hg heads' to see heads, 'hg merge' to merge)
   668   (run 'hg heads' to see heads, 'hg merge' to merge)
   627 
   669 
   628 Figure 9 shows the situation in Bob's repository.
   670 Figure 9 shows the situation in Bob's repository.
   629 
   671 
   630   [figure SG09: Bob's repo with 2 heads for the 2 content-divergent changesets, 5:541f and 6:e3a5; wc is at 5:541f; both are successors of obsolete 4:b2be, hence divergence]
   672 .. figure:: figures/figure-sg09.svg
       
   673 
       
   674    Figure 9: Bob's repo with 2 heads for the 2 content-divergent changesets,
       
   675    5:541f and 6:e3a5; wc is at 5:541f; both are successors of obsolete 4:b2be,
       
   676    hence divergence
   631 
   677 
   632 Now we need to get out of trouble. As usual, the answer is to evolve
   678 Now we need to get out of trouble. As usual, the answer is to evolve
   633 history. ::
   679 history. ::
   634 
   680 
   635   $ HGMERGE=internal:other hg evolve
   681   $ HGMERGE=internal:other hg evolve