Changeset 296 in tailor


Ignore:
Timestamp:
05/10/05 11:47:07 (8 years ago)
Author:
Markus Schiltknecht <markus@…>
Hash name:
20050510094707-ff256-0a3d206aa9a7826918def462dff861a1b3bedd6b
Message:

Revised monotone support, merging with Riccardo patch
My --monotone_db and --monotone_branch options disappeared. The monotone
setup command now has to be called by the user. What I don't like about
this is: the user either

a) has to start tailor.py -b -t monotone ... first, get an error

message, invoke monotone setup in the correct directory and then
start tailor.py again. Or

b) he creates the directories which tailor creates himself and prepares

monotone setup there, then launches tailor.py.

With a) you have to cvs update && cvs rlog twice (in case of a CVS
source) which takes a lot of time and networking bandwith. It's obvious
that this isn't a nice way to go. b) requires a lot of knowledge from
the user. This could be documented, but options for tailor would be
nicer, IMHO.

Then there was the problem of monotone beeing called outside of it's
working copy for the very first commit during bootstrap. Riccardo has
solved that by not touching the MT/log but adding a --message options to
monotone. That's nice, too. I've come up with another solution: instead
of monotone commit $SUBDIR we can change to $SUBDIR and issue a plain
monotone commit there. So if MonotoneCommit? misses the MT directory it
now checks if only one entry (the subdir) was given. In that case it
changes the working directory to that subdir and commits there. That
solution now works with monotone-0.19 and seems better to me (we never
call monotone outside its working copy).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/monotone.py

    r291 r296  
    1818 
    1919class MonotoneCommit(SystemCommand): 
    20     COMMAND = "MONOTONE_AUTHOR=\"%(key)s\" monotone commit --date=\"%(date)s\" %(entries)s" 
     20    COMMAND = "monotone commit --author=\"%(key)s\" --date=\"%(date)s\"" 
    2121 
    2222    def __call__(self, output=None, dry_run=False, **kwargs): 
     23 
     24        from os.path import exists, join 
     25 
     26        if not exists(join(self.working_dir, 'MT')): 
     27            # If MonotoneCommit is called outside the working copy 
     28            # (i.e. there is no MT directory) we test if we are given 
     29            # only the subdir as entry to commit. In that case, switch 
     30            # to root/subdir as working directory and issue a commit 
     31            # without any entries. 
     32             
     33            entries = kwargs['entries'] 
     34            entries = entries.replace(' ', '') 
     35            entries = entries.strip('\"') 
     36            if (exists(join(self.working_dir, entries))): 
     37                self.working_dir = join(self.working_dir, entries) 
     38                kwargs['entries'] = "" 
     39            else: 
     40                raise TargetInitializationFailure("not a valid monotone working copy (MT directory is missing in %s)" % self.working_dir) 
     41 
    2342        log = open(self.working_dir + "/MT/log", "w"); 
    2443 
     
    4059 
    4160 
    42 class MonotoneWorkingDir(UpdatableSourceWorkingDir, SyncronizableTargetWorkingDir): 
     61class MonotoneWorkingDir(SyncronizableTargetWorkingDir): 
    4362 
    4463    ## SyncronizableTargetWorkingDir 
     
    6382        else: 
    6483            entries = '.' 
    65              
    66         c(key=author, logmessage=changelog, date=date, entries=entries) 
    6784 
     85        # monotone doesn't like empty changelogs ... 
     86        if changelog == None or len(changelog)<1: 
     87            if len(remark)>0: 
     88                changelog = remark 
     89            else: 
     90                changelog = "**** empty log message ****" 
     91        changelog = changelog.replace('"', '\\"') 
     92         
     93        # monotone date must be expressed as ISO8601  
     94        outstr = c(output=True, key=author, logmessage=changelog, 
     95                   date=date.isoformat(), entries=entries) 
     96 
     97        # monotone complaints if there are no changes from the last commit. 
     98        # we ignore those errors ... 
    6899        if c.exit_status: 
    69             raise TargetInitializationFailure( 
    70                 "'monotone commit returned %s" % c.exit_status) 
     100           if outstr.getvalue().find("monotone: misuse: no changes to commit") == -1: 
     101               outstr.close() 
     102               raise TargetInitializationFailure( 
     103                  "'monotone commit returned %s" % c.exit_status) 
     104        outstr.close()       
    71105         
    72106    def _removePathnames(self, root, names): 
     
    88122    def _initializeWorkingDir(self, root, repository, module, subdir): 
    89123        """ 
    90         Execute `monotone setup`. 
     124        Setup the monotone working copy 
     125         
     126        The user must setup a monotone working directory himself. Then 
     127        we simply use 'monotone commit', without having to specify a database 
     128        file or branch. Monotone looks up the database and branch in it's MT 
     129        directory. 
    91130        """ 
    92131 
    93         from os.path import join 
     132        from os.path import exists, join 
    94133         
    95         c = SystemCommand(working_dir=root, command="monotone setup .") 
    96         c(output=True) 
     134        if not exists(join(root, subdir, 'MT')): 
     135            raise TargetInitializationFailure("Please setup %s as a monotone working directory." % root) 
    97136 
    98         if c.exit_status: 
    99             raise TargetInitializationFailure( 
    100                 "'monotone setup' returned status %s" % c.exit_status) 
    101  
    102         c = SystemCommand(working_dir=root, 
     137        c = SystemCommand(working_dir=join(root, subdir), 
    103138                          command="monotone add %(names)s") 
    104         c(names=shrepr(subdir)) 
     139        c(names='.') 
Note: See TracChangeset for help on using the changeset viewer.