]> thyrsus.com Git - src.git/commitdiff
Another encapslation step.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 17:23:23 +0000 (12:23 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 8 Nov 2014 17:23:23 +0000 (12:23 -0500)
src

diff --git a/src b/src
index 7ea09188c92358d0d0e1e4c94df6552fb730f2f7..887963666e8490e14551690c28ed60c508b7b568 100755 (executable)
--- a/src
+++ b/src
@@ -389,16 +389,6 @@ def add_method(*args):
            if not quiet and len(args) > 1:
               announce("%s -> 0" % arg) 
 
-class lifted:
-    "Temporatily lift a master to the working directory."
-    def __init__(self, name):
-        self.name = name
-    def __enter__(self):
-        do_or_die("mv {0}/{1},v .".format(repodir, self.name))
-    def __exit__(self, extype, value, traceback_unused):
-        do_or_die("mv {0},v {1}".format(self.name, repodir))
-        return True
-
 def commit_method(*args):
     "Commit changes to files."
     if not os.path.exists(repodir):
@@ -448,7 +438,7 @@ def commit_method(*args):
            if not comment.endswith("\n"):
                comment += "\n"
            comment = comment.replace("'", r"\'")
-           with lifted(arg):
+           with RCS.lifter(arg):
                backend.checkin(arg, comment)
            if not quiet and len(args) > 1:
                announce("%s -> %d" % (arg, len(metadata))) 
@@ -502,7 +492,7 @@ def checkout_method(*args):
             croak("%s has only %d revisions" % (arg, len(master)))
         else:
             revision = master[len(master) - revspec[0]].revision
-        with lifted(arg):
+        with RCS.lifter(arg):
             backend.checkout(arg, revision)
         if not quiet and len(args) > 1:
             announce("%s <- %d" % (arg, revspec[0])) 
@@ -515,7 +505,7 @@ def cat_method(*args):
         revspec = master.resolve(revspec)
         if revspec is None:
             revspec = [master.tip().revno]
-        with lifted(arg):
+        with RCS.lifter(arg):
             for item in master:
                 if item.revno in revspec:
                     backend.cat(arg, item.revision)
@@ -534,7 +524,7 @@ def diff_method(*args):
             diffspec1 += master.revno_to_rcs(revspec[0])
             if len(revspec) > 1:
                 diffspec2 += master.revno_to_rcs(revspec[1])
-        with lifted(arg):
+        with RCS.lifter(arg):
             backend.diff(diffspec1, diffspec2, diffopts, arg)
 
 def list_tags(*args):
@@ -561,7 +551,7 @@ def delete_tags(args):
         if tagname not in master.symbols:
             croak("%s is not a tag in %s" % (tagname, arg))
         else:
-            with lifted(arg):
+            with RCS.lifter(arg):
                 backend.delete_tag(tagname, arg)
             if not quiet and len(args) > 1:
                 announce("tag %s removed from %s" % (tagname, arg))
@@ -582,7 +572,7 @@ def set_tags(args):
             revno = revspec[0]
         else:
             croak("can't accept a range when setting tags.")
-        with lifted(arg):
+        with RCS.lifter(arg):
             backend.set_tag(tagname, revision, arg)
             if not quiet and len(args) > 1:
                 announce("tag %s = %s in " % (tagname, revno, arg))
@@ -638,7 +628,7 @@ def fast_export_method(*args):
         if revspec is None:
             revspec = 1
         revrange = range(revspec, len(metadata)+1)
-        with lifted(arg):
+        with RCS.lifter(arg):
             markmap = {}
             last_commit_mark = 0
             if len(args) == 1:
@@ -747,6 +737,15 @@ dispatch = {
 
 class RCS:
     "Encapsulate RCS back end methods."
+    class lifter:
+        "Temporatily lift a master to the working directory."
+        def __init__(self, name):
+            self.name = name
+        def __enter__(self):
+            do_or_die("mv {0}/{1},v .".format(repodir, self.name))
+        def __exit__(self, extype, value, traceback_unused):
+            do_or_die("mv {0},v {1}".format(self.name, repodir))
+            return True
     def master(self, arg):
         return os.path.join(repodir, arg + ",v")
     def add(self, arg):