From: Eric S. Raymond Date: Sat, 8 Nov 2014 15:22:09 +0000 (-0500) Subject: Implemented copyto X-Git-Tag: 0.2~23 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=644a9800f7ea8f03a922ea96c75cb75a6879ed56;p=src.git Implemented copyto --- diff --git a/src b/src index 6e90d4f..4c8127e 100755 --- a/src +++ b/src @@ -302,6 +302,9 @@ src diff ['revision-spec'] ['file'...] src moveto 'directory' ['file'...] Moves files and their histories to another directory. +src copyto 'directory' ['file'...] + Copies files and their histories to another directory. + 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. @@ -665,7 +668,7 @@ def fast_export_method(*args): sys.stdout.write("reset refs/tags/%s\nfrom :%d\n\n" % (key, markmap[val])) def moveto_method(*args): - "Register a file into src control." + "Move a file and its history to another directory." (revspec, args) = preamble("moveto", args) if revspec is not None: croak("moveto doesn't take a revision spec") @@ -687,7 +690,32 @@ def moveto_method(*args): # Using mv(1) evades cross-filesystem issues do_or_die("mv {0} {1} && mv {2} {3]/{4}".format(arg, target, master(arg), target, repodir)) if not quiet and len(args) > 1: - announce("%s -> %s" % target) + announce("%s -> %s" % target) + +def copyto_method(*args): + "Copy a file and its history to another directory." + (revspec, args) = preamble("moveto", args) + if revspec is not None: + croak("moveto doesn't take a revision spec") + if args: + target = args.pop(0) + else: + croak("moveto requires a sirectory argument") + if not os.path.exists(target): + croak("%s does not exist" % arg) + if not os.path.isdir(target): + croak("%s is not a directory" % arg) + init_method(target) + for arg in args: + if not os.path.exists(arg): + croak("I see no '%s' here." % arg) + elif not os.path.exists(master(arg)): + croak("%s is not registered, skipping." % arg) + else: + # Using cp(1) evades cross-filesystem issues + do_or_die("cp {0} {1} && cp {2} {3]/{4}".format(arg, target, master(arg), target, repodir)) + if not quiet and len(args) > 1: + announce("%s -> %s" % target) dispatch = { "help": help_method, @@ -704,6 +732,7 @@ dispatch = { "tag": tag_method, "fast-export": fast_export_method, "moveto": moveto_method, + "copyto": copyto_method, } if __name__ == "__main__": diff --git a/src.asc b/src.asc index febf04c..539fed3 100644 --- a/src.asc +++ b/src.asc @@ -85,6 +85,9 @@ src diff ['revision-spec'] ['file'...] src moveto 'directory' ['file'...] Moves files and their histories to another directory. +src copyto 'directory' ['file'...] + Copies files and their histories to another directory. + src fast-export ['file'...] Export one or more projects as a git fast-import stream. The committer identification is copied from your Git configuration.