From: Eric S. Raymond Date: Thu, 20 Nov 2014 03:24:07 +0000 (-0500) Subject: Restore 'src add', Emacs VC needs it. Regression tests pass. X-Git-Tag: 0.11~4 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=15beb8176717eb7893107e59f2a3050e519b11bc;p=src.git Restore 'src add', Emacs VC needs it. Regression tests pass. Removes the commit -a option from the previous commit. --- diff --git a/src b/src index 0b106b7..ebe4a12 100755 --- a/src +++ b/src @@ -429,18 +429,23 @@ A good topic to read next would be 'commands'. src help [command] Displays help for commands. -src commit [-a] [- | -m 'string' | -f 'file' | -e] ['file'...] +src commit [- | -m 'string' | -f 'file' | -e] ['file'...] Enters a commit for specified files. Separately to each one. A history is created for the file if it does not already exist. With '-', take comment text from stdin; with '-m' use the following string as the comment; with '-f' take from a file. With '-e', edit even after '-f' or '-m'. 'ci' is a synonym for commit. - Find out more under 'help commit'. src amend [- | -m string | -f file | -e] ['revision'] ['file'...] Amends the stored comment for a specified revision, defaulting to the latest revision on the current branch. Flags are as for commit. +src add ['file'...] + Initialize new project histories for specified files. Creates + the repository directory if required. This command is not intended + for human use - commit adds files when necessary. It's a helper + for Emacs VC mode. + src checkout ['revision'] ['file'...] Refresh the working copies of the file(s) from their history files. 'co' is a synonym for checkout. @@ -540,7 +545,7 @@ L - The file is locked. You can usually recover of file from A, L, and ! status with src checkout. A and L statuses should only occur if you have used RCS -directly on a file. +directly on a file, or if you have called 'src add' manually. If you give 'src status' no filename arguments, it surveys all files in the current directory but untracked and ignored files @@ -587,10 +592,6 @@ forced editing with -e). This is a major difference from other VCSes, which are usually designed to create changesets common to multiple files. -The -a option is not for human use, but provided to fit Emacs -VC-mode's model of the editing/version-control cycle. With -a, the -file is registered but no first commit is performed. - 'ci' is a synonym for commit. """, "amend" : """ @@ -1038,13 +1039,6 @@ def commit_method(*args): except OSError: croak(" %s creation failed, check directory permissions." % repodir) args = list(args) - addflag = False - if args: - if args[0] == '--': - args.pop(0) - elif args[0] == '-a': - addflag = True - args.pop(0) comment = CommentContext("commit", args) ctx = CommandContext("commit", args, require_empty=True) for arg in ctx.args: @@ -1065,9 +1059,8 @@ def commit_method(*args): else: if not registered(arg): backend.add(arg) - if not addflag: - with backend.lifter(arg): - backend.checkin(arg, comment.content()) + with backend.lifter(arg): + backend.checkin(arg, comment.content()) if not quiet and len(args) > 1: announce("%s -> %d" % (arg, revcount)) @@ -1101,6 +1094,24 @@ def amend_method(*args): if not quiet and len(args) > 1: announce("%s : %d" % (arg, ctx.start)) +def add_method(*args): + "Register a file into src control." + if not os.path.exists(repodir): + try: + os.mkdir(repodir) + except OSError: + croak(" %s creation failed, check directory permissions." % repodir) + ctx = CommandContext("add", args, require_empty=True) + for arg in ctx.args: + if not os.path.exists(arg): + croak("I see no '%s' here." % arg) + elif os.path.exists(backend.master(arg)): + croak("%s is already registered." % arg) + else: + backend.add(arg) + if not quiet and len(ctx.args) > 1: + announce("%s -> 0" % arg) + def list_method(*args): "Generate a summary listing of commits, one line per commit." args = list(args) @@ -1514,6 +1525,7 @@ def fast_import_method(*args): os.rename(fn, corresponding) shutil.rmtree("RCS") + def version_method(*args): "Report SRC's version" sys.stdout.write("%s\n" % version) @@ -1524,6 +1536,7 @@ dispatch = { "ci": commit_method, "amend": amend_method, "am": amend_method, + "add": add_method, "list": list_method, "li": list_method, "log": log_method,