source: contrib/port-whatsnew/port-whatsnew @ 70612

Last change on this file since 70612 was 70612, checked in by ryandesign@…, 7 years ago

port-whatsnew: new script to show you the subversion log of what changes have been committed to a port since you installed it; see #26028

  • Property svn:executable set to *
File size: 4.1 KB
Line 
1#!/usr/bin/tclsh
2# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
3#
4# Show the svn log of what changed since this port was installed.
5
6
7set MY_VERSION 0.1
8
9
10proc printUsage {} {
11    puts "Usage: $::argv0 \[-hvV\] \[-t macports-tcl-path\] port-name"
12    puts "  -h    This help"
13    puts "  -t    Give a different location for the base MacPorts Tcl"
14    puts "        file (defaults to /Library/Tcl)"
15    puts "  -v    verbose output"
16    puts "  -V    show version and MacPorts version being used"
17    puts ""
18    puts "port-name is the name of the port whose log you want to see"
19}
20
21
22# Begin
23
24set macportsTclPath /Library/Tcl
25set verbose 0
26set showVersion 0
27
28while {[string index [lindex $::argv 0] 0] == "-" } {
29    switch [string range [lindex $::argv 0] 1 end] {
30        h {
31            printUsage
32            exit 0
33        }
34        t {
35            if {[llength $::argv] < 2} {
36                puts "-t needs a path"
37                printUsage
38                exit 1
39            }
40            set macportsTclPath [lindex $::argv 1]
41            set ::argv [lrange $::argv 1 end]
42        }
43        v {
44             set verbose 1
45        }
46        V {
47            set showVersion 1
48        }
49        default {
50            puts "Unknown option [lindex $::argv 0]"
51            printUsage
52            exit 1
53        }
54    }
55    set ::argv [lrange $::argv 1 end]
56}
57
58source ${macportsTclPath}/macports1.0/macports_fastload.tcl
59package require macports
60mportinit
61
62if {$showVersion} {
63    puts "Version $MY_VERSION"
64    puts "MacPorts version [macports::version]"
65    exit 0
66}
67
68if {![string equal ${macports::registry.format} "receipt_sqlite"]} {
69    puts "registry format must be sqlite"
70    exit 1
71}
72
73if {[llength $::argv] == 0} {
74    puts "missing port-name"
75    printUsage
76    exit 1
77}
78set portname [lindex $::argv 0]
79
80set portSearchResult [mportlookup $portname]
81if {[llength $portSearchResult] < 1} {
82    puts "port \"$portname\" not found"
83    return [list]
84}
85
86if {[catch {set ilist [registry::installed $portname {}]}]} {
87    puts "port \"$portname\" is not installed"
88    return [list]
89}
90
91# find the active version, or if none is active, the latest version installed
92set version_selected {}
93foreach i $ilist {
94    set variant [lindex $i 3]
95    set version [lindex $i 1]
96    set revision [lindex $i 2]
97    set epoch [lindex $i 5]
98    if { $version_selected == {} || $epoch > $epoch_selected ||
99            ($epoch == $epoch_selected && [rpm-vercomp $version $version_selected] > 0)
100            || ($epoch == $epoch_selected
101                && [rpm-vercomp $version $version_selected] == 0
102                && $revision > $revision_selected)} {
103        set version_selected $version
104        set revision_selected $revision
105        set variant_selected $variant
106        set epoch_selected $epoch
107    }
108
109    set isactive [lindex $i 4]
110    if {$isactive == 1} {
111        set version_selected $version
112        set revision_selected $revision
113        set variant_selected $variant
114        set epoch_selected $epoch
115        break
116    }
117}
118
119# find when it was installed
120set regref [registry::open_entry $portname $version_selected $revision_selected $variant_selected $epoch_selected]
121set installedDate [registry::property_retrieve $regref date]
122
123# get the svn log since then
124array set portInfo [lindex $portSearchResult 1]
125set portSvnUrl http://svn.macosforge.org/repository/macports/trunk/dports/$portInfo(portdir)/Portfile
126if {[catch {set log [exec svn log -r "{[clock format $installedDate -format {%Y-%m-%dT%H:%M:%SZ} -gmt 1]}:HEAD" $portSvnUrl]}]} {
127    puts "error getting svn log"
128    exit 1
129}
130
131if {[llength [split $log "\n"]] == 1} {
132    puts "No changes have been committed for $portname since you installed $portname @${version_selected}_$revision_selected$variant_selected on [clock format $installedDate -format {%Y-%m-%d at %H:%M:%S}]."
133    exit 0
134}
135
136puts "The following changes have been committed for $portname since you installed $portname @${version_selected}_$revision_selected$variant_selected on [clock format $installedDate -format {%Y-%m-%d at %H:%M:%S}]:\n"
137puts $log
Note: See TracBrowser for help on using the repository browser.