Skip to content

Commit 4b0a586

Browse files
LT-21752: Add Send/Receive data option to backup/restore (#907)
* Add option to include Send/Recieve data in backup [LT-21752] * Add a user choice for including Send/Receive data on by default for projects using Send/Receive * Always restore the repository if it is in the backup but display a checkbox to show if the data is there * Only Block the restore if the backup does not have Send/Receive data in it * Update liblcm to the version including this backup option * Make library name consistent for pack and version updates
1 parent 5727e82 commit 4b0a586

13 files changed

Lines changed: 228 additions & 41 deletions

Build/Manage-LocalLibraries.ps1

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
6161
.PARAMETER Library
6262
Which library to set a version for (SetVersion mode only):
63-
liblcm, libpalaso, chorus, machine, or l10nsharp.
63+
lcm, palaso, chorus, machine, or l10nsharp.
6464
6565
.PARAMETER Version
6666
Sets the version in SilVersions.props (SetVersion mode). Use to revert
@@ -75,7 +75,7 @@
7575
Packs libpalaso (from env var) and then chorus from the given path.
7676
7777
.EXAMPLE
78-
.\Build\Manage-LocalLibraries.ps1 -Library libpalaso -Version 17.0.0
78+
.\Build\Manage-LocalLibraries.ps1 -Library palaso -Version 17.0.0
7979
Sets libpalaso version to 17.0.0 in SilVersions.props (e.g. to revert).
8080
#>
8181
[CmdletBinding()]
@@ -95,7 +95,7 @@ param(
9595
[switch]$L10nSharp,
9696
[string]$L10nSharpPath,
9797

98-
[ValidateSet('liblcm', 'libpalaso', 'chorus', 'machine', 'l10nsharp')]
98+
[ValidateSet('palaso', 'lcm', 'chorus', 'machine', 'l10nsharp')]
9999
[string]$Library,
100100

101101
[string]$Version
@@ -108,7 +108,7 @@ $ErrorActionPreference = "Stop"
108108
# ---------------------------------------------------------------------------
109109

110110
$LibraryConfig = @{
111-
libpalaso = @{
111+
palaso = @{
112112
VersionProperty = 'SilLibPalasoVersion'
113113
PdbRelativeDir = 'output/Debug/net462'
114114
CachePrefixes = @(
@@ -118,7 +118,7 @@ $LibraryConfig = @{
118118
)
119119
EnvVar = 'LIBPALASO_PATH'
120120
}
121-
liblcm = @{
121+
lcm = @{
122122
VersionProperty = 'SilLcmVersion'
123123
PdbRelativeDir = 'artifacts/Debug/net462'
124124
CachePrefixes = @('sil.lcmodel')
@@ -150,7 +150,7 @@ $LibraryConfig = @{
150150
}
151151

152152
# Pack order: libpalaso first (other libraries may depend on it)
153-
$PackOrder = @('libpalaso', 'l10nsharp', 'liblcm', 'chorus', 'machine')
153+
$PackOrder = @('palaso', 'l10nsharp', 'lcm', 'chorus', 'machine')
154154

155155
# ---------------------------------------------------------------------------
156156
# Read SilVersions.props
@@ -188,7 +188,21 @@ function Update-VersionAndClearCache {
188188
$cfg = $LibraryConfig[$LibName]
189189
$node = Get-VersionNode $LibName
190190
$node.InnerText = $NewVersion
191-
$versionProps.Save($versionPropsPath)
191+
192+
# Save with XmlWriter to preserve tab indentation (XmlDocument.Save() converts tabs to spaces)
193+
$writerSettings = New-Object System.Xml.XmlWriterSettings
194+
$writerSettings.Indent = $true
195+
$writerSettings.IndentChars = "`t"
196+
$writerSettings.NewLineChars = "`r`n"
197+
$writerSettings.Encoding = New-Object System.Text.UTF8Encoding($false) # UTF-8 without BOM
198+
$writerSettings.OmitXmlDeclaration = -not $versionProps.FirstChild.NodeType.Equals([System.Xml.XmlNodeType]::XmlDeclaration)
199+
$writer = [System.Xml.XmlWriter]::Create($versionPropsPath, $writerSettings)
200+
try {
201+
$versionProps.WriteTo($writer)
202+
} finally {
203+
$writer.Close()
204+
}
205+
192206
Write-Host "Updated SilVersions.props ($($cfg.VersionProperty) = $NewVersion)" -ForegroundColor Yellow
193207

194208
$packagesDir = Join-Path $repoRoot "packages"
@@ -345,8 +359,8 @@ function Invoke-PackLibrary {
345359

346360
# Map switches and explicit paths to library names
347361
$switchMap = @{
348-
libpalaso = @{ Enabled = [bool]$Palaso; ExplicitPath = $PalasoPath }
349-
liblcm = @{ Enabled = [bool]$Lcm; ExplicitPath = $LcmPath }
362+
palaso = @{ Enabled = [bool]$Palaso; ExplicitPath = $PalasoPath }
363+
lcm = @{ Enabled = [bool]$Lcm; ExplicitPath = $LcmPath }
350364
chorus = @{ Enabled = [bool]$Chorus; ExplicitPath = $ChorusPath }
351365
machine = @{ Enabled = [bool]$Machine; ExplicitPath = $MachinePath }
352366
l10nsharp = @{ Enabled = [bool]$L10nSharp; ExplicitPath = $L10nSharpPath }
@@ -436,5 +450,5 @@ elseif ($Library -and $Version) {
436450
Write-Host "Run .\build.ps1 to restore and build with the new version." -ForegroundColor Cyan
437451
}
438452
else {
439-
throw "Nothing to do. Use -Palaso/-Lcm/-Chorus/-Machine/-L10nSharp switches to pack, or -Library and -Version to set a version.`nExamples:`n .\Build\Manage-LocalLibraries.ps1 -Palaso -PalasoPath C:\Repos\libpalaso`n .\Build\Manage-LocalLibraries.ps1 -Palaso -Chorus`n .\Build\Manage-LocalLibraries.ps1 -Machine -MachinePath C:\Repos\machine`n .\Build\Manage-LocalLibraries.ps1 -Library l10nsharp -Version 10.0.0`n .\Build\Manage-LocalLibraries.ps1 -Library libpalaso -Version 17.0.0"
453+
throw "Nothing to do. Use -Palaso/-Lcm/-Chorus/-Machine/-L10nSharp switches to pack, or -Library and -Version to set a version.`nExamples:`n .\Build\Manage-LocalLibraries.ps1 -Palaso -PalasoPath C:\Repos\libpalaso`n .\Build\Manage-LocalLibraries.ps1 -Palaso -Chorus`n .\Build\Manage-LocalLibraries.ps1 -Machine -MachinePath C:\Repos\machine`n .\Build\Manage-LocalLibraries.ps1 -Library l10nsharp -Version 10.0.0`n .\Build\Manage-LocalLibraries.ps1 -Library palaso -Version 17.0.0"
440454
}

Build/SilVersions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
2-
<!--
2+
<!--
33
=============================================================
44
SIL ECOSYSTEM VERSION PROPERTIES
55
Single source of truth for all SIL dependency versions.
@@ -12,7 +12,7 @@
1212
=============================================================
1313
-->
1414
<PropertyGroup Label="SIL Ecosystem Versions">
15-
<SilLcmVersion>11.0.0-beta0161</SilLcmVersion>
15+
<SilLcmVersion>11.0.0-beta0166</SilLcmVersion>
1616
<SilLibPalasoVersion>18.0.0-beta0013</SilLibPalasoVersion>
1717
<SilLibPalasoL10nsVersion>18.0.0-beta0012</SilLibPalasoL10nsVersion>
1818
<SilChorusVersion>6.0.0-beta0065</SilChorusVersion>

Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.Designer.cs

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ public BackupProjectDlg(LcmCache cache,
6262
m_supportingFiles.Enabled = false;
6363
}
6464

65+
if (m_presenter.SendReceiveDataExists)
66+
{
67+
m_sendReceiveData.Checked = true;
68+
}
69+
else
70+
{
71+
m_sendReceiveData.Enabled = false;
72+
}
73+
6574
DestinationFolder = FwDirectoryFinder.DefaultBackupDirectory;
6675
if (File.Exists(m_presenter.PersistanceFilePath))
6776
{
@@ -240,6 +249,15 @@ public bool IncludeSpellCheckAdditions
240249
set { m_spellCheckAdditions.Checked = value; }
241250
}
242251

252+
///<summary>
253+
/// Whether or not user wants Send/Receive repository data in the backup.
254+
///</summary>
255+
public bool IncludeSendReceiveData
256+
{
257+
get { return m_sendReceiveData.Checked; }
258+
set { m_sendReceiveData.Checked = value; }
259+
}
260+
243261
/// <summary>
244262
/// Read/Write the comment from/to the dialog text control.
245263
/// </summary>

Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.resx

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,33 @@
154154
<value>groupBox1</value>
155155
</data>
156156
<data name="&gt;&gt;m_spellCheckAdditions.ZOrder" xml:space="preserve">
157+
<value>1</value>
158+
</data>
159+
<data name="m_sendReceiveData.AutoSize" type="System.Boolean, mscorlib">
160+
<value>True</value>
161+
</data>
162+
<data name="m_sendReceiveData.Location" type="System.Drawing.Point, System.Drawing">
163+
<value>15, 113</value>
164+
</data>
165+
<data name="m_sendReceiveData.Size" type="System.Drawing.Size, System.Drawing">
166+
<value>200, 17</value>
167+
</data>
168+
<data name="m_sendReceiveData.TabIndex" type="System.Int32, mscorlib">
169+
<value>5</value>
170+
</data>
171+
<data name="m_sendReceiveData.Text" xml:space="preserve">
172+
<value>Send/Receive data (repository history)</value>
173+
</data>
174+
<data name="&gt;&gt;m_sendReceiveData.Name" xml:space="preserve">
175+
<value>m_sendReceiveData</value>
176+
</data>
177+
<data name="&gt;&gt;m_sendReceiveData.Type" xml:space="preserve">
178+
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
179+
</data>
180+
<data name="&gt;&gt;m_sendReceiveData.Parent" xml:space="preserve">
181+
<value>groupBox1</value>
182+
</data>
183+
<data name="&gt;&gt;m_sendReceiveData.ZOrder" xml:space="preserve">
157184
<value>0</value>
158185
</data>
159186
<data name="m_supportingFiles.AutoSize" type="System.Boolean, mscorlib">
@@ -241,7 +268,7 @@
241268
<value>12, 12</value>
242269
</data>
243270
<data name="groupBox1.Size" type="System.Drawing.Size, System.Drawing">
244-
<value>555, 148</value>
271+
<value>555, 171</value>
245272
</data>
246273
<data name="groupBox1.TabIndex" type="System.Int32, mscorlib">
247274
<value>1</value>
@@ -265,7 +292,7 @@
265292
<value>True</value>
266293
</data>
267294
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
268-
<value>9, 174</value>
295+
<value>9, 197</value>
269296
</data>
270297
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
271298
<value>54, 13</value>
@@ -289,7 +316,7 @@
289316
<value>7</value>
290317
</data>
291318
<data name="m_comment.Location" type="System.Drawing.Point, System.Drawing">
292-
<value>12, 194</value>
319+
<value>12, 217</value>
293320
</data>
294321
<data name="m_comment.Size" type="System.Drawing.Size, System.Drawing">
295322
<value>555, 20</value>
@@ -313,7 +340,7 @@
313340
<value>True</value>
314341
</data>
315342
<data name="label3.Location" type="System.Drawing.Point, System.Drawing">
316-
<value>12, 229</value>
343+
<value>12, 252</value>
317344
</data>
318345
<data name="label3.Size" type="System.Drawing.Size, System.Drawing">
319346
<value>46, 13</value>
@@ -337,7 +364,7 @@
337364
<value>5</value>
338365
</data>
339366
<data name="m_destinationFolder.Location" type="System.Drawing.Point, System.Drawing">
340-
<value>12, 251</value>
367+
<value>12, 274</value>
341368
</data>
342369
<data name="m_destinationFolder.Size" type="System.Drawing.Size, System.Drawing">
343370
<value>476, 20</value>
@@ -358,7 +385,7 @@
358385
<value>4</value>
359386
</data>
360387
<data name="m_browse.Location" type="System.Drawing.Point, System.Drawing">
361-
<value>494, 248</value>
388+
<value>494, 271</value>
362389
</data>
363390
<data name="m_browse.Size" type="System.Drawing.Size, System.Drawing">
364391
<value>73, 23</value>
@@ -385,7 +412,7 @@
385412
<value>Bottom, Right</value>
386413
</data>
387414
<data name="m_backUp.Location" type="System.Drawing.Point, System.Drawing">
388-
<value>328, 290</value>
415+
<value>328, 313</value>
389416
</data>
390417
<data name="m_backUp.Size" type="System.Drawing.Size, System.Drawing">
391418
<value>75, 23</value>
@@ -412,7 +439,7 @@
412439
<value>Bottom, Right</value>
413440
</data>
414441
<data name="m_cancel.Location" type="System.Drawing.Point, System.Drawing">
415-
<value>409, 290</value>
442+
<value>409, 313</value>
416443
</data>
417444
<data name="m_cancel.Size" type="System.Drawing.Size, System.Drawing">
418445
<value>75, 23</value>
@@ -439,7 +466,7 @@
439466
<value>Bottom, Right</value>
440467
</data>
441468
<data name="m_help.Location" type="System.Drawing.Point, System.Drawing">
442-
<value>491, 290</value>
469+
<value>491, 313</value>
443470
</data>
444471
<data name="m_help.Size" type="System.Drawing.Size, System.Drawing">
445472
<value>75, 23</value>
@@ -475,7 +502,7 @@
475502
<value>6, 13</value>
476503
</data>
477504
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
478-
<value>581, 326</value>
505+
<value>581, 349</value>
479506
</data>
480507
<data name="$this.Text" xml:space="preserve">
481508
<value>Back up this Project</value>

Src/FwCoreDlgs/BackupRestore/BackupProjectPresenter.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ internal String PersistanceFilePath
5252
}
5353
}
5454

55+
///<summary>
56+
/// Returns true if the project has Send/Receive repository data (.hg or OtherRepositories).
57+
///</summary>
58+
internal bool SendReceiveDataExists
59+
{
60+
get
61+
{
62+
var projectFolder = m_cache.ProjectId.ProjectFolder;
63+
return Directory.Exists(Path.Combine(projectFolder, ".hg")) ||
64+
(Directory.Exists(LcmFileHelper.GetOtherRepositoriesDir(projectFolder)) &&
65+
Directory.EnumerateDirectories(LcmFileHelper.GetOtherRepositoriesDir(projectFolder))
66+
.Any(dir => Directory.Exists(Path.Combine(dir, ".hg"))));
67+
}
68+
}
69+
5570
///<summary>
5671
/// If the SupportingFiles folder contains any files return true. Otherwise resturn false.
5772
///</summary>

Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ public bool SpellCheckAdditions
222222
set { m_spellCheckAdditions.Checked = value; }
223223
}
224224

225+
///<summary>
226+
/// Whether or not user wants Send/Receive repository data restored.
227+
///</summary>
228+
public bool SendReceiveData
229+
{
230+
get { return m_sendReceiveData.Checked; }
231+
set { m_sendReceiveData.Checked = value; }
232+
}
233+
225234
/// ------------------------------------------------------------------------------------
226235
/// <summary>
227236
/// Sets the backup file settings and updates the dialog controls accordingly
@@ -363,6 +372,8 @@ private void SetDialogControlsFromBackupSettings(BackupFileSettings settings, St
363372
m_supportingFiles.Enabled = settings.IncludeSupportingFiles;
364373
m_spellCheckAdditions.Checked = settings.IncludeSpellCheckAdditions;
365374
m_spellCheckAdditions.Enabled = settings.IncludeSpellCheckAdditions;
375+
m_sendReceiveData.Checked = settings.IncludeSendReceiveData;
376+
m_sendReceiveData.Enabled = false;
366377
if (m_rdoDefaultFolder.Checked)
367378
m_lblDefaultBackupIncludes.Text = m_presenter.IncludesFiles(settings);
368379
else
@@ -591,6 +602,7 @@ private void UpdateSettingsFromControls()
591602
m_settings.IncludeLinkedFiles = LinkedFiles;
592603
m_settings.IncludeSupportingFiles = SupportingFiles;
593604
m_settings.IncludeSpellCheckAdditions = SpellCheckAdditions;
605+
m_settings.IncludeSendReceiveData = SendReceiveData;
594606
}
595607

596608
/// ------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)