]> thyrsus.com Git - rcs-fast-import.git/commitdiff
Store branches and lightweight tags.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 11 Nov 2010 17:31:24 +0000 (12:31 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 11 Nov 2010 17:31:24 +0000 (12:31 -0500)
rcs-fast-import
rcs-fast-import.xml

index 369749be36b6295e7d872801fb21756e6edb0d8d..001866947ea0d56a0919aa22c722c3624c0722d9 100755 (executable)
@@ -176,13 +176,12 @@ class Tag:
     def email_out(self, eventnum):
         "Enable do_mailbox_out() to report these."
         msg = email.message.Message()
-        msg.set_unixfrom(None)
         msg["Event-Number"] = str(eventnum+1)
         msg["Tag-Name"] = self.name
         if self.tagger:
             self.tagger.email_out(msg, "Tagger")
         msg.set_payload(self.comment)
-        return str(msg)
+        return msg.as_string(False)
 
 class Reset:
     "Represents a branch creation."
@@ -222,10 +221,18 @@ class Commit:
         self.fileops = []            # blob and file operation list
         self.properties = {}         # commit properties (extension)
         self.taglist = []            # Tags that point at this commit
+    def children(self):
+        "Get a list of this commit's children."
+        return filter(lambda e:self.mark in e.parent_marks,self.repo.commits()) 
+    def is_tip(self):
+        "Is this commit a branch tip?"
+        for child in self.children():
+            if child.branch == self.branch:
+                return False
+        return True
     def email_out(self):
         "Enable do_mailbox_out() to report these."
         msg = email.message.Message()
-        msg.set_unixfrom(None)
         if self.authors:
             self.authors[0].email_out(msg, "Author")
             for (i, coauthor) in enumerate(self.authors[1:]):
@@ -245,7 +252,7 @@ class Commit:
         if empty_properties:
             msg["Empty-Properties"] = ",".join(empty_properties)
         msg.set_payload(self.comment)
-        return str(msg)
+        return msg.as_string(False)
 
 class Passthrough:
     "Represents a passthrough line."
@@ -571,8 +578,7 @@ class RCS:
         "Perform RCS file checkins and modifications,"
         for (path, mode, copyfile) in committables:
             if mode == "160000":
-                announce("ignoring a submodule link %s", path)
-                continue
+                raise FatalException("ignoring a submodule link %s", path)
             else:
                 rcsdir = os.path.join(os.path.dirname(path), "RCS")
                 if not os.path.exists(rcsdir):
@@ -602,6 +608,8 @@ class RCS:
                     os.remove(path)
         for tag in event.taglist:
             do_or_die("rcs -n'%s': %s" % (tag.name, " ".join(RCS.rcsfiles())))
+        if event.is_tip():
+            do_or_die("rcs -n'%s': %s" % (event.branch, " ".join(RCS.rcsfiles())))
     def rename(self, source, target):
         "Perform RCS renames."
         # Dodgy, but since user is more likely to be
@@ -654,7 +662,10 @@ if __name__ == '__main__':
                     if op.op == "M":
                         if verbose:
                             announce("%5s M %s" % (event.mark, op.path))
-                        committables.append((op.path, op.mode, op.copyname))
+                        if op.mode == "160000":
+                            complain("cannot represent a submodule link in RCS")
+                        else:
+                            committables.append((op.path, op.mode, op.copyname))
                     elif op.op in ("D", "deleteall"):
                         # If we delete masters, we lose ability to
                         # retrieve old versions.
index 474fc450b62de2820d51d90426ce1e263e34515a..f5deb003fd6f863757da78bbd3c220d2dd97e433 100644 (file)
@@ -63,10 +63,6 @@ combination with -v.</para>
 <para>R file operations rename corresponding RCS master files; C file operations
 copy them.</para>
 
-<para>If D, R, or C operations are present, the conversion will not
-round-trip properly (that is the file structure after ,
-rcs-fast-export | rcs-fast-import won't be an exact copy) with
-differences near deleted, renamed, and copied files.</para>
 </refsect1>
 
 <refsect1 id='bugs'><title>BUGS</title>
@@ -74,14 +70,34 @@ differences near deleted, renamed, and copied files.</para>
 It is likely they will throw errors on some tag and branch names that
 are legal in fast-import files.</para>
 
+<para>The following limitations are inherent in the RCS format:</para>
+
+<para>If D, R, or C operations are present in the import stream, the
+conversion will not round-trip properly (that is the file structure
+after , rcs-fast-export | rcs-fast-import won't be an exact copy) with
+differences near deleted, renamed, and copied files.</para>
+
 <para>In each commit, the committer date entered in RCS metadata will
 be the committer date from the import stream, but the committer
 identity will be lost; all commits are checked in as if by the
 invoking user and identified with the invoking user's login name.
-However, complete attribution is preserved in comment headers unless
-the -p option was selected.</para>
+(However, this tool preserves complete attribution in comment headers
+unless the -p option was selected.)</para>
+
+<para>Lightweight tags and branches may cause errors in older RCS versions,
+as they are saved with their full (path) names, including slashes.</para>
+
+<para>Submodule links ("M" entries mith mode 160000) can't be handled;
+the tool will throw an error if it sees one.</para>
+
+<para>The following are implementation limits of this tool which may be 
+fixed in a future release :</para>
+
+<para>All annotated-tag metadata other than the tag name will be lost.</para>
 
-<para>All annotated-tag metadata other than its name will be lost.</para>
+<para>Branch structure in the input stream is not yet mapped to RCS
+branches.  Round-tripping will fail if the history in the import 
+stream was not linear.</para>
 </refsect1>
 
 <refsect1 id='returns'><title>ERROR RETURNS</title>