[Zope3-checkins] CVS: Zope3/src/zope/fssync - main.py:1.24
Fred L. Drake, Jr.
fred at zope.com
Thu Aug 7 17:38:07 EDT 2003
Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv23763
Modified Files:
main.py
Log Message:
- wherever -m/--message is accepted to provide a change message, allow
a -F/--file to specify a file containing the message to use
- be really careful to allow the message to be specified at most once
=== Zope3/src/zope/fssync/main.py 1.23 => 1.24 ===
--- Zope3/src/zope/fssync/main.py:1.23 Thu Aug 7 15:06:33 2003
+++ Zope3/src/zope/fssync/main.py Thu Aug 7 16:38:02 2003
@@ -175,11 +175,9 @@
The -m option specifies a message to label the transaction.
The default message is 'fssync_commit'.
"""
- message = "fssync_commit"
+ message, opts = extract_message(opts, "commit")
raise_on_conflicts = False
for o, a in opts:
- if o in ("-m", "--message"):
- message = a
if o in ("-r", "--raise-on-conflicts"):
raise_on_conflicts = True
fs = FSSync()
@@ -301,10 +299,7 @@
/path. subdirectory of TARGETDIR whose name is the last component
of /path.
"""
- message = "fssync_checkin"
- for o, a in opts:
- if o in ("-m", "--message"):
- message = a
+ message, opts = extract_message(opts, "checkin")
if not args:
raise Usage("checkin requires a URL argument")
rooturl = args[0]
@@ -317,19 +312,43 @@
fs = FSSync(rooturl=rooturl)
fs.checkin(target, message)
+def extract_message(opts, cmd):
+ L = []
+ message = None
+ msgfile = None
+ for o, a in opts:
+ if o in ("-m", "--message"):
+ if message:
+ raise Usage(cmd + " accepts at most one -m/--message option")
+ message = a
+ elif o in ("-F", "--file"):
+ if msgfile:
+ raise Usage(cmd + " accepts at most one -F/--file option")
+ msgfile = a
+ else:
+ L.append((o, a))
+ if not message:
+ if msgfile:
+ message = open(msgfile).read()
+ else:
+ message = "fssync_" + cmd
+ elif msgfile:
+ raise Usage(cmd + " requires at most one of -F/--file or -m/--message")
+ return message, L
+
command_table = {
"checkout": ("", [], checkout),
"co": ("", [], checkout),
"update": ("", [], update),
- "commit": ("m:r", ["message=", "raise-on-conflicts"], commit),
+ "commit": ("F:m:r", ["file=", "message=", "raise-on-conflicts"], commit),
"add": ("f:t:", ["factory=", "type="], add),
"remove": ("", [], remove),
"rm": ("", [], remove),
"r": ("", [], remove),
"diff": ("bBcC:iNuU:", ["brief", "context=", "unified="], diff),
"status": ("", [], status),
- "checkin": ("m:", ["message="], checkin),
- "ci": ("m:", ["message="], checkin),
+ "checkin": ("F:m:", ["file=", "message="], checkin),
+ "ci": ("F:m:", ["file=", "message="], checkin),
}
if __name__ == "__main__":
More information about the Zope3-Checkins
mailing list