src/Pure/General/mercurial.scala
changeset 71320 1e2e68984a9f
parent 71319 26614beb3529
child 71321 edf3210a61a2
equal deleted inserted replaced
71319:26614beb3529 71320:1e2e68984a9f
   192     val Entry = """^(\S+)\s*=\s*(.*)$""".r
   192     val Entry = """^(\S+)\s*=\s*(.*)$""".r
   193     val new_entry = path_name + " = " + source
   193     val new_entry = path_name + " = " + source
   194 
   194 
   195     def commit(lines: List[String]): Boolean =
   195     def commit(lines: List[String]): Boolean =
   196     {
   196     {
   197       File.write_backup(hgrc, cat_lines(lines))
   197       File.write(hgrc, cat_lines(lines))
   198       true
   198       true
   199     }
   199     }
   200     val edited =
   200     val edited =
   201       hgrc.is_file && {
   201       hgrc.is_file && {
   202         val lines = split_lines(File.read(hgrc))
   202         val lines = split_lines(File.read(hgrc))
   203         lines.filter(header).length == 1 && {
   203         lines.filter(header).length == 1 && {
   204           if (local_hg.paths(options = "-q").contains(path_name)) {
   204           if (local_hg.paths(options = "-q").contains(path_name)) {
   205             val old_source = local_hg.paths(args = path_name).head
   205             val old_source = local_hg.paths(args = path_name).head
       
   206             val old_entry = path_name + ".old = " + old_source
   206             val lines1 =
   207             val lines1 =
   207               lines.map {
   208               lines.map {
   208                 case Entry(a, b) if a == path_name && b == old_source => new_entry
   209                 case Entry(a, b) if a == path_name && b == old_source =>
       
   210                   new_entry + "\n" + old_entry
   209                 case line => line
   211                 case line => line
   210               }
   212               }
   211             lines != lines1 && commit(lines1)
   213             lines != lines1 && commit(lines1)
   212           }
   214           }
   213           else {
   215           else {