From: Eric S. Raymond Date: Thu, 11 Nov 2010 17:31:24 +0000 (-0500) Subject: Store branches and lightweight tags. X-Git-Tag: 0.1~53 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=cf087c655a06f2bbca336a3d7054a740555d513d;p=rcs-fast-import.git Store branches and lightweight tags. --- diff --git a/rcs-fast-import b/rcs-fast-import index 369749b..0018669 100755 --- a/rcs-fast-import +++ b/rcs-fast-import @@ -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. diff --git a/rcs-fast-import.xml b/rcs-fast-import.xml index 474fc45..f5deb00 100644 --- a/rcs-fast-import.xml +++ b/rcs-fast-import.xml @@ -63,10 +63,6 @@ combination with -v. R file operations rename corresponding RCS master files; C file operations copy them. -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. BUGS @@ -74,14 +70,34 @@ differences near deleted, renamed, and copied files. It is likely they will throw errors on some tag and branch names that are legal in fast-import files. +The following limitations are inherent in the RCS format: + +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. + 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. +(However, this tool preserves complete attribution in comment headers +unless the -p option was selected.) + +Lightweight tags and branches may cause errors in older RCS versions, +as they are saved with their full (path) names, including slashes. + +Submodule links ("M" entries mith mode 160000) can't be handled; +the tool will throw an error if it sees one. + +The following are implementation limits of this tool which may be +fixed in a future release : + +All annotated-tag metadata other than the tag name will be lost. -All annotated-tag metadata other than its name will be lost. +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. ERROR RETURNS