| 17 | | Let there be two tailor directories, once which ports patches from svn |
| 18 | | to darcs (called `"SD"` from here on) and one which ports patches from |
| 19 | | darcs to svn (called `"DS"` from here on). Each of these tailor |
| 20 | | directories contains an svn working dir subdirectory (called `"SDs"` or |
| 21 | | `"DSs"`) and a darcs repo subdirectory (called `"SDd"` or `"DSd"`). |
| | 18 | Let there be two tailor directories, once which translates patches from svn to darcs (called `"SD"` from here on) and one which translates patches from darcs to svn (called `"DS"` from here on). Each of these tailor directories contains an svn working dir subdirectory (called `"SDs"` or `"DSs"`) and a darcs repo subdirectory (called `"SDd"` or `"DSd"`). |
| 37 | | Let `"the up-to-date condition"` be such that the contents of all six of |
| 38 | | SDs, SDd, DSs, DSd, SO, and DO are up-to-date with each other. The |
| 39 | | up-to-date condition implies the internally-consistent condition. The |
| 40 | | complete Algorithm -- Algorithm D will result in the up-to-date state |
| 41 | | unless there is a conflict or unless new patches are added to SO or to |
| 42 | | DO after the algorithm has checked for new patches and before it |
| 43 | | terminates. |
| | 25 | Subroutine C: clean up any intermediate state |
| | 26 | -------------------------------------------------------- |
| 45 | | I'll first show three subroutines and then show the complete algorithm. |
| | 28 | Make sure that any intermediate state left behind from Subroutines A or B completing, raising MergeConflict, or crashing (i.e. being killed in mid-step) gets cleaned up and that we return to the Internally Consistent State if possible, or else raise an error if impossible. CLEANUP has to be run at the beginning of every run of the two-way-sync algorithm, since we never know if the previous run crashed and left things in an inconsistent state. |
| | 29 | |
| | 30 | 1. For each patch in SDd which has the special line as the last line of the log entry, run {{{darcs obliterate}}} to obliterate that patch from SDd. |
| | 31 | |
| | 32 | 2. {{{darcs pull -a $DSd}}} in SDd to pull all darcs patches from DSd into SDd. |
| | 33 | |
| | 34 | 3. {{{darcs push -a DO}}} in SDd. If the push fails (which will happen if it would cause a conflict in DO) then raise MergeConflict. |
| 58 | | 2. Use darcs push --match='hash $HASH' to push the resulting darcs |
| 59 | | patch from the SDd to DO (where HASH is equal to the hash of the |
| 60 | | patch which was just created). If the push fails for the reason |
| 61 | | that pushing would cause a conflict in DO then this algorithm must |
| 62 | | stop and notify the user of a conflict condition. |
| 63 | | |
| 64 | | 3. Run svn up -r$REVNUMBER in DSs (note: not SDs), with REVNUMBER |
| 65 | | equal to the revision number of the patch that was translated from |
| 66 | | SVN world in step A1. |
| 67 | | |
| 68 | | 4. Run ``darcs pull --match='hash $HASH'`` in DSd (note: not SDd), with |
| 69 | | HASH equal to the hash of the patch which was created in darcs |
| 70 | | world in step A1. |
| 71 | | |
| 72 | | Observe that if the internally-consistent condition held before |
| 73 | | `Subroutine A`_, and there was no conflict, then the |
| 74 | | internally-consistent condition must hold after `Subroutine A`_. |
| | 43 | 2. Use tailor in the SD directory to translate the next patch from SVN to darcs. This will update SDs to that revision and add a new patch into SDd. If there are no more untranslated svn patches in SO then raise StopIteration. |
| 101 | | Observe that the starting from the internally-consistent condition is |
| 102 | | necessary but not sufficient for Subroutine B to result in the |
| 103 | | internally-consistent condition. In addition to the |
| 104 | | internally-consistent condition, another condition is required, namely |
| 105 | | that SDs is required to have been up-to-date with SO. If SDs was not |
| 106 | | up-to-date with SO before Subroutine B, then step B4 will, in addition |
| 107 | | to adding the new patch into SDs also add other patches into SDs which |
| 108 | | are not also in SDd, violating the internally-consistent |
| 109 | | condition. This is why step B3 has to be inserted in Subroutine B. |
| | 61 | Incomplete Design |
| | 62 | ----------------- |
| 111 | | That motivates us to invent this subroutine: |
| 112 | | |
| 113 | | .. _subroutine c: |
| 114 | | |
| 115 | | Subroutine C: translate all patches from SVN to darcs and then translate the next patch from darcs to SVN |
| 116 | | --------------------------------------------------------------------------------------------------------- |
| 117 | | |
| 118 | | 1. Iterate `Subroutine A`_ until there are no more patches in SO that are |
| 119 | | not already in SDs, i.e. that SDs is up-to-date with SO. |
| 120 | | |
| 121 | | 2. Run `Subroutine B`_. |
| 122 | | |
| 123 | | .. algorithm d: |
| 124 | | |
| 125 | | Algorithm D: translate all patches between worlds |
| 126 | | ------------------------------------------------- |
| 127 | | |
| 128 | | 1. Iterate `Subroutine C`_ until there are no more patches in DO that are |
| 129 | | not already in DSd, i.e. that DSd is up-to-date with DO. |
| 130 | | |
| 131 | | Now it is safe to invoke Algorithm D whenever you want to synchronize |
| 132 | | the two worlds. One of three things will happen: |
| 133 | | |
| 134 | | 1. the worlds will be synchronized |
| 135 | | |
| 136 | | 2. it will turn out that there is a merge conflict, Algorithm D will |
| 137 | | stop at that point (either Step A2 or else step B2) and notify the |
| 138 | | user. |
| 139 | | |
| 140 | | 3. it will turn out that another patch was committed to SO between |
| 141 | | Step C1 and Step C2. Algorithm D will stop at that point and notify |
| 142 | | the user. |
| | 64 | What does the user do in response to MergeConflict in order to get back into the Internally Consistent State? |