John P. Cavanaugh wrote, regarding his preference for "main" or "trunk"
over ".trunk":
> Partly for personal preference of liking main or trunk better than .trunk.
> But it also allows for main.latest (which I will admit is only to facilitate
> similarity with other branches)
So, it's partly for the sake of consistency. Well, ".trunk" is perfectly
consistent too. It's a branch tag name for the trunk. If you want the
latest stuff from a branch, you use the branch tag name. If you want the
latest stuff from the trunk, you use the branch tag name: ".trunk"
(my words, and here I confuse BASE, and ".base" which are completely
different).
>>
>><branchname>.base - For the version where the branch sprouted
>> I haven't thought about BASE, or what it means, at all, not one whit, so I
>> haven't yet formed an opinion.
>>
>
>Its nice to be able to easily figure out where your branch sprouted from
>using an abstract mechanism.
>
Yes it is, actually it's more than nice, it's essential, which is
why everybody manually tags this point before creating a branch,
except for newbies, who learn the hard way.
So I've thought about it a bit more and written some rough code
(below). (I didn't put the code in patch form because it's not
quite cooked yet and it would be a bit irresponsible to put it
out there in such easily edible form.)
These changes were made to rcs.c, and TAG_ORIGIN was #defined to
".origin", (to avoid confusion with BASE, I didn't use ".base"
but of course we can #define TAG_ORIGIN to be whatever everybody
likes)
Anyway it seemed to work with "update", "checkout", "diff" and
"rdiff", but then I tried sanity.sh, and it failed "make remotecheck"
(I forget which test, something to do with removing a branch tag.)
I'm not sure why, I would have though my code would only fire if you
used a tag of the form xxx.origin, but that's where things stand now.
Anyway, one thing I haven't figured out is what to do for the case
of the trunk, e.g. ".trunk.origin", (and/or maybe just ".origin" by
itself) The super easy but surely wrong implementation is just
return "1.1" in that case maybe? I'm not sure how to implement it
correctly though. Also, what should be done about the
"force_tag_match" case? I'm not sure that even makes sense
with ".origin", so just ignore it?
Anyway, here's a snippet of the code that I'm working on:
-- steve
/*
* Find the revision for a specific tag.
* If force_tag_match is set, return NULL if an exact match is not
* possible otherwise return RCS_head (). We are careful to look for
* and handle "magic" revisions specially.
*
* If the matched tag is a branch tag, find the head of the branch.
*
* Returns pointer to newly malloc'd string, or NULL.
*/
char *
RCS_gettag (rcs, symtag, force_tag_match, simple_tag)
RCSNode *rcs;
char *symtag;
int force_tag_match;
int *simple_tag;
{
char *tag = symtag;
int tag_allocated = 0;
if (simple_tag != NULL)
*simple_tag = 0;
/* make sure we have something to look at... */
assert (rcs != NULL);
/* XXX this is probably not necessary, --jtc */
if (rcs->flags & PARTIAL)
RCS_reparsercsfile (rcs, (FILE **) NULL, (struct rcsbuffer *) NULL);
/* If tag is "HEAD", special case to get head RCS revision */
if (tag && (STREQ (tag, TAG_HEAD) || *tag == '\0'))
#if 0 /* This #if 0 is only in the Cygnus code. Why? Death support? */
if (force_tag_match && (rcs->flags & VALID) && (rcs->flags & INATTIC))
return ((char *) NULL); /* head request for removed file */
else
#endif
return (RCS_head (rcs));
/* If tag is "TRUNK", special case to get trunk RCS revision */
if (tag && (STREQ (tag, TAG_TRUNK) ))
return (RCS_trunk (rcs));
if (!isdigit ((unsigned char) tag[0]))
{
char *version;
/* add this for ".origin" .... */
/* if asking for the ".origin" of a branch tag, then find it */
if ( strlen(tag) > strlen(TAG_ORIGIN) &&
strcmp(tag+strlen(tag)-strlen(TAG_ORIGIN), TAG_ORIGIN) == 0)
{
char *branchtag;
branchtag = xstrdup(tag);
strncpy(branchtag, tag, strlen(tag) - strlen(TAG_ORIGIN));
/* cut off the ".origin" */
branchtag = xstrdup(tag);
branchtag[ strlen(branchtag) - strlen(TAG_TRUNK)-1] = '\0';
version = RCS_getbranchoriginrev(rcs, branchtag);
free(branchtag);
return(version);
}
[..........]
/*
* Get the origin of the specified branch.
* If the branch does not exist,
* return NULL
*
* Note, force_tag_match is IGNORED. I'm not sure what it should do,
* return "1.1", or the lowest numbered version? Seems questionable.
*
* What about ".trunk"?
*
* A lot of this code was copied mercilessly from RCS_getdatebranch
*
*/
char *
RCS_getbranchoriginrev (rcs, branch)
RCSNode *rcs;
char *branch;
{
char * version;
char *cur_rev = NULL;
char *cp;
char *xbranch, *xrev;
Node *p;
RCSVers *vers;
version = RCS_whatbranch(rcs, branch);
if (version == NULL) return (NULL);
/* look up the first revision on the branch */
xrev = xstrdup (version);
cp = strrchr (xrev, '.');
if (cp == NULL)
{
free (xrev);
return (NULL);
}
*cp = '\0'; /* turn it into a revision */
assert (rcs != NULL);
if (rcs->flags & PARTIAL)
RCS_reparsercsfile (rcs, (FILE **) NULL, (struct rcsbuffer *) NULL);
p = findnode (rcs->versions, xrev);
free (xrev);
if (p == NULL)
return (NULL);
vers = (RCSVers *) p->data;
/* Tentatively use this revision */
cur_rev = vers->version;
/* If no branches list, return now. This is what happens if the branch
is a (magic) branch with no revisions yet. */
if (vers->branches == NULL)
return xstrdup (cur_rev);
/* walk the branches list looking for the branch number */
xbranch = xmalloc (strlen (branch) + 1 + 1); /* +1 for the extra dot */
(void) strcpy (xbranch, branch);
(void) strcat (xbranch, ".");
for (p = vers->branches->list->next; p != vers->branches->list; p =
p->next)
if (strncmp (p->key, xbranch, strlen (xbranch)) == 0)
break;
free (xbranch);
if (p == vers->branches->list)
{
/* This is what happens if the branch is a (magic) branch with
no revisions yet. Similar to the case where vers->branches ==
NULL, except here there was a another branch off the same
branchpoint. */
return xstrdup (cur_rev);
}
/* if we get here, it means that somehow */
/* we didn't find our branch. I'm not sure _how_ we can get here... */
return(NULL);
}
__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/