src/Pure/General/mercurial.scala
changeset 75487 167660a8f99e
parent 75485 d8ee3e4d74ef
child 75489 f08fd5048df3
equal deleted inserted replaced
75486:ba4ed9a50be3 75487:167660a8f99e
   252     def known_files(): List[String] = status(options = "--modified --added --clean --no-status")
   252     def known_files(): List[String] = status(options = "--modified --added --clean --no-status")
   253 
   253 
   254     def sync(target: String,
   254     def sync(target: String,
   255       progress: Progress = new Progress,
   255       progress: Progress = new Progress,
   256       verbose: Boolean = false,
   256       verbose: Boolean = false,
       
   257       thorough: Boolean = false,
   257       dry_run: Boolean = false,
   258       dry_run: Boolean = false,
   258       clean: Boolean = false,
   259       clean: Boolean = false,
   259       filter: List[String] = Nil,
   260       filter: List[String] = Nil,
   260       rev: String = ""
   261       rev: String = ""
   261     ): Unit = {
   262     ): Unit = {
   276             val source = File.standard_path(tmp_dir + Path.explode("archive"))
   277             val source = File.standard_path(tmp_dir + Path.explode("archive"))
   277             archive(source, rev = rev)
   278             archive(source, rev = rev)
   278             (Nil, source)
   279             (Nil, source)
   279           }
   280           }
   280         Isabelle_System.rsync(
   281         Isabelle_System.rsync(
   281           progress = progress, verbose = verbose, dry_run = dry_run, clean = clean, filter = filter,
   282           progress = progress, verbose = verbose, thorough = thorough,
       
   283           dry_run = dry_run, clean = clean, filter = filter,
   282           args = List("--prune-empty-dirs") ::: options ::: List("--", source + "/.", target))
   284           args = List("--prune-empty-dirs") ::: options ::: List("--", source + "/.", target))
   283       }
   285       }
   284     }
   286     }
   285 
   287 
   286     def graph(): Graph = {
   288     def graph(): Graph = {
   484     Isabelle_Tool("hg_sync", "synchronize Mercurial repository with target directory",
   486     Isabelle_Tool("hg_sync", "synchronize Mercurial repository with target directory",
   485       Scala_Project.here, { args =>
   487       Scala_Project.here, { args =>
   486         var clean = false
   488         var clean = false
   487         var protect: List[String] = Nil
   489         var protect: List[String] = Nil
   488         var root: Option[Path] = None
   490         var root: Option[Path] = None
       
   491         var thorough = false
   489         var dry_run = false
   492         var dry_run = false
   490         var rev = ""
   493         var rev = ""
   491         var verbose = false
   494         var verbose = false
   492 
   495 
   493         val getopts = Getopts("""
   496         val getopts = Getopts("""
   497     -C           clean all unknown/ignored files on target
   500     -C           clean all unknown/ignored files on target
   498                  (implies -n for testing; use option -f to confirm)
   501                  (implies -n for testing; use option -f to confirm)
   499     -P NAME      protect NAME within TARGET from deletion
   502     -P NAME      protect NAME within TARGET from deletion
   500     -R ROOT      explicit repository root directory
   503     -R ROOT      explicit repository root directory
   501                  (default: implicit from current directory)
   504                  (default: implicit from current directory)
       
   505     -T           thorough check of file content (default: time and size)
   502     -f           force changes: no dry-run
   506     -f           force changes: no dry-run
   503     -n           no changes: dry-run
   507     -n           no changes: dry-run
   504     -r REV       explicit revision (default: state of working directory)
   508     -r REV       explicit revision (default: state of working directory)
   505     -v           verbose
   509     -v           verbose
   506 
   510 
   508   which can be local or remote (using notation of rsync).
   512   which can be local or remote (using notation of rsync).
   509 """,
   513 """,
   510           "C" -> { _ => clean = true; dry_run = true },
   514           "C" -> { _ => clean = true; dry_run = true },
   511           "P:" -> (arg => protect = protect ::: List(arg)),
   515           "P:" -> (arg => protect = protect ::: List(arg)),
   512           "R:" -> (arg => root = Some(Path.explode(arg))),
   516           "R:" -> (arg => root = Some(Path.explode(arg))),
       
   517           "T" -> (_ => thorough = true),
   513           "f" -> (_ => dry_run = false),
   518           "f" -> (_ => dry_run = false),
   514           "n" -> (_ => dry_run = true),
   519           "n" -> (_ => dry_run = true),
   515           "r:" -> (arg => rev = arg),
   520           "r:" -> (arg => rev = arg),
   516           "v" -> (_ => verbose = true))
   521           "v" -> (_ => verbose = true))
   517 
   522 
   526         val hg =
   531         val hg =
   527           root match {
   532           root match {
   528             case Some(dir) => repository(dir)
   533             case Some(dir) => repository(dir)
   529             case None => the_repository(Path.current)
   534             case None => the_repository(Path.current)
   530           }
   535           }
   531         hg.sync(target, progress = progress, verbose = verbose, dry_run = dry_run, clean = clean,
   536         hg.sync(target, progress = progress, verbose = verbose, thorough = thorough,
   532           filter = protect.map("protect /" + _), rev = rev)
   537           dry_run = dry_run, clean = clean, rev = rev,
       
   538           filter = protect.map("protect /" + _))
   533       }
   539       }
   534     )
   540     )
   535 }
   541 }