From: Eric S. Raymond Date: Sun, 9 Nov 2014 05:28:42 +0000 (-0500) Subject: src fast-import is implemented (by callout to rcs-fast-import). X-Git-Tag: 0.3~18 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=3b216d6d21370cf7a46ef4e127c6803d49265286;p=src.git src fast-import is implemented (by callout to rcs-fast-import). No test for it yet. Regression test passes. --- diff --git a/TODO b/TODO index ccf5a64..1987f03 100644 --- a/TODO +++ b/TODO @@ -2,8 +2,6 @@ * src branch -* src fast-import - * vc.el * .srcignore diff --git a/src b/src index 763757f..64c12f4 100755 --- a/src +++ b/src @@ -315,6 +315,13 @@ src fast-export ['file'...] Export one or more projects to standard output as a git fast-import stream. The committer identification is copied from your Git configuration. +src fast-import [-p] + Parse a git-fast-import stream from standard input. The modifications for + each individual file become a SRC history. Mark, committer and + author data, and mark cross-references to parent commits, are preserved + in RFC-822-style headers on log comments unless the -p (plain) option + is given, in which case this metadata is discarded. + The omission of 'src remove' is a deliberate speed bump. """ @@ -636,6 +643,44 @@ def branch_method(*args): args = list(args) croak("branches are not yet implemented.") +def filecmd(legend, hook, args): + (revspec, args) = preamble(legend, args) + if revspec is not None: + croak("%s doesn't take a revision spec" % legend) + elif len(args) != 2: + croak("%s requires exactly two arguments" % legend) + (source, target) = args + if not os.path.exists(source): + croak("I see no '%s' here." % source) + elif not os.path.exists(backend.master(source)): + croak("%s is not registered, skipping." % source) + elif os.path.exists(backend.master(target)): + croak("%s is registered, I won't step on it" % source) + elif os.path.exists(target): + croak("%s exists, please delete manually if you want it gone" % target) + else: + hook(source, target) + +def move_method(*args): + "Move a file and its history." + filecmd("move", backend.move, args) + +def copy_method(*args): + "Copy a file and its history." + filecmd("copy", backend.copy, args) + +def ls_method(*args): + "List registered files." + if args: + croak("ls cannot accept arguments") + try: + masters = os.listdir(repodir) + except OSError: + croak("repo directory %s does not exist" % repodir) + masters.sort() + for master in masters: + sys.stdout.write(backend.workfile(master) + "\n") + def fast_export_method(*args): "Dump revision content to standard output." (revspec, args) = preamble("cat", args) @@ -702,43 +747,10 @@ def fast_export_method(*args): if val in revrange: sys.stdout.write("reset refs/tags/%s\nfrom :%d\n\n" % (key, markmap[val])) -def filecmd(legend, hook, args): - (revspec, args) = preamble(legend, args) - if revspec is not None: - croak("%s doesn't take a revision spec" % legend) - elif len(args) != 2: - croak("%s requires exactly two arguments" % legend) - (source, target) = args - if not os.path.exists(source): - croak("I see no '%s' here." % source) - elif not os.path.exists(backend.master(source)): - croak("%s is not registered, skipping." % source) - elif os.path.exists(backend.master(target)): - croak("%s is registered, I won't step on it" % source) - elif os.path.exists(target): - croak("%s exists, please delete manually if you want it gone" % target) - else: - hook(source, target) - -def move_method(*args): - "Move a file and its history." - filecmd("move", backend.move, args) - -def copy_method(*args): - "Copy a file and its history." - filecmd("copy", backend.copy, args) - -def ls_method(*args): - "List registered files." - if args: - croak("ls cannot accept arguments") - try: - masters = os.listdir(repodir) - except OSError: - croak("repo directory %s does not exist" % repodir) - masters.sort() - for master in masters: - sys.stdout.write(backend.workfile(master) + "\n") +def fast_import_method(*args): + "Accept a git fast-import stream on stdin, turn it into file histories." + # Force -l to fit SRC's lockless interface. + do_or_die(r"rcs-fast-import -l " +" ".join(args)) dispatch = { "help": help_method, @@ -754,13 +766,14 @@ dispatch = { "diff": diff_method, "tag": tag_method, "branch": branch_method, - "fast-export": fast_export_method, "ls": ls_method, "move": move_method, "mv": move_method, "rename": move_method, "copy": copy_method, "cp": copy_method, + "fast-export": fast_export_method, + "fast-import": fast_import_method, } class RCS: diff --git a/src.asc b/src.asc index 74fe69a..f27e6cd 100644 --- a/src.asc +++ b/src.asc @@ -99,6 +99,13 @@ src fast-export ['file'...]:: Export one or more projects as a git fast-import stream. The committer identification is copied from your Git configuration. +src fast-import [-p]:: + Parse a git-fast-import stream from standard input. The modifications for + each individual file become a SRC history. Mark, committer and + author data, and mark cross-references to parent commits, are preserved + in RFC-822-style headers on log comments unless the -p (plain) option + is given, in which case this metadata is discarded. + The omission of 'src remove' is a deliberate speed bump. If no files are specified, all eligible files are operated on in sequence. @@ -106,15 +113,15 @@ If no files are specified, all eligible files are operated on in sequence. == NOISE CONTROL == Silence is golden. When you have selected only one file to operate -on, and the command is not a report generator (cat, log, list, +on, and the command is not a report generator (status, cat, log, list, fast-export, the listing modes of tag and branch, ls) you will see a reply only if the operation failed. -Other commands (add, commit, checkout, tag creation and deletion, -moveto, copyto) give you a success message per file when operating on -multiple files, so you will not be in doubt about which operation -succeeded. This behavior can be suppressed with the -q option, placed -'before' the subcommand word. +Other commands (add, commit, checkout, tag creation and deletion) give +you a success message per file when operating on multiple files, so +you will not be in doubt about which operation succeeded. This +behavior can be suppressed with the -q option, placed 'before' the +subcommand word. == BACKWARD COMPATIBILITY == @@ -132,7 +139,7 @@ will quietly operate on the files in the RCS directory. == DEBUGGING OPTIONS == -These will be of interet mainly to developers. +These will be of interest mainly to developers. A '-d' option before the main command word turns on debugging messages; it can be repeated for higher debugging levels. @@ -145,6 +152,11 @@ revision and fixes the user information to be used in fast-export; It also attributes all commits to J. Random Hacker and sets a constant screen witch of 79. It's for regression testing. +== REQUIREMENTS == + +The RCS tools must be installed and accessible on your path; +rcs-fast-import(1) is required to support the src fast-import command. + == LIMITATIONS == The 'branch' command is not yet implemented; it is described here to