]> thyrsus.com Git - src.git/commitdiff
Implementation and basic regression test for branch delete.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 15 Nov 2014 20:43:17 +0000 (15:43 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 15 Nov 2014 20:43:17 +0000 (15:43 -0500)
TODO
src
srctest

diff --git a/TODO b/TODO
index 450958aeb326cc3eaf4f1086db39305ab45e0e41..c9c8582b3b652d702be19689176d862084179a9a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,8 +1,5 @@
                        SRC TODO list
 
-* src branch delete. Should branch_delete really obsolesce branches or just
-  mark them dead?
-
 * should be possible to range-restict a tag or branch listing.
 
 * break up the tag and branch commands - separate delete/list/rename.
diff --git a/src b/src
index 6dacd5b4e9528a9be26bbcc5ccc546742dcd0a66..1ed78a2a5890407c0555337c8057465fc48c647c 100755 (executable)
--- a/src
+++ b/src
@@ -102,9 +102,9 @@ def do_or_die(dcmd, legend=b"", loud=False):
     try:
         retcode = subprocess.call("(" + dcmd + ")" + mute, shell=True)
         if retcode < 0:
-            croak(b"child was terminated by signal %d." % -retcode)
+            croak(b"%s was terminated by signal %d." % (dcmd, -retcode))
         elif retcode != 0:
-            croak(b"child returned %d." % retcode)
+            croak(b"%s returned %d." % (dcmd, retcode))
     except (OSError, IOError) as e:
         croak(b"execution of %s%s failed: %s" % (dcmd, legend, e))
 
@@ -264,7 +264,7 @@ intro     -- Basic concepts: commits, tags, branches. The form of commands.
 revisions -- How to specify ranges of commits to operate on.
 commands  -- a summary of the commands.
 commit    -- the commit comand: how to commit changes to a file.
-amend     -- the amend commant: editing stored change comments.
+amend     -- the amend command: editing stored change comments.
 status    -- the status command: more details and unusual status codes
 ignores   -- .srcignore files and their uses.
 """,
@@ -684,7 +684,7 @@ class CommandContext:
             if type(part) == type(0):
                 return part
             if part not in metadata.symbols:
-                croak("in {0}, can't resolve symbol {0}".format(metadata.name,token))
+                croak("in {0}, can't resolve symbol {1}".format(metadata.name,token))
             else:
                 part = metadata.symbols[part]
             if backend.isbranch(part):
@@ -1398,14 +1398,14 @@ class RCS:
         # What we need do is find the branch tip, then walk back to
         # just after the first point where it joins another branch,
         # then do a delete to end of branch from there.
-        base = metadata.branch_to_tip(branchname)
+        base = self.branch_to_tip(metadata.symbols[branchname], metadata)
         while True:
             if base is not None and metadata.by_native_d[base].branches:
                 break
             else:
                 base = self.pred(base)
-        do_or_die("rcs -o{0}: {1}".format(self.succ(base), arg))
-        self.delete_tag(branchname, metadata.name)
+        do_or_die("rcs -o{0}: {1}".format(self.succ(base), metadata.name))
+        self.delete_tag(branchname, metadata)
     def set_branch(self, name, revision, metadata):
         "Set the specified branch to be default, creating it if required."
         if name in metadata.symbols:
diff --git a/srctest b/srctest
index 586b9ff8a43f8234b6096ee6ee00a8861ff009fc..b20bb738929478acd2cfb722557f325dee7bcdae 100755 (executable)
--- a/srctest
+++ b/srctest
@@ -248,12 +248,12 @@ head      1.4;
 branch 1.3.1.4.1;
 access;
 symbols
-       BLARGH:1.4
+       GLARB:1.4
        GORP:1.3.1.4
        sample:1.3.1.4.0.1
        muggle:1.3.0.1;
 locks
-       esr:1.3.1.4;
+       esr:1.3.1.4.1.5;
 comment        @# @;
 expand @b@;
 
@@ -296,6 +296,32 @@ next       1.3.1.4;
 
 1.3.1.4
 date   2014.11.12.03.36.45;    author esr;     state Exp;
+branches
+       1.3.1.4.1.1;
+next   ;
+
+1.3.1.4.1.1
+date   2014.11.13.04.04.55;    author esr;     state Exp;
+branches;
+next   1.3.1.4.1.2;
+
+1.3.1.4.1.2
+date   2014.11.13.04.23.04;    author esr;     state Exp;
+branches;
+next   1.3.1.4.1.3;
+
+1.3.1.4.1.3
+date   2014.11.13.04.26.23;    author esr;     state Exp;
+branches;
+next   1.3.1.4.1.4;
+
+1.3.1.4.1.4
+date   2014.11.13.04.30.39;    author esr;     state Exp;
+branches;
+next   1.3.1.4.1.5;
+
+1.3.1.4.1.5
+date   2014.11.13.04.31.02;    author esr;     state Exp;
 branches;
 next   ;
 
@@ -327,7 +353,7 @@ text
 
 1.3.1.1
 log
-@On a branch 2?
+@Totally unfubared.
 @
 text
 @a3 2
@@ -338,7 +364,7 @@ Again, this should be branch text.
 
 1.3.1.2
 log
-@Let's see if this commend has a sepaeator before it.
+@Still utterly fubar
 @
 text
 @d5 1
@@ -360,7 +386,7 @@ Revision 7.
 
 1.3.1.4
 log
-@foo-bar
+@Utterly fubar
 @
 text
 @d4 4
@@ -370,6 +396,58 @@ Try a comment with a hyphen.
 @
 
 
+1.3.1.4.1.1
+log
+@All fixed up.
+@
+text
+@a5 1
+Test of commit comments.
+@
+
+
+1.3.1.4.1.2
+log
+@It' all good.
+@
+text
+@a6 1
+Glotch.
+@
+
+
+1.3.1.4.1.3
+log
+@No good.
+@
+text
+@a7 1
+Random modification.
+@
+
+
+1.3.1.4.1.4
+log
+@That's good.
+@
+text
+@a4 1
+jjjj
+d7 1
+@
+
+
+1.3.1.4.1.5
+log
+@I see you
+@
+text
+@d5 1
+a5 1
+jjjjjjjjkkk
+@
+
+
 1.2
 log
 @Second comment.
@@ -391,10 +469,10 @@ EOF
 cat >sample.seqlog <<EOF
 = sample ====================================================================
 6    | 1970-01-02T00:05:00Z
-Let's see if this commend has a sepaeator before it.
+Still utterly fubar
 ------------------------------------------------------------------------------
 5    | 1970-01-02T00:04:00Z
-On a branch 2?
+Totally unfubared.
 ------------------------------------------------------------------------------
 4    | 1970-01-02T00:03:00Z
 On a branch?
@@ -414,10 +492,10 @@ check "traversal by -"
 cat >sample.branchlog <<EOF
 = sample ====================================================================
 6    | 1970-01-02T00:05:00Z
-Let's see if this commend has a sepaeator before it.
+Still utterly fubar
 ------------------------------------------------------------------------------
 5    | 1970-01-02T00:04:00Z
-On a branch 2?
+Totally unfubared.
 ------------------------------------------------------------------------------
 3    | 1970-01-02T00:02:00Z
 Third comment.
@@ -427,20 +505,20 @@ Second comment.
 ------------------------------------------------------------------------------
 EOF
 
+src $TESTOPTS log 2..6 sample >tryit
+diff -u tryit sample.branchlog
+check "traversal by .."
+
 cat >sample.taglog <<EOF
 = sample ====================================================================
 4     - 1970-01-02T00:03:00Z On a branch?
 EOF
 
-src $TESTOPTS log 2..6 sample >tryit
-diff -u tryit sample.branchlog
-check "traversal by .."
-
-src $TESTOPTS list @BLARGH sample >tryit
+src $TESTOPTS list @GLARB sample >tryit
 diff -u tryit sample.taglog
 check "named-tag lookup with @"
 
-src $TESTOPTS tag -r BLARGH GROTTY sample
+src $TESTOPTS tag -r GLARB GROTTY sample
 check "tag renaming"
 
 cat >changes <<EOF
@@ -499,6 +577,64 @@ src $TESTOPTS status newname1 newname2 >tryit
 diff -u statuslog tryit
 check "status after ignore"
 
+src $TESTOPTS branch delete GORP sample
+check "branch delete"
+
+cat >newlist <<EOF
+= sample ====================================================================
+   0   trunk
+   3   muggle
+   8   sample
+EOF
+
+src $TESTOPTS branch -l sample >tryit
+diff -u newlist tryit
+check "branch list check after delete" delete
+
+cat >newlog <<EOF
+= sample ====================================================================
+13   | 1970-01-02T00:12:00Z
+I see you
+------------------------------------------------------------------------------
+12   | 1970-01-02T00:11:00Z
+That's good.
+------------------------------------------------------------------------------
+11   | 1970-01-02T00:10:00Z
+No good.
+------------------------------------------------------------------------------
+10   | 1970-01-02T00:09:00Z
+It' all good.
+------------------------------------------------------------------------------
+9    | 1970-01-02T00:08:00Z
+All fixed up.
+------------------------------------------------------------------------------
+8    | 1970-01-02T00:07:00Z
+Utterly fubar
+------------------------------------------------------------------------------
+7    | 1970-01-02T00:06:00Z
+Totally chenille.
+------------------------------------------------------------------------------
+6    | 1970-01-02T00:05:00Z
+Still utterly fubar
+------------------------------------------------------------------------------
+5    | 1970-01-02T00:04:00Z
+Totally unfubared.
+------------------------------------------------------------------------------
+3    | 1970-01-02T00:02:00Z
+Third comment.
+------------------------------------------------------------------------------
+2    | 1970-01-02T00:01:00Z
+Second comment.
+------------------------------------------------------------------------------
+1    | 1970-01-02T00:00:00Z
+First comment.
+------------------------------------------------------------------------------
+EOF
+
+src $TESTOPTS log sample >tryit 
+diff -u newlog tryit
+check "content after branch deletion"
+
 rm -fr $SANDBOX
 
 # end