/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_resolve.py

  • Committer: Tim Marston
  • Date: 2014-03-08 00:40:42 UTC
  • Revision ID: tim@ed.am-20140308004042-j5rco14bjp3teegj
updated .bzrignore

Show diffs side-by-side

added added

removed removed

1
 
# resolve.py
 
1
# command_resolve.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 ResolveCommand( Command ):
 
23
import the
 
24
from deployment import Deployment
 
25
 
 
26
 
 
27
class CommandResolve:
 
28
 
 
29
 
 
30
        def __init__( self ):
 
31
                self.repo = None
29
32
 
30
33
 
31
34
        def print_help( self ):
59
62
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
60
63
                                        raise the.program.FatalError(
61
64
                                                'invalid repository name: ' + optarg )
62
 
                                the.repo = optarg
 
65
                                self.repo = optarg
63
66
                        elif opt in [ '--verbose', '-v' ]:
64
 
                                the.verbose += 1
 
67
                                the.verbose = True
65
68
                        elif opt == "--help":
66
69
                                self.print_help()
67
70
                
76
79
        def run( self ):
77
80
 
78
81
                # set up repo and check it exists
 
82
                the.set_repo( self.repo )
79
83
                the.repo.check_dir_exists()
80
84
 
81
85
                # initialise deployment (check it's valid)
87
91
                # check for conflicts in repo
88
92
                files = the.repo.vcs.get_conflicts()
89
93
                if files:
90
 
                        message += 'conflicts in %s:\n  %s' % \
 
94
                        message += 'Conflicts in %s:\n  %s' % \
91
95
                                           ( the.repo.name, '\n  '.join( files ) )
92
96
 
93
97
                # check for deployment conclicts
94
98
                conflicts = deployment.get_conflicts()
95
99
                if conflicts:
96
 
                        message += 'deployment conflicts:\n  %s' % \
 
100
                        message += 'Deployment conflicts:\n  %s' % \
97
101
                                           '\n  '.join( conflicts )
98
102
 
99
103
                # stop if there are conflicts
105
109
                deployment.copy_out()
106
110
 
107
111
                # now we've copied-out, revert any copied-in changes!
108
 
                if the.verbose >= 1: print "reverting %s" % the.repo.dir
 
112
                if the.verbose: print "reverting %s" % the.repo.dir
109
113
                the.repo.vcs.revert()