#!/bin/env tclsh8.3 # -*- Tcl -*- export-tree.tcl (c) Clemens Hintze 02.02.2004 # # This program is thought to export one revision or a consecutive range of # revisions using the monotone I/O packet format. To do this job the module # monotone.tcl is needed. # # You may use this program under the same license as Tcl's one. You may not # claim you wrote it or remove this comment header. As this is made # available free of charge I do not warrant anything. Using this program # even may destroy your whole monotone repository. You was warned! source [file join [file dir $argv0] monotone.tcl] namespace import monotone::* if {$argc < 1 || $argc > 3} { puts stderr "Syntax: $argv0 ?-delta? fromId ?toId?" exit 1 } set opt "" if {[string compare [lindex $argv 0] "-delta"] == 0} { set opt "-delta" monotone::lvarshift argv } set fromId [monotone::lvarshift argv] set toId [monotone::lvarshift argv] proc either {args} { foreach script $args { set res [uplevel $script] if {[string length $res] != 0} { return $res } } return $res } Init repos if {[string compare $fromId "current"] == 0} { set id1 [GetCurrentId repos] } else { set id1 [GetIdOfPartId -revision repos $fromId] } set id2 {} if {[string length $id1] == 0} { puts stderr "no manifest found for \"$fromId\"" exit 1 } elseif {[llength $id1] > 1} { puts stderr "fromId \"$fromId\" ambiguous:\n[join [split $id1] "\n"]" exit 1 } elseif {[string length $toId] != 0} { set id2 [GetIdOfPartId -revision repos $toId] if {[string length $id2] == 0} { puts stderr "no manifest found for \"$toId\"" exit 1 } elseif {[llength $id2] > 1} { puts stderr "toId \"$toId\" ambiguous:\n[join [split $id2] "\n"]" exit 1 } set idlist [GetShortestAncestorPath repos $id1 $id2] if {[llength $idlist] == 0} { puts stderr "no ancestor path between \"$fromId\" --> \"$toId\" found" exit 1 } } else { set idlist $id1 } puts stderr "I will dump: [join $idlist " --> "]" set anchor [lindex $idlist 0] if {[string length $opt] != 0} { puts [DumpRevision repos $anchor [lindex [GetAncestors repos $anchor] 0]] } else { puts [DumpRevision repos $anchor] } foreach mid [lrange $idlist 1 end] { puts [DumpRevision repos $mid $anchor] set anchor $mid } exit 0