(Steve Dougherty)
2013-06-10: Return inserted URI on create and push. Return inserted URI on create and push.
diff --git a/infocalypse/infcmds.py b/infocalypse/infcmds.py
--- a/infocalypse/infcmds.py
+++ b/infocalypse/infcmds.py
@@ -495,8 +495,12 @@ def is_redundant(uri):
############################################################
# User feedback? success, failure?
def execute_create(ui_, repo, params, stored_cfg):
- """ Run the create command. """
+ """
+ Run the create command.
+ Return the URIs the repo was inserted to, or None in the case of an error.
+ """
update_sm = None
+ inserted_to = None
try:
update_sm = setup(ui_, repo, params, stored_cfg)
# REDFLAG: Do better.
@@ -516,9 +520,9 @@ def execute_create(ui_, repo, params, st
run_until_quiescent(update_sm, params['POLL_SECS'])
if update_sm.get_state(QUIESCENT).arrived_from(((FINISHING,))):
+ inserted_to = update_sm.get_state(INSERTING_URI).get_request_uris()
ui_.status("Inserted to:\n%s\n" %
- '\n'.join(update_sm.get_state(INSERTING_URI).
- get_request_uris()))
+ '\n'.join(inserted_to))
else:
ui_.status("Create failed.\n")
@@ -526,6 +530,8 @@ def execute_create(ui_, repo, params, st
finally:
cleanup(update_sm)
+ return inserted_to
+
# REDFLAG: LATER: make this work without a repo?
def execute_copy(ui_, repo, params, stored_cfg):
""" Run the copy command. """
@@ -606,10 +612,14 @@ def execute_reinsert(ui_, repo, params,
cleanup(update_sm)
def execute_push(ui_, repo, params, stored_cfg):
- """ Run the push command. """
+ """
+ Run the push command.
+ Return the URIs the repo was inserted to if it changed, or None otherwise.
+ """
assert params.get('REQUEST_URI', None) is None
update_sm = None
+ inserted_to = None
try:
update_sm = setup(ui_, repo, params, stored_cfg)
request_uri, is_keypair = do_key_setup(ui_, update_sm, params,
@@ -626,9 +636,9 @@ def execute_push(ui_, repo, params, stor
run_until_quiescent(update_sm, params['POLL_SECS'])
if update_sm.get_state(QUIESCENT).arrived_from(((FINISHING,))):
+ inserted_to = update_sm.get_state(INSERTING_URI).get_request_uris()
ui_.status("Inserted to:\n%s\n" %
- '\n'.join(update_sm.get_state(INSERTING_URI).
- get_request_uris()))
+ '\n'.join(inserted_to))
else:
extra = ''
if update_sm.ctx.get('UP_TO_DATE', False):
@@ -639,6 +649,8 @@ def execute_push(ui_, repo, params, stor
finally:
cleanup(update_sm)
+ return inserted_to
+
def execute_pull(ui_, repo, params, stored_cfg):
""" Run the pull command. """
update_sm = None