<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14512] CalendarServer/branches/users/cdaboo/pod2pod-migration</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14512">14512</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-03-05 12:20:10 -0800 (Thu, 05 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge from trunk.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationcalendarservertaputilpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/calendarserver/tap/util.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationconfcaldavdappleplist">CalendarServer/branches/users/cdaboo/pod2pod-migration/conf/caldavd-apple.plist</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtwistedcaldavdatabasepy">CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/database.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtwistedcaldavdirectorycalendaruserproxypy">CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/directory/calendaruserproxy.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtwistedcaldavdirectorytesttest_proxyprincipaldbpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/directory/test/test_proxyprincipaldb.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtwistedcaldavstdconfigpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavbasedatastoresubpostgrespy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/subpostgres.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavbasedatastoretesttest_subpostgrespy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/test/test_subpostgres.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcaldavdatastoretesttest_sqlpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/test/test_sql.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcarddavdatastoresqlpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/carddav/datastore/sql.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcarddavdatastoretesttest_sqlpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/carddav/datastore/test/test_sql.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_utilpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_util.py</a></li>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoretesttest_sqlpy">CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/test_sql.py</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdaboopod2podmigration">CalendarServer/branches/users/cdaboo/pod2pod-migration/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserscdaboopod2podmigration"></a>
<div class="propset"><h4>Property changes: CalendarServer/branches/users/cdaboo/pod2pod-migration</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4>Modified: svn:mergeinfo</h4></div>
<span class="cx">/CalendarServer/branches/config-separation:4379-4443
</span><span class="cx">/CalendarServer/branches/egg-info-351:4589-4625
</span><span class="cx">/CalendarServer/branches/generic-sqlstore:6167-6191
</span><span class="cx">/CalendarServer/branches/new-store:5594-5934
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile:5911-5935
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-5.2-dev:11972,12357-12358,12794,12814
</span><span class="cx">/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
</span><span class="cx">/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cross-pod-sharing:12038-12191
</span><span class="cx">/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
</span><span class="cx">/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11607-11871
</span><span class="cx">/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
</span><span class="cx">/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
</span><span class="cx">/CalendarServer/branches/users/cdaboo/json:11622-11912
</span><span class="cx">/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
</span><span class="cx">/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
</span><span class="cx">/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
</span><span class="cx">/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pods:7297-7377
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycard:7227-7237
</span><span class="cx">/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
</span><span class="cx">/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
</span><span class="cx">/CalendarServer/branches/users/cdaboo/reverse-proxy-pods:11875-11900
</span><span class="cx">/CalendarServer/branches/users/cdaboo/scheduling-queue-refresh:11783-12557
</span><span class="cx">/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
</span><span class="cx">/CalendarServer/branches/users/cdaboo/sharing-in-the-store:11935-12016
</span><span class="cx">/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
</span><span class="cx">/CalendarServer/branches/users/cdaboo/timezones:7443-7699
</span><span class="cx">/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
</span><span class="cx">/CalendarServer/branches/users/gaya/cleanrevisions:12152-12334
</span><span class="cx">/CalendarServer/branches/users/gaya/groupsharee2:13669-13773
</span><span class="cx">/CalendarServer/branches/users/gaya/sharedgroupfixes:12120-12142
</span><span class="cx">/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
</span><span class="cx">/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
</span><span class="cx">/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
</span><span class="cx">/CalendarServer/branches/users/glyph/conn-limit:6574-6577
</span><span class="cx">/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
</span><span class="cx">/CalendarServer/branches/users/glyph/dalify:6932-7023
</span><span class="cx">/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
</span><span class="cx">/CalendarServer/branches/users/glyph/deploybuild:7563-7572
</span><span class="cx">/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
</span><span class="cx">/CalendarServer/branches/users/glyph/disable-quota:7718-7727
</span><span class="cx">/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
</span><span class="cx">/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
</span><span class="cx">/CalendarServer/branches/users/glyph/hang-fix:11465-11491
</span><span class="cx">/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
</span><span class="cx">/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
</span><span class="cx">/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
</span><span class="cx">/CalendarServer/branches/users/glyph/linux-tests:6893-6900
</span><span class="cx">/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
</span><span class="cx">/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
</span><span class="cx">/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
</span><span class="cx">/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
</span><span class="cx">/CalendarServer/branches/users/glyph/new-export:7444-7485
</span><span class="cx">/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle:7106-7155
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
</span><span class="cx">/CalendarServer/branches/users/glyph/other-html:8062-8091
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
</span><span class="cx">/CalendarServer/branches/users/glyph/q:9560-9688
</span><span class="cx">/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
</span><span class="cx">/CalendarServer/branches/users/glyph/quota:7604-7637
</span><span class="cx">/CalendarServer/branches/users/glyph/sendfdport:5388-5424
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
</span><span class="cx">/CalendarServer/branches/users/glyph/sharedpool:6490-6550
</span><span class="cx">/CalendarServer/branches/users/glyph/sharing-api:9192-9205
</span><span class="cx">/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
</span><span class="cx">/CalendarServer/branches/users/glyph/sql-store:5929-6073
</span><span class="cx">/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
</span><span class="cx">/CalendarServer/branches/users/glyph/subtransactions:7248-7258
</span><span class="cx">/CalendarServer/branches/users/glyph/table-alias:8651-8664
</span><span class="cx">/CalendarServer/branches/users/glyph/uidexport:7673-7676
</span><span class="cx">/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
</span><span class="cx">/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
</span><span class="cx">/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
</span><span class="cx">/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
</span><span class="cx">/CalendarServer/branches/users/glyph/whenNotProposed:11881-11897
</span><span class="cx">/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
</span><span class="cx">/CalendarServer/branches/users/sagen/applepush:8126-8184
</span><span class="cx">/CalendarServer/branches/users/sagen/inboxitems:7380-7381
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources:5032-5051
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who:12819-12860
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-2:12861-12898
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-3:12899-12913
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-4:12914-13157
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-5:13158-13163
</span><span class="cx">/CalendarServer/branches/users/sagen/newcua:13309-13327
</span><span class="cx">/CalendarServer/branches/users/sagen/newcua-1:13328-13330
</span><span class="cx">/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
</span><span class="cx">/CalendarServer/branches/users/sagen/recordtypes:13648-13656
</span><span class="cx">/CalendarServer/branches/users/sagen/recordtypes-2:13657
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
</span><span class="cx">/CalendarServer/branches/users/sagen/resources-2:5084-5093
</span><span class="cx">/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
</span><span class="cx">/CalendarServer/branches/users/wsanchez/psycopg2cffi:14427-14439
</span><span class="cx">/CalendarServer/branches/users/wsanchez/transations:5515-5593
</span><span class="cx">/CalendarServer/trunk:14338-14482
</span><span class="cx">   + /CalDAVTester/trunk:11193-11198
</span><span class="cx">/CalendarServer/branches/config-separation:4379-4443
</span><span class="cx">/CalendarServer/branches/egg-info-351:4589-4625
</span><span class="cx">/CalendarServer/branches/generic-sqlstore:6167-6191
</span><span class="cx">/CalendarServer/branches/new-store:5594-5934
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile:5911-5935
</span><span class="cx">/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
</span><span class="cx">/CalendarServer/branches/release/CalendarServer-5.2-dev:11972,12357-12358,12794,12814
</span><span class="cx">/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
</span><span class="cx">/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
</span><span class="cx">/CalendarServer/branches/users/cdaboo/cross-pod-sharing:12038-12191
</span><span class="cx">/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
</span><span class="cx">/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11607-11871
</span><span class="cx">/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
</span><span class="cx">/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
</span><span class="cx">/CalendarServer/branches/users/cdaboo/json:11622-11912
</span><span class="cx">/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
</span><span class="cx">/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
</span><span class="cx">/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
</span><span class="cx">/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pods:7297-7377
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
</span><span class="cx">/CalendarServer/branches/users/cdaboo/pycard:7227-7237
</span><span class="cx">/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
</span><span class="cx">/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
</span><span class="cx">/CalendarServer/branches/users/cdaboo/reverse-proxy-pods:11875-11900
</span><span class="cx">/CalendarServer/branches/users/cdaboo/scheduling-queue-refresh:11783-12557
</span><span class="cx">/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
</span><span class="cx">/CalendarServer/branches/users/cdaboo/sharing-in-the-store:11935-12016
</span><span class="cx">/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
</span><span class="cx">/CalendarServer/branches/users/cdaboo/timezones:7443-7699
</span><span class="cx">/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
</span><span class="cx">/CalendarServer/branches/users/gaya/cleanrevisions:12152-12334
</span><span class="cx">/CalendarServer/branches/users/gaya/groupsharee2:13669-13773
</span><span class="cx">/CalendarServer/branches/users/gaya/sharedgroupfixes:12120-12142
</span><span class="cx">/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
</span><span class="cx">/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
</span><span class="cx">/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
</span><span class="cx">/CalendarServer/branches/users/glyph/conn-limit:6574-6577
</span><span class="cx">/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
</span><span class="cx">/CalendarServer/branches/users/glyph/dalify:6932-7023
</span><span class="cx">/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
</span><span class="cx">/CalendarServer/branches/users/glyph/deploybuild:7563-7572
</span><span class="cx">/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
</span><span class="cx">/CalendarServer/branches/users/glyph/disable-quota:7718-7727
</span><span class="cx">/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
</span><span class="cx">/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
</span><span class="cx">/CalendarServer/branches/users/glyph/hang-fix:11465-11491
</span><span class="cx">/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
</span><span class="cx">/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
</span><span class="cx">/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
</span><span class="cx">/CalendarServer/branches/users/glyph/linux-tests:6893-6900
</span><span class="cx">/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
</span><span class="cx">/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
</span><span class="cx">/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
</span><span class="cx">/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
</span><span class="cx">/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
</span><span class="cx">/CalendarServer/branches/users/glyph/new-export:7444-7485
</span><span class="cx">/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle:7106-7155
</span><span class="cx">/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
</span><span class="cx">/CalendarServer/branches/users/glyph/other-html:8062-8091
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
</span><span class="cx">/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
</span><span class="cx">/CalendarServer/branches/users/glyph/q:9560-9688
</span><span class="cx">/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
</span><span class="cx">/CalendarServer/branches/users/glyph/quota:7604-7637
</span><span class="cx">/CalendarServer/branches/users/glyph/sendfdport:5388-5424
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
</span><span class="cx">/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
</span><span class="cx">/CalendarServer/branches/users/glyph/sharedpool:6490-6550
</span><span class="cx">/CalendarServer/branches/users/glyph/sharing-api:9192-9205
</span><span class="cx">/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
</span><span class="cx">/CalendarServer/branches/users/glyph/sql-store:5929-6073
</span><span class="cx">/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
</span><span class="cx">/CalendarServer/branches/users/glyph/subtransactions:7248-7258
</span><span class="cx">/CalendarServer/branches/users/glyph/table-alias:8651-8664
</span><span class="cx">/CalendarServer/branches/users/glyph/uidexport:7673-7676
</span><span class="cx">/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
</span><span class="cx">/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
</span><span class="cx">/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
</span><span class="cx">/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
</span><span class="cx">/CalendarServer/branches/users/glyph/whenNotProposed:11881-11897
</span><span class="cx">/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
</span><span class="cx">/CalendarServer/branches/users/sagen/applepush:8126-8184
</span><span class="cx">/CalendarServer/branches/users/sagen/inboxitems:7380-7381
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources:5032-5051
</span><span class="cx">/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who:12819-12860
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-2:12861-12898
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-3:12899-12913
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-4:12914-13157
</span><span class="cx">/CalendarServer/branches/users/sagen/move2who-5:13158-13163
</span><span class="cx">/CalendarServer/branches/users/sagen/newcua:13309-13327
</span><span class="cx">/CalendarServer/branches/users/sagen/newcua-1:13328-13330
</span><span class="cx">/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
</span><span class="cx">/CalendarServer/branches/users/sagen/recordtypes:13648-13656
</span><span class="cx">/CalendarServer/branches/users/sagen/recordtypes-2:13657
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
</span><span class="cx">/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
</span><span class="cx">/CalendarServer/branches/users/sagen/resources-2:5084-5093
</span><span class="cx">/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
</span><span class="cx">/CalendarServer/branches/users/wsanchez/psycopg2cffi:14427-14439
</span><span class="cx">/CalendarServer/branches/users/wsanchez/transations:5515-5593
</span><span class="cx">/CalendarServer/trunk:14338-14507
</span><a id="CalendarServerbranchesuserscdaboopod2podmigrationcalendarservertaputilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/calendarserver/tap/util.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/calendarserver/tap/util.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/calendarserver/tap/util.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -150,7 +150,6 @@
</span><span class="cx">         options=config.Postgres.Options,
</span><span class="cx">         uid=uid, gid=gid,
</span><span class="cx">         spawnedDBUser=config.SpawnedDBUser,
</span><del>-        importFileName=config.DBImportFile,
</del><span class="cx">         pgCtl=config.Postgres.Ctl,
</span><span class="cx">         initDB=config.Postgres.Init,
</span><span class="cx">     )
</span><span class="lines">@@ -161,8 +160,8 @@
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Create a postgres DB-API connector from the given configuration.
</span><span class="cx">     &quot;&quot;&quot;
</span><del>-    import pgdb
-    return DBAPIConnector(pgdb, postgresPreflight, config.DSN).connect
</del><ins>+    from txdav.base.datastore.subpostgres import postgres
+    return DBAPIConnector(postgres, postgresPreflight, config.DSN).connect
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationconfcaldavdappleplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/conf/caldavd-apple.plist (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/conf/caldavd-apple.plist        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/conf/caldavd-apple.plist        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -99,8 +99,6 @@
</span><span class="cx">     &lt;string&gt;&lt;/string&gt;
</span><span class="cx">     &lt;key&gt;DSN&lt;/key&gt;
</span><span class="cx">     &lt;string&gt;&lt;/string&gt;
</span><del>-    &lt;key&gt;DBImportFile&lt;/key&gt;
-    &lt;string&gt;/Library/Server/Calendar and Contacts/DataDump.sql&lt;/string&gt;
</del><span class="cx">     &lt;key&gt;Postgres&lt;/key&gt;
</span><span class="cx">     &lt;dict&gt;
</span><span class="cx">         &lt;key&gt;Ctl&lt;/key&gt;
</span><span class="lines">@@ -331,7 +329,7 @@
</span><span class="cx"> 
</span><span class="cx">     &lt;!-- Log levels --&gt;
</span><span class="cx">     &lt;key&gt;DefaultLogLevel&lt;/key&gt;
</span><del>-    &lt;string&gt;warn&lt;/string&gt; &lt;!-- debug, info, warn, error --&gt;
</del><ins>+    &lt;string&gt;info&lt;/string&gt; &lt;!-- debug, info, warn, error --&gt;
</ins><span class="cx"> 
</span><span class="cx">     &lt;!-- Server process ID file --&gt;
</span><span class="cx">     &lt;key&gt;PIDFile&lt;/key&gt;
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtwistedcaldavdatabasepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/database.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/database.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/database.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -14,11 +14,19 @@
</span><span class="cx"> # limitations under the License.
</span><span class="cx"> ##
</span><span class="cx"> 
</span><ins>+&quot;&quot;&quot;
+Generic ADAPI database access object.
+&quot;&quot;&quot;
+
+__all__ = [
+    &quot;AbstractADBAPIDatabase&quot;,
+]
+
</ins><span class="cx"> import thread
</span><span class="cx"> 
</span><span class="cx"> try:
</span><del>-    import pgdb as postgres
-except:
</del><ins>+    from txdav.base.datastore.subpostgres import postgres
+except ImportError:
</ins><span class="cx">     postgres = None
</span><span class="cx"> 
</span><span class="cx"> from twisted.enterprise.adbapi import ConnectionPool
</span><span class="lines">@@ -29,15 +37,9 @@
</span><span class="cx"> 
</span><span class="cx"> from twistedcaldav.config import ConfigurationError
</span><span class="cx"> 
</span><del>-&quot;&quot;&quot;
-Generic ADAPI database access object.
-&quot;&quot;&quot;
</del><ins>+log = Logger()
</ins><span class="cx"> 
</span><del>-__all__ = [
-    &quot;AbstractADBAPIDatabase&quot;,
-]
</del><span class="cx"> 
</span><del>-log = Logger()
</del><span class="cx"> 
</span><span class="cx"> class ConnectionClosingThreadPool(ThreadPool):
</span><span class="cx">     &quot;&quot;&quot;
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtwistedcaldavdirectorycalendaruserproxypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/directory/calendaruserproxy.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/directory/calendaruserproxy.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/directory/calendaruserproxy.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -873,9 +873,13 @@
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">     def __init__(self, host, database, user=None, password=None, dbtype=None):
</span><ins>+        from txdav.base.datastore.subpostgres import postgres
</ins><span class="cx"> 
</span><span class="cx">         ADBAPIPostgreSQLMixin.__init__(self,)
</span><del>-        ProxyDB.__init__(self, &quot;Proxies&quot;, &quot;pgdb&quot;, (), host=host, database=database, user=user, password=password,)
</del><ins>+        ProxyDB.__init__(
+            self, &quot;Proxies&quot;, postgres.__name__, (),
+            host=host, database=database, user=user, password=password,
+        )
</ins><span class="cx">         if dbtype:
</span><span class="cx">             ProxyDB.schema_type = dbtype
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtwistedcaldavdirectorytesttest_proxyprincipaldbpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/directory/test/test_proxyprincipaldb.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/directory/test/test_proxyprincipaldb.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/directory/test/test_proxyprincipaldb.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -598,7 +598,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> try:
</span><del>-    import pgdb as postgres
</del><ins>+    from txdav.base.datastore.subpostgres import postgres
</ins><span class="cx"> except ImportError:
</span><span class="cx">     ProxyPrincipalDBPostgreSQL.skip = True
</span><span class="cx"> else:
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/stdconfig.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/stdconfig.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/twistedcaldav/stdconfig.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -202,8 +202,6 @@
</span><span class="cx"> 
</span><span class="cx">     &quot;SpawnedDBUser&quot;: &quot;caldav&quot;, # The username to use when DBType is empty
</span><span class="cx"> 
</span><del>-    &quot;DBImportFile&quot;: &quot;&quot;, # File path to SQL file to import at startup (includes schema)
-
</del><span class="cx">     &quot;DSN&quot;: &quot;&quot;, # Data Source Name.  Used to connect to an external
</span><span class="cx">                # database if DBType is non-empty.  Format varies
</span><span class="cx">                # depending on database type.
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavbasedatastoresubpostgrespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/subpostgres.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/subpostgres.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/subpostgres.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> from twisted.internet.defer import Deferred
</span><span class="cx"> from txdav.base.datastore.dbapiclient import DBAPIConnector
</span><span class="cx"> from txdav.base.datastore.dbapiclient import postgresPreflight
</span><ins>+from txdav.common.icommondatastore import InternalDataStoreError
</ins><span class="cx"> 
</span><span class="cx"> from twisted.application.service import MultiService
</span><span class="cx"> 
</span><span class="lines">@@ -48,10 +49,12 @@
</span><span class="cx"> _MAGIC_READY_COOKIE = &quot;database system is ready to accept connections&quot;
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-class _PostgresMonitor(ProcessProtocol):
</del><ins>+
+class PostgresMonitor(ProcessProtocol):
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     A monitoring protocol which watches the postgres subprocess.
</span><span class="cx">     &quot;&quot;&quot;
</span><ins>+    log = Logger()
</ins><span class="cx"> 
</span><span class="cx">     def __init__(self, svc=None):
</span><span class="cx">         self.lineReceiver = LineReceiver()
</span><span class="lines">@@ -77,18 +80,22 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def outReceived(self, out):
</span><del>-        log.warn(&quot;received postgres stdout {out!r}&quot;, out=out)
</del><ins>+        for line in out.split(&quot;\n&quot;):
+            if line:
+                self.log.info(&quot;{message}&quot;, message=line)
</ins><span class="cx">         # self.lineReceiver.dataReceived(out)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def errReceived(self, err):
</span><del>-        log.warn(&quot;received postgres stderr {err}&quot;, err=err)
</del><ins>+        for line in err.split(&quot;\n&quot;):
+            if line:
+                self.log.error(&quot;{message}&quot;, message=line)
</ins><span class="cx">         self.lineReceiver.dataReceived(err)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def processEnded(self, reason):
</span><del>-        log.warn(
-            &quot;postgres process ended with status {status}&quot;,
</del><ins>+        self.log.info(
+            &quot;pg_ctl process ended with status={status}&quot;,
</ins><span class="cx">             status=reason.value.status
</span><span class="cx">         )
</span><span class="cx">         # If pg_ctl exited with zero, we were successful in starting postgres
</span><span class="lines">@@ -98,7 +105,7 @@
</span><span class="cx">         if reason.value.status == 0:
</span><span class="cx">             self.completionDeferred.callback(None)
</span><span class="cx">         else:
</span><del>-            log.warn(&quot;Could not start postgres; see postgres.log&quot;)
</del><ins>+            self.log.error(&quot;Could not start postgres; see postgres.log&quot;)
</ins><span class="cx">             self.completionDeferred.errback(reason)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -161,7 +168,7 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         The process is over, fire the Deferred with the output.
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        self.deferred.callback(''.join(self.output))
</del><ins>+        self.deferred.callback(&quot;&quot;.join(self.output))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -179,7 +186,6 @@
</span><span class="cx">         testMode=False,
</span><span class="cx">         uid=None, gid=None,
</span><span class="cx">         spawnedDBUser=&quot;caldav&quot;,
</span><del>-        importFileName=None,
</del><span class="cx">         pgCtl=&quot;pg_ctl&quot;,
</span><span class="cx">         initDB=&quot;initdb&quot;,
</span><span class="cx">         reactor=None,
</span><span class="lines">@@ -196,9 +202,6 @@
</span><span class="cx"> 
</span><span class="cx">         @param spawnedDBUser: the postgres role
</span><span class="cx">         @type spawnedDBUser: C{str}
</span><del>-        @param importFileName: path to SQL file containing previous data to
-            import
-        @type importFileName: C{str}
</del><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">         # FIXME: By default there is very little (4MB) shared memory available,
</span><span class="lines">@@ -262,12 +265,20 @@
</span><span class="cx">         self.uid = uid
</span><span class="cx">         self.gid = gid
</span><span class="cx">         self.spawnedDBUser = spawnedDBUser
</span><del>-        self.importFileName = importFileName
</del><span class="cx">         self.schema = schema
</span><span class="cx">         self.monitor = None
</span><span class="cx">         self.openConnections = []
</span><del>-        self._pgCtl = pgCtl
-        self._initdb = initDB
</del><ins>+
+        def locateCommand(name, cmd):
+            for found in which(cmd):
+                return found
+
+            raise InternalDataStoreError(
+                &quot;Unable to locate {} command: {}&quot;.format(name, cmd)
+            )
+
+        self._pgCtl = locateCommand(&quot;pg_ctl&quot;, pgCtl)
+        self._initdb = locateCommand(&quot;initdb&quot;, initDB)
</ins><span class="cx">         self._reactor = reactor
</span><span class="cx">         self._postgresPid = None
</span><span class="cx"> 
</span><span class="lines">@@ -280,33 +291,22 @@
</span><span class="cx">         return self._reactor
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def pgCtl(self):
-        &quot;&quot;&quot;
-        Locate the path to pg_ctl.
-        &quot;&quot;&quot;
-        return which(self._pgCtl)[0]
-
-
-    def initdb(self):
-        return which(self._initdb)[0]
-
-
</del><span class="cx">     def activateDelayedShutdown(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Call this when starting database initialization code to
</span><span class="cx">         protect against shutdown.
</span><span class="cx"> 
</span><del>-        Sets the delayedShutdown flag to True so that if reactor
-        shutdown commences, the shutdown will be delayed until
-        deactivateDelayedShutdown is called.
</del><ins>+        Sets the delayedShutdown flag to True so that if reactor shutdown
+        commences, the shutdown will be delayed until deactivateDelayedShutdown
+        is called.
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         self.delayedShutdown = True
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def deactivateDelayedShutdown(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        Call this when database initialization code has completed so
-        that the reactor can shutdown.
</del><ins>+        Call this when database initialization code has completed so that the
+        reactor can shutdown.
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         self.delayedShutdown = False
</span><span class="cx">         if self.shutdownDeferred:
</span><span class="lines">@@ -317,24 +317,72 @@
</span><span class="cx">         if databaseName is None:
</span><span class="cx">             databaseName = self.databaseName
</span><span class="cx"> 
</span><ins>+        m = getattr(self, &quot;_connectorFor_{}&quot;.format(postgres.__name__), None)
+        if m is None:
+            raise InternalDataStoreError(
+                &quot;Unknown Postgres DBM module: {}&quot;.format(postgres)
+            )
+
+        return m(databaseName)
+
+
+    def _connectorFor_pgdb(self, databaseName):
+        dsn = &quot;{}:dbname={}&quot;.format(self.host, databaseName)
+
</ins><span class="cx">         if self.spawnedDBUser:
</span><del>-            dsn = &quot;{}:dbname={}:{}&quot;.format(
-                self.host, databaseName, self.spawnedDBUser
-            )
</del><ins>+            dsn = &quot;{}:{}&quot;.format(dsn, self.spawnedDBUser)
</ins><span class="cx">         elif self.uid is not None:
</span><del>-            dsn = &quot;{}:dbname={}:{}&quot;.format(
-                self.host, databaseName, pwd.getpwuid(self.uid).pw_name
-            )
-        else:
-            dsn = &quot;{}:dbname={}&quot;.format(self.host, databaseName)
</del><ins>+            dsn = &quot;{}:{}&quot;.format(dsn, pwd.getpwuid(self.uid).pw_name)
</ins><span class="cx"> 
</span><span class="cx">         kwargs = {}
</span><span class="cx">         if self.port:
</span><span class="cx">             kwargs[&quot;host&quot;] = &quot;{}:{}&quot;.format(self.host, self.port)
</span><span class="cx"> 
</span><ins>+        log.info(
+            &quot;Connecting to Postgres with dsn={dsn!r} args={args}&quot;,
+            dsn=dsn, args=kwargs
+        )
+
</ins><span class="cx">         return DBAPIConnector(postgres, postgresPreflight, dsn, **kwargs)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def _connectorFor_pg8000(self, databaseName):
+        kwargs = dict(database=databaseName)
+
+        if self.host.startswith(&quot;/&quot;):
+            # We're using a socket file
+            socketFP = CachingFilePath(self.host)
+
+            if socketFP.isdir():
+                # We have been given the directory, not the actual socket file
+                socketFP = socketFP.child(
+                    &quot;.s.PGSQL.{}&quot;.format(self.port if self.port else 5432)
+                )
+
+            if not socketFP.isSocket():
+                raise InternalDataStoreError(
+                    &quot;No such socket file: {}&quot;.format(socketFP.path)
+                )
+
+            kwargs[&quot;host&quot;] = None
+            kwargs[&quot;unix_sock&quot;] = socketFP.path
+        else:
+            kwargs[&quot;host&quot;] = self.host
+            kwargs[&quot;unix_sock&quot;] = None
+
+        if self.port:
+            kwargs[&quot;port&quot;] = self.port
+
+        if self.spawnedDBUser:
+            kwargs[&quot;user&quot;] = self.spawnedDBUser
+        elif self.uid is not None:
+            kwargs[&quot;user&quot;] = pwd.getpwuid(self.uid).pw_name
+
+        log.info(&quot;Connecting to Postgres with args={args}&quot;, args=kwargs)
+
+        return DBAPIConnector(postgres, postgresPreflight, **kwargs)
+
+
</ins><span class="cx">     def produceConnection(self, label=&quot;&lt;unlabeled&gt;&quot;, databaseName=None):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Produce a DB-API 2.0 connection pointed at this database.
</span><span class="lines">@@ -348,7 +396,6 @@
</span><span class="cx">         If the database has not been created and there is a dump file,
</span><span class="cx">         then the dump file is imported.
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-
</del><span class="cx">         if self.resetSchema:
</span><span class="cx">             try:
</span><span class="cx">                 createDatabaseCursor.execute(
</span><span class="lines">@@ -370,10 +417,6 @@
</span><span class="cx">             # otherwise execute schema
</span><span class="cx">             executeSQL = True
</span><span class="cx">             sqlToExecute = self.schema
</span><del>-            if self.importFileName:
-                importFilePath = CachingFilePath(self.importFileName)
-                if importFilePath.exists():
-                    sqlToExecute = importFilePath.getContent()
</del><span class="cx"> 
</span><span class="cx">         createDatabaseCursor.close()
</span><span class="cx">         createDatabaseConn.close()
</span><span class="lines">@@ -419,7 +462,6 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Start the database and initialize the subservice.
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-
</del><span class="cx">         def createConnection():
</span><span class="cx">             try:
</span><span class="cx">                 createDatabaseConn = self.produceConnection(
</span><span class="lines">@@ -427,16 +469,26 @@
</span><span class="cx">                 )
</span><span class="cx">             except postgres.DatabaseError as e:
</span><span class="cx">                 log.error(
</span><del>-                    &quot;Unable to connect to database for schema creation: {error}&quot;,
</del><ins>+                    &quot;Unable to connect to database for schema creation:&quot;
+                    &quot; {error}&quot;,
</ins><span class="cx">                     error=e
</span><span class="cx">                 )
</span><span class="cx">                 raise
</span><ins>+
</ins><span class="cx">             createDatabaseCursor = createDatabaseConn.cursor()
</span><del>-            createDatabaseCursor.execute(&quot;commit&quot;)
</del><ins>+
+            if postgres.__name__ == &quot;pg8000&quot;:
+                createDatabaseConn.realConnection.autocommit = True
+            elif postgres.__name__ == &quot;pgdb&quot;:
+                createDatabaseCursor.execute(&quot;commit&quot;)
+            else:
+                raise InternalDataStoreError(
+                    &quot;Unknown Postgres DBM module: {}&quot;.format(postgres)
+                )
+
</ins><span class="cx">             return createDatabaseConn, createDatabaseCursor
</span><span class="cx"> 
</span><del>-        monitor = _PostgresMonitor(self)
-        pgCtl = self.pgCtl()
</del><ins>+        monitor = PostgresMonitor(self)
</ins><span class="cx">         # check consistency of initdb and postgres?
</span><span class="cx"> 
</span><span class="cx">         options = []
</span><span class="lines">@@ -446,7 +498,7 @@
</span><span class="cx">         )
</span><span class="cx">         if self.socketDir:
</span><span class="cx">             options.append(
</span><del>-                &quot;-k {}&quot;
</del><ins>+                &quot;-c unix_socket_directories={}&quot;
</ins><span class="cx">                 .format(shell_quote(self.socketDir.path))
</span><span class="cx">             )
</span><span class="cx">         if self.port:
</span><span class="lines">@@ -477,23 +529,17 @@
</span><span class="cx">         if self.testMode:
</span><span class="cx">             options.append(&quot;-c log_statement=all&quot;)
</span><span class="cx"> 
</span><del>-        log.warn(
-            &quot;Requesting postgres start via {cmd} {opts}&quot;,
-            cmd=pgCtl, opts=options
-        )
</del><ins>+        args = [
+            self._pgCtl, &quot;start&quot;,
+            &quot;--log={}&quot;.format(self.logFile),
+            &quot;--timeout=86400&quot;,  # Plenty of time for a long cluster upgrade
+            &quot;-w&quot;,  # Wait for startup to complete
+            &quot;-o&quot;, &quot; &quot;.join(options),  # Options passed to postgres
+        ]
+
+        log.info(&quot;Requesting postgres start via: {args}&quot;, args=args)
</ins><span class="cx">         self.reactor.spawnProcess(
</span><del>-            monitor, pgCtl,
-            [
-                pgCtl,
-                &quot;start&quot;,
-                &quot;-l&quot;, self.logFile,
-                &quot;-t 86400&quot;,  # Give plenty of time for a long cluster upgrade
-                &quot;-w&quot;,
-                # XXX what are the quoting rules for '-o'?  do I need to repr()
-                # the path here?
-                &quot;-o&quot;,
-                &quot; &quot;.join(options),
-            ],
</del><ins>+            monitor, self._pgCtl, args,
</ins><span class="cx">             env=self.env, path=self.workingDir.path,
</span><span class="cx">             uid=self.uid, gid=self.gid,
</span><span class="cx">         )
</span><span class="lines">@@ -517,12 +563,12 @@
</span><span class="cx">             We started postgres; we're responsible for stopping it later.
</span><span class="cx">             Call pgCtl status to get the pid.
</span><span class="cx">             &quot;&quot;&quot;
</span><del>-            log.warn(&quot;{cmd} exited&quot;, cmd=pgCtl)
</del><ins>+            log.info(&quot;{cmd} exited&quot;, cmd=self._pgCtl)
</ins><span class="cx">             self.shouldStopDatabase = True
</span><span class="cx">             d = Deferred()
</span><span class="cx">             statusMonitor = CapturingProcessProtocol(d, None)
</span><span class="cx">             self.reactor.spawnProcess(
</span><del>-                statusMonitor, pgCtl, [pgCtl, &quot;status&quot;],
</del><ins>+                statusMonitor, self._pgCtl, [self._pgCtl, &quot;status&quot;],
</ins><span class="cx">                 env=self.env, path=self.workingDir.path,
</span><span class="cx">                 uid=self.uid, gid=self.gid,
</span><span class="cx">             )
</span><span class="lines">@@ -537,7 +583,7 @@
</span><span class="cx">             d = Deferred()
</span><span class="cx">             statusMonitor = CapturingProcessProtocol(d, None)
</span><span class="cx">             self.reactor.spawnProcess(
</span><del>-                statusMonitor, pgCtl, [pgCtl, &quot;status&quot;],
</del><ins>+                statusMonitor, self._pgCtl, [self._pgCtl, &quot;status&quot;],
</ins><span class="cx">                 env=self.env, path=self.workingDir.path,
</span><span class="cx">                 uid=self.uid, gid=self.gid,
</span><span class="cx">             )
</span><span class="lines">@@ -548,7 +594,10 @@
</span><span class="cx">             We can't start postgres or connect to a running instance.  Shut
</span><span class="cx">             down.
</span><span class="cx">             &quot;&quot;&quot;
</span><del>-            log.failure(&quot;Can't start or connect to postgres&quot;, f)
</del><ins>+            log.critical(
+                &quot;Can't start or connect to postgres: {failure.value}&quot;,
+                failure=f
+            )
</ins><span class="cx">             self.deactivateDelayedShutdown()
</span><span class="cx">             self.reactor.stop()
</span><span class="cx"> 
</span><span class="lines">@@ -565,11 +614,10 @@
</span><span class="cx">         env.update(PGDATA=clusterDir.path,
</span><span class="cx">                    PGHOST=self.host,
</span><span class="cx">                    PGUSER=self.spawnedDBUser)
</span><del>-        initdb = self.initdb()
</del><span class="cx"> 
</span><span class="cx">         if self.socketDir:
</span><span class="cx">             if not self.socketDir.isdir():
</span><del>-                log.warn(&quot;Creating {dir}&quot;, dir=self.socketDir.path)
</del><ins>+                log.info(&quot;Creating {dir}&quot;, dir=self.socketDir.path)
</ins><span class="cx">                 self.socketDir.createDirectory()
</span><span class="cx"> 
</span><span class="cx">             if self.uid and self.gid:
</span><span class="lines">@@ -578,11 +626,11 @@
</span><span class="cx">             os.chmod(self.socketDir.path, 0770)
</span><span class="cx"> 
</span><span class="cx">         if not self.dataStoreDirectory.isdir():
</span><del>-            log.warn(&quot;Creating {dir}&quot;, dir=self.dataStoreDirectory.path)
</del><ins>+            log.info(&quot;Creating {dir}&quot;, dir=self.dataStoreDirectory.path)
</ins><span class="cx">             self.dataStoreDirectory.createDirectory()
</span><span class="cx"> 
</span><span class="cx">         if not self.workingDir.isdir():
</span><del>-            log.warn(&quot;Creating {dir}&quot;, dir=self.workingDir.path)
</del><ins>+            log.info(&quot;Creating {dir}&quot;, dir=self.workingDir.path)
</ins><span class="cx">             self.workingDir.createDirectory()
</span><span class="cx"> 
</span><span class="cx">         if self.uid and self.gid:
</span><span class="lines">@@ -591,11 +639,12 @@
</span><span class="cx"> 
</span><span class="cx">         if not clusterDir.isdir():
</span><span class="cx">             # No cluster directory, run initdb
</span><del>-            log.warn(&quot;Running initdb for {dir}&quot;, dir=clusterDir.path)
</del><ins>+            log.info(&quot;Running initdb for {dir}&quot;, dir=clusterDir.path)
</ins><span class="cx">             dbInited = Deferred()
</span><span class="cx">             self.reactor.spawnProcess(
</span><span class="cx">                 CapturingProcessProtocol(dbInited, None),
</span><del>-                initdb, [initdb, &quot;-E&quot;, &quot;UTF8&quot;, &quot;-U&quot;, self.spawnedDBUser],
</del><ins>+                self._initdb,
+                [self._initdb, &quot;-E&quot;, &quot;UTF8&quot;, &quot;-U&quot;, self.spawnedDBUser],
</ins><span class="cx">                 env=env, path=self.workingDir.path,
</span><span class="cx">                 uid=self.uid, gid=self.gid,
</span><span class="cx">             )
</span><span class="lines">@@ -603,7 +652,7 @@
</span><span class="cx">             def doCreate(result):
</span><span class="cx">                 if result.find(&quot;FATAL:&quot;) != -1:
</span><span class="cx">                     log.error(result)
</span><del>-                    raise RuntimeError(
</del><ins>+                    raise InternalDataStoreError(
</ins><span class="cx">                         &quot;Unable to initialize postgres database: {}&quot;
</span><span class="cx">                         .format(result)
</span><span class="cx">                     )
</span><span class="lines">@@ -612,7 +661,7 @@
</span><span class="cx">             dbInited.addCallback(doCreate)
</span><span class="cx"> 
</span><span class="cx">         else:
</span><del>-            log.warn(&quot;Cluster already exists at {dir}&quot;, dir=clusterDir.path)
</del><ins>+            log.info(&quot;Cluster already exists at {dir}&quot;, dir=clusterDir.path)
</ins><span class="cx">             self.startDatabase()
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -633,12 +682,11 @@
</span><span class="cx">             # If pg_ctl's startup wasn't successful, don't bother to stop the
</span><span class="cx">             # database.  (This also happens in command-line tools.)
</span><span class="cx">             if self.shouldStopDatabase:
</span><del>-                monitor = _PostgresMonitor()
-                pgCtl = self.pgCtl()
</del><ins>+                monitor = PostgresMonitor()
</ins><span class="cx">                 # FIXME: why is this 'logfile' and not self.logfile?
</span><span class="cx">                 self.reactor.spawnProcess(
</span><del>-                    monitor, pgCtl,
-                    [pgCtl, &quot;-l&quot;, &quot;logfile&quot;, &quot;stop&quot;],
</del><ins>+                    monitor, self._pgCtl,
+                    [self._pgCtl, &quot;-l&quot;, &quot;logfile&quot;, &quot;stop&quot;],
</ins><span class="cx">                     env=self.env, path=self.workingDir.path,
</span><span class="cx">                     uid=self.uid, gid=self.gid,
</span><span class="cx">                 )
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavbasedatastoretesttest_subpostgrespy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/test/test_subpostgres.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/test/test_subpostgres.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/base/datastore/test/test_subpostgres.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -139,61 +139,3 @@
</span><span class="cx">         cursor.execute(&quot;select * from test_dummy_table&quot;)
</span><span class="cx">         values = cursor.fetchall()
</span><span class="cx">         self.assertEquals(map(list, values), [[&quot;dummy&quot;]])
</span><del>-
-
-    @inlineCallbacks
-    def test_startService_withDumpFile(self):
-        &quot;&quot;&quot;
-        Assuming a properly configured environment ($PATH points at an 'initdb'
-        and 'postgres', $PYTHONPATH includes pgdb), starting a
-        L{PostgresService} will start the service passed to it, after importing
-        an existing dump file.
-        &quot;&quot;&quot;
-
-        test = self
-
-        class SimpleService1(Service):
-
-            instances = []
-            ready = Deferred()
-
-            def __init__(self, connectionFactory, storageService):
-                self.connection = connectionFactory()
-                test.addCleanup(self.connection.close)
-                self.instances.append(self)
-
-
-            def startService(self):
-                cursor = self.connection.cursor()
-                try:
-                    cursor.execute(
-                        &quot;insert into import_test_table values ('value2')&quot;
-                    )
-                except:
-                    self.ready.errback()
-                else:
-                    self.ready.callback(None)
-                finally:
-                    cursor.close()
-
-        # The SQL in importFile.sql will get executed, including the insertion
-        # of &quot;value1&quot;
-        importFileName = (
-            CachingFilePath(__file__).parent().child(&quot;importFile.sql&quot;).path
-        )
-        svc = PostgresService(
-            CachingFilePath(&quot;postgres_3.pgdb&quot;),
-            SimpleService1,
-            &quot;&quot;,
-            databaseName=&quot;dummy_db&quot;,
-            testMode=True,
-            importFileName=importFileName
-        )
-        svc.startService()
-        self.addCleanup(svc.stopService)
-        yield SimpleService1.ready
-        connection = SimpleService1.instances[0].connection
-        cursor = connection.cursor()
-        cursor.execute(&quot;select * from import_test_table&quot;)
-        values = cursor.fetchall()
-        self.assertEquals(map(list, values), [[&quot;value1&quot;], [&quot;value2&quot;]])
</del></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcaldavdatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/test/test_sql.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/test/test_sql.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/caldav/datastore/test/test_sql.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -2223,7 +2223,37 @@
</span><span class="cx">         yield self.commit()
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @inlineCallbacks
+    def test_removeAfterRevisionCleanup(self):
+        &quot;&quot;&quot;
+        Make sure L{Calendar}'s can be renamed after revision cleanup
+        removes their revision table entry..
+        &quot;&quot;&quot;
+        yield self.homeUnderTest(name=&quot;user01&quot;, create=True)
+        cal = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(cal is not None)
+        yield self.commit()
</ins><span class="cx"> 
</span><ins>+        # Remove the revision
+        cal = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        yield cal.syncToken()
+        yield self.transactionUnderTest().deleteRevisionsBefore(cal._syncTokenRevision + 1)
+        yield self.commit()
+
+        # Rename the calendar
+        cal = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(cal is not None)
+        yield cal.rename(&quot;calendar_renamed&quot;)
+        yield self.commit()
+
+        cal = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar&quot;)
+        self.assertTrue(cal is None)
+        cal = yield self.calendarUnderTest(home=&quot;user01&quot;, name=&quot;calendar_renamed&quot;)
+        self.assertTrue(cal is not None)
+        yield self.commit()
+
+
+
</ins><span class="cx"> class SchedulingTests(CommonCommonTests, unittest.TestCase):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     CalendarObject splitting tests
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcarddavdatastoresqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/carddav/datastore/sql.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/carddav/datastore/sql.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/carddav/datastore/sql.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -591,6 +591,14 @@
</span><span class="cx">                     self._txn, resourceID=self._resourceID, name=name, id=id))
</span><span class="cx">             if rows:
</span><span class="cx">                 self._syncTokenRevision = rows[0][0]
</span><ins>+            else:
+                # Nothing was matched on the delete so insert a new row
+                self._syncTokenRevision = (
+                    yield self._completelyNewDeletedRevisionQuery.on(
+                        self._txn, homeID=self.ownerHome()._resourceID,
+                        resourceID=self._resourceID, name=name)
+                )[0][0]
+
</ins><span class="cx">         elif action == &quot;update&quot;:
</span><span class="cx">             rows = (
</span><span class="cx">                 yield self._updateBumpTokenQuery.on(
</span><span class="lines">@@ -598,9 +606,14 @@
</span><span class="cx">             if rows:
</span><span class="cx">                 self._syncTokenRevision = rows[0][0]
</span><span class="cx">             else:
</span><del>-                action = &quot;insert&quot;
</del><ins>+                # Nothing was matched on the update so insert a new row
+                self._syncTokenRevision = (
+                    yield self._completelyNewRevisionQuery.on(
+                        self._txn, homeID=self.ownerHome()._resourceID,
+                        resourceID=self._resourceID, name=name)
+                )[0][0]
</ins><span class="cx"> 
</span><del>-        if action == &quot;insert&quot;:
</del><ins>+        elif action == &quot;insert&quot;:
</ins><span class="cx">             # Note that an &quot;insert&quot; may happen for a resource that previously
</span><span class="cx">             # existed and then was deleted. In that case an entry in the
</span><span class="cx">             # REVISIONS table still exists so we have to detect that and do db
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcarddavdatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/carddav/datastore/test/test_sql.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/carddav/datastore/test/test_sql.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/carddav/datastore/test/test_sql.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -917,3 +917,119 @@
</span><span class="cx">         obj = yield self.addressbookObjectUnderTest(name=&quot;data1.ics&quot;, addressbook_name=&quot;addressbook&quot;)
</span><span class="cx">         self.assertEqual(obj._dataversion, obj._currentDataVersion)
</span><span class="cx">         yield self.commit()
</span><ins>+
+
+    @inlineCallbacks
+    def test_updateAfterRevisionCleanup(self):
+        &quot;&quot;&quot;
+        Make sure L{AddressBookObject}'s can be updated or removed after revision cleanup
+        removes their revision table entry..
+        &quot;&quot;&quot;
+        person = &quot;&quot;&quot;BEGIN:VCARD
+VERSION:3.0
+N:Thompson;Default1;;;
+FN:Default1 Thompson
+EMAIL;type=INTERNET;type=WORK;type=pref:lthompson1@example.com
+TEL;type=WORK;type=pref:1-555-555-5555
+TEL;type=CELL:1-444-444-4444
+item1.ADR;type=WORK;type=pref:;;1245 Test;Sesame Street;California;11111;USA
+item1.X-ABADR:us
+UID:uid-person
+X-ADDRESSBOOKSERVER-KIND:person
+END:VCARD
+&quot;&quot;&quot;
+        group = &quot;&quot;&quot;BEGIN:VCARD
+VERSION:3.0
+N:Group;Fancy;;;
+FN:Fancy Group
+UID:uid-group
+X-ADDRESSBOOKSERVER-KIND:group
+X-ADDRESSBOOKSERVER-MEMBER:urn:uuid:uid-person
+END:VCARD
+&quot;&quot;&quot;
+        group_update = &quot;&quot;&quot;BEGIN:VCARD
+VERSION:3.0
+N:Group2;Fancy;;;
+FN:Fancy Group2
+UID:uid-group
+X-ADDRESSBOOKSERVER-KIND:group
+X-ADDRESSBOOKSERVER-MEMBER:urn:uuid:uid-person
+END:VCARD
+&quot;&quot;&quot;
+
+        yield self.homeUnderTest()
+        adbk = yield self.addressbookUnderTest(name=&quot;addressbook&quot;)
+        yield adbk.createAddressBookObjectWithName(&quot;person.vcf&quot;, VCard.fromString(person))
+        yield adbk.createAddressBookObjectWithName(&quot;group.vcf&quot;, VCard.fromString(group))
+        yield self.commit()
+
+        # Remove the revision
+        adbk = yield self.addressbookUnderTest(name=&quot;addressbook&quot;)
+        yield adbk.syncToken()
+        yield self.transactionUnderTest().deleteRevisionsBefore(adbk._syncTokenRevision + 1)
+        yield self.commit()
+
+        # Update the object
+        obj = yield self.addressbookObjectUnderTest(name=&quot;group.vcf&quot;, addressbook_name=&quot;addressbook&quot;)
+        yield obj.setComponent(VCard.fromString(group_update))
+        yield self.commit()
+
+        obj = yield self.addressbookObjectUnderTest(name=&quot;group.vcf&quot;, addressbook_name=&quot;addressbook&quot;)
+        self.assertTrue(obj is not None)
+        obj = yield self.addressbookObjectUnderTest(name=&quot;person.vcf&quot;, addressbook_name=&quot;addressbook&quot;)
+        self.assertTrue(obj is not None)
+        yield self.commit()
+
+
+    @inlineCallbacks
+    def test_removeAfterRevisionCleanup(self):
+        &quot;&quot;&quot;
+        Make sure L{AddressBookObject}'s can be updated or removed after revision cleanup
+        removes their revision table entry..
+        &quot;&quot;&quot;
+        person = &quot;&quot;&quot;BEGIN:VCARD
+VERSION:3.0
+N:Thompson;Default1;;;
+FN:Default1 Thompson
+EMAIL;type=INTERNET;type=WORK;type=pref:lthompson1@example.com
+TEL;type=WORK;type=pref:1-555-555-5555
+TEL;type=CELL:1-444-444-4444
+item1.ADR;type=WORK;type=pref:;;1245 Test;Sesame Street;California;11111;USA
+item1.X-ABADR:us
+UID:uid-person
+X-ADDRESSBOOKSERVER-KIND:person
+END:VCARD
+&quot;&quot;&quot;
+        group = &quot;&quot;&quot;BEGIN:VCARD
+VERSION:3.0
+N:Group;Fancy;;;
+FN:Fancy Group
+UID:uid-group
+X-ADDRESSBOOKSERVER-KIND:group
+X-ADDRESSBOOKSERVER-MEMBER:urn:uuid:uid-person
+END:VCARD
+&quot;&quot;&quot;
+
+        yield self.homeUnderTest()
+        adbk = yield self.addressbookUnderTest(name=&quot;addressbook&quot;)
+        yield adbk.createAddressBookObjectWithName(&quot;person.vcf&quot;, VCard.fromString(person))
+        yield adbk.createAddressBookObjectWithName(&quot;group.vcf&quot;, VCard.fromString(group))
+        yield self.commit()
+
+        # Remove the revision
+        adbk = yield self.addressbookUnderTest(name=&quot;addressbook&quot;)
+        yield adbk.syncToken()
+        yield self.transactionUnderTest().deleteRevisionsBefore(adbk._syncTokenRevision + 1)
+        yield self.commit()
+
+        # Remove the object
+        obj = yield self.addressbookObjectUnderTest(name=&quot;group.vcf&quot;, addressbook_name=&quot;addressbook&quot;)
+        self.assertTrue(obj is not None)
+        yield obj.remove()
+        yield self.commit()
+
+        obj = yield self.addressbookObjectUnderTest(name=&quot;group.vcf&quot;, addressbook_name=&quot;addressbook&quot;)
+        self.assertTrue(obj is None)
+        obj = yield self.addressbookObjectUnderTest(name=&quot;person.vcf&quot;, addressbook_name=&quot;addressbook&quot;)
+        self.assertTrue(obj is not None)
+        yield self.commit()
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoresql_utilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_util.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_util.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/sql_util.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -216,9 +216,13 @@
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def _renameSyncToken(self):
</span><del>-        self._syncTokenRevision = (yield self._renameSyncTokenQuery.on(
-            self._txn, name=self._name, resourceID=self._resourceID))[0][0]
-        self._txn.bumpRevisionForObject(self)
</del><ins>+        rows = yield self._renameSyncTokenQuery.on(
+            self._txn, name=self._name, resourceID=self._resourceID)
+        if rows:
+            self._syncTokenRevision = rows[0][0]
+            self._txn.bumpRevisionForObject(self)
+        else:
+            yield self._initSyncToken()
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @classproperty
</span><span class="lines">@@ -397,6 +401,21 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @classproperty
+    def _completelyNewDeletedRevisionQuery(cls):
+        rev = cls._revisionsSchema
+        return Insert(
+            {
+                rev.HOME_RESOURCE_ID: Parameter(&quot;homeID&quot;),
+                rev.RESOURCE_ID: Parameter(&quot;resourceID&quot;),
+                rev.RESOURCE_NAME: Parameter(&quot;name&quot;),
+                rev.REVISION: schema.REVISION_SEQ,
+                rev.DELETED: True
+            },
+            Return=rev.REVISION
+        )
+
+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def _changeRevision(self, action, name):
</span><span class="cx"> 
</span><span class="lines">@@ -409,6 +428,13 @@
</span><span class="cx">                     self._txn, resourceID=self._resourceID, name=name))
</span><span class="cx">             if rows:
</span><span class="cx">                 self._syncTokenRevision = rows[0][0]
</span><ins>+            else:
+                self._syncTokenRevision = (
+                    yield self._completelyNewDeletedRevisionQuery.on(
+                        self._txn, homeID=self.ownerHome()._resourceID,
+                        resourceID=self._resourceID, name=name)
+                )[0][0]
+
</ins><span class="cx">         elif action == &quot;update&quot;:
</span><span class="cx">             rows = (
</span><span class="cx">                 yield self._updateBumpTokenQuery.on(
</span><span class="lines">@@ -416,9 +442,13 @@
</span><span class="cx">             if rows:
</span><span class="cx">                 self._syncTokenRevision = rows[0][0]
</span><span class="cx">             else:
</span><del>-                action = &quot;insert&quot;
</del><ins>+                self._syncTokenRevision = (
+                    yield self._completelyNewRevisionQuery.on(
+                        self._txn, homeID=self.ownerHome()._resourceID,
+                        resourceID=self._resourceID, name=name)
+                )[0][0]
</ins><span class="cx"> 
</span><del>-        if action == &quot;insert&quot;:
</del><ins>+        elif action == &quot;insert&quot;:
</ins><span class="cx">             # Note that an &quot;insert&quot; may happen for a resource that previously
</span><span class="cx">             # existed and then was deleted. In that case an entry in the
</span><span class="cx">             # REVISIONS table still exists so we have to detect that and do db
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdaboopod2podmigrationtxdavcommondatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/test_sql.py (14511 => 14512)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/test_sql.py        2015-03-05 19:47:06 UTC (rev 14511)
+++ CalendarServer/branches/users/cdaboo/pod2pod-migration/txdav/common/datastore/test/test_sql.py        2015-03-05 20:20:10 UTC (rev 14512)
</span><span class="lines">@@ -347,7 +347,7 @@
</span><span class="cx">         token = yield homeChild.syncToken()
</span><span class="cx">         yield homeChild._changeRevision(&quot;delete&quot;, &quot;E&quot;)
</span><span class="cx">         changed = yield homeChild.resourceNamesSinceToken(token)
</span><del>-        self.assertEqual(changed, ([], [], [],))
</del><ins>+        self.assertEqual(changed, ([], [&quot;E&quot;], [],))
</ins><span class="cx"> 
</span><span class="cx">         yield txn.abort()
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>