# # # add_dir "tests/warn_on_weird_branch_names" # # add_file "tests/warn_on_weird_branch_names/__driver__.lua" # content [28335819f62ef233f16b9eca53cc518addeefba0] # # patch "NEWS" # from [f35be225a248b0365a615ae2cb7ebf9e670ec5c7] # to [073fce5a18909977325ac839f297708eefbd175b] # # patch "database.cc" # from [8d0e1cf1db07ba61bd878f65a9e36da81db25bfd] # to [952142c0f95ce957b3d4b55f26c1d035794b60eb] # # patch "monotone.texi" # from [052708a573fa282057916ea145b1b4df34c22e3c] # to [ef8a5a77add25ad77eb1c135a73b504846878ed7] # ============================================================ --- tests/warn_on_weird_branch_names/__driver__.lua 28335819f62ef233f16b9eca53cc518addeefba0 +++ tests/warn_on_weird_branch_names/__driver__.lua 28335819f62ef233f16b9eca53cc518addeefba0 @@ -0,0 +1,27 @@ + +mtn_setup() + +addfile("foo", "foofile") +commit() +R=base_revision() + +local branch_map = { + ["com.project"] = 0, + ["com.project.release-1.0"] = 0, + ["-com.project"] = 1, + ["com.project*"] = 1, + ["com.pr?ject"] = 1, + ["com.pr[o]j{e}ct"] = 1, + ["com.project-%20"] = 1, + ["com.project-1,0"] = 1, + ["^com.project!"] = 1 +} + +for branch,res in pairs(branch_map) do + check(mtn("cert", "--", R, "branch", branch), 0, false, true) + if res == 1 then + check(qgrep("contains meta characters", "stderr")) + else + check(not qgrep("contains meta characters", "stderr")) + end +end ============================================================ --- NEWS f35be225a248b0365a615ae2cb7ebf9e670ec5c7 +++ NEWS 073fce5a18909977325ac839f297708eefbd175b @@ -57,6 +57,19 @@ Xxx Xxx 99 99:99:99 UTC 2010 commands such as `clone`, `automate remote` and `automate remote_stdio`. + - The following characters have been deprecated in branch names + + ?,*%+{}[]!^ + + as they denote either meta characters in monotone's URI syntax + or are used in globs to resolve branch patterns. + Furthermore, branch names should no longer start with a dash + (-), since this character is used to denote an exclude pattern + in the aforementioned URI syntax. + + monotone warns on the creation of branches which violate these + restrictions and gives further directions. + - The `import` command now keeps the created bookkeeping root if --dry-run is not specified. This makes it possible to re-use the import directory as workspace and is also more closely ============================================================ --- database.cc 8d0e1cf1db07ba61bd878f65a9e36da81db25bfd +++ database.cc 952142c0f95ce957b3d4b55f26c1d035794b60eb @@ -3612,6 +3612,24 @@ database::put_revision_cert(cert const & return false; } + if (cert.name() == "branch") + { + string branch_name = cert.value(); + if (branch_name.find_first_of("?,*%%+{}[]!^") != string::npos || + branch_name.find_first_of('-') == 0) + { + W(F("The branch name\n" + " '%s'\n" + "contains meta characters (one or more of '?,*%%+{}[]!^') or\n" + "starts with a dash, which might cause malfunctions when used\n" + "in a netsync branch pattern.\n\n" + "If you want to undo this operation, please use the\n" + "'%s local kill_certs' command to delete the particular branch\n" + "cert and re-add a valid one.") + % cert.value() % prog_name); + } + } + imp->put_cert(cert, "revision_certs"); if (cert.name() == "branch") ============================================================ --- monotone.texi 052708a573fa282057916ea145b1b4df34c22e3c +++ monotone.texi ef8a5a77add25ad77eb1c135a73b504846878ed7 @@ -927,6 +927,8 @@ @section Branches You can see all the available branches using @command{mtn list branches}. address@hidden Heads and merging + Branches are indicated with certs. The cert name @code{branch} is reserved for use by monotone, for the purpose of identifying the revisions which are members of a branch. A @code{branch} cert has a @@ -1046,12 +1048,12 @@ @subsection Branch Names world. Otherwise, bad things can happen. Fortunately, we have a handy source of globally unique names --- the DNS system. -When naming a branch, always prepend the reversed, fully qualified, domain name of a host that -you control or are otherwise authorized to use. For example, monotone -development happens on the branch @code{net.venge.monotone}, because address@hidden belongs to monotone's primary author. The idea is that -this way, you can coordinate with other people using a host to make sure -there are no conflicts --- in the example, monotone's primary author can +When naming a branch, always prepend the reversed, fully qualified, domain +name of a host that you control or are otherwise authorized to use. For +example, monotone development happens on the branch @code{net.venge.monotone}, +because @code{venge.net} belongs to monotone's original author. The idea is +that this way, you can coordinate with other people using a host to make sure +there are no conflicts --- in the example, monotone's original author can be certain that no-one else using @code{venge.net} will start up a different program named @code{monotone}. If you work for Yoyodyne, Inc. (owners of yoyodyne.com), then all your branch names should look @@ -1061,10 +1063,23 @@ @subsection Branch Names usually the first part is the project name (the @code{monotone} in @code{net.venge.monotone}), and then possibly more stuff after that to describe a particular branch. For example, monotone's win32 support -was initially developed on the branch @code{net.venge.monotone.win32}. +was initially developed on the branch @code{net.venge.monotone.win32} +(for more information, see @ref{Naming Conventions}). -(For more information, see @ref{Naming Conventions}.) +It has to be noted that earlier versions of monotone enforced no restrictions +on branch names. Newer versions, starting with 0.99, exclude a set of control +characters though, which mostly denote either meta characters in monotone's +URI syntax or are used in globs to resolve branch patterns. These characters are address@hidden, @code{,}, @code{*}, @code{%}, @code{+}, @address@hidden, @address@hidden, @code{[}, address@hidden, @code{!} and @code{^}. Additionally, @code{-} is deprecated as first +character of a branch name, since it is used to denote branch exclude patterns +in the aforementioned URI syntax. +monotone warns on the creation of branch names which violate one of the above +restrictions and gives further directions. Future versions of monotone are +likely to enforce these restrictions by disallowing such branch names completely. + + @page @node Tutorial, Advanced Uses, Concepts, Top @chapter Tutorial