This file is indexed.

/usr/share/doc/xxdiff-scripts/html/xxdiff-scripts.html is in xxdiff-scripts 1:4.0.1+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="generator" content="Docutils 0.11: http://docutils.sourceforge.net/" />
<title>Helper Scripts for xxdiff</title>
<meta name="author" content="Martin Blais &lt;blais&#64;furius.ca&gt;" />
<meta name="date" content="2006-03-30" />
<link rel="stylesheet" href="../style.css" type="text/css" />
</head>
<body>

<div id="project-header">
  <div id="project-home"><a href="http://furius.ca/xxdiff">Project Home</a></div>
</div>

<div class="document" id="helper-scripts-for-xxdiff">
<h1 class="title">Helper Scripts for xxdiff</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr><th class="docinfo-name">Author:</th>
<td>Martin Blais &lt;<a class="reference external" href="mailto:blais&#64;furius.ca">blais&#64;furius.ca</a>&gt;</td></tr>
<tr><th class="docinfo-name">Date:</th>
<td>2006-03-30</td></tr>
</tbody>
</table>
<div class="abstract topic">
<p class="topic-title first">Abstract</p>
<p>A description of the Python scripts and infrastructure that is provided around
xxdiff, to facilitate implementing processes requiring display and selection
of differences.</p>
</div>
<div class="contents topic" id="contents">
<p class="topic-title first">Contents</p>
<ul class="auto-toc simple">
<li><a class="reference internal" href="#introduction" id="id6">1&nbsp;&nbsp;&nbsp;Introduction</a><ul class="auto-toc">
<li><a class="reference internal" href="#history" id="id7">1.1&nbsp;&nbsp;&nbsp;History</a></li>
</ul>
</li>
<li><a class="reference internal" href="#xxdiff-s-decision-mode" id="id8">2&nbsp;&nbsp;&nbsp;xxdiff's Decision Mode</a></li>
<li><a class="reference internal" href="#looping-and-confirming" id="id9">3&nbsp;&nbsp;&nbsp;Looping and Confirming</a><ul class="auto-toc">
<li><a class="reference internal" href="#backups" id="id10">3.1&nbsp;&nbsp;&nbsp;Backups</a></li>
<li><a class="reference internal" href="#write-permissions-checkout" id="id11">3.2&nbsp;&nbsp;&nbsp;Write Permissions / Checkout</a></li>
<li><a class="reference internal" href="#running-without-graphical-diff" id="id12">3.3&nbsp;&nbsp;&nbsp;Running Without Graphical Diff</a></li>
<li><a class="reference internal" href="#per-file-conditional-replacement" id="id13">3.4&nbsp;&nbsp;&nbsp;Per-File Conditional Replacement</a><ul class="auto-toc">
<li><a class="reference internal" href="#xx-cond-replace" id="id14">3.4.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-cond-replace</span></tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#higher-level-loops" id="id15">3.5&nbsp;&nbsp;&nbsp;Higher-Level Loops</a><ul class="auto-toc">
<li><a class="reference internal" href="#selecting-files" id="id16">3.5.1&nbsp;&nbsp;&nbsp;Selecting Files</a><ul class="auto-toc">
<li><a class="reference internal" href="#selecting-by-filename" id="id17">3.5.1.1&nbsp;&nbsp;&nbsp;Selecting By Filename</a></li>
<li><a class="reference internal" href="#selecting-by-contents" id="id18">3.5.1.2&nbsp;&nbsp;&nbsp;Selecting By Contents</a></li>
<li><a class="reference internal" href="#selecting-from-a-fixed-list" id="id19">3.5.1.3&nbsp;&nbsp;&nbsp;Selecting From A Fixed List</a></li>
<li><a class="reference internal" href="#all-options" id="id20">3.5.1.4&nbsp;&nbsp;&nbsp;All Options</a></li>
<li><a class="reference internal" href="#debugging-the-file-selection-process" id="id21">3.5.1.5&nbsp;&nbsp;&nbsp;Debugging The File Selection Process</a></li>
</ul>
</li>
<li><a class="reference internal" href="#xx-filter" id="id22">3.5.2&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-filter</span></tt></a></li>
<li><a class="reference internal" href="#xx-rename" id="id23">3.5.3&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-rename</span></tt></a></li>
<li><a class="reference internal" href="#xx-find-grep-sed" id="id24">3.5.4&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-find-grep-sed</span></tt></a></li>
<li><a class="reference internal" href="#xx-pyline" id="id25">3.5.5&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-pyline</span></tt></a></li>
<li><a class="reference internal" href="#writing-other-transformation-loops" id="id26">3.5.6&nbsp;&nbsp;&nbsp;Writing Other Transformation Loops</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#xx-match" id="id27">4&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-match</span></tt></a></li>
<li><a class="reference internal" href="#cvs-support" id="id28">5&nbsp;&nbsp;&nbsp;CVS Support</a><ul class="auto-toc">
<li><a class="reference internal" href="#xx-cvs-diff" id="id29">5.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-cvs-diff</span></tt></a></li>
<li><a class="reference internal" href="#resolving-cvs-conflicts" id="id30">5.2&nbsp;&nbsp;&nbsp;Resolving CVS Conflicts</a></li>
</ul>
</li>
<li><a class="reference internal" href="#subversion-support" id="id31">6&nbsp;&nbsp;&nbsp;Subversion Support</a><ul class="auto-toc">
<li><a class="reference internal" href="#ignoring-svn-files-in-loops" id="id32">6.1&nbsp;&nbsp;&nbsp;Ignoring .svn Files In Loops</a></li>
<li><a class="reference internal" href="#xx-diff-proxy" id="id33">6.2&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-diff-proxy</span></tt></a></li>
<li><a class="reference internal" href="#xx-svn-diff" id="id34">6.3&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-svn-diff</span></tt></a><ul class="auto-toc">
<li><a class="reference internal" href="#future-features" id="id35">6.3.1&nbsp;&nbsp;&nbsp;Future Features</a></li>
</ul>
</li>
<li><a class="reference internal" href="#xx-svn-resolve" id="id36">6.4&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-svn-resolve</span></tt></a></li>
<li><a class="reference internal" href="#handling-unregistered-files" id="id37">6.5&nbsp;&nbsp;&nbsp;Handling Unregistered Files</a><ul class="auto-toc">
<li><a class="reference internal" href="#svn-foreign" id="id38">6.5.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">svn-foreign</span></tt></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#mercurial-support" id="id39">7&nbsp;&nbsp;&nbsp;Mercurial Support</a><ul class="auto-toc">
<li><a class="reference internal" href="#after-version-0-9-5" id="id40">7.1&nbsp;&nbsp;&nbsp;After version 0.9.5</a></li>
<li><a class="reference internal" href="#before-version-0-9-5" id="id41">7.2&nbsp;&nbsp;&nbsp;Before version 0.9.5</a></li>
</ul>
</li>
<li><a class="reference internal" href="#encrypted-files" id="id42">8&nbsp;&nbsp;&nbsp;Encrypted Files</a><ul class="auto-toc">
<li><a class="reference internal" href="#xx-encrypted" id="id43">8.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-encrypted</span></tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#pre-visualizing-and-cherry-picking-from-patches" id="id44">9&nbsp;&nbsp;&nbsp;Pre-Visualizing And Cherry-Picking From Patches</a></li>
<li><a class="reference internal" href="#comparing-sql-schemas" id="id45">10&nbsp;&nbsp;&nbsp;Comparing SQL Schemas</a></li>
<li><a class="reference internal" href="#writing-your-own-scripts" id="id46">11&nbsp;&nbsp;&nbsp;Writing Your Own Scripts</a></li>
<li><a class="reference internal" href="#questions" id="id47">12&nbsp;&nbsp;&nbsp;Questions</a></li>
</ul>
</div>
<!-- 1   Introduction
  1.1  History
2   xxdiff's Decision Mode
3   Looping and Confirming
  3.1  Backups
  3.2  Write Permissions / Checkout
  3.3  Running Without Graphical Diff
  3.4  Per-File Conditional Replacement
    3.4.1  ``xx-cond-replace``
  3.5  Higher-Level Loops
    3.5.1  Selecting Files
      3.5.1.1  Selecting By Filename
      3.5.1.2  Selecting By Contents
      3.5.1.3  Selecting From A Fixed List
      3.5.1.4  All Options
      3.5.1.5  Debugging The File Selection Process
    3.5.2  ``xx-filter``
    3.5.3  ``xx-rename``
    3.5.4  ``xx-find-grep-sed``
    3.5.5  ``xx-pyline``
    3.5.6  Writing Other Transformation Loops
4   ``xx-match``
5   CVS Support
  5.1  ``xx-cvs-diff``
  5.2  Resolving CVS Conflicts
6   Subversion Support
  6.1  Ignoring .svn Files In Loops
  6.2  ``xx-diff-proxy``
  6.3  ``xx-svn-diff``
    6.3.1  Future Features
  6.4  ``xx-svn-resolve``
  6.5  Handling Unregistered Files
    6.5.1  ``svn-foreign``
7   Mercurial Support
  7.1  After version 0.9.5
  7.2  Before version 0.9.5
8   Encrypted Files
  8.1  ``xx-encrypted``
9   Pre-Visualizing And Cherry-Picking From Patches
10  Comparing SQL Schemas
11  Writing Your Own Scripts
12  Questions -->
<div class="section" id="introduction">
<h1><a class="toc-backref" href="#id6">1&nbsp;&nbsp;&nbsp;Introduction</a></h1>
<p>xxdiff is a computer program that allows a user (usually a software developer of
some sort) to easily visualize the differences between files.  The manner and
goal for which this process is applied over multiple files is highly dependent
on the application, and most of the time is driven by custom user scripts.</p>
<p>For example, a configuration management engineer in a company might provide some
kind of merge policing environment, that allows software developers to review
changes in files for the purpose of accepting or rejecting a submitted changeset
to a codebase.  Another example is that of a developer wishing to review the
changes he made to a checkout of files from a source-code management system such
as CVS, Subversion, ClearCase, Perforce, etc.</p>
<div class="section" id="history">
<h2><a class="toc-backref" href="#id7">1.1&nbsp;&nbsp;&nbsp;History</a></h2>
<p>xxdiff has been developed in a corporate environment with hundreds of users.
Over time, it has been progressively augmented with features to allow it to
better interact with caller scripts, and many of Python scripts were provided as
open source on the internet, to perform various common tasks.  It was only
natural that at some point in time common code between these programs should be
shared in a library, and a Python package provided to ease the task of writing
other, new, custom scripts.</p>
<p>This document describes this package, and the scripts that are provided along
with xxdiff, implemented using the same code.</p>
</div>
</div>
<div class="section" id="xxdiff-s-decision-mode">
<h1><a class="toc-backref" href="#id8">2&nbsp;&nbsp;&nbsp;xxdiff's Decision Mode</a></h1>
<p>The prototypical task of carrying out a merge is that of visualizing and
accepting or rejecting all or some changes to a file, changes from a source file
(e.g. in the case of an update, these are changes forced by other developers) to
a target file (in that case, files living in a developer's own checkout).  There
are three possibilities:</p>
<ol class="arabic simple">
<li>Accept all changes to the file;</li>
<li>Reject all changes to the file, leaving the target file as is;</li>
<li>Accept only some of the changes.  In the great majority of cases, this
usually only involves selecting diff hunks from either of the files.  It is
relatively rare to have to edit the files, as this is often related to the
presence of conflicts, and various SCM systems already provide means to deal
with those.</li>
</ol>
<p>xxdiff already provides the ability to interactively select diff hunks from
either files to produce a merged output file.</p>
<p>Therefore, in order to answer the needs above in the context of a script
querying the user for actions to be carried out, a special mode was added to
xxdiff, that <em>forces</em> the user to answer with either &#8220;accept&#8221;, &#8220;reject&#8221; or
&#8220;merge&#8221; <a class="footnote-reference" href="#id2" id="id1">[1]</a>.  xxdiff takes special precautions to ensure that the file you
decide to output is complete, for example, if you answer with <em>merge</em>, it
insures that you have made a decision about all the diff hunks.</p>
<table class="docutils footnote" frame="void" id="id2" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>This mode is invoked with the <tt class="docutils literal"><span class="pre">--decision</span></tt> switch, and the corresponding
keys are <tt class="docutils literal">A</tt>, <tt class="docutils literal">R</tt> and <tt class="docutils literal">M</tt>.</td></tr>
</tbody>
</table>
</div>
<div class="section" id="looping-and-confirming">
<h1><a class="toc-backref" href="#id9">3&nbsp;&nbsp;&nbsp;Looping and Confirming</a></h1>
<p>A very commonly occuring case is that of having to loop over multiple files for
changes, either from an update from a source code repository, or applying a set
of modifications to a file via a program--such as sed--and reviewing and
accepting those changes.  The high-level algorithm looks like this:</p>
<pre class="literal-block">
Recurse in directories, selecting files.
For each file selected

   Apply automated changes to the file
   OR
   Fetch the different versions of the file

   Launch xxdiff in decision mode to find out what action to perform

      xxdiff runs, while the parent script waits

   Conditionally replace the target file with the result of the merge (or
   simply, with the newer file, in case of ACCEPT).
</pre>
<p>There are many functionalities involved:</p>
<ol class="loweralpha simple">
<li>Recursively traversing and selecting files for processing</li>
<li>Invoking xxdiff to get the user's opinion</li>
<li>Performing the conditional replacement.  This may mean that the file has to
be checked out of the SCM system.</li>
<li>When your original files are overwritten, first create a backup of the
original file in case something went wrong.</li>
<li>Produce a nice-looking textual log of all the changes that were applied to
the files.</li>
</ol>
<p>The provided scripts allow you to carry out some of these tasks in different
combinations.</p>
<div class="section" id="backups">
<h2><a class="toc-backref" href="#id10">3.1&nbsp;&nbsp;&nbsp;Backups</a></h2>
<p>File backups are automatically created.  There are a few options about where to
put the backup files:</p>
<ul>
<li><p class="first">Along with the original files, but with an added extension, e.g.:</p>
<pre class="literal-block">
source.cpp
source.cpp.bak.1
source.cpp.bak.2
</pre>
</li>
<li><p class="first">In a separate directory, recreating the directory hierarchy there (just for
the backed up files).</p>
</li>
</ul>
<p>All backup options:</p>
<pre class="literal-block">
File backup options:
  These options affect automatic backup of overwritten files.

  -b CHOICE, --backup-type=CHOICE
                      Selects the backup type from: along, other, none
  --backup-dir=BACKUP_DIR
                      Specify backup directory for type 'other'
</pre>
<p>Note that if you're using the same directory for backups over multiple runs, if
some files are the same, the backed up files get overwritten (a warning is
displayed).</p>
</div>
<div class="section" id="write-permissions-checkout">
<h2><a class="toc-backref" href="#id11">3.2&nbsp;&nbsp;&nbsp;Write Permissions / Checkout</a></h2>
<p>Some SCM systems require the user to <em>checkout</em> files to make them writable,
like ClearCase (under certain configurations).  There are options to do that.</p>
</div>
<div class="section" id="running-without-graphical-diff">
<h2><a class="toc-backref" href="#id12">3.3&nbsp;&nbsp;&nbsp;Running Without Graphical Diff</a></h2>
<p>There is a <tt class="docutils literal"><span class="pre">--no-confirm</span></tt> option that runs the transformation, accepting the
changes on all the files, producing a nice log of all the changes applied,
without querying the user with a graphical diff at all.  This is useful when
you've started confirming changes and after checking many files you've become
confident that your transformation code will not fail.  If you have a large
codebase to process, you may prefer to just apply unconditionally and them
visualize the changes in the textual side-by-side diff log.</p>
</div>
<div class="section" id="per-file-conditional-replacement">
<h2><a class="toc-backref" href="#id13">3.4&nbsp;&nbsp;&nbsp;Per-File Conditional Replacement</a></h2>
<p>We can easily implement the (c) part without embedding it in a loop.</p>
<div class="section" id="xx-cond-replace">
<h3><a class="toc-backref" href="#id14">3.4.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-cond-replace</span></tt></a></h3>
<p>This program is akin to the UNIX command <tt class="docutils literal">cp</tt>, but its actions are conditional
to your feedback within xxdiff.  If you <em>accept</em>, the target file is overwritten
with the contents of the source file.  If you <em>reject</em>, nothing happens to the
target file.  If you <em>merge</em>, the target file is overwritten with the contents
of the merged results.</p>
<p>This allows you to write the produce the modified file yourself and to write the
loop in, for example, Bourne shell:</p>
<pre class="literal-block">
# Remove all empty lines in files
find . -name '*.txt' | while read i ; do
      cat $i | tr -s \\n | xx-cond-replace - $i ;
   done
</pre>
<div class="important">
<p class="first admonition-title">Important</p>
<p>Note that for this program the backups are not enabled by default.  Since
every invocation is separate, if the backups were on by default a unique
backup directory would be created for each invocation.  You can imagine that
this would create a lot of goo in the temporary directory.</p>
<p class="last">If you want to backup all the files from a loop run to a single backup
directory root, make sure to use the <tt class="docutils literal"><span class="pre">--backup-dir</span></tt> option.</p>
</div>
</div>
</div>
<div class="section" id="higher-level-loops">
<h2><a class="toc-backref" href="#id15">3.5&nbsp;&nbsp;&nbsp;Higher-Level Loops</a></h2>
<p>Many of the find-loops that occur in practice are very simple, e.g. replace a
string in all the files ending with <tt class="docutils literal">.h</tt> and <tt class="docutils literal">.cpp</tt>.  For this purpose, we
have implemented a few scripts that perform the loop for you.  This is the
functionality mentioned as (a) in the introduction.</p>
<div class="section" id="selecting-files">
<h3><a class="toc-backref" href="#id16">3.5.1&nbsp;&nbsp;&nbsp;Selecting Files</a></h3>
<p>These scripts all work from the same loop: a recursive walk of all the files in
a set of root directories, by default the current directory.  The selection
process embodies common patterns for selecting files.</p>
<div class="section" id="selecting-by-filename">
<h4><a class="toc-backref" href="#id17">3.5.1.1&nbsp;&nbsp;&nbsp;Selecting By Filename</a></h4>
<p>You can restrict and ignore files by filename, for example, to select all the
.html and .htm files, you could use:</p>
<pre class="literal-block">
xx-rename -I \.svn --select='.*.htm$' --select='.*.html$' ...
</pre>
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">The <em>ignore</em> patterns works on directories, but the <em>select</em> patterns
do not.</p>
</div>
</div>
<div class="section" id="selecting-by-contents">
<h4><a class="toc-backref" href="#id18">3.5.1.2&nbsp;&nbsp;&nbsp;Selecting By Contents</a></h4>
<p>There are switches that allow you to <em>grep</em> the files for some patterns in order
to determine if they should be processed or not, e.g.:</p>
<pre class="literal-block">
xx-rename --select-grep='^#include' FROM TO
</pre>
</div>
<div class="section" id="selecting-from-a-fixed-list">
<h4><a class="toc-backref" href="#id19">3.5.1.3&nbsp;&nbsp;&nbsp;Selecting From A Fixed List</a></h4>
<p>You can also instruct the scripts to work on a fixed set of filenames, which you
provide via a file:</p>
<pre class="literal-block">
xx-rename --select-from-file=/tmp/procfiles FROM TO
</pre>
<p>Where <tt class="docutils literal">/tmp/procfiles</tt> would have been generated by your beforehand, in any
way you like.</p>
</div>
<div class="section" id="all-options">
<h4><a class="toc-backref" href="#id20">3.5.1.4&nbsp;&nbsp;&nbsp;All Options</a></h4>
<p>Here is the full set of options (as of [2006-03-31]):</p>
<pre class="literal-block">
File selection options:
  These options affect which files are selected for grepping in the
  first place.

  -s REGEXP, --select=REGEXP
                      Adds a regular expression for filenames to process.
  -I REGEXP, --ignore=REGEXP
                      Adds a regular expression for filenames to ignore.
  --cpp, --select-cpp
                      Adds a regular expression for selecting C++ files to
                      match against.
  --py, --select-py   Adds a regular expression for selecting Python files
                      to match against.
  --select-grep=REGEXP
                      Further restrict the files to those which match the
                      given regular expression.
  --ignore-grep=REGEXP
                      Do not select files to those which match the given
                      regular expression.
  -f FILE, --select-from-file=FILE
                      Do not recurse through directories to find files but
                      instead read the list of filenames from the given
                      file.
  -r ROOTS, --root=ROOTS
                      Specify a root to perform the search from (default is
                      CWD).  You can use this option many timesfor multiple
                      roots.
</pre>
</div>
<div class="section" id="debugging-the-file-selection-process">
<h4><a class="toc-backref" href="#id21">3.5.1.5&nbsp;&nbsp;&nbsp;Debugging The File Selection Process</a></h4>
<p>To test which files are going to be selected before running your modification
command, you can use the <tt class="docutils literal"><span class="pre">--select-debug</span></tt> switch (or <tt class="docutils literal"><span class="pre">-&#64;</span></tt>) to view the list,
e.g.:</p>
<pre class="literal-block">
xx-rename --cpp 'Application', 'LargeApplication' -&#64;
</pre>
<p>Would give output like this, without running any graphical diff at all:</p>
<pre class="literal-block">
/home/blais/p/xxdiff/src/builderFiles3.h
/home/blais/p/xxdiff/src/diffutils.h
/home/blais/p/xxdiff/src/scrollView.h
/home/blais/p/xxdiff/src/diffs.h
/home/blais/p/xxdiff/src/accelUtil.cpp
/home/blais/p/xxdiff/src/app.inline.h
...
</pre>
</div>
</div>
<div class="section" id="xx-filter">
<h3><a class="toc-backref" href="#id22">3.5.2&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-filter</span></tt></a></h3>
<p>This script invokes the selection loop (a), runs a command that you specify and
invokes xxdiff on each result (c).  It basically directs the process, and runs
should UNIX filter command in a shell for you.  You command must be a filter,
that is, it takes each file as stdin and outputs the modified file as stdout.</p>
<p>For example, repeating the previous example:</p>
<pre class="literal-block">
xx-filter 'tr -s \\n'
</pre>
<p>The output will be a log of all the decisions that were made and all
the changes that were applied, as a side-by-side log.</p>
</div>
<div class="section" id="xx-rename">
<h3><a class="toc-backref" href="#id23">3.5.3&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-rename</span></tt></a></h3>
<p>By far, the most common use case for this kind of process is that of renaming a
string or text matched by a regular expression by another string.  This works
similarly to the <strong>sed</strong> <tt class="docutils literal">s/FROM/TO/g</tt> program expression.</p>
<p>Here is an example invocation:</p>
<pre class="literal-block">
xx-rename FrobnicatorBaseClass FrobnicatorBase
</pre>
<p>Note that you can also specify more than one from/to rename pair and all the
renamings are applied in the same run, in the same order that they appear on the
command-line:</p>
<pre class="literal-block">
xx-rename from1 to1 from2 to2 from3 to3
</pre>
</div>
<div class="section" id="xx-find-grep-sed">
<h3><a class="toc-backref" href="#id24">3.5.4&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-find-grep-sed</span></tt></a></h3>
<p>This script is a relic of the past, the actual ancestor to all of this.  You
see, this used to be a Bourne shell script, before it became something called
<tt class="docutils literal">cc_multi</tt>--its first Python incarnation.  We then used to perform a grep in a
subprocess, to find out if the file should be processed (if it matched the
pattern), followed by a sed subprocess to perform the actual change.</p>
<p>Here is an example invocation:</p>
<pre class="literal-block">
xx-find-grep-sed 'class Frobni.*' 's/Frobnica/Brofnica/g'
</pre>
<p>Today we have a much more generic version of the same idea:</p>
<pre class="literal-block">
xx-filter --select-grep='class Frobni.*' &quot;sed -e 's/Frobnica/Brofnica/g'&quot;
</pre>
<p>There <tt class="docutils literal"><span class="pre">xx-find-grep-sed</span></tt> is a bit obsolete.  I mean, it still works fine,
and I provide it to support those who already have it in their process, but
really, it should go.</p>
</div>
<div class="section" id="xx-pyline">
<h3><a class="toc-backref" href="#id25">3.5.5&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-pyline</span></tt></a></h3>
<p>In the Python cookbook, <a class="reference external" href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/437932">this recipe</a> proposes to compile and run a Python
expression on lines, similar to sed, but just using Python code.  With the new
scripting infrastructure, it was trivial to build another transformation program
that uses that method.  Here is an example:</p>
<pre class="literal-block">
xx-pyline -m os &quot;os.stat(line).st_size &gt; 1024 and line&quot;
</pre>
</div>
<div class="section" id="writing-other-transformation-loops">
<h3><a class="toc-backref" href="#id26">3.5.6&nbsp;&nbsp;&nbsp;Writing Other Transformation Loops</a></h3>
<p>With the provided Python package, it is quite easy to create a new program to
process a file in your own very customly way and to use the visualization and
confirmation loop described above.  You need to do the following:</p>
<ol class="arabic">
<li><p class="first">Implement a transformer class that will perform the file transformation:</p>
<pre class="literal-block">
class CustomTransformer(xxdiff.xformloop.Transformer):
    def transform( self, fn, outf ):
        text = open(fn, 'r').read()
        newtext = ... # transform text somehow
        outf.write(newtext)
        return True
</pre>
<p>You can return False to skip the file in that method.  You can also
initialize your transformer with the parameters of your transformation, if
needed.</p>
</li>
<li><p class="first">Add your own options and parse the arguments with the provided loop's
method:</p>
<pre class="literal-block">
import optparse
parser = optparse.OptionParser()

parser.add_option('-M', '--my-option', action='store_true',
                  help=&quot;My custom special option for my transformer.&quot;)

opts, args, selector = xxdiff.xformloop.parse_args(parser)
</pre>
</li>
<li><p class="first">Do your own arguments validation, if your script takes arguments.</p>
</li>
<li><p class="first">Create an instance of your transformer and use our main loop to invoke it
over the selected files:</p>
<pre class="literal-block">
# Create an appropriate transformer.
xformer = CustomTransformer(opts, &lt;custom-arguments...&gt;)

xxdiff.xformloop.transform_replace_loop(
    opts, selector, xformer, sys.stdout)
</pre>
</li>
</ol>
<p>Some simplistic details are omitted, but that is the gist of it.  You can use
the scripts provided with the package as examples, they all follow that pattern.</p>
</div>
</div>
</div>
<div class="section" id="xx-match">
<h1><a class="toc-backref" href="#id27">4&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-match</span></tt></a></h1>
<p>One day, a silly man asked me the following question via email:</p>
<blockquote>
&#8220;Why is it that when I call <tt class="docutils literal">xxdiff <span class="pre">dir1/*.c</span> <span class="pre">dir2/*.c</span></tt> it doesn't work?&#8221;</blockquote>
<p>The answer is simple: the globbing patterns get expanded <em>by the shell</em> and not
by xxdiff itself.  <tt class="docutils literal">xxdiff</tt> only gets a large list of files, and clearly,
there isn't much it can do... almost.</p>
<p>I thought, &#8220;hey, maybe I can do something for this person&#8221; and I wrote
<tt class="docutils literal"><span class="pre">xx-match</span></tt>.  It just builds a map of basenames and runs diffs on sets of
matching basenames.  The result: it mostly works like the gentleman wanted it.</p>
<p>So there.</p>
<p>I provide the script for educational value more than anything else (or for those
who really like that syntax).</p>
<p>Note that the matching algorithm can be implemented separately, and therefore is
a more generic version of this available in my <a class="reference external" href="http://furius.ca/pubcode">pubcode</a> directory: <a class="reference external" href="http://furius.ca/pubcode/pub/conf/common/bin/match-files.html">match-files</a>, e.g.:</p>
<pre class="literal-block">
match-files -x '--single' dir1/*.c dir2/*.c | xargs -n2 xxdiff
</pre>
</div>
<div class="section" id="cvs-support">
<h1><a class="toc-backref" href="#id28">5&nbsp;&nbsp;&nbsp;CVS Support</a></h1>
<div class="section" id="xx-cvs-diff">
<h2><a class="toc-backref" href="#id29">5.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-cvs-diff</span></tt></a></h2>
<p>I wanted to be able to preview the changes that I had made in a CVS checkout.
This script does it.  It pulls the original versions from the server by using
<tt class="docutils literal">cvs diff</tt>, which is very efficient as it provides a single file with all the
diffs (a patch).  The patch is then applied to temporary files to visualize the
changes.</p>
<p>Unfortunately, I never wrote much more than this for CVS, but with the new
packaged architecture of xxdiff Python code it should be easy to create new
scripts for it if you need to.</p>
</div>
<div class="section" id="resolving-cvs-conflicts">
<h2><a class="toc-backref" href="#id30">5.2&nbsp;&nbsp;&nbsp;Resolving CVS Conflicts</a></h2>
<p>Back in the days where xxdiff did not have any scripts, I implemented unmerging
of CVS conflict markers directly in xxdiff itself (should I have to do this
today I would definitely implement that in a script instead).  Just can just
invoke xxdiff with the <tt class="docutils literal"><span class="pre">--unmerge</span></tt> or <tt class="docutils literal"><span class="pre">--unmerge3</span></tt> options to do that.</p>
</div>
</div>
<div class="section" id="subversion-support">
<h1><a class="toc-backref" href="#id31">6&nbsp;&nbsp;&nbsp;Subversion Support</a></h1>
<p>Since 2005, I have switched my repository of files to Subversion and I will
therefore begin producing more support for this SCM.</p>
<div class="section" id="ignoring-svn-files-in-loops">
<h2><a class="toc-backref" href="#id32">6.1&nbsp;&nbsp;&nbsp;Ignoring .svn Files In Loops</a></h2>
<p>If you use any of the looping scripts described before in a Subversion checkout,
you can avoid changing the administrative files stored in the .svn directories
by using the following ignore option:</p>
<pre class="literal-block">
xx-rename -I .svn   ...
</pre>
<p>Note that by default Subversion and CVS directories are ignored (you can disable
that with an option).</p>
</div>
<div class="section" id="xx-diff-proxy">
<h2><a class="toc-backref" href="#id33">6.2&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-diff-proxy</span></tt></a></h2>
<p>Subversion has a diff subcommand:;</p>
<blockquote>
svn diff</blockquote>
<p>It also has the ability to let you specify which diff program you want to use to
actually display the diffs.  This program has to behave like GNU diff, i.e. the
options it accepts, the return value, etc.</p>
<p><tt class="docutils literal"><span class="pre">xx-diff-proxy</span></tt> is a script whose interface is compatible with being
invoked from Subversion, but that displays the diffs graphically rather than
textually, using xxdiff.  You can configure this per-user by adding the
following lines to your <tt class="docutils literal"><span class="pre">~/.subversion/config</span></tt> file:</p>
<pre class="literal-block">
[helpers]
diff-cmd = xx-diff-proxy
diff3-cmd = xx-diff-proxy
</pre>
<div class="important">
<p class="first admonition-title">Important</p>
<p class="last">Note: there have been reports of bugs in certain cases.  I still
need to investigate in which cases it breaks down because I have
not had problems with it yet, I have not experienced bugs.</p>
</div>
</div>
<div class="section" id="xx-svn-diff">
<h2><a class="toc-backref" href="#id34">6.3&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-svn-diff</span></tt></a></h2>
<p>In my opinion, Subversion provides a diff loop that is rather weak.  I want more
options in the ways that I can review my changes.  <tt class="docutils literal"><span class="pre">xx-svn-diff</span></tt> runs
<tt class="docutils literal">svn status</tt> and then loops over the files using xxdiff.</p>
<p>A problem with the approach described in the <tt class="docutils literal"><span class="pre">xx-diff-proxy</span></tt> section above
is that I want to <em>also</em> have normal <tt class="docutils literal">svn diff</tt> behaviour (i.e. textual
output) and I don't want to hack my config file everytime I want to do this.</p>
<p>It is a good script to use instead of svn commit:</p>
<ul class="simple">
<li>It has an option to run <tt class="docutils literal"><span class="pre">svn-foreign</span></tt> before starting the graphical diffs,
so you can quickly handle the unregistered files with a few keystrokes.  This
process is enhanced with an automatic backup of the deleted files;</li>
<li>It has an option to commit the files after the preview is done.  When you
select that option, it opens a file editor with the list of files to be
committed, which allows you to write up your merge comments to be used on the
subsequent commit.</li>
</ul>
<div class="section" id="future-features">
<h3><a class="toc-backref" href="#id35">6.3.1&nbsp;&nbsp;&nbsp;Future Features</a></h3>
<ul class="simple">
<li>It would be nice to be able to optionally automatically spawn a 3-way diff for
those files which have a newer version on the server.  This would allow you to
preview not only your changes, but also future problems when updating and
committing the file (before actually updating);</li>
<li>It will maintain a history of the files that have been previewed already, so
that you can easily interrupt the process and restart where you left off.</li>
<li>I want to have the option to unmerge some changes and save the results
conveniently.  And I want backup files for the original overwritten files,
taken care of automatically;</li>
<li>I would like to have a graphical or curses interface to select which files to
view, in which order I want.</li>
<li>I want to be able to review diffs between any revisions.</li>
</ul>
</div>
</div>
<div class="section" id="xx-svn-resolve">
<h2><a class="toc-backref" href="#id36">6.4&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-svn-resolve</span></tt></a></h2>
<p>Subversion provides a fancier version of conflict resolution: all three files--
yours, the other and the ancestor--are provided in your checkout to help you
figure out what happened.  This is a perfect situation for xxdiff: I simply can
invoke it with the 3 files, ignoring the automatic merging that took place
within Subversion, and providing the user with the interactive merge
capabilities within xxdiff to resolve the conflicts, if possible.</p>
<p>Then the user's changes can be applied automatically over the merged file and we
can call <tt class="docutils literal">svn resolve</tt> as well to clear it (optionally).  All the versions
used to resolve the conflict are backed up before the files are removed.</p>
<p>This is what <tt class="docutils literal"><span class="pre">xx-svn-resolve</span></tt> does.  If you give it a directory, it also
finds and loops through all the conflicting files recursively to resolve them
graphically.</p>
</div>
<div class="section" id="handling-unregistered-files">
<h2><a class="toc-backref" href="#id37">6.5&nbsp;&nbsp;&nbsp;Handling Unregistered Files</a></h2>
<p>After a long session of work in various checkouts, having to type up commands to
decide what to do with each unregistered file is a bit tiresome.  I wrote an
interactive script to handle that.</p>
<div class="section" id="svn-foreign">
<h3><a class="toc-backref" href="#id38">6.5.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">svn-foreign</span></tt></a></h3>
<p>This script runs an <tt class="docutils literal">svn status</tt>, outputs that for you to see, and then
queries the user for what to do with each file that is not registered with
Subversion.  You can add it, delete the file (with or without backups), mask it
(setting the <tt class="docutils literal">svn:ignore</tt> property on the parent directory), and more.</p>
<p>Here is an example session:</p>
<pre class="literal-block">
banane:$ svn-foreign
Status
------
M      current/todo.txt
?      cv/cv.pdf
?      cv/cv.aux
?      cv/cv.log
 M     cv
?      reading/reviews/books/the-da-vinci-code.txt

=&gt; [Add|Del|Mask|Ign|View|Quit]       14699  cv/cv.pdf  ? d
Backed up to: '/tmp/svn-foreign.xYz8nm/home/blais/tmp/priv/cv/cv.pdf'
=&gt; [Add|Del|Mask|Ign|View|Quit]           8  cv/cv.aux  ? m
--(current svn:ignore on 'cv')--

----------------------------
Add pattern (! to cancel, default: [cv.aux]):*.aux
property 'svn:ignore' set on 'cv'
----------------------------

*.aux
----------------------------
=&gt; [Add|Del|Mask|Ign|View|Quit]        6265  cv/cv.log  ? d
Backed up to: '/tmp/svn-foreign.xYz8nm/home/blais/tmp/priv/cv/cv.log'
=&gt; [Add|Del|Mask|Ign|View|Quit]        1689  reading/reviews/books/the-da-vinci-code.txt  ? a
A         reading/reviews/books/the-da-vinci-code.txt
(Done.)
</pre>
<p><tt class="docutils literal"><span class="pre">svn-foreign</span></tt> is included with the xxdiff scripts, because it is used
internally by some of the them, and also because it reuses the backup module of
the xxdiff scripts.  You can copy its file separately and it will still work
(minus the backups).</p>
</div>
</div>
</div>
<div class="section" id="mercurial-support">
<h1><a class="toc-backref" href="#id39">7&nbsp;&nbsp;&nbsp;Mercurial Support</a></h1>
<div class="section" id="after-version-0-9-5">
<h2><a class="toc-backref" href="#id40">7.1&nbsp;&nbsp;&nbsp;After version 0.9.5</a></h2>
<p>[2008-02-15] Apparently there is a new version of the merge code that
supports invoking xxdiff directly for doing merges. I have not tried
it yet, but this should become the way to go once it is released and
stable.</p>
</div>
<div class="section" id="before-version-0-9-5">
<h2><a class="toc-backref" href="#id41">7.2&nbsp;&nbsp;&nbsp;Before version 0.9.5</a></h2>
<p>xxdiff already works pretty well with Mercurial for viewing
differences, all you have to do is to add the following to your
<tt class="docutils literal">.hgrc</tt> file to view diffs graphically:</p>
<pre class="literal-block">
[extensions]
extdiff =

[extdiff]
cmd.xdiff = xxdiff
opts.xdiff = -r
</pre>
<p>However, graphical conflict resolution during merging requires a
wrapper script that will invoke xxdiff in decision mode and that will
automatically save the merge results where Mercurial expects them. The
script is called <tt class="docutils literal"><span class="pre">xx-hg-merge</span></tt>, and you will need to add the
following to your <tt class="docutils literal">.hgrc</tt>:</p>
<pre class="literal-block">
[ui]
merge = xx-hg-merge
</pre>
</div>
</div>
<div class="section" id="encrypted-files">
<h1><a class="toc-backref" href="#id42">8&nbsp;&nbsp;&nbsp;Encrypted Files</a></h1>
<p>I maintain some of my more sensitive personal data in ascii-armored encrypted
files in an CVS/Subversion repository.  I can open, modify and save the files
from within Emacs without ever writing a non-encrypted version on disk.  This
means that if I edit the files in two different machines, the merge operation
will surely fail, because the encrypted file does not merge.  This happens
rarely, but when it does, it is quite a problem: for each of the conflicting
file, I must:</p>
<ul class="simple">
<li>Find the original file;</li>
<li>Rebuild my local file somehow, from the file with the conflicts in it;</li>
<li>Decrypt both files;</li>
<li>Launch xxdiff and resolve the conflict;</li>
<li>Encrypt the new, merged file;</li>
<li>And most importantly: make sure I do not forget to <em>remove the decrypted files
from disk</em>.  If the files are encrypted, there is a reason, and you don't want
to leave plaintext version of the data on disk.</li>
</ul>
<p>This is quite time-consuming.  Let's automate!</p>
<div class="section" id="xx-encrypted">
<h2><a class="toc-backref" href="#id43">8.1&nbsp;&nbsp;&nbsp;<tt class="docutils literal"><span class="pre">xx-encrypted</span></tt></a></h2>
<p>This script will do all of the above for two encryped files, and it also
attempts to minimize the amount of time that a decrypted file will live on
disk--if needed at all.  In the cases where it needs to temporarily write
decrypted text to disk, as soon as xxdiff finished gulping the files in, it
deletes them right away.   This is not the super-dooper safest way of doing
this, but it sure beats doing it all by hand <a class="footnote-reference" href="#id5" id="id4">[2]</a>.</p>
<p>It also supports unmerging CVS conflict markers in order to obtain the original
and the new file automatically.  For example:</p>
<pre class="literal-block">
xx-encrypted --unmerge  my_secrets.asc
</pre>
<table class="docutils footnote" frame="void" id="id5" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id4">[2]</a></td><td>xxdiff could be enhanced to accept input from multiple file descriptors
to avoid having to use temporary files in most cases.  This just has not
been done yet.</td></tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="pre-visualizing-and-cherry-picking-from-patches">
<h1><a class="toc-backref" href="#id44">9&nbsp;&nbsp;&nbsp;Pre-Visualizing And Cherry-Picking From Patches</a></h1>
<p>I would like to be able to apply a patch to a temporary copy of a set of files,
and then to visualize the patch's changes, pick and choose the ones that we want
using xxdiff, and apply them to the original files.  I have started doing some
work on this in the <tt class="docutils literal"><span class="pre">xx-patch</span></tt> program, but there remains some unsolved
issues:</p>
<ul class="simple">
<li>How do we deal with failed hunks?  What do we do with them?  How do we present
them to the user?</li>
<li>How do we insure that our patch selected from the merged output will apply
correctly?</li>
<li>How do we deal with added and deleted files?</li>
</ul>
<p>For these reasons, until I find a good solution for all of these problems, the
<tt class="docutils literal"><span class="pre">xx-patch</span></tt> code remains hidden in the codebase.  If you're interested in
working on this let me know.</p>
</div>
<div class="section" id="comparing-sql-schemas">
<h1><a class="toc-backref" href="#id45">10&nbsp;&nbsp;&nbsp;Comparing SQL Schemas</a></h1>
<p>One annoying problem is that of migrating a database from one schema to
another.  A typical web application setup has the stable codebase running on the
server, and test setup running the some other machine, on which the programmer
makes changes and develops new features.</p>
<p>In the course of doing so, a database-based application involves changing the
database schema, that is, adding columns, changing types, tables, indexes, and
the like.  In an ideal world, a developer would be careful to take note of all
the required changes.  Oh, by the way, we're not living in an ideal world.</p>
<p>One problem is that when upgrading the code of the application on the production
machine, the existing database has to be migrated to fit the new schema that
corresponds to the new code.  This is usually carried out &#8220;by hand&#8221; on the
database's shell interface, or by writing a script (if you're a Python hacker),
and can be quite tricky, it is very easy to forget some things and to make
mistakes.</p>
<p>Since we're in the business of comparing things, I wrote a script that fetches
the schemas of two databases, parses the schema description, outputs two files
with appropriate garbage so that corresponding objects line up when diffed, and
I run xxdiff on them.  This results in a nice side-by-side view of the
differences between the objects of the two schemas, and allows you to clearly
view what needs to be carried out for the database migration task.</p>
<p>Currently, only the PostgreSQL database is supported, but it would be
quasi-trivial to add support for other databases.</p>
<div class="figure">
<img alt="screenshot-sql-schema-compare.png" src="screenshot-sql-schema-compare.png" />
<p class="caption">SQL Schema comparison.</p>
</div>
<p>xxdiff can be used to compare pairs of corresponding objects, and I'm sure that
there are many other exciting uses that people can apply it to.</p>
</div>
<div class="section" id="writing-your-own-scripts">
<h1><a class="toc-backref" href="#id46">11&nbsp;&nbsp;&nbsp;Writing Your Own Scripts</a></h1>
<p>Use the provided scripts as examples.  There are many convenient functions in
the package that you can leverage from to write your own processing scripts
around xxdiff.</p>
</div>
<div class="section" id="questions">
<h1><a class="toc-backref" href="#id47">12&nbsp;&nbsp;&nbsp;Questions</a></h1>
<p>Any questions should be directed to Martin Blais &lt;<a class="reference external" href="mailto:blais&#64;furius.ca">blais&#64;furius.ca</a>&gt;.
Contributions appreciated.  If you find these programs useful, drop me a note.</p>
</div>
</div>
</body>
</html>