/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-03-19 20:02:10 UTC
  • Revision ID: tim@ed.am-20140319200210-b6nm63rpktfmw0l3
changed working of output

Show diffs side-by-side

added added

removed removed

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