[Frugalware-darcs] vmexam: dg: implemented whatsnew subcommand

VMiklos vmiklos at frugalware.org
Thu Jun 14 00:49:16 CEST 2007


Darcsweb-Url: http://darcs.frugalware.org/darcsweb/darcsweb.cgi?r=vmexam;a=darcs_commitdiff;h=20070613224618-e2957-0b7ad8223e01bc87a7eac0415ef41da3cf675d88.gz;

[dg: implemented whatsnew subcommand
VMiklos <vmiklos at frugalware.org>**20070613224618
 supported switches: -h and -s
 -l is not (yet) supported
] {
hunk ./python/dg.py 323
+def whatsnew(argv):
+	def usage(ret):
+		print """Usage: darcs-git whatsnew [OPTION]... [FILE or DIRECTORY]...
+Display uncommitted changes in the working directory.
+
+Options:
+  -s  --summary             summarize changes
+  -h  --help                shows brief description of command and its arguments"""
+		sys.exit(ret)
+
+	class Options:
+		def __init__(self):
+			self.summary = ""
+			self.help = False
+			self.files = ""
+	options = Options()
+
+	try:
+		opts, args = getopt.getopt(argv, "sh", ["summary", "help"])
+	except getopt.GetoptError:
+		usage(1)
+	optind = 0
+	for opt, arg in opts:
+		if opt in ("-s", "--summary"):
+			options.summary = "--name-status"
+		elif opt in ("-h", "--help"):
+			options.help = True
+		optind += 1
+	if optind < len(argv):
+		options.files = " ".join(argv[optind:])
+	if options.help:
+		usage(0)
+	ret = os.system("git diff HEAD -M --exit-code %s %s" % (options.summary, options.files))
+	if not ret:
+		print "No changes!"
+
hunk ./python/dg.py 367
+		elif sys.argv[1][:4] == "what":
+			whatsnew(argv[1:])
}


More information about the Frugalware-darcs mailing list