diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-11-29 23:04:26 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-11-29 23:04:26 +0000 |
commit | 6507be4290a65c0ad7bbd614325e0b6f97c2446f (patch) | |
tree | 5a7fd64cc583ec8fa84bad757f252582c715355b | |
parent | f910dc73d3a67ef559de0febb027a2df73eeaca4 (diff) | |
download | tor-6507be4290a65c0ad7bbd614325e0b6f97c2446f.tar.gz tor-6507be4290a65c0ad7bbd614325e0b6f97c2446f.zip |
Implement new version format for post 0.1.
svn:r3022
-rw-r--r-- | doc/TODO | 2 | ||||
-rw-r--r-- | src/or/or.h | 41 | ||||
-rw-r--r-- | src/or/routerparse.c | 22 | ||||
-rw-r--r-- | src/or/test.c | 16 |
4 files changed, 70 insertions, 11 deletions
@@ -20,7 +20,7 @@ N - pump up periods for fetching things; figure out how to do this get the right behavior. - If dirport is set, we should have a maximum dirfetchperiod and a maximum statusfetchperiod, or else we'll serve very stale stuff. -N - Adapt version parsing code to handle new version scheme; document new + o Adapt version parsing code to handle new version scheme; document new version scheme. N&R. make loglevels info,debug less noisy R - fix dfc/weasel's intro point bug diff --git a/src/or/or.h b/src/or/or.h index 87fab798cd..3f39f3d938 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1614,13 +1614,52 @@ void clear_trusted_dir_servers(void); /********************************* routerparse.c ************************/ +#define MAX_STATUS_TAG_LEN 32 +/** Structure to hold parsed Tor versions. This is a little messier + * than we would like it to be, because we changed version schemes with 0.1.0. + * + * Before 0.1.0, versions were of the format: + * MAJOR.MINOR.MICRO(status(PATCHLEVEL))?(-cvs)? + * where MAJOR, MINOR, MICRO, and PATCHLEVEL are numbers, status is one of + * "pre" (for an alpha release), "rc" (for a release candidate), or "." for a + * release. As a special case, "a.b.c" was equivalent to "a.b.c.0". We + * compare the elements in order (major, minor, micro, status, patchlevel, + * cvs), with "cvs" preceding non-cvs. + * + * We would start each development branch with a final version in mind: say, + * "0.0.8". Our first pre-release would be "0.0.8pre1", followed by (for + * example) "0.0.8pre2-cvs", "0.0.8pre2", "0.0.8pre3-cvs", "0.0.8rc1", + * "0.0.8rc2-cvs", and "0.0.8rc2". Finally, we'd release 0.0.8. The stable + * CVS branch would then be versioned "0.0.8.1-cvs", and any eventual bugfix + * release would be "0.0.8.1". + * + * After 0.1.0, versions are of the format: + * MAJOR.MINOR.MICRO(.PATCHLEVEL([-.]status_tag)?)? + * As before, MAJOR, MINOR, MICRO, and PATCHLEVEL are numbers, with an absent + * number equivalent to 0. All versions _should_ be distinguishable purely by + * those four numbers; the status tag is purely informational. If we *do* + * encounter two versions that differ only by status tag, we compare them + * lexically. + * + * Now, we start each development branch with (say) 0.1.1.1-cvs. The + * patchlevel increments consistently as the status tag changes, for example, + * as in: 0.1.1.2-alpha, 0.1.1.3-cvs, 0.1.1.4-alpha, 0.1.1.5-cvs, 0.1.1.6-rc + * 0.1.1.7-cvs, 0.1.1.8-rc, 0.1.1.9-cvs. Eventually, we release 0.1.1.10. + * The stable CVS repository gets the version 0.1.1.11-maint_cvs; the + * next patch release is 0.1.1.12. + */ typedef struct tor_version_t { int major; int minor; int micro; - enum { VER_PRE=0, VER_RC=1, VER_RELEASE=2 } status; + /** Release status. For version in the post-0.1 format, this is always + * VER_RELEASE. */ + enum { VER_PRE=0, VER_RC=1, VER_RELEASE=2, } status; int patchlevel; + /** CVS status. For version in the post-0.1 format, this is always + * IS_NOT_CVS */ enum { IS_CVS=0, IS_NOT_CVS=1} cvs; + char status_tag[MAX_STATUS_TAG_LEN]; } tor_version_t; int router_get_router_hash(const char *s, char *digest); diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 21d69cbbb2..f9b5879010 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -1440,6 +1440,7 @@ int tor_version_parse(const char *s, tor_version_t *out) */ tor_assert(s); tor_assert(out); + memset(out, 0, sizeof(tor_version_t)); /* Get major. */ @@ -1482,13 +1483,14 @@ int tor_version_parse(const char *s, tor_version_t *out) if (!eos || eos==cp) return -1; cp = eos; - /* Get cvs status. */ - if (!*eos) { - out->cvs = IS_NOT_CVS; - } else if (0==strcmp(cp, "-cvs")) { + /* Get cvs status and status tag. */ + if (*cp == '-' || *cp == '.') + ++cp; + strlcpy(out->status_tag, cp, sizeof(out->status_tag)); + if (0==strcmp(cp, "cvs") && out->major == 0 && out->minor == 0) { out->cvs = IS_CVS; } else { - return -1; + out->cvs = IS_NOT_CVS; } return 0; @@ -1511,9 +1513,11 @@ int tor_version_compare(tor_version_t *a, tor_version_t *b) return i; else if ((i = a->patchlevel - b->patchlevel)) return i; - else if ((i = a->cvs - b->cvs)) - return i; - else - return 0; + + if (a->major > 0 || a->minor > 0) { + return strcmp(a->status_tag, b->status_tag); + } else { + return (a->cvs - b->cvs); + } } diff --git a/src/or/test.c b/src/or/test.c index e1e89c75b6..557c80f878 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -1157,6 +1157,22 @@ test_dir_format(void) test_eq(VER_RELEASE, ver1.status); test_eq(999, ver1.patchlevel); test_eq(IS_NOT_CVS, ver1.cvs); + test_eq(0, tor_version_parse("0.1.2.4-alpha", &ver1)); + test_eq(0, ver1.major); + test_eq(1, ver1.minor); + test_eq(2, ver1.micro); + test_eq(4, ver1.patchlevel); + test_eq(VER_RELEASE, ver1.status); + test_eq(IS_NOT_CVS, ver1.cvs); + test_streq("alpha", ver1.status_tag); + test_eq(0, tor_version_parse("0.1.2.4", &ver1)); + test_eq(0, ver1.major); + test_eq(1, ver1.minor); + test_eq(2, ver1.micro); + test_eq(4, ver1.patchlevel); + test_eq(VER_RELEASE, ver1.status); + test_eq(IS_NOT_CVS, ver1.cvs); + test_streq("", ver1.status_tag); /* make sure is_obsolete_version() works */ test_eq(1, is_obsolete_version("0.0.1", "Tor 0.0.2")); |