|
From: Fred L. D. <fd...@us...> - 2003-07-14 16:49:44
|
Update of /cvsroot/cvs-syncmail/syncmail
In directory sc8-pr-cvs1:/tmp/cvs-serv11396
Modified Files:
branchctl
Log Message:
This time, actually copy in the tested, working version of the script
from my test repository.
Index: branchctl
===================================================================
RCS file: /cvsroot/cvs-syncmail/syncmail/branchctl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- branchctl 14 Jul 2003 16:30:00 -0000 1.1
+++ branchctl 14 Jul 2003 16:49:30 -0000 1.2
@@ -16,7 +16,7 @@
--config=file
Use file as the configuration file. By default, a file named
- %(DEFAULT_CONFIGURATION_FILE) is used if it exists. If the name of the
+ %(DEFAULT_CONFIGURATION_FILE)s is used if it exists. If the name of the
configuration file is relative, it is interpreted as relative
to the CVSROOT administrative directory of the repository.
--config is incompatible with --no-config.
@@ -43,14 +43,34 @@
import getopt
import os
import re
+import socket
import string
import sys
+try:
+ from socket import getfqdn
+except ImportError:
+ def getfqdn():
+ # Python 1.5.2 :(
+ hostname = socket.gethostname()
+ byaddr = socket.gethostbyaddr(socket.gethostbyname(hostname))
+ aliases = byaddr[1]
+ aliases.insert(0, byaddr[0])
+ aliases.insert(0, hostname)
+ for fqdn in aliases:
+ if '.' in fqdn:
+ break
+ else:
+ fqdn = 'localhost.localdomain'
+ return fqdn
+
+
DEFAULT_CONFIGURATION_FILE = "branchctl.conf"
DEFAULT_CONFIGURATION = {
"verbose": "true",
"open": "true",
+ "cross-branch-commits": "true",
}
@@ -77,6 +97,9 @@
parts = string.split(line, "/")
_, name, revision, timestamp, options, tagdate = parts
tagdate = string.rstrip(tagdate) or None
+ if tagdate:
+ assert tagdate[0] == "T"
+ tagdate = tagdate[1:]
key = namekey(prefix, name)
try:
entry = mapping[key]
@@ -98,12 +121,11 @@
else:
return name
-def load_change_info(prefix=None):
+def load_entries(prefix=None):
if prefix is not None:
entries_fn = os.path.join(prefix, "CVS", "Entries")
else:
entries_fn = os.path.join("CVS", "Entries")
- entries_log_fn = entries_fn + ".Log"
mapping = {}
f = open(entries_fn)
while 1:
@@ -126,6 +148,13 @@
get_entry(prefix, mapping, line, entries_fn)
# else: bogus Entries line
f.close()
+ return mapping
+
+def load_change_info(mapping, prefix=None):
+ if prefix is not None:
+ entries_log_fn = os.path.join(prefix, "CVS", "Entries.Log")
+ else:
+ entries_log_fn = os.path.join("CVS", "Entries.Log")
if os.path.isfile(entries_log_fn):
f = open(entries_log_fn)
while 1:
@@ -270,7 +299,7 @@
self.config = None
if filename and os.path.isfile(filename):
self.config = ConfigParser()
- if hasattr(cp, "readfp"):
+ if hasattr(self.config, "readfp"):
self.config.readfp(open(filename), filename)
else:
# We have to use this old method for compatibility with
@@ -280,6 +309,7 @@
def get_config(self, branch):
dicts = []
if self.config:
+ cp = self.config
if branch:
dicts.append(get_section_as_dict(cp, "branch " + branch))
dicts.append(get_section_as_dict(cp, "branch"))
@@ -288,7 +318,7 @@
else:
dicts.append(self.cmdline)
dicts = filter(None, dicts)
- dicts.append(DEFAULT_CONFIGURATION.copy())
+ dicts.append(DEFAULT_CONFIGURATION)
return Options(OptionLookup(dicts, branch), self.args)
@@ -334,7 +364,7 @@
OptionsBase.__init__(self, config, args)
self.open = config.getbool("open")
-
+ self.cross_commits = config.getbool("cross-branch-commits")
def load_cmdline(args):
try:
@@ -364,23 +394,36 @@
def main():
branch = load_branch_name()
- configdb = load_configuration(sys.argv[1:], branch)
- changes = load_change_info().values()
+ configdb = load_configuration(sys.argv[1:])
+ changes = load_entries().values()
d = {}
for change in changes:
- tag = changes.tagdate or branch
- d[tag] = 1
- closed = 0
+ tag = change.tagdate or branch
+ if d.has_key(tag):
+ d[tag].append(change)
+ else:
+ d[tag] = [change]
+ denied = 0
+ crossed_branches = len(d) > 1
for tag in d.keys():
config = configdb.get_config(tag)
+ if tag:
+ branchname = "branch " + tag
+ else:
+ branchname = "trunk"
if not config.open:
- closed = 1
- if tag:
- print "branch %s is closed" % `tag`
- else:
- print "trunk is closed"
- if closed:
+ if not denied:
+ denied = 1
+ print
+ print branchname, "is closed"
+ if crossed_branches and not config.cross_commits:
+ if not denied:
+ denied = 1
+ print
+ print branchname, "does not permit cross-branch commits"
+ if denied:
+ print
sys.exit(1)
|