]> thyrsus.com Git - src.git/commitdiff
Implemented src ls.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 17:53:19 +0000 (12:53 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 17:53:19 +0000 (12:53 -0500)
TODO
src
src.asc

diff --git a/TODO b/TODO
index 2f2c1bb0d37f055440e0ce12a1e903ddf4dac376..62e1d343032780c027ae7bdceb41f2d7fd979a4f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -11,5 +11,3 @@
 * vc.el
 
 * .srcignore
-
-* Test reposurgeon import.
diff --git a/src b/src
index be9acc946acef4623b02214c62130be4aa47acb6..aede05d07e68e05b5ebef74ae829a07940ce378d 100755 (executable)
--- a/src
+++ b/src
@@ -308,6 +308,9 @@ src copyto 'directory' ['file'...]
 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 ls
+   List all registered files.
 """
 
 def init_method(*args):
@@ -369,7 +372,7 @@ def preamble(cmd, args):
         except OSError:
             croak("repo directory %s does not exist" % repodir)
         if len(masters) == 1:
-            args += [master[:-2] for master in masters]
+            args += [backend.workfile(master) for master in masters]
         else:
             croak("%s requires at least one file argument" % cmd)
     return(revspec, args)
@@ -694,7 +697,7 @@ def moveto_method(*args):
 
 def copyto_method(*args):
     "Copy a file and its history to another directory."
-    (revspec, args) = preamble("moveto", args)
+    (revspec, args) = preamble("copyto", args)
     if revspec is not None:
         croak("moveto doesn't take a revision spec")
     if args:
@@ -716,6 +719,18 @@ def copyto_method(*args):
            if not quiet and len(args) > 1:
               announce("%s -> %s" % target)
 
+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")
+
 dispatch = {
     "help":        help_method,
     "init":        init_method,
@@ -733,6 +748,7 @@ dispatch = {
     "fast-export": fast_export_method,
     "moveto":      moveto_method,
     "copyto":      copyto_method,
+    "ls":          ls_method,
 }
 
 class RCS:
@@ -750,6 +766,8 @@ class RCS:
         return RCS.RCSLifter(name)
     def master(self, arg):
         return os.path.join(repodir, arg + ",v")
+    def workfile(self, arg):
+        return arg[:-2]
     def add(self, arg):
         "Register a file"
         do_or_die("rcs -q -kb -i {0} </dev/null && mv {0},v {1}".format(arg, repodir))
diff --git a/src.asc b/src.asc
index 9116b2e41d51aa3168fbbf2e33130bfea8b787dd..dbfb89b55dff0bad58f0b5a92647407178d19c99 100644 (file)
--- a/src.asc
+++ b/src.asc
@@ -93,13 +93,16 @@ 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 ls
+   List all registered files.
+
 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,
-fast-export, the listing modes of tag and branch) you will see a reply
+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,