Changeset 596 in tailor
- Timestamp:
- 08/16/05 22:15:38 (8 years ago)
- Hash name:
- 20050816201538-2c016-42f18a85dee805089e54c56a0acdea806452fc08
- File:
-
- 1 edited
-
vcpx/monotone.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vcpx/monotone.py
r594 r596 12 12 __docformat__ = 'reStructuredText' 13 13 14 from shwrap import ExternalCommand, PIPE, ReopenableNamedTemporaryFile 14 from shwrap import ExternalCommand, PIPE, ReopenableNamedTemporaryFile, STDOUT 15 15 from source import UpdatableSourceWorkingDir, \ 16 16 ChangesetApplicationFailure, GetUpstreamChangesetsFailure 17 17 from target import SyncronizableTargetWorkingDir, TargetInitializationFailure 18 18 from sys import stderr 19 from os.path import exists, join, isdir 20 from os import renames, access, F_OK 19 21 20 22 class MonotoneWorkingDir(SyncronizableTargetWorkingDir): … … 24 26 def _addPathnames(self, names): 25 27 """ 26 Add some new filesystem objects .28 Add some new filesystem objects, skipping directories (directory addition is implicit in monotone) 27 29 """ 30 fnames=[] 31 for fn in names: 32 if isdir(join(self.basedir, fn)): 33 self.log_info("ignoring addition of directory '%s' (%s)" % (fn, join(self.basedir, fn)) ); 34 else: 35 fnames.append(fn) 28 36 29 37 cmd = [self.repository.MONOTONE_CMD, "add"] 30 38 add = ExternalCommand(cwd=self.basedir, command=cmd) 31 add.execute(names) 39 add.execute(fnames) 40 if add.exit_status: 41 raise ChangesetApplicationFailure("%s returned status %s" % (str(add),add.exit_status)) 42 43 def _addSubtree(self, subdir): 44 """ 45 Add a whole subtree 46 """ 47 cmd = [self.repository.MONOTONE_CMD, "add"] 48 add = ExternalCommand(cwd=self.basedir, command=cmd) 49 add.execute(subdir) 50 if add.exit_status: 51 raise ChangesetApplicationFailure("%s returned status %s" % (str(add),add.exit_status)) 32 52 33 53 def _commit(self, date, author, patchname, changelog=None, entries=None): … … 68 88 text = error.read() 69 89 if text.find("monotone: misuse: no changes to commit") == -1: 70 s tderr.write(text)90 self.log_error(text) 71 91 raise ChangesetApplicationFailure( 72 92 "%s returned status %s" % (str(commit),commit.exit_status)) … … 76 96 def _removePathnames(self, names): 77 97 """ 78 Remove some filesystem object. 98 Remove some filesystem object. 79 99 """ 80 100 101 # Monotone currently doesn't allow removing a directory, 102 # so we must remove every item separately and intercept monotone directory errore messages. 103 # We can't just filter the directories, because the wc doesn't contain them anymore ... 81 104 cmd = [self.repository.MONOTONE_CMD, "drop"] 82 105 drop = ExternalCommand(cwd=self.basedir, command=cmd) 83 drop.execute(names) 106 for fn in names: 107 dum, error = drop.execute(fn, stderr=PIPE) 108 if drop.exit_status: 109 if not error.read().find("drop <directory>"): 110 log_error(error.read()) 111 raise ChangesetApplicationFailure("%s returned status %s" % (str(drop),drop.exit_status)) 84 112 85 113 def _renamePathname(self, oldname, newname): … … 87 115 Rename a filesystem object. 88 116 """ 89 117 # this function is called *after* the file/dir has changed name, 118 # and monotone doesn't like it. 119 # we put names back to make it happy ... 120 if access(join(self.basedir, newname), F_OK): 121 if access(join(self.basedir, oldname), F_OK): 122 raise ChangesetApplicationFailure("Can't rename %s to %s. Both names already exist" % (oldname, newname) ) 123 renames(join(self.basedir, newname), join(self.basedir, oldname)) 124 self.log_info("preparing to rename %s->%s" % (oldname, newname)) 125 90 126 cmd = [self.repository.MONOTONE_CMD, "rename"] 91 127 rename = ExternalCommand(cwd=self.basedir, command=cmd) 92 rename.execute(oldname, newname) 128 o1, o2 =rename.execute(oldname, newname, stderr=PIPE) 129 stderr.write(o2.read()) 130 131 # redo the rename ... 132 renames(join(self.basedir, oldname), join(self.basedir, newname)) 133 if rename.exit_status: 134 raise ChangesetApplicationFailure("%s returned status %s" % (str(rename),rename.exit_status)) 93 135 94 136 def _initializeWorkingDir(self): … … 102 144 """ 103 145 104 from os.path import exists, join105 106 146 if not exists(join(self.basedir, 'MT')): 107 147 raise TargetInitializationFailure("Please setup '%s' as a monotone working directory" % self.basedir) 108 148 109 self._add Pathnames([self.repository.subdir])149 self._addSubtree([self.repository.subdir])
Note: See TracChangeset
for help on using the changeset viewer.
