View | Details | Raw Unified | Return to bug 167033
Collapse All | Expand All

(-)article.sgml (+259 lines)
Lines 2143-2148 Link Here
2143
      </sect3>
2143
      </sect3>
2144
2144
2145
      <sect3>
2145
      <sect3>
2146
	<title>Vendor imports with <acronym>SVN</acronym></title>
2147
2148
	<important>
2149
	  <para>Please read this entire section before starting a vendor
2150
	    import.</para>
2151
	</important>
2152
2153
	<note>
2154
	  <para>Patches to vendor code fall into two categories:</para>
2155
2156
	  <itemizedlist>
2157
	    <listitem>
2158
	      <para>Vendor patches: these are patches that have been
2159
		issued by the vendor, or that have been extracted from
2160
		the vendor's version control system, which address
2161
		issues which in your opinion can't wait until the next
2162
		vendor release.</para>
2163
	    </listitem>
2164
	    <listitem>
2165
	      <para>&os; patches: these are patches that modify the
2166
		vendor code to address &os;-specific issues.</para>
2167
	    </listitem>
2168
	  </itemizedlist>
2169
2170
	  <para>The nature of a patch dictates where it should be
2171
	    committed:</para>
2172
2173
	  <itemizedlist>
2174
	    <listitem>
2175
	      <para>Vendor patches should be committed to the vendor
2176
		branch, and merged from there to head.  If the patch
2177
		addresses an issue in a new release that is currently
2178
		being imported, it <emphasis>must not</emphasis> be
2179
		committed along with the new release: the release must
2180
		be imported and tagged first, then the patch can be
2181
		applied and committed.  There is no need to re-tag the
2182
		vendor sources after committing the patch.</para>
2183
	    </listitem>
2184
	    <listitem>
2185
	      <para>&os; patches should be committed directly to
2186
		head.</para>
2187
	    </listitem>
2188
	  </itemizedlist>
2189
	</note>
2190
2191
	<sect4>
2192
	  <title>Preparing the tree</title>
2193
2194
	  <para>If importing for the first time after the switch to
2195
	    Subversion, flattening and cleaning up the vendor tree is
2196
	    necessary, as well as bootstrapping the merge history in
2197
	    the main tree.</para>
2198
2199
	  <sect5>
2200
	    <title>Flattening</title>
2201
2202
	    <para>During the conversion from <acronym>CVS</acronym> to
2203
	      Subversion, vendor branches were imported with the same
2204
	      layout as the main tree.  This means that the
2205
	      <literal>pf</literal> vendor sources ended up in
2206
	      <filename>vendor/pf/dist/contrib/pf</filename>.  The
2207
	      vendor source is best directly in
2208
	      <filename>vendor/pf/dist</filename>.</para>
2209
2210
	    <para>To flatten the <literal>pf</literal> tree:</para>
2211
2212
	    <screen>&prompt.user; <userinput>cd <replaceable>vendor/pf/dist/contrib/pf</replaceable></userinput>
2213
&prompt.user; <userinput>svn mv $(svn list) ../..</userinput>
2214
&prompt.user; <userinput>cd ../..</userinput>
2215
&prompt.user; <userinput>svn rm contrib</userinput>
2216
&prompt.user; <userinput>svn propdel -R svn:mergeinfo .</userinput>
2217
&prompt.user; <userinput>svn commit</userinput></screen>
2218
2219
	    <para>The <literal>propdel</literal> bit is necessary
2220
	      because starting with 1.5, Subversion will automatically
2221
	      add <literal>svn:mergeinfo</literal> to any directory
2222
	      that is copied or moved.  In this case, as nothing is
2223
	      being merged from the deleted tree, they just get in the
2224
	      way.</para>
2225
2226
	    <para>Tags may be flattened as well (3, 4, 3.5 etc.); the
2227
	      procedure is exactly the same, only changing
2228
	      <literal>dist</literal> to <literal>3.5</literal> or
2229
	      similar, and putting the <command>svn commit</command>
2230
	      off until the end of the process.</para>
2231
	  </sect5>
2232
	  <sect5>
2233
	    <title>Cleaning up</title>
2234
2235
	    <para>The <literal>dist</literal> tree can be cleaned up
2236
	      as necessary.  Disabling keyword expansion is
2237
	      recommended, as it makes no sense on unmodified vendor
2238
	      code and in some cases it can even be harmful.
2239
	      <application>OpenSSH</application>, for example, includes
2240
	      two files that originated with &os; and still contain the
2241
	      original version tags.  To do this:</para>
2242
2243
	    <screen>&prompt.user; <userinput>svn propdel svn:keywords -R .</userinput>
2244
&prompt.root; <userinput>svn commit</userinput></screen>
2245
	  </sect5>
2246
	  <sect5>
2247
	    <title>Bootstrapping merge history</title>
2248
2249
	    <para>If importing for the first time after the switch to
2250
	      Subversion, bootstrapping
2251
	      <literal>svn:mergeinfo</literal> on the target directory
2252
	      in the main tree to the to the revision that corresponds
2253
	      to the last related change to the vendor tree, prior to
2254
	      importing new sources:</para>
2255
2256
	    <screen>&prompt.user; <userinput>cd <replaceable>head/contrib/pf</replaceable></userinput>
2257
&prompt.user; <userinput>svn merge --record-only svn+ssh://svn.freebsd.org/base/<replaceable>vendor/pf/dist@180876</replaceable> .</userinput>
2258
&prompt.user; <userinput>svn commit</userinput></screen>
2259
	  </sect5>
2260
	</sect4>
2261
2262
	<sect4>
2263
	  <title>Importing new sources</title>
2264
2265
	  <para>With two commits&mdash;one for the import itself and
2266
	    one for the tag&mdash;this step can optionally be repeated
2267
	    for every upstream release between the last import and the
2268
	    current import.</para>
2269
2270
	  <sect5>
2271
	    <title>Preparing the vendor sources</title>
2272
2273
	    <para>Unlike in <acronym>CVS</acronym> where only the needed
2274
	      parts were imported into the vendor tree to avoid bloating
2275
	      the main tree, Subversion is able to store a full
2276
	      distribution in the vendor tree.  So, import everything,
2277
	      but merge only what is required.</para>
2278
2279
	    <para>A <command>svn add</command> is required to add any
2280
	      files that were added since the last vendor import, and
2281
	      <command>svn rm</command> is required to remove any that
2282
	      were removed since.  Preparing sorted lists of the
2283
	      contents of the vendor tree and of the sources that are
2284
	      about to be imported is recommended, to facilitate the
2285
	      process.</para>
2286
2287
	    <screen>&prompt.user; <userinput>cd <replaceable>vendor/pf/dist</replaceable></userinput>
2288
&prompt.user; <userinput>svn list -R | grep -v '/$' | sort >../old</userinput>
2289
&prompt.user; <userinput>cd <replaceable>../pf-4.3</replaceable></userinput>
2290
&prompt.user; <userinput>find . -type f | cut -c 3- | sort >../new</userinput></screen>
2291
2292
	    <para>With these two files, <command>comm -23 ../old ../new</command>
2293
	      will list removed files (files only in
2294
	      <filename>old</filename>), while <command>comm -13 ../old ../new</command>
2295
	      will list added files only in <filename>new</filename>.</para>
2296
	  </sect5>
2297
	  <sect5>
2298
	    <title>Importing into the vendor tree</title>
2299
2300
	    <para>Now, the sources must be copied into
2301
	      <filename><replaceable>dist</replaceable></filename> and
2302
	      the <command>svn add</command> and
2303
	      <command>svn rm</command> commands should be used as
2304
	      needed:</para>
2305
2306
	    <screen>&prompt.user; <userinput>cd <replaceable>vendor/pf/pf-4.3</replaceable></userinput>
2307
&prompt.user; <userinput>tar cf - . | tar xf - -C ../dist</userinput>
2308
&prompt.user; <userinput>cd <replaceable>../dist</replaceable></userinput>
2309
&prompt.user; <userinput>comm -23 ../old ../new | xargs svn rm</userinput>
2310
&prompt.user; <userinput>comm -13 ../old ../new | xargs svn --parents add</userinput></screen>
2311
2312
	    <para>If any directories were removed, they will have to be
2313
	      <command>svn rm</command>ed manually.  Nothing will break
2314
	      if they are not, but they will remain in the tree.</para>
2315
2316
	    <para>Check properties on any new files. All text files
2317
	      should have <literal>svn:eol-style</literal> set to
2318
	      <literal>native</literal>.  All binary files should have
2319
	      <literal>svn:mime-type</literal> set to
2320
	      <literal>application/octet-stream</literal> unless there
2321
	      is a more appropriate media type.  Executable files should
2322
	      have <literal>svn:executable</literal> set to
2323
	      <literal>*</literal>.  No other properties should exist
2324
	      on any file in the tree.</para>
2325
2326
	    <para>Committing is now possible, however it is good
2327
	      practice to make sure that everything is OK by using the
2328
	      <command>svn stat</command> and
2329
	      <command>svn diff</command> commands.</para>
2330
	  </sect5>
2331
	  <sect5>
2332
	    <title>Tagging</title>
2333
2334
	    <para>Once committed, vendor releases should be tagged for
2335
	      future reference.  The best and quickest way to do this
2336
	      is directly in the repository:</para>
2337
2338
	    <screen>&prompt.user; <userinput>svn cp svn+ssh://svn.freebsd.org/base/<replaceable>vendor/pf/dist</replaceable> svn+ssh://svn.freebsd.org/base/<replaceable>vendor/pf/4.3</replaceable></userinput></screen>
2339
2340
	    <para>Once that is complete, <command>svn up</command> the
2341
	      working copy of
2342
	      <filename><replaceable>vendor/pf</replaceable></filename>
2343
	      to get the new tag, although this is rarely
2344
	      needed.</para>
2345
2346
	    <para>If creating the tag in the working copy of the tree,
2347
	      <command>svn:mergeinfo</command> results must be removed:</para>
2348
2349
	    <screen>&prompt.user; <userinput>cd	<replaceable>vendor/pf</replaceable></userinput>
2350
&prompt.user; <userinput>svn cp dist 4.3</userinput>
2351
&prompt.user; <userinput>svn propdel svn:mergeinfo -R 4.3</userinput></screen>
2352
	  </sect5>
2353
	</sect4>
2354
	<sect4>
2355
	  <title>Merging to head</title>
2356
2357
	  <screen>&prompt.user; <userinput>cd <replaceable>head/contrib/pf</replaceable></userinput>
2358
&prompt.user; <userinput>svn up</userinput>
2359
&prompt.user; <userinput>svn merge --accept=postpone svn+ssh://svn.freebsd.org/base/<replaceable>vendor/pf/dist</replaceable> .</userinput></screen>
2360
2361
	  <para>The <literal>--accept=postpone</literal> tells
2362
	    Subversion that it shouldn't complain because merge conflicts
2363
	    will be taken care of manually.</para>
2364
2365
	  <para>It is necessary to resolve any merge conflicts.
2366
	    This process is the same in <acronym>SVN</acronym> as in
2367
	    <acronym>CVS</acronym>.</para>
2368
2369
	  <para>Make sure that any files that were added or removed in
2370
	    the vendor tree have been properly added or removed in the
2371
	    main tree.  To check diffs against the vendor branch:</para>
2372
2373
	  <screen>&prompt.user; <userinput>svn diff --no-diff-deleted --old=svn+ssh://svn.freebsd.org/base/<replaceable>vendor/pf/dist</replaceable> --new=.</userinput></screen>
2374
2375
	  <para>The <literal>--no-diff-deleted</literal> tells
2376
	    Subversion not to complain about files that are in the
2377
	    vendor tree but not in the main tree, i.e. things that
2378
	    would have previously been removed before the vendor
2379
	    import, like for example the like the vendor's makefiles
2380
	    and configure scripts.</para>
2381
2382
	  <para>Using <acronym>CVS</acronym>, once a file was off the
2383
	    vendor branch, it was not able to be put back.  With
2384
	    Subversion, there is no concept of on or off the vendor
2385
	    branch.  If a file that previously had local
2386
	    modifications, to make it not show up in diffs in the
2387
	    vendor tree, all that has to be done is remove any left-over
2388
	    cruft like &os; version tags, which is much easier.</para>
2389
2390
	  <para>If any changes are required for the world to build
2391
	    with the new sources, make them now, and keep testing
2392
	    until everything builds and runs perfectly.</para>
2393
	</sect4>
2394
	<sect4>
2395
	  <title>Committing the vendor import</title>
2396
2397
	  <para>Committing is now possible!  Everything must be
2398
	    committed in one go.  If done properly, the tree will move
2399
	    from a consistent state with old code, to a consistent
2400
	    state with new code.</para>
2401
	</sect4>
2402
      </sect3>
2403
2404
      <sect3>
2146
	<title>Reverting a Commit</title>
2405
	<title>Reverting a Commit</title>
2147
2406
2148
	<para>Reverting a commit to a previous version is fairly
2407
	<para>Reverting a commit to a previous version is fairly

Return to bug 167033