#
#
# patch "ChangeLog"
# from [93d76946e23624c4eb829ed3da6ef24739d06a9c]
# to [925d81d543463205ddb43e9210f2fc5f8926f8c3]
#
# patch "commands.cc"
# from [d016ccfbd6f5a771a3893406ed78fb44f23b0a50]
# to [57f48ca9b6cb4aefe356d5061c727b6fa6d0c923]
#
============================================================
--- ChangeLog 93d76946e23624c4eb829ed3da6ef24739d06a9c
+++ ChangeLog 925d81d543463205ddb43e9210f2fc5f8926f8c3
@@ -1,5 +1,10 @@
2006-03-22 Matt Johnston
+ * commands.cc (CMD(update)): update the workspace branch
+ to match a revision given with -r.
+
+2006-03-22 Matt Johnston
+
* schema_migration.cc, database.cc: print a more helpful
error message when we fail in calculate_schema_id() (usually
because of locking). Don't bother telling the user what the
============================================================
--- commands.cc d016ccfbd6f5a771a3893406ed78fb44f23b0a50
+++ commands.cc 57f48ca9b6cb4aefe356d5061c727b6fa6d0c923
@@ -2940,21 +2940,52 @@
P(F("selected update target %s\n") % r_chosen_id);
- if (!app.branch_name().empty())
- {
- cert_value branch_name(app.branch_name());
- base64 branch_encoded;
- encode_base64(branch_name, branch_encoded);
-
- vector< revision > certs;
- app.db.get_revision_certs(r_chosen_id, branch_cert_name, branch_encoded, certs);
+ {
+ // figure out which branches the target is in
+ vector< revision > certs;
+ app.db.get_revision_certs(r_chosen_id, branch_cert_name, certs);
+ erase_bogus_certs(certs, app);
- N(certs.size() != 0,
- F("revision %s is not a member of branch %s\n"
- "try again with explicit --branch\n")
- % r_chosen_id % app.branch_name);
- }
+ set< utf8 > branches;
+ for (vector< revision >::const_iterator i = certs.begin();
+ i != certs.end(); i++)
+ {
+ cert_value b;
+ decode_base64(i->inner().value, b);
+ branches.insert(utf8(b()));
+ }
+ if (branches.find(app.branch_name) != branches.end())
+ {
+ L(FL("using existing branch %s") % app.branch_name());
+ }
+ else
+ {
+ if (branches.size() > 1)
+ {
+ // multiple non-matching branchnames
+ string branch_list;
+ for (set::const_iterator i = branches.begin();
+ i != branches.end(); i++)
+ branch_list += "\n" + (*i)();
+ N(false, F("revision %s is a member of the following branches,\ntry again with explicit --branch\n%s") % r_chosen_id % branch_list);
+ }
+ else if (branches.size() == 1)
+ {
+ // one non-matching, inform and update
+ app.branch_name = (*(branches.begin()))();
+ P(F("revision %s is a member of\n%s, updating workspace branch")
+ % r_chosen_id % app.branch_name());
+ }
+ else
+ {
+ I(branches.size() == 0);
+ W(F("revision %s is a member of no branches,\nusing branch %s for workspace")
+ % r_chosen_id % app.branch_name());
+ }
+ }
+ }
+
app.db.get_roster(r_chosen_id, chosen_roster, chosen_mm);
std::set