Skip to content

Conversation

@billsacks
Copy link
Member

Two related changes here:

  1. For any failed command run via execute_subprocess, print more
    information about the problem to stdout

  2. After doing an svn switch, check the status of the resulting
    repository; if dirty, abort with a helpful message

The immediate purpose of both of these is to give more helpful error
messages if there are failures due to the presence of untracked files,
now that we attempt a checkout even if there are untracked files (via
#57). If there is an
untracked file in the working directory that would get overwritten by a
tracked file in the new version:

  • git aborts the checkout with an error code; the new information
    printed by (1) will help users in this case

  • svn attempts the checkout and returns a 0 error status, but may
    leave you in a conflict state; we check this via (2)

Note that (2) should never happen currently (due to the up-front
conservative check of the repository status, which doesn't even allow
untracked files), but it will become possible after
#57.

User interface changes?: No

Testing:
new unit tests added for some utility functions
unit tests: pass
system tests: pass
manual testing: For both git and svn, tested having an untracked file
in the working directory that gets overwritten after checking out a
new branch; did this testing on top of the changes in
#57

Here is sample output when git refuses to do the checkout:

Processing externals description file : CESM.cfg
Checking status of externals: clm, mosart, ww3, cime, cice, pop, cism, rtm, cam, cime_config,
Checking out externals: clm, mosart, ww3, cime,
ERROR: Failed with output:
    error: The following untracked working tree files would be overwritten by checkout:
    	LICENSE.TXT
    Please move or remove them before you switch branches.
    Aborting

ERROR: In directory
    /Users/sacks/cesm_code/cesm/cime
Process did not run successfully; returned status 1:
    git checkout cime5.4.0-alpha.03
See above for output from failed command.
Please check the log file manage_externals.log for more details.

And for svn:

Processing externals description file : CESM.cfg
Checking status of externals: clm, mosart, ww3, cime, cice, pop, cism, rtm, cam, cime_config,
Checking out externals: clm,
ERROR: In directory
    /Users/sacks/cesm_code/cesm/components/clm

svn status now shows:
    X       /Users/sacks/cesm_code/cesm/components/clm/src/fates
    ?       /Users/sacks/cesm_code/cesm/components/clm/testfile
    X       /Users/sacks/cesm_code/cesm/components/clm/tools/PTCLM
    D     C /Users/sacks/cesm_code/cesm/components/clm/tools/mksurfdata_map/src/test/mkgridmap_test
          >   local dir unversioned, incoming dir add upon switch
    D       /Users/sacks/cesm_code/cesm/components/clm/tools/mksurfdata_map/src/test/mkgridmap_test/CMakeLists.txt
    D       /Users/sacks/cesm_code/cesm/components/clm/tools/mksurfdata_map/src/test/mkgridmap_test/test_mkgridmap.pf

    Performing status on external item at 'src/fates':

    Performing status on external item at 'tools/PTCLM':
    Summary of conflicts:
      Tree conflicts: 1


ERROR: Expected clean state following switch

One possible cause of this problem is that there may have been untracked
files in your working directory that had the same name as tracked files
in the new revision.

To recover: Clean up the above directory (resolving conflicts, etc.),
then rerun checkout_externals.

The main motivation is to echo the git error message if a checkout
results in an error (e.g., due to a conflict between an untracked file
in the working directory and a tracked file in the new sha).
Unlike git, we cannot rely on the return status here; instead, we need
to check 'svn status' following the switch.

This is to signal to the user if there was an problem in doing the
switch, such as a conflict in the final state. This can happen if you
had an untracked file in the working directory with the same name as a
tracked file in the new revision.
manic/utils.py Outdated
Returns a string containing the last n lines of the_string
If truncation_message is provided, the returned string begins with
the given message if and only if the string is less than n lines to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'less' --> 'greater'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

@billsacks
Copy link
Member Author

I installed autopep8, so will take a stab at fixing the lint problems

@billsacks
Copy link
Member Author

Okay, autopep8 and pylint problems fixed now, I think

@coveralls
Copy link

coveralls commented Jan 10, 2018

Coverage Status

Coverage decreased (-0.3%) to 93.178% when pulling 290c205 on billsacks:print_command_error into 2e0de46 on NCAR:master.

@bandre-ucar bandre-ucar merged commit 290c205 into ESMCI:master Jan 18, 2018
@billsacks billsacks deleted the print_command_error branch January 18, 2018 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants