--- a/src/modules/client/history.py Wed Sep 08 16:56:50 2010 -0700
+++ b/src/modules/client/history.py Thu Sep 09 18:08:00 2010 -0700
@@ -331,7 +331,8 @@
# Some operations shouldn't be saved -- they're merely
# included in the stack for completeness or to support
# client functionality.
- if op.name not in DISCARDED_OPERATIONS:
+ if op.name not in DISCARDED_OPERATIONS and \
+ value != RESULT_NOTHING_TO_DO:
# Write current history and last operation to a
# file.
self.__save()
--- a/src/modules/client/image.py Wed Sep 08 16:56:50 2010 -0700
+++ b/src/modules/client/image.py Thu Sep 09 18:08:00 2010 -0700
@@ -1910,7 +1910,8 @@
pubs_to_refresh.append(p)
if not pubs_to_refresh:
- self.history.log_operation_end()
+ self.history.log_operation_end(
+ result=history.RESULT_NOTHING_TO_DO)
return
try:
@@ -1952,6 +1953,11 @@
len(succeeded))
self.history.log_operation_end(error=e)
raise e
+
+ if not updated:
+ self.history.log_operation_end(
+ result=history.RESULT_NOTHING_TO_DO)
+ return
self.history.log_operation_end()
def _get_publisher_meta_dir(self):
--- a/src/tests/cli/t_pkg_history.py Wed Sep 08 16:56:50 2010 -0700
+++ b/src/tests/cli/t_pkg_history.py Thu Sep 09 18:08:00 2010 -0700
@@ -56,7 +56,7 @@
pkg5unittest.ManyDepotTestCase.setUp(self, ["test1", "test2"])
rurl1 = self.dcs[1].get_repo_url()
- self.pkgsend_bulk(rurl1, self.foo1)
+ self.pkgsend_bulk(rurl1, (self.foo1, self.foo2))
# Ensure that the second repo's packages are exactly the same
# as those in the first ... by duplicating the repo.
@@ -87,9 +87,9 @@
rurl2 = self.dcs[2].get_repo_url()
commands = [
- ("install foo", 0),
+ ("install foo@1", 0),
+ ("image-update", 0),
("uninstall foo", 0),
- ("image-update", 4),
("set-publisher -O " + rurl2 + " test2", 0),
("set-publisher -P test1", 0),
("set-publisher -m " + rurl2 + " test1", 0),
@@ -100,8 +100,8 @@
operations = [
"install",
+ "image-update",
"uninstall",
- "image-update",
"add-publisher",
"update-publisher",
"set-preferred-publisher",
@@ -133,6 +133,17 @@
raise RuntimeError("Command: %s wasn't recorded,"
" o:%s" % (cmd, o))
+ # Verify that a successful operation with no effect won't
+ # be recorded.
+ self.pkg("purge-history")
+ self.pkg("refresh")
+ self.pkg("history -l")
+ self.assert_(" refresh" not in self.output)
+
+ self.pkg("refresh --full")
+ self.pkg("history -l")
+ self.assert_(" refresh" in self.output)
+
def test_3_purge_history(self):
"""Verify that the purge-history command works as expected.
"""