/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/command/update.py

  • Committer: Tim Marston
  • Date: 2016-02-13 14:18:32 UTC
  • Revision ID: tim@ed.am-20160213141832-o0odt4p3nuj97211
switched init command (and update command) to checking for conflicts prior to
deployment.copy_out(), and removed remaining references to CopyInConflict
(supposedly done in r24)

Show diffs side-by-side

added added

removed removed

28
28
class UpdateCommand( Command ):
29
29
 
30
30
 
31
 
        def __init__( self ):
32
 
                self.repo = None
33
 
 
34
 
 
35
31
        def print_help( self ):
36
32
                print "Usage: " + the.program.name + " update [--repo=REPO]"
37
33
                print
48
44
                print "Conflicts that arise from files already existing in your home directory must be"
49
45
                print "dealt with by moving those files aside (currently)."
50
46
                print
51
 
                print "You can resume the redeployment of your repository by typing:"
 
47
                print "After a failed update, you can list outstanding conflicts by typing:"
 
48
                print "    " + the.program.name + " conflicts"
 
49
                print
 
50
                print "After fixing outstanding conflicts, you can re-attempt the redeployment of"
 
51
                print "your repository by typing:"
52
52
                print "    " + the.program.name + " resolve"
53
53
                print
54
 
                print "You can list outstanding conflicts by typing:"
55
 
                print "    " + the.program.name + " conflicts"
 
54
                print "To back out of trying to update and revert the local repository, type:"
 
55
                print "    " + the.program.name + " stage-revert"
56
56
                print
57
57
                print "Options:"
58
58
                print "  -r, --repo=REPO  select the repo to check-out or create (defaults to 'home')"
70
70
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
71
71
                                        raise the.program.FatalError(
72
72
                                                'invalid repository name: ' + optarg )
73
 
                                self.repo = optarg
74
 
                        elif opt in [ '--verbose', '-v' ]:
75
 
                                the.verbose += 1
 
73
                                the.repo = optarg
76
74
                        elif opt == "--help":
77
75
                                self.print_help()
78
 
                
 
76
 
79
77
                # discard first argument (the command)
80
78
                args.pop( 0 )
81
79
 
87
85
        def run( self ):
88
86
 
89
87
                # set up repo and check it exists
90
 
                the.set_repo( self.repo )
91
88
                the.repo.check_dir_exists()
92
89
 
93
90
                # initialise deployment (and check it)
98
95
                if the.repo.vcs.has_changes():
99
96
                        raise the.program.FatalError(
100
97
                                'repo has local changes: %s\n'
101
 
                                'Hint: see "%s stage-revert --help"' % 
 
98
                                'Hint: see "%s stage-revert --help"' %
102
99
                                ( the.repo.name, the.program.name ) )
103
100
 
104
101
                # copy-in changes to repo
105
 
                try:
106
 
                        deployment.copy_in()
107
 
                except deployment.CopyInConflicts as e:
108
 
                        raise the.program.FatalError(
109
 
                                'Files in %s differ too severly from %s:\n  %s\n' % \
110
 
                                ( the.hdir, the.repo.dir, '\n  '.join( e.conflicts ) ) )
 
102
                deployment.copy_in()
111
103
 
112
104
                # perform vcs update
113
 
                if the.verbose: print "updating %s" % the.repo.dir
 
105
                if the.verbose >= 1: print "updating %s" % the.repo.dir
114
106
                updated_files = the.repo.vcs.update()
115
107
 
116
108
                message = ''
118
110
                # check for conflicts in repo
119
111
                files = the.repo.vcs.get_conflicts()
120
112
                if files:
121
 
                        message += 'Conflicts in %s:\n  %s' % \
 
113
                        message += 'conflicts in %s:\n  %s' % \
122
114
                                           ( the.repo.name, '\n  '.join( files ) )
123
115
 
124
116
                # check for deployment conclicts
125
117
                conflicts = deployment.get_conflicts( updated_files )
126
118
                if conflicts:
127
 
                        message += 'Deployment conflicts:\n  %s' % \
 
119
                        message += 'deployment conflicts:\n  %s' % \
128
120
                                           '\n  '.join( conflicts )
129
121
 
130
122
                # stop if there are conflicts
135
127
                deployment.copy_out()
136
128
 
137
129
                # now we've copied-out, revert any copied-in changes!
138
 
                if the.verbose: print "reverting %s" % the.repo.dir
 
130
                if the.verbose >= 1: print "reverting %s" % the.repo.dir
139
131
                the.repo.vcs.revert()