/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: 2014-02-26 19:10:31 UTC
  • Revision ID: tim@ed.am-20140226191031-elcqy5j09h2syn2j
moved copy-in, copy-out and deployment conflict checking to a set of "walkers";
bzr vcs back-end now parses affected files during update; deployment state now
includes affected files

Show diffs side-by-side

added added

removed removed

1
 
# update.py
 
1
# command_update.py
2
2
#
3
3
# Copyright (C) 2014 Tim Marston <tim@edm.am>
4
4
#
20
20
 
21
21
 
22
22
import sys, re, getopt
23
 
from command import Command
24
 
import stdhome.the as the
25
 
from stdhome.deployment import Deployment
26
 
 
27
 
 
28
 
class UpdateCommand( Command ):
 
23
import the
 
24
from deployment import Deployment
 
25
 
 
26
 
 
27
class CommandUpdate:
29
28
 
30
29
 
31
30
        def __init__( self ):
72
71
                                                'invalid repository name: ' + optarg )
73
72
                                self.repo = optarg
74
73
                        elif opt in [ '--verbose', '-v' ]:
75
 
                                the.verbose += 1
 
74
                                the.verbose = True
76
75
                        elif opt == "--help":
77
76
                                self.print_help()
78
77
                
90
89
                the.set_repo( self.repo )
91
90
                the.repo.check_dir_exists()
92
91
 
93
 
                # initialise deployment (and check it)
 
92
                # initialise deployment (check it's valid)
94
93
                deployment = Deployment()
95
94
                deployment.check_ongoing( False )
96
95
 
107
106
                except deployment.CopyInConflicts as e:
108
107
                        raise the.program.FatalError(
109
108
                                'Files in %s differ too severly from %s:\n  %s\n' % \
110
 
                                ( the.home_dir, the.repo.dir, '\n  '.join( e.conflicts ) ) )
 
109
                                ( the.fsdir, the.repo.dir, '\n  '.join( e.conflicts ) ) )
111
110
 
112
111
                # perform vcs update
113
112
                if the.verbose: print "updating %s" % the.repo.dir
118
117
                # check for conflicts in repo
119
118
                files = the.repo.vcs.get_conflicts()
120
119
                if files:
121
 
                        message += 'conflicts in %s:\n  %s' % \
 
120
                        message += 'Conflicts in %s:\n  %s' % \
122
121
                                           ( the.repo.name, '\n  '.join( files ) )
123
122
 
124
123
                # check for deployment conclicts
125
124
                conflicts = deployment.get_conflicts( updated_files )
126
125
                if conflicts:
127
 
                        message += 'deployment conflicts:\n  %s' % \
 
126
                        message += 'Deployment conflicts:\n  %s' % \
128
127
                                           '\n  '.join( conflicts )
129
128
 
130
129
                # stop if there are conflicts
131
130
                if message:
132
131
                        raise the.program.FatalError(
133
132
                                'there were conflicts...\n' + message )
 
133
 
134
134
                # copy-out changes from repo
135
135
                deployment.copy_out()
136
136