author | wenzelm |
Tue, 07 Jun 2022 19:15:08 +0200 | |
changeset 75536 | 7cdeed5dc96d |
parent 75525 | 68162e4f60a7 |
permissions | -rw-r--r-- |
75481 | 1 |
/* Title: Pure/Admin/sync_repos.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Synchronize Isabelle + AFP repositories. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle |
|
8 |
||
9 |
||
10 |
object Sync_Repos { |
|
75525
68162e4f60a7
clarified signature: more explicit type Rsync.Context;
wenzelm
parents:
75524
diff
changeset
|
11 |
def sync_repos(context: Rsync.Context, target: String, |
75481 | 12 |
verbose: Boolean = false, |
75487 | 13 |
thorough: Boolean = false, |
75492 | 14 |
preserve_jars: Boolean = false, |
75481 | 15 |
dry_run: Boolean = false, |
16 |
rev: String = "", |
|
17 |
afp_root: Option[Path] = None, |
|
18 |
afp_rev: String = "" |
|
19 |
): Unit = { |
|
75506 | 20 |
val hg = Mercurial.self_repository() |
75481 | 21 |
val afp_hg = afp_root.map(Mercurial.repository(_)) |
22 |
||
75492 | 23 |
val more_filter = if (preserve_jars) List("include *.jar", "protect *.jar") else Nil |
24 |
||
75511 | 25 |
def sync(hg: Mercurial.Repository, dest: String, r: String, |
26 |
contents: List[File.Content] = Nil, filter: List[String] = Nil |
|
27 |
): Unit = { |
|
75525
68162e4f60a7
clarified signature: more explicit type Rsync.Context;
wenzelm
parents:
75524
diff
changeset
|
28 |
hg.sync(context, dest, rev = r, verbose = verbose, thorough = thorough, dry_run = dry_run, |
68162e4f60a7
clarified signature: more explicit type Rsync.Context;
wenzelm
parents:
75524
diff
changeset
|
29 |
contents = contents, filter = filter ::: more_filter) |
75511 | 30 |
} |
75481 | 31 |
|
75525
68162e4f60a7
clarified signature: more explicit type Rsync.Context;
wenzelm
parents:
75524
diff
changeset
|
32 |
context.progress.echo_if(verbose, "\n* Isabelle repository:") |
75511 | 33 |
sync(hg, target, rev, |
34 |
contents = List(File.Content(Path.explode("etc/ISABELLE_ID"), hg.id(rev = rev))), |
|
35 |
filter = List("protect /AFP")) |
|
75481 | 36 |
|
37 |
for (hg <- afp_hg) { |
|
75525
68162e4f60a7
clarified signature: more explicit type Rsync.Context;
wenzelm
parents:
75524
diff
changeset
|
38 |
context.progress.echo_if(verbose, "\n* AFP repository:") |
75524 | 39 |
sync(hg, Rsync.append(target, "AFP"), afp_rev) |
75481 | 40 |
} |
41 |
} |
|
42 |
||
43 |
val isabelle_tool = |
|
44 |
Isabelle_Tool("sync_repos", "synchronize Isabelle + AFP repositories", |
|
45 |
Scala_Project.here, { args => |
|
46 |
var afp_root: Option[Path] = None |
|
75492 | 47 |
var preserve_jars = false |
75536
7cdeed5dc96d
more robust treatment of rsync on macOS (see also 96fb1f9a4042);
wenzelm
parents:
75525
diff
changeset
|
48 |
var protect_args = false |
75487 | 49 |
var thorough = false |
75481 | 50 |
var afp_rev = "" |
51 |
var dry_run = false |
|
52 |
var rev = "" |
|
75499 | 53 |
var port = SSH.default_port |
75481 | 54 |
var verbose = false |
55 |
||
56 |
val getopts = Getopts(""" |
|
57 |
Usage: isabelle sync_repos [OPTIONS] TARGET |
|
58 |
||
59 |
Options are: |
|
75497 | 60 |
-A ROOT include AFP with given root directory (":" for """ + AFP.BASE.implode + """) |
75492 | 61 |
-J preserve *.jar files |
75536
7cdeed5dc96d
more robust treatment of rsync on macOS (see also 96fb1f9a4042);
wenzelm
parents:
75525
diff
changeset
|
62 |
-S robust (but less portable) treatment of spaces in directory names |
75493 | 63 |
-T thorough treatment of file content and directory times |
75481 | 64 |
-a REV explicit AFP revision (default: state of working directory) |
65 |
-n no changes: dry-run |
|
66 |
-r REV explicit revision (default: state of working directory) |
|
75499 | 67 |
-p PORT explicit SSH port (default: """ + SSH.default_port + """) |
75481 | 68 |
-v verbose |
69 |
||
70 |
Synchronize Isabelle + AFP repositories; see also "isabelle hg_sync". |
|
75486 | 71 |
|
75511 | 72 |
Example: quick testing |
75492 | 73 |
|
75511 | 74 |
isabelle sync_repos -A: -J testmachine:test/isabelle_afp |
75486 | 75 |
|
75511 | 76 |
Example: accurate testing |
75492 | 77 |
|
75511 | 78 |
isabelle sync_repos -A: -T testmachine:test/isabelle_afp |
75481 | 79 |
""", |
75497 | 80 |
"A:" -> (arg => afp_root = Some(if (arg == ":") AFP.BASE else Path.explode(arg))), |
75492 | 81 |
"J" -> (_ => preserve_jars = true), |
75536
7cdeed5dc96d
more robust treatment of rsync on macOS (see also 96fb1f9a4042);
wenzelm
parents:
75525
diff
changeset
|
82 |
"S" -> (_ => protect_args = true), |
75487 | 83 |
"T" -> (_ => thorough = true), |
75481 | 84 |
"a:" -> (arg => afp_rev = arg), |
85 |
"n" -> (_ => dry_run = true), |
|
86 |
"r:" -> (arg => rev = arg), |
|
75499 | 87 |
"p:" -> (arg => port = Value.Int.parse(arg)), |
75481 | 88 |
"v" -> (_ => verbose = true)) |
89 |
||
90 |
val more_args = getopts(args) |
|
91 |
val target = |
|
92 |
more_args match { |
|
93 |
case List(target) => target |
|
94 |
case _ => getopts.usage() |
|
95 |
} |
|
96 |
||
97 |
val progress = new Console_Progress |
|
75536
7cdeed5dc96d
more robust treatment of rsync on macOS (see also 96fb1f9a4042);
wenzelm
parents:
75525
diff
changeset
|
98 |
val context = Rsync.Context(progress, port = port, protect_args = protect_args) |
75525
68162e4f60a7
clarified signature: more explicit type Rsync.Context;
wenzelm
parents:
75524
diff
changeset
|
99 |
sync_repos(context, target, verbose = verbose, thorough = thorough, |
75511 | 100 |
preserve_jars = preserve_jars, dry_run = dry_run, rev = rev, afp_root = afp_root, |
101 |
afp_rev = afp_rev) |
|
75481 | 102 |
} |
103 |
) |
|
104 |
} |