#
# add_file "tests/t_setup_checkout_modify_new_dir.at"
#
# add_file "tests/t_update_off_branch.at"
#
# patch "ChangeLog"
# from [17843e67fe34252032e29f3d4b4d639fccf91d55]
# to [41f028c591c054cdc72ebcc3837baa8abc671896]
#
# patch "commands.cc"
# from [49781d677513ee9c26814e3111c8f12ff2d515b5]
# to [958cd3bbc982aef81f63b90b24dcebaddf135166]
#
# patch "tests/t_setup_checkout_modify_new_dir.at"
# from []
# to [d3861a3bdaf6b55792cb14000ab5e79f6b00d82b]
#
# patch "tests/t_update_off_branch.at"
# from []
# to [951445e014367f691ff2d44c2018ec13a24daf7b]
#
# patch "testsuite.at"
# from [9dd9341aff7611ddac4fd64b48ed17a46ed6f69e]
# to [03503ada6caff92de4120e9248a98cfacf60862d]
#
--- ChangeLog
+++ ChangeLog
@@ -1,5 +1,14 @@
2005-04-13 Nathaniel Smith
+ * tests/t_setup_checkout_modify_new_dir.at:
+ * tests/t_update_off_branch.at: New tests.
+ * testsuite.at: Add them.
+
+ * commands.cc (checkout): Tweak branch checking logic.
+ (update): Make user explicitly switch branches.
+
+2005-04-13 Nathaniel Smith
+
* rcs_import.cc (import_cvs_repo): Check that user isn't trying to
import a whole CVS repo.
* tests/t_cvsimport.at: Test new check.
--- commands.cc
+++ commands.cc
@@ -1797,26 +1797,24 @@
cert_value b;
guess_branch(ident, app, b);
}
+ {
+ I(!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(ident, branch_cert_name, branch_encoded, certs);
+
+ L(F("found %d %s branch certs on revision %s\n")
+ % certs.size()
+ % app.branch_name
+ % ident);
+
+ N(certs.size() != 0, F("revision %s is not a member of branch %s\n")
+ % ident % app.branch_name);
+ }
- if (!app.branch_name().empty())
- {
- app.make_branch_sticky();
- cert_value branch_name(app.branch_name());
- base64 branch_encoded;
- encode_base64(branch_name, branch_encoded);
-
- vector< revision > certs;
- app.db.get_revision_certs(ident, branch_cert_name, branch_encoded, certs);
-
- L(F("found %d %s branch certs on revision %s\n")
- % certs.size()
- % app.branch_name
- % ident);
-
- N(certs.size() != 0, F("revision %s is not a member of branch %s\n")
- % ident % app.branch_name);
- }
-
app.create_working_copy(dir);
}
@@ -3151,8 +3149,24 @@
P(F("already up to date at %s\n") % r_old_id);
return;
}
+
+ P(F("selected update target %s\n") % r_chosen_id);
- 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);
+
+ 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);
+ }
+
app.db.get_revision_manifest(r_chosen_id, m_chosen_id);
app.db.get_manifest(m_chosen_id, m_chosen);
--- tests/t_setup_checkout_modify_new_dir.at
+++ tests/t_setup_checkout_modify_new_dir.at
@@ -0,0 +1,30 @@
+AT_SETUP([setup/checkout touch new MT/options only])
+MONOTONE_SETUP
+
+ADD_FILE(foo, [blah blah
+])
+COMMIT(testbranch)
+
+# okay, now wd is on testbranch
+
+# setup a dir on otherbranch and make sure we stay on testbranch
+AT_CHECK(MONOTONE setup setupdir --branch=otherbranch, [], [ignore], [ignore])
+SET_FILE(foo, [stuff stuff
+])
+AT_CHECK(MONOTONE commit --message=foo, [], [ignore], [ignore])
+CHECK_SAME_STDOUT(BASE_REVISION, MONOTONE automate heads testbranch)
+
+# now create a revision in otherbranch...
+AT_DATA(setupdir/blah, [yum yum
+])
+AT_CHECK(cd setupdir && MONOTONE add blah, [], [ignore], [ignore])
+AT_CHECK(cd setupdir && MONOTONE commit --message=foo, [], [ignore], [ignore])
+# and check it out
+AT_CHECK(MONOTONE checkout codir --branch=otherbranch, [], [ignore], [ignore])
+# and make sure we still stayed on testbranch
+SET_FILE(foo, [more more
+])
+AT_CHECK(MONOTONE commit --message=foo, [], [ignore], [ignore])
+CHECK_SAME_STDOUT(BASE_REVISION, MONOTONE automate heads testbranch)
+
+AT_CLEANUP
--- tests/t_update_off_branch.at
+++ tests/t_update_off_branch.at
@@ -0,0 +1,18 @@
+AT_SETUP([update to off-branch rev])
+MONOTONE_SETUP
+
+ADD_FILE(testfile, [blah blah
+])
+COMMIT(testbranch)
+TR=`BASE_REVISION`
+
+SET_FILE(testfile, [other other
+])
+COMMIT(otherbranch)
+OR=`BASE_REVISION`
+
+AT_CHECK(MONOTONE checkout --branch=testbranch $TR codir, [], [ignore], [ignore])
+AT_CHECK(cd codir && MONOTONE update $OR, [1], [ignore], [ignore])
+AT_CHECK(cd codir && MONOTONE update --branch=otherbranch $OR, [], [ignore], [ignore])
+
+AT_CLEANUP
--- testsuite.at
+++ testsuite.at
@@ -548,3 +548,5 @@
m4_include(tests/t_cvsimport_samelog.at)
m4_include(tests/t_sticky_branch.at)
m4_include(tests/t_checkout_id_sets_branch.at)
+m4_include(tests/t_update_off_branch.at)
+m4_include(tests/t_setup_checkout_modify_new_dir.at)