Changeset 527 in tailor
- Timestamp:
- 08/09/05 01:36:47 (8 years ago)
- Hash name:
- 20050808233647-97f81-c2b161feb61fde0d387d466b1710dc661e822899
- Location:
- vcpx
- Files:
-
- 16 edited
-
cvsps.py (modified) (23 diffs)
-
source.py (modified) (10 diffs)
-
target.py (modified) (17 diffs)
-
darcs.py (modified) (23 diffs)
-
svn.py (modified) (21 diffs)
-
dualwd.py (modified) (1 diff)
-
tailor.py (modified) (1 diff)
-
cvs.py (modified) (1 diff)
-
monotone.py (modified) (7 diffs)
-
cdv.py (modified) (9 diffs)
-
bzr.py (modified) (10 diffs)
-
session.py (modified) (3 diffs)
-
hg.py (modified) (10 diffs)
-
project.py (modified) (9 diffs)
-
repository.py (modified) (7 diffs)
-
arx.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vcpx/cvsps.py
r515 r527 138 138 ## UpdatableSourceWorkingDir 139 139 140 def _getUpstreamChangesets(self, root, repository, module, sincerev=None, 141 branch=None): 140 def _getUpstreamChangesets(self, sincerev=None): 142 141 from os.path import join, exists 143 142 144 if branch is None: 145 branch="HEAD" 146 fname = join(root, 'CVS', 'Tag') 147 if exists(fname): 148 tag = open(fname).read() 149 if tag.startswith('T'): 150 branch=tag[1:-1] 143 branch="HEAD" 144 fname = join(self.basedir, 'CVS', 'Tag') 145 if exists(fname): 146 tag = open(fname).read() 147 if tag.startswith('T'): 148 branch=tag[1:-1] 151 149 152 150 if sincerev: … … 155 153 changesets = [] 156 154 cmd = [self.repository.CVSPS_CMD, "--cvs-direct", "-u", "-b", branch, 157 "--root", repository]155 "--root", self.repository.repository] 158 156 cvsps = ExternalCommand(command=cmd) 159 log = cvsps.execute( module, stdout=PIPE, TZ='UTC')157 log = cvsps.execute(self.repository.module, stdout=PIPE, TZ='UTC') 160 158 161 159 for cs in changesets_from_cvsps(log, sincerev): … … 164 162 return changesets 165 163 166 def __maybeDeleteDirectory(self, root,entrydir, changeset):164 def __maybeDeleteDirectory(self, entrydir, changeset): 167 165 from os.path import join, exists 168 166 from os import listdir … … 171 169 return 172 170 173 absentrydir = join( root, entrydir)171 absentrydir = join(self.basedir, entrydir) 174 172 if not exists(absentrydir) or listdir(absentrydir) == ['CVS']: 175 173 deldir = changeset.addEntry(entrydir, None) 176 174 deldir.action_kind = deldir.DELETED 177 175 178 def _applyChangeset(self, root, changeset, logger=None):176 def _applyChangeset(self, changeset): 179 177 from os.path import join, exists, dirname, split 180 178 from os import makedirs, listdir … … 183 181 from time import sleep 184 182 185 entries = CvsEntries( root)183 entries = CvsEntries(self.basedir) 186 184 187 185 for e in changeset.entries: … … 189 187 info = entries.getFileInfo(e.name) 190 188 if not info: 191 if logger: logger.info("promoting '%s' to ADDED at " 192 "revision %s", e.name, 193 e.new_revision) 189 self.log_info("promoting '%s' to ADDED at " 190 "revision %s", e.name, e.new_revision) 194 191 e.action_kind = e.ADDED 195 self.__createParentCVSDirectories(changeset, root,e.name)192 self.__createParentCVSDirectories(changeset, e.name) 196 193 elif info.cvs_version == e.new_revision: 197 if logger: logger.debug("skipping '%s' since it's already " 198 "at revision %s", e.name, 199 e.new_revision) 194 self.log_info("skipping '%s' since it's already " 195 "at revision %s", e.name, e.new_revision) 200 196 continue 201 197 elif e.action_kind == e.DELETED: 202 if not exists(join(root, e.name)): 203 if logger: logger.debug("skipping '%s' since it's already " 204 "deleted", e.name) 205 self.__maybeDeleteDirectory(root, split(e.name)[0], 206 changeset) 198 if not exists(join(self.basedir, e.name)): 199 self.log_info("skipping '%s' since it's already " 200 "deleted", e.name) 201 self.__maybeDeleteDirectory(split(e.name)[0], changeset) 207 202 continue 208 203 elif e.action_kind == e.ADDED and e.new_revision is None: … … 218 213 219 214 if e.action_kind == e.DELETED and e.new_revision is None: 220 assert listdir(join( root, e.name)) == ['CVS'], '%s should be empty' % e.name221 rmtree(join( root, e.name))215 assert listdir(join(self.basedir, e.name)) == ['CVS'], '%s should be empty' % e.name 216 rmtree(join(self.basedir, e.name)) 222 217 else: 223 218 cmd = [self.repository.CVS_CMD, "-q", "update", "-d", "-r", e.new_revision] 224 cvsup = ExternalCommand(cwd= root, command=cmd)219 cvsup = ExternalCommand(cwd=self.basedir, command=cmd) 225 220 retry = 0 226 221 while True: … … 232 227 break 233 228 delay = 2**retry 234 if logger: 235 logger.warning("%s returned status %s, " 236 "retrying in %d seconds..." % 237 (str(cvsup), cvsup.exit_status, 238 delay)) 229 self.log_info("%s returned status %s, " 230 "retrying in %d seconds..." % 231 (str(cvsup), cvsup.exit_status, 232 delay)) 239 233 sleep(retry) 240 234 else: … … 246 240 cvsup.exit_status)) 247 241 248 if logger: logger.info("%s updated to %s" % (e.name, 249 e.new_revision)) 242 self.log_info("%s updated to %s" % (e.name, e.new_revision)) 250 243 251 244 if e.action_kind == e.DELETED: 252 self.__maybeDeleteDirectory(root, split(e.name)[0], changeset) 253 254 def _checkoutUpstreamRevision(self, basedir, repository, module, revision, 255 subdir=None, logger=None, **kwargs): 245 self.__maybeDeleteDirectory(split(e.name)[0], changeset) 246 247 def _checkoutUpstreamRevision(self, revision): 256 248 """ 257 249 Concretely do the checkout of the upstream sources. Use `revision` as … … 279 271 revision, timestamp = revision.split(' ', 1) 280 272 281 wdir = join(basedir, subdir) 282 csets = self._getUpstreamChangesets(wdir, repository, module, 283 branch=revision or 'HEAD') 273 csets = self._getUpstreamChangesets(revision) 284 274 csets.reverse() 285 275 … … 287 277 timestamp = csets[-1].date.isoformat(sep=' ') 288 278 289 if not exists(join( wdir, 'CVS')):279 if not exists(join(self.basedir, 'CVS')): 290 280 cmd = [self.repository.CVS_CMD, "-q", "-d", repository, "checkout", 291 "-d", s ubdir]281 "-d", self.basedir] 292 282 if revision: 293 283 cmd.extend(["-r", revision]) … … 295 285 cmd.extend(["-D", "%s UTC" % timestamp]) 296 286 297 checkout = ExternalCommand(c wd=basedir, command=cmd)287 checkout = ExternalCommand(command=cmd) 298 288 checkout.execute(module) 299 289 … … 303 293 checkout.exit_status)) 304 294 else: 305 if logger: logger.info("Using existing %s", wdir)306 307 self.__forceTagOnEachEntry( wdir)295 self.log_info("Using existing %s", self.basedir) 296 297 self.__forceTagOnEachEntry(self.basedir) 308 298 309 299 entries = CvsEntries(wdir) … … 331 321 "revision of the checked out tree in '%s'" % wdir) 332 322 else: 333 if logger: logger.info("working copy up to cvsps revision %s", 334 last.revision) 323 self.log_info("working copy up to cvsps revision %s", last.revision) 335 324 336 325 return last 337 326 338 def _willApplyChangeset(self, root,changeset, applyable=None):327 def _willApplyChangeset(self, changeset, applyable=None): 339 328 """ 340 329 This gets called just before applying each changeset. … … 344 333 """ 345 334 346 if UpdatableSourceWorkingDir._willApplyChangeset(self, root,changeset,335 if UpdatableSourceWorkingDir._willApplyChangeset(self, changeset, 347 336 applyable): 348 337 for m in changeset.entries: 349 338 if m.action_kind == m.ADDED: 350 self.__createParentCVSDirectories(changeset, root,m.name)339 self.__createParentCVSDirectories(changeset, m.name) 351 340 352 341 return True … … 354 343 return False 355 344 356 def __createParentCVSDirectories(self, changeset, root,entry):345 def __createParentCVSDirectories(self, changeset, entry): 357 346 """ 358 347 Verify that the hierarchy down to the entry is under CVS. … … 368 357 path = split(entry)[0] 369 358 if path: 370 basedir = join( root, path)359 basedir = join(self.basedir, path) 371 360 else: 372 basedir = root361 basedir = self.basedir 373 362 cvsarea = join(basedir, 'CVS') 374 363 375 364 if path and not exists(cvsarea): 376 parentcvs = self.__createParentCVSDirectories(changeset, 377 root, path) 365 parentcvs = self.__createParentCVSDirectories(changeset, path) 378 366 379 367 assert exists(parentcvs), "Uhm, strange things happen" … … 415 403 ## SyncronizableTargetWorkingDir 416 404 417 def _addPathnames(self, root,names):405 def _addPathnames(self, names): 418 406 """ 419 407 Add some new filesystem objects. … … 421 409 422 410 cmd = [self.repository.CVS_CMD, "-q", "add"] 423 ExternalCommand(cwd= root, command=cmd).execute(names)424 425 def __forceTagOnEachEntry(self , root):411 ExternalCommand(cwd=self.basedir, command=cmd).execute(names) 412 413 def __forceTagOnEachEntry(self): 426 414 """ 427 415 Massage each CVS/Entries file, locking (ie, tagging) each … … 435 423 from os.path import join 436 424 437 for dir, subdirs, files in walk( root):425 for dir, subdirs, files in walk(self.basedir): 438 426 if dir[-3:] == 'CVS': 439 427 efn = join(dir, 'Entries') … … 470 458 return entries 471 459 472 def _commit(self, root,date, author, patchname, changelog=None, entries=None):460 def _commit(self, date, author, patchname, changelog=None, entries=None): 473 461 """ 474 462 Commit the changeset. … … 499 487 entries = ['.'] 500 488 501 ExternalCommand(cwd= root, command=cmd).execute(entries)502 503 def _removePathnames(self, root,names):489 ExternalCommand(cwd=self.basedir, command=cmd).execute(entries) 490 491 def _removePathnames(self, names): 504 492 """ 505 493 Remove some filesystem objects. … … 507 495 508 496 cmd = [self.repository.CVS_CMD, "-q", "remove"] 509 ExternalCommand(cwd= root, command=cmd).execute(names)510 511 def _renamePathname(self, root,oldname, newname):497 ExternalCommand(cwd=self.basedir, command=cmd).execute(names) 498 499 def _renamePathname(self, oldname, newname): 512 500 """ 513 501 Rename a filesystem object. 514 502 """ 515 503 516 self._removePathnames( root,[oldname])517 self._addPathnames( root,[newname])504 self._removePathnames([oldname]) 505 self._addPathnames([newname]) -
vcpx/source.py
r516 r527 63 63 self.state_file = state_file 64 64 65 def applyPendingChangesets(self, root, module, applyable=None, 66 replayable=None, replay=None, applied=None, 67 logger=None): 65 def applyPendingChangesets(self, applyable=None, replayable=None, 66 replay=None, applied=None): 68 67 """ 69 68 Apply the collected upstream changes. … … 89 88 remaining = self.pending[:] 90 89 for c in self.pending: 91 if not self._willApplyChangeset( root,c, applyable):90 if not self._willApplyChangeset(c, applyable): 92 91 break 93 92 94 if logger: 95 logger.info("Applying changeset %s", c.revision) 93 self.log_info("Applying changeset %s" % c.revision) 96 94 97 95 try: 98 res = self._applyChangeset( root, c, logger=logger)96 res = self._applyChangeset(c) 99 97 except: 100 if logger: 101 logger.critical("Couldn't apply changeset %s", 102 c.revision, exc_info=True) 103 logger.debug(str(c)) 98 self.log_error("Couldn't apply changeset %s" % c.revision, 99 exc=True) 104 100 raise 105 101 … … 109 105 raw_input(CONFLICTS_PROMPT % (str(c), '\n * '.join(res))) 110 106 except KeyboardInterrupt: 111 if logger: logger.info("INTERRUPTED BY THE USER!")107 self.log_info("INTERRUPTED BY THE USER!") 112 108 return last, conflicts 113 109 114 if not self._didApplyChangeset( root,c, replayable):110 if not self._didApplyChangeset(c, replayable): 115 111 continue 116 112 117 113 if replay: 118 replay( root, module, c, logger=logger)114 replay(c) 119 115 120 116 remaining.remove(c) … … 122 118 123 119 if applied: 124 applied( root,c)120 applied(c) 125 121 126 122 last = c … … 129 125 return last, conflicts 130 126 131 def _willApplyChangeset(self, root,changeset, applyable=None):127 def _willApplyChangeset(self, changeset, applyable=None): 132 128 """ 133 129 This gets called just before applying each changeset. The whole … … 139 135 140 136 if applyable: 141 return applyable( root,changeset)137 return applyable(changeset) 142 138 else: 143 139 return True 144 140 145 def _didApplyChangeset(self, root,changeset, replayable=None):141 def _didApplyChangeset(self, changeset, replayable=None): 146 142 """ 147 143 This gets called right after changeset application. The final … … 154 150 155 151 if replayable: 156 return replayable( root,changeset)152 return replayable(changeset) 157 153 else: 158 154 return True 159 155 160 def getPendingChangesets(self , root, repository, module):156 def getPendingChangesets(self): 161 157 """ 162 158 Load the pending changesets from the state file, or query the … … 166 162 revision, self.pending = self.state_file.load() 167 163 if not self.pending: 168 self.pending = self._getUpstreamChangesets(root, repository, module, 169 revision) 164 self.pending = self._getUpstreamChangesets(revision) 170 165 return self.pending 171 166 172 def _getUpstreamChangesets(self, root, repository, module,sincerev):167 def _getUpstreamChangesets(self, sincerev): 173 168 """ 174 169 Query the upstream repository about what happened on the … … 181 176 raise "%s should override this method" % self.__class__ 182 177 183 def _applyChangeset(self, root, changeset, logger=None):178 def _applyChangeset(self, changeset): 184 179 """ 185 180 Do the actual work of applying the changeset to the working copy. … … 192 187 raise "%s should override this method" % self.__class__ 193 188 194 def checkoutUpstreamRevision(self, root, repository, module, revision, 195 **kwargs): 196 """ 197 Extract a working copy from a repository. 198 199 :root: the name of the directory (that **must** exists) 200 that will contain the working copy of the sources under the 201 *module* subdirectory 202 203 :repository: the address of the repository (the format depends on 204 the actual method used by the subclass) 205 206 :module: the name of the module to extract 207 208 :revision: extract that revision/branch 189 def checkoutUpstreamRevision(self, revision): 190 """ 191 Extract a working copy of the given revision from a repository. 209 192 210 193 Return the last applied changeset. 211 194 """ 212 195 213 if not root: 214 raise InvocationError("Must specify a root directory") 215 if not repository: 216 raise InvocationError("Must specify an upstream repository") 217 218 last = self._checkoutUpstreamRevision(root, repository, 219 module, revision, 220 **kwargs) 196 last = self._checkoutUpstreamRevision(revision) 221 197 self.state_file.write(last.revision, None) 222 198 223 199 return last 224 200 225 def _checkoutUpstreamRevision(self, basedir, repository, module, revision, 226 subdir=None, logger=None, **kwargs): 201 def _checkoutUpstreamRevision(self, revision): 227 202 """ 228 203 Concretely do the checkout of the upstream revision. -
vcpx/target.py
r517 r527 60 60 """ 61 61 62 def replayChangeset(self, root, module, changeset, logger=None):62 def replayChangeset(self, changeset): 63 63 """ 64 64 Do whatever is needed to replay the changes under the target … … 68 68 69 69 try: 70 self._replayChangeset( root, changeset, logger)70 self._replayChangeset(changeset) 71 71 except: 72 if logger: logger.critical(str(changeset))72 self.log_error(str(changeset), exc=True) 73 73 raise 74 74 … … 96 96 changelog = changeset.log 97 97 entries = self._getCommitEntries(changeset) 98 self._commit( root,changeset.date, changeset.author,98 self._commit(changeset.date, changeset.author, 99 99 patchname, changelog, entries) 100 100 … … 106 106 return [e.name for e in changeset.entries] 107 107 108 def _replayChangeset(self, root, changeset, logger):108 def _replayChangeset(self, changeset): 109 109 """ 110 110 Replicate the actions performed by the changeset on the tree of … … 128 128 # Replay the actions 129 129 130 if renamed: self._renameEntries(r oot, renamed)131 if removed: self._removeEntries(r oot, removed)132 if added: self._addEntries( root,added)130 if renamed: self._renameEntries(renamed) 131 if removed: self._removeEntries(removed) 132 if added: self._addEntries(added) 133 133 134 134 # Finally, deal with "copied" directories. The simple way is … … 138 138 while added: 139 139 subdir = added.pop(0).name 140 if isdir(join( root, subdir)):141 self._addSubtree( root,subdir)140 if isdir(join(self.basedir, subdir)): 141 self._addSubtree(subdir) 142 142 added = [e for e in added if not e.name.startswith(subdir)] 143 143 144 def _addEntries(self, root,entries):144 def _addEntries(self, entries): 145 145 """ 146 146 Add a sequence of entries 147 147 """ 148 148 149 self._addPathnames( root,[e.name for e in entries])150 151 def _addPathnames(self, root,names):149 self._addPathnames([e.name for e in entries]) 150 151 def _addPathnames(self, names): 152 152 """ 153 153 Add some new filesystem objects. … … 156 156 raise "%s should override this method" % self.__class__ 157 157 158 def _addSubtree(self, root,subdir):158 def _addSubtree(self, subdir): 159 159 """ 160 160 Add a whole subtree. … … 173 173 from dualwd import IGNORED_METADIRS 174 174 175 if subdir <>'.':176 self._addPathnames( root,[subdir])177 178 for dir, subdirs, files in walk(join( root, subdir)):175 if subdir and subdir<>'.': 176 self._addPathnames([subdir]) 177 178 for dir, subdirs, files in walk(join(self.basedir, subdir)): 179 179 for excd in IGNORED_METADIRS: 180 180 if excd in subdirs: … … 187 187 188 188 if subdirs or files: 189 self._addPathnames( dir, subdirs + files)190 191 def _commit(self, root, date, author, patchname, 192 changelog=None, entries=None):189 self._addPathnames([join(dir, df)[len(self.basedir)+1:] 190 for df in subdirs + files]) 191 192 def _commit(self, date, author, patchname, changelog=None, entries=None): 193 193 """ 194 194 Commit the changeset. … … 197 197 raise "%s should override this method" % self.__class__ 198 198 199 def _removeEntries(self, root,entries):199 def _removeEntries(self, entries): 200 200 """ 201 201 Remove a sequence of entries. 202 202 """ 203 203 204 self._removePathnames( root,[e.name for e in entries])205 206 def _removePathnames(self, root,names):204 self._removePathnames([e.name for e in entries]) 205 206 def _removePathnames(self, names): 207 207 """ 208 208 Remove some filesystem object. … … 211 211 raise "%s should override this method" % self.__class__ 212 212 213 def _renameEntries(self, root,entries):213 def _renameEntries(self, entries): 214 214 """ 215 215 Rename a sequence of entries, adding all the parent directories … … 230 230 if parents: 231 231 parents.reverse() 232 self._addPathnames( root,parents)233 234 self._renamePathname( root,e.old_name, e.name)235 236 def _renamePathname(self, root,oldname, newname):232 self._addPathnames(parents) 233 234 self._renamePathname(e.old_name, e.name) 235 236 def _renamePathname(self, oldname, newname): 237 237 """ 238 238 Rename a filesystem object to some other name/location. … … 241 241 raise "%s should override this method" % self.__class__ 242 242 243 def prepareWorkingDirectory(self , root, target_repository, target_module):243 def prepareWorkingDirectory(self): 244 244 """ 245 245 Do anything required to setup the hosting working directory. 246 246 """ 247 247 248 if target_repository: 249 self._prepareTargetRepository(root, target_repository, 250 target_module) 251 self._prepareWorkingDirectory(root, target_repository, 252 target_module) 253 254 def _prepareTargetRepository(self, root, target_repository, target_module): 248 if self.repository.repository: 249 self._prepareTargetRepository() 250 self._prepareWorkingDirectory() 251 252 def _prepareTargetRepository(self): 255 253 """ 256 254 Possibly create the repository, when overriden by subclasses. 257 255 """ 258 256 259 def _prepareWorkingDirectory(self , root, target_repository, target_module):257 def _prepareWorkingDirectory(self): 260 258 """ 261 259 Possibly checkout a working copy of the target VC, that will host the … … 263 261 """ 264 262 265 def initializeNewWorkingDir(self, root, source_repository, 266 source_module, subdir, changeset, initial): 263 def initializeNewWorkingDir(self, source_repo, changeset, initial): 267 264 """ 268 265 Initialize a new working directory, just extracted from … … 270 267 """ 271 268 272 self._initializeWorkingDir(root, source_repository, source_module, 273 subdir) 269 self._initializeWorkingDir() 274 270 revision = changeset.revision 271 source_repository = source_repo.repository 272 source_module = source_repo.module 275 273 if initial: 276 274 author = changeset.author … … 281 279 patchname = BOOTSTRAP_PATCHNAME % source_module 282 280 log = BOOTSTRAP_CHANGELOG % locals() 283 self._commit(root, changeset.date, author, patchname, log, 284 entries=[subdir]) 285 286 def _initializeWorkingDir(self, root, source_repository, source_module, 287 subdir): 288 """ 289 Assuming the ``root`` directory contains a working copy ``module`` 281 self._commit(changeset.date, author, patchname, log) 282 283 def _initializeWorkingDir(self): 284 """ 285 Assuming the ``basedir`` directory contains a working copy ``module`` 290 286 extracted from some VC repository, add it and all its content 291 287 to the target repository. … … 296 292 """ 297 293 298 self._addSubtree( root, subdir)294 self._addSubtree('.') -
vcpx/darcs.py
r526 r527 133 133 ## UpdatableSourceWorkingDir 134 134 135 def _getUpstreamChangesets(self, root, repository, module, sincerev=None):135 def _getUpstreamChangesets(self, sincerev): 136 136 """ 137 137 Do the actual work of fetching the upstream changeset. … … 143 143 144 144 cmd = [self.repository.DARCS_CMD, "pull", "--dry-run"] 145 pull = ExternalCommand(cwd=root, command=cmd) 146 output = pull.execute(repository, stdout=PIPE, stderr=STDOUT, TZ='UTC') 145 pull = ExternalCommand(cwd=self.basedir, command=cmd) 146 output = pull.execute(self.repository.repository, 147 stdout=PIPE, stderr=STDOUT, TZ='UTC') 147 148 148 149 if pull.exit_status: … … 196 197 return changesets 197 198 198 def _applyChangeset(self, root, changeset, logger=None):199 def _applyChangeset(self, changeset): 199 200 """ 200 201 Do the actual work of applying the changeset to the working copy. … … 214 215 215 216 cmd = [self.repository.DARCS_CMD, "pull", "--all", selector, revtag] 216 pull = ExternalCommand(cwd= root, command=cmd)217 pull = ExternalCommand(cwd=self.basedir, command=cmd) 217 218 output = pull.execute(stdout=PIPE, stderr=STDOUT) 218 219 … … 224 225 cmd = [self.repository.DARCS_CMD, "changes", selector, revtag, 225 226 "--xml-output", "--summ"] 226 changes = ExternalCommand(cwd= root, command=cmd)227 changes = ExternalCommand(cwd=self.basedir, command=cmd) 227 228 last = changesets_from_darcschanges(changes.execute(stdout=PIPE)) 228 229 if last: 229 230 changeset.entries.extend(last[0].entries) 230 231 231 def _checkoutUpstreamRevision(self, basedir, repository, module, revision, 232 subdir=None, logger=None, **kwargs): 232 def _checkoutUpstreamRevision(self, revision): 233 233 """ 234 234 Concretely do the checkout of the upstream revision and return … … 243 243 initial = True 244 244 cmd = [self.repository.DARCS_CMD, "changes", "--xml-output", 245 "--repo", repository]245 "--repo", self.repository.repository] 246 246 changes = ExternalCommand(command=cmd) 247 247 output = changes.execute(stdout=PIPE, stderr=STDOUT) … … 261 261 initial = False 262 262 263 wdir = join(basedir, subdir) 264 if subdir == '.': 263 if self.repository.subdir == '.': 265 264 # This is currently *very* slow, compared to the darcs get 266 265 # below! 267 if not exists(join( wdir, '_darcs')):268 if not exists( wdir):269 mkdir( wdir)270 271 init = ExternalCommand(cwd= wdir,266 if not exists(join(self.basedir, '_darcs')): 267 if not exists(self.basedir): 268 mkdir(self.basedir) 269 270 init = ExternalCommand(cwd=self.basedir, 272 271 command=[self.repository.DARCS_CMD, 273 272 "initialize"]) … … 281 280 cmd = [self.repository.DARCS_CMD, "pull", "--all", "--verbose"] 282 281 if revision and revision<>'HEAD': 283 cmd.extend([initial and "--patches" or "--tags", revision]) 284 dpull = ExternalCommand(cwd=wdir, command=cmd) 285 output = dpull.execute(repository, stdout=PIPE, stderr=STDOUT) 282 cmd.extend([initial and "--match" or "--tags", revision]) 283 dpull = ExternalCommand(cwd=self.basedir, command=cmd) 284 output = dpull.execute(self.repository.repository, 285 stdout=PIPE, stderr=STDOUT) 286 286 287 287 if dpull.exit_status: … … 294 294 if revision and revision<>'HEAD': 295 295 cmd.extend([initial and "--to-patch" or "--tag", revision]) 296 dget = ExternalCommand(c wd=basedir, command=cmd)297 output = dget.execute( repository, subdir,296 dget = ExternalCommand(command=cmd) 297 output = dget.execute(self.repository.repository, self.basedir, 298 298 stdout=PIPE, stderr=STDOUT) 299 299 … … 305 305 cmd = [self.repository.DARCS_CMD, "changes", "--last", "1", 306 306 "--xml-output"] 307 changes = ExternalCommand(cwd= wdir, command=cmd)307 changes = ExternalCommand(cwd=self.basedir, command=cmd) 308 308 output = changes.execute(stdout=PIPE, stderr=STDOUT) 309 309 … … 320 320 ## SyncronizableTargetWorkingDir 321 321 322 def _addPathnames(self, root,names):322 def _addPathnames(self, names): 323 323 """ 324 324 Add some new filesystems objects. … … 327 327 cmd = [self.repository.DARCS_CMD, "add", "--case-ok", 328 328 "--not-recursive", "--quiet"] 329 ExternalCommand(cwd= root, command=cmd).execute(names)330 331 def _addSubtree(self, root,subdir):329 ExternalCommand(cwd=self.basedir, command=cmd).execute(names) 330 331 def _addSubtree(self, subdir): 332 332 """ 333 333 Use the --recursive variant of ``darcs add`` to add a subtree. … … 336 336 cmd = [self.repository.DARCS_CMD, "add", "--case-ok", "--recursive", 337 337 "--quiet"] 338 ExternalCommand(cwd= root, command=cmd).execute(subdir)339 340 def _commit(self, root,date, author, patchname, changelog=None, entries=None):338 ExternalCommand(cwd=self.basedir, command=cmd).execute(subdir) 339 340 def _commit(self, date, author, patchname, changelog=None, entries=None): 341 341 """ 342 342 Commit the changeset. … … 359 359 entries = ['.'] 360 360 361 record = ExternalCommand(cwd= root, command=cmd)361 record = ExternalCommand(cwd=self.basedir, command=cmd) 362 362 record.execute(entries, input='\n'.join(logmessage), stdout=PIPE) 363 363 … … 366 366 "%s returned status %d" % (str(record), record.exit_status)) 367 367 368 def _removePathnames(self, root,names):368 def _removePathnames(self, names): 369 369 """ 370 370 Remove some filesystem object. … … 374 374 # darcs will do the right thing with it, do nothing here, instead 375 375 # of 376 # c = ExternalCommand(cwd= root,376 # c = ExternalCommand(cwd=self.basedir, 377 377 # command=[self.repository.DARCS_CMD, 378 378 # "remove"]) … … 382 382 pass 383 383 384 def _renamePathname(self, root,oldname, newname):384 def _renamePathname(self, oldname, newname): 385 385 """ 386 386 Rename a filesystem object. … … 397 397 # finally restore its name. 398 398 399 renamed = exists(join( root, oldname))399 renamed = exists(join(self.basedir, oldname)) 400 400 if renamed: 401 401 rename(oldname, oldname + '-TAILOR-HACKED-TEMP-NAME') … … 403 403 try: 404 404 cmd = [self.repository.DARCS_CMD, "mv"] 405 ExternalCommand(cwd=root, command=cmd).execute(oldname, newname) 405 ExternalCommand(cwd=self.basedir, command=cmd).execute(oldname, 406 newname) 406 407 finally: 407 408 if renamed: 408 409 rename(oldname + '-TAILOR-HACKED-TEMP-NAME', oldname) 409 410 410 def _initializeWorkingDir(self, root, source_repository, source_module, 411 subdir): 411 def _initializeWorkingDir(self): 412 412 """ 413 413 Execute ``darcs initialize`` and tweak the default settings of … … 419 419 from dualwd import IGNORED_METADIRS 420 420 421 init = ExternalCommand(cwd=root, command=[self.repository.DARCS_CMD, 422 "initialize"]) 421 init = ExternalCommand(cwd=self.basedir, 422 command=[self.repository.DARCS_CMD, 423 "initialize"]) 423 424 init.execute(stdout=PIPE) 424 425 … … 427 428 "%s returned status %s" % (str(init), init.exit_status)) 428 429 429 motd = open(join( root, '_darcs/prefs/motd'), 'w')430 motd = open(join(self.basedir, '_darcs/prefs/motd'), 'w') 430 431 motd.write(MOTD % (source_repository, source_module)) 431 432 motd.close() 432 433 433 434 # Remove .cvsignore from default boring file 434 boring = open(join( root, '_darcs/prefs/boring'), 'r')435 boring = open(join(self.basedir, '_darcs/prefs/boring'), 'r') 435 436 ignored = [line for line in boring if line <> '\.cvsignore$\n'] 436 437 boring.close() … … 438 439 # Augment the boring file, that contains a regexp per line 439 440 # with all known VCs metadirs to be skipped. 440 boring = open(join( root, '_darcs/prefs/boring'), 'w')441 boring = open(join(self.basedir, '_darcs/prefs/boring'), 'w') 441 442 boring.write(''.join(ignored)) 442 443 boring.write('\n'.join(['(^|/)%s($|/)' % escape(md) … … 445 446 boring.close() 446 447 447 SyncronizableTargetWorkingDir._initializeWorkingDir(self, root, 448 source_repository, 449 source_module, 450 subdir) 448 SyncronizableTargetWorkingDir._initializeWorkingDir(self) -
vcpx/svn.py
r515 r527 173 173 ## UpdatableSourceWorkingDir 174 174 175 def _getUpstreamChangesets(self, root, repository, module,sincerev=None):175 def _getUpstreamChangesets(self, sincerev=None): 176 176 if sincerev: 177 177 sincerev = int(sincerev) … … 181 181 cmd = [self.repository.SVN_CMD, "log", "--verbose", "--xml", 182 182 "--revision", "%d:HEAD" % (sincerev+1)] 183 svnlog = ExternalCommand(cwd= root, command=cmd)183 svnlog = ExternalCommand(cwd=self.basedir, command=cmd) 184 184 log = svnlog.execute('.', stdout=PIPE, TZ='UTC') 185 185 … … 187 187 return [] 188 188 189 return changesets_from_svnlog(log, repository, module) 190 191 def _applyChangeset(self, root, changeset, logger=None): 189 return changesets_from_svnlog(log, 190 self.repository.repository, 191 self.repository.module) 192 193 def _applyChangeset(self, changeset): 192 194 cmd = [self.repository.SVN_CMD, "update", 193 195 "--revision", changeset.revision, "."] 194 svnup = ExternalCommand(cwd= root, command=cmd)196 svnup = ExternalCommand(cwd=self.basedir, command=cmd) 195 197 out = svnup.execute(stdout=PIPE) 196 198 … … 199 201 "%s returned status %s" % (str(svnup), svnup.exit_status)) 200 202 201 if logger: logger.info("%s updated to %s" % (203 self.log_info("%s updated to %s" % ( 202 204 ','.join([e.name for e in changeset.entries]), 203 205 changeset.revision)) … … 206 208 for line in out: 207 209 if len(line)>2 and line[0] == 'C' and line[1] == ' ': 208 logger.warn("Conflict after 'svn update': '%s'" % line)210 self.log_info("Conflict after 'svn update': '%s'" % line) 209 211 result.append(line[2:-1]) 210 212 211 213 return result 212 214 213 def _checkoutUpstreamRevision(self, basedir, repository, module, revision, 214 subdir=None, logger=None, **kwargs): 215 def _checkoutUpstreamRevision(self, revision): 215 216 """ 216 217 Concretely do the checkout of the upstream revision. … … 224 225 "--limit", "1", "--revision", "1:HEAD"] 225 226 svnlog = ExternalCommand(command=cmd) 226 output = svnlog.execute("%s%s" % (repository, module), stdout=PIPE) 227 output = svnlog.execute("%s%s" % (self.repository.repository, 228 self.repository.module), 229 stdout=PIPE) 227 230 228 231 if svnlog.exit_status: … … 231 234 (str(output), changes.exit_status, output.read())) 232 235 233 csets = changesets_from_svnlog(output, repository, module) 236 csets = changesets_from_svnlog(output, 237 self.repository.repository, 238 self.repository.module) 234 239 revision = escape(csets[0].revision) 235 240 else: 236 241 initial = False 237 242 238 wdir = join(basedir, subdir) 239 if not exists(join(wdir, '.svn')): 240 if logger: logger.info("checking out a working copy") 243 if not exists(join(self.basedir, '.svn')): 244 self.log_info("checking out a working copy") 241 245 cmd = [self.repository.SVN_CMD, "co", "--quiet", 242 246 "--revision", revision] 243 svnco = ExternalCommand(cwd=basedir, command=cmd) 244 svnco.execute("%s%s" % (repository, module), subdir) 247 svnco = ExternalCommand(command=cmd) 248 svnco.execute("%s%s" % (self.repository.repository, 249 self.repository.module), self.basedir) 245 250 if svnco.exit_status: 246 251 raise TargetInitializationFailure( 247 252 "%s returned status %s" % (str(svnco), svnco.exit_status)) 248 253 else: 249 if logger: logger.info("%s already exists, assuming it's a svn working dir" % wdir)254 self.log_info("%s already exists, assuming it's a svn working dir" % self.basedir) 250 255 251 256 if not initial: 252 257 cmd = [self.repository.SVN_CMD, "log", "--verbose", "--xml", 253 258 "--revision", revision] 254 svnlog = ExternalCommand(cwd= wdir, command=cmd)259 svnlog = ExternalCommand(cwd=self.basedir, command=cmd) 255 260 output = svnlog.execute(stdout=PIPE) 256 261 … … 260 265 (str(changes), changes.exit_status, output.read())) 261 266 262 csets = changesets_from_svnlog(output, repository, module) 267 csets = changesets_from_svnlog(output, 268 self.repository.repository, 269 self.repository.module) 263 270 264 271 last = csets[0] 265 272 266 if logger: logger.info("working copy up to svn revision %s", 267 last.revision) 273 self.log_info("working copy up to svn revision %s", last.revision) 268 274 269 275 return last … … 271 277 ## SyncronizableTargetWorkingDir 272 278 273 def _addPathnames(self, root,names):279 def _addPathnames(self, names): 274 280 """ 275 281 Add some new filesystem objects. … … 278 284 cmd = [self.repository.SVN_CMD, "add", "--quiet", "--no-auto-props", 279 285 "--non-recursive"] 280 ExternalCommand(cwd= root, command=cmd).execute(names)286 ExternalCommand(cwd=self.basedir, command=cmd).execute(names) 281 287 282 288 def _getCommitEntries(self, changeset): … … 293 299 return entries 294 300 295 def _commit(self, root,date, author, patchname, changelog=None, entries=None):301 def _commit(self, date, author, patchname, changelog=None, entries=None): 296 302 """ 297 303 Commit the changeset. … … 326 332 cmd = [self.repository.SVN_CMD, "commit", "--quiet", 327 333 "--file", rontf.name] 328 commit = ExternalCommand(cwd= root, command=cmd)334 commit = ExternalCommand(cwd=self.basedir, command=cmd) 329 335 330 336 if not entries: … … 336 342 cmd = [self.repository.SVN_CMD, "propset", "%(propname)s", 337 343 "--quiet", "--revprop", "-rHEAD"] 338 propset = ExternalCommand(cwd= root, command=cmd)344 propset = ExternalCommand(cwd=self.basedir, command=cmd) 339 345 340 346 propset.execute(date.isoformat()+".000000Z", propname='svn:date') 341 347 propset.execute(author, propname='svn:author') 342 348 343 def _removePathnames(self, root,names):349 def _removePathnames(self, names): 344 350 """ 345 351 Remove some filesystem objects. … … 347 353 348 354 cmd = [self.repository.SVN_CMD, "remove", "--quiet", "--force"] 349 remove = ExternalCommand(cwd= root, command=cmd)355 remove = ExternalCommand(cwd=self.basedir, command=cmd) 350 356 remove.execute(names) 351 357 352 def _renamePathname(self, root,oldname, newname):358 def _renamePathname(self, oldname, newname): 353 359 """ 354 360 Rename a filesystem object. … … 356 362 357 363 cmd = [self.repository.SVN_CMD, "mv", "--quiet"] 358 move = ExternalCommand(cwd= root, command=cmd)364 move = ExternalCommand(cwd=self.basedir, command=cmd) 359 365 move.execute(oldname, newname) 360 366 if move.exit_status: … … 365 371 # moved the item. OTOH, svn really treats "mv" as "cp+rm", 366 372 # so we do the same here 367 self._removePathnames( root,[oldname])368 self._addPathnames( root,[newname])373 self._removePathnames([oldname]) 374 self._addPathnames([newname]) 369 375 370 376 def __createRepository(self, target_repository, target_module): … … 395 401 target_module) 396 402 397 def _prepareTargetRepository(self , root, target_repository, target_module):403 def _prepareTargetRepository(self): 398 404 """ 399 405 Check for target repository existence, eventually create it. … … 402 408 cmd = [self.repository.SVN_CMD, "info"] 403 409 svninfo = ExternalCommand(command=cmd) 404 svninfo.execute( target_repository, stdout=PIPE, stderr=STDOUT)410 svninfo.execute(self.repository.repository, stdout=PIPE, stderr=STDOUT) 405 411 406 412 if svninfo.exit_status: 407 if target_repository.startswith('file:///'): 408 self.__createRepository(target_repository, target_module) 413 if self.repository.repository.startswith('file:///'): 414 self.__createRepository(self.repository.repository, 415 self.repository.module) 409 416 else: 410 417 raise TargetInitializationFailure("%r does not exist and " … … 412 419 "it's not a local (file:///) " 413 420 "repository" % 414 target_repository)415 416 def _prepareWorkingDirectory(self , root, target_repository, target_module):421 self.repository.repository) 422 423 def _prepareWorkingDirectory(self): 417 424 """ 418 425 Checkout a working copy of the target SVN repository. … … 421 428 cmd = [self.repository.SVN_CMD, "co", "--quiet"] 422 429 svnco = ExternalCommand(command=cmd) 423 svnco.execute( target_repository + target_module, root)424 425 def _initializeWorkingDir(self, root, source_repository, source_module, 426 subdir):430 svnco.execute("%s%s" % (self.repository.repository, 431 self.repository.module), self.basedir) 432 433 def _initializeWorkingDir(self): 427 434 """ 428 435 Add the given directory to an already existing svn working tree. … … 431 438 from os.path import exists, join 432 439 433 if not exists(join(root, '.svn')): 434 raise TargetInitializationFailure("'%s' needs to be an SVN working copy already under SVN" % root) 435 436 SyncronizableTargetWorkingDir._initializeWorkingDir(self, root, 437 source_repository, 438 source_module, 439 subdir) 440 if not exists(join(self.basedir, '.svn')): 441 raise TargetInitializationFailure("'%s' needs to be an SVN working copy already under SVN" % self.basedir) 442 443 SyncronizableTargetWorkingDir._initializeWorkingDir(self) -
vcpx/dualwd.py
r511 r527 52 52 self.replayChangeset = self.target.replayChangeset 53 53 54 def applyPendingChangesets(self, root, module, applyable=None, 55 replay=None, applied=None, logger=None): 56 return self.source.applyPendingChangesets(root, module, 57 replay=self.replayChangeset, 54 def applyPendingChangesets(self, applyable=None, replay=None, applied=None): 55 return self.source.applyPendingChangesets(replay=self.replayChangeset, 58 56 applyable=applyable, 59 applied=applied, 60 logger=logger) 57 applied=applied) -
vcpx/tailor.py
r525 r527 45 45 """ 46 46 47 self.project.log_info("Bootstrapping '%s'" % self.project.root )47 self.project.log_info("Bootstrapping '%s'" % self.project.rootdir) 48 48 49 49 try: -
vcpx/cvs.py
r515 r527 287 287 """ 288 288 289 def _getUpstreamChangesets(self, root, repository, module, sincerev=None, 290 branch=None): 289 def _getUpstreamChangesets(self, sincerev): 291 290 from os.path import join, exists 292 291 from datetime import timedelta 293 292 294 if branch is None: 295 entries = CvsEntries(root) 296 youngest_entry = entries.getYoungestEntry() 297 if youngest_entry is None: 298 raise EmptyRepositoriesFoolsMe("The working copy '%s' of the CVS repository seems empty, don't know how to deal with that." % root) 299 300 branch = '' 301 fname = join(root, 'CVS', 'Tag') 302 if exists(fname): 303 tag = open(fname).read() 304 if tag[0] in 'NT': 305 branch=tag[1:-1] 293 entries = CvsEntries(self.basedir) 294 youngest_entry = entries.getYoungestEntry() 295 if youngest_entry is None: 296 raise EmptyRepositoriesFoolsMe("The working copy '%s' of the CVS repository seems empty, don't know how to deal with that." % self.basedir) 297 298 branch = '' 299 fname = join(self.basedir, 'CVS', 'Tag') 300 if exists(fname): 301 tag = open(fname).read() 302 if tag[0] in 'NT': 303 branch=tag[1:-1] 306 304 307 305 if not sincerev: -
vcpx/monotone.py
r515 r527 22 22 ## SyncronizableTargetWorkingDir 23 23 24 def _addPathnames(self, root,names):24 def _addPathnames(self, names): 25 25 """ 26 26 Add some new filesystem objects. … … 28 28 29 29 cmd = [self.repository.MONOTONE_CMD, "add"] 30 add = ExternalCommand(cwd= root, command=cmd)30 add = ExternalCommand(cwd=self.basedir, command=cmd) 31 31 add.execute(names) 32 32 33 def _commit(self, root,date, author, patchname, changelog=None, entries=None):33 def _commit(self, date, author, patchname, changelog=None, entries=None): 34 34 """ 35 35 Commit the changeset. … … 56 56 "--date", date.isoformat(), 57 57 "--message-file", rontf.name] 58 commit = ExternalCommit(cwd= root, command=cmd)58 commit = ExternalCommit(cwd=self.basedir, command=cmd) 59 59 60 60 if not entries: … … 74 74 stderr.write("No changes to commit - changeset ignored\n") 75 75 76 def _removePathnames(self, root,names):76 def _removePathnames(self, names): 77 77 """ 78 78 Remove some filesystem object. … … 80 80 81 81 cmd = [self.repository.MONOTONE_CMD, "drop"] 82 drop = ExternalCommand(cwd= root, command=cmd)82 drop = ExternalCommand(cwd=self.basedir, command=cmd) 83 83 drop.execute(names) 84 84 85 def _renamePathname(self, root,oldname, newname):85 def _renamePathname(self, oldname, newname): 86 86 """ 87 87 Rename a filesystem object. … … 89 89 90 90 cmd = [self.repository.MONOTONE_CMD, "rename"] 91 rename = ExternalCommand(cwd= root, command=cmd)91 rename = ExternalCommand(cwd=self.basedir, command=cmd) 92 92 rename.execute(oldname, newname) 93 93 94 def _initializeWorkingDir(self, root, source_repository, source_module, 95 subdir): 94 def _initializeWorkingDir(self): 96 95 """ 97 96 Setup the monotone working copy … … 105 104 from os.path import exists, join 106 105 107 if not exists(join( root, 'MT')):108 raise TargetInitializationFailure("Please setup '%s' as a monotone working directory" % root)106 if not exists(join(self.basedir, 'MT')): 107 raise TargetInitializationFailure("Please setup '%s' as a monotone working directory" % self.basedir) 109 108 110 self._addPathnames( root, [subdir])109 self._addPathnames([self.repository.subdir]) -
vcpx/cdv.py
r515 r527 19 19 ## SyncronizableTargetWorkingDir 20 20 21 def _addPathnames(self, root,names):21 def _addPathnames(self, names): 22 22 """ 23 23 Add some new filesystem objects. … … 25 25 26 26 cmd = [self.repository.CDV_CMD, "add"] 27 ExternalCommand(cwd= root, command=cmd).execute(names)27 ExternalCommand(cwd=self.basedir, command=cmd).execute(names) 28 28 29 def _commit(self, root,date, author, patchname, changelog=None, entries=None):29 def _commit(self, date, author, patchname, changelog=None, entries=None): 30 30 """ 31 31 Commit the changeset. … … 50 50 entries = ['.'] 51 51 52 ExternalCommand(cwd= root, command=cmd).execute(entries)52 ExternalCommand(cwd=self.basedir, command=cmd).execute(entries) 53 53 54 def _removePathnames(self, root,names):54 def _removePathnames(self, names): 55 55 """ 56 56 Remove some filesystem object. … … 58 58 59 59 cmd = [self.repository.CDV_CMD, "remove"] 60 ExternalCommand(cwd= root, command=cmd).execute(names)60 ExternalCommand(cwd=self.basedir, command=cmd).execute(names) 61 61 62 def _renamePathname(self, root,oldname, newname):62 def _renamePathname(self, oldname, newname): 63 63 """ 64 64 Rename a filesystem object. … … 66 66 67 67 cmd = [self.repository.CDV_CMD, "rename"] 68 ExternalCommand(cwd= root, command=cmd).execute(oldname, newname)68 ExternalCommand(cwd=self.basedir, command=cmd).execute(oldname, newname) 69 69 70 def initializeNewWorkingDir(self, root, source_repository, source_module, 71 subdir, changeset, initial): 70 def initializeNewWorkingDir(self, source_repo, changeset, initial): 72 71 """ 73 72 Initialize a new working directory, just extracted from … … 78 77 BOOTSTRAP_CHANGELOG 79 78 80 self._initializeWorkingDir(root, source_repository, source_module, 81 subdir) 79 self._initializeWorkingDir() 82 80 revision = changeset.revision 81 source_repository = source_repo.repository 82 source_module = source_repo.module 83 83 if initial: 84 84 author = changeset.author … … 89 89 patchname = BOOTSTRAP_PATCHNAME % source_module 90 90 log = BOOTSTRAP_CHANGELOG % locals() 91 self._commit( root,changeset.date, author, patchname, log,92 entries=[ subdir, '%s/...' % subdir])91 self._commit(changeset.date, author, patchname, log, 92 entries=['%s/...' % self.basedir]) 93 93 94 def _initializeWorkingDir(self, root, source_repository, source_module, 95 subdir): 94 def _initializeWorkingDir(self): 96 95 """ 97 96 Execute ``cdv init``. … … 101 100 from os.path import join 102 101 103 init = ExternalCommand(cwd=root, command=[self.repository.CDV_CMD, "init"]) 102 init = ExternalCommand(cwd=self.basedir, 103 command=[self.repository.CDV_CMD, "init"]) 104 104 init.execute() 105 105 … … 110 110 cmd = [self.repository.CDV_CMD, "set", "user"] 111 111 user = getenv('CDV_USER') or getenv('LOGNAME') 112 ExternalCommand(cwd= root, command=cmd).execute(user)112 ExternalCommand(cwd=self.basedir, command=cmd).execute(user) 113 113 114 SyncronizableTargetWorkingDir._initializeWorkingDir(self, root, 115 source_repository, 116 source_module, 117 subdir) 114 SyncronizableTargetWorkingDir._initializeWorkingDir(self) -
vcpx/bzr.py
r515 r527 19 19 ## SyncronizableTargetWorkingDir 20 20 21 def _addEntries(self, root,entries):21 def _addEntries(self, entries): 22 22 """ 23 23 Add a sequence of entries. … … 25 25 26 26 cmd = [self.repository.BZR_CMD, "add"] 27 ExternalCommand(cwd= root, command=cmd).execute(entries)27 ExternalCommand(cwd=self.basedir, command=cmd).execute(entries) 28 28 29 def _commit(self, root,date, author, patchname, changelog=None, entries=None):29 def _commit(self, date, author, patchname, changelog=None, entries=None): 30 30 """ 31 31 Commit the changeset. … … 50 50 entries = ['.'] 51 51 52 ExternalCommand(cwd= root, command=cmd).execute(entries)52 ExternalCommand(cwd=self.basedir, command=cmd).execute(entries) 53 53 54 def _removeEntries(self, root,entries):54 def _removeEntries(self, entries): 55 55 """ 56 56 Remove a sequence of entries. … … 58 58 59 59 cmd = [self.repository.BZR_CMD, "remove"] 60 ExternalCommand(cwd= root, command=cmd).execute(entries)60 ExternalCommand(cwd=self.basedir, command=cmd).execute(entries) 61 61 62 def _renameEntry(self, root,oldentry, newentry):62 def _renameEntry(self, oldentry, newentry): 63 63 """ 64 64 Rename an entry. … … 66 66 67 67 cmd = [self.repository.BZR_CMD, "rename"] 68 ExternalCommand(cwd= root, command=cmd).execute(old, new)68 ExternalCommand(cwd=self.basedir, command=cmd).execute(old, new) 69 69 70 def initializeNewWorkingDir(self, root, source_repository, 71 source_module, subdir, changeset, initial): 70 def initializeNewWorkingDir(self, source_repo, changeset, initial): 72 71 """ 73 72 Initialize a new working directory, just extracted from … … 78 77 BOOTSTRAP_CHANGELOG 79 78 80 self._initializeWorkingDir(root, source_repository, source_module, 81 subdir) 79 self._initializeWorkingDir() 82 80 revision = changeset.revision 81 source_repository = source_repo.repository 82 source_module = source_repo.module 83 83 if initial: 84 84 author = changeset.author … … 89 89 patchname = BOOTSTRAP_PATCHNAME % source_module 90 90 log = BOOTSTRAP_CHANGELOG % locals() 91 self._commit( root,changeset.date, author, patchname, log,92 entries=[ subdir, '%s/...' % subdir])91 self._commit(changeset.date, author, patchname, log, 92 entries=['%s/...' % self.basedir]) 93 93 94 def _initializeWorkingDir(self, root, source_repository, source_module, 95 subdir): 94 def _initializeWorkingDir(self): 96 95 """ 97 96 Execute ``bzr init``. … … 103 102 104 103 cmd = [self.repository.BZR_CMD, "init"] 105 init = ExternalCommand(cwd= root, command=cmd)104 init = ExternalCommand(cwd=self.basedir, command=cmd) 106 105 init.execute() 107 106 … … 112 111 # Create the .bzrignore file, that contains a glob per line, 113 112 # with all known VCs metadirs to be skipped. 114 ignore = open(join( root, '.hgignore'), 'w')113 ignore = open(join(self.basedir, '.hgignore'), 'w') 115 114 ignore.write('\n'.join(['(^|/)%s($|/)' % md 116 115 for md in IGNORED_METADIRS])) … … 118 117 ignore.close() 119 118 120 SyncronizableTargetWorkingDir._initializeWorkingDir(self, root, 121 source_repository, 122 source_module, 123 subdir) 119 SyncronizableTargetWorkingDir._initializeWorkingDir(self) -
vcpx/session.py
r511 r527 520 520 return 521 521 522 def willApply(self, root,changeset):522 def willApply(self, changeset): 523 523 """ 524 524 Print the changeset being applied. … … 533 533 return True 534 534 535 def shouldApply(self, root,changeset):535 def shouldApply(self, changeset): 536 536 """ 537 537 Ask weather a changeset should be applied. … … 561 561 self.stdout.write(str(changeset) + '\n') 562 562 563 def applied(self, root,changeset):563 def applied(self, changeset): 564 564 """ 565 565 Save current status. -
vcpx/hg.py
r515 r527 19 19 ## SyncronizableTargetWorkingDir 20 20 21 def _addPathnames(self, root,names):21 def _addPathnames(self, names): 22 22 """ 23 23 Add some new filesystem objects. … … 29 29 # them out. 30 30 31 notdirs = [n for n in names if not isdir(join( root, n))]31 notdirs = [n for n in names if not isdir(join(self.basedir, n))] 32 32 if notdirs: 33 33 cmd = [self.repository.HG_CMD, "add"] 34 ExternalCommand(cwd= root, command=cmd).execute(notdirs)34 ExternalCommand(cwd=self.basedir, command=cmd).execute(notdirs) 35 35 36 def _commit(self, root,date, author, patchname, changelog=None, entries=None):36 def _commit(self, date, author, patchname, changelog=None, entries=None): 37 37 """ 38 38 Commit the changeset. … … 55 55 "-l", "%(logfile)s", 56 56 "-d", "%(time)s UTC"] 57 c = ExternalCommand(cwd= root, command=cmd)57 c = ExternalCommand(cwd=self.basedir, command=cmd) 58 58 59 59 rontf = ReopenableNamedTemporaryFile('hg', 'tailor') … … 64 64 c.execute(logfile=rontf.name, time=mktime(date.timetuple())) 65 65 66 def _removePathnames(self, root,names):66 def _removePathnames(self, names): 67 67 """ 68 68 Remove some filesystem object. … … 74 74 # them out. 75 75 76 notdirs = [n for n in names if not isdir(join( root, n))]76 notdirs = [n for n in names if not isdir(join(self.basedir, n))] 77 77 if notdirs: 78 78 cmd = [self.repository.HG_CMD, "remove"] 79 ExternalCommand(cwd= root, command=cmd).execute(notdirs)79 ExternalCommand(cwd=self.basedir, command=cmd).execute(notdirs) 80 80 81 def _renamePathname(self, root,oldname, newname):81 def _renamePathname(self, oldname, newname): 82 82 """ 83 83 Rename a filesystem object. … … 89 89 90 90 cmd = [self.repository.HG_CMD, "copy"] 91 copy = ExternalCommand(cwd= root, command=cmd)92 if isdir(join( root, newname)):91 copy = ExternalCommand(cwd=self.basedir, command=cmd) 92 if isdir(join(self.basedir, newname)): 93 93 # Given lack of support for directories in current HG, 94 94 # loop over all files under the new directory and 95 95 # do a copy on them. 96 skip = len( root)+len(newname)+297 for dir, subdirs, files in walk(join( root, newname)):96 skip = len(self.basedir)+len(newname)+2 97 for dir, subdirs, files in walk(join(self.basedir, newname)): 98 98 prefix = dir[skip:] 99 99 … … 108 108 copy.execute(oldname, newname) 109 109 110 def _initializeWorkingDir(self, root, source_repository, source_module, 111 subdir): 110 def _initializeWorkingDir(self): 112 111 """ 113 112 Execute ``hg init``. … … 119 118 from dualwd import IGNORED_METADIRS 120 119 121 init = ExternalCommand(cwd= root,120 init = ExternalCommand(cwd=self.basedir, 122 121 command=[self.repository.HG_CMD, "init"]) 123 122 init.execute() … … 129 128 # Create the .hgignore file, that contains a regexp per line 130 129 # with all known VCs metadirs to be skipped. 131 ignore = open(join( root, '.hgignore'), 'w')130 ignore = open(join(self.basedir, '.hgignore'), 'w') 132 131 ignore.write('\n'.join(['(^|/)%s($|/)' % escape(md) 133 132 for md in IGNORED_METADIRS])) … … 135 134 ignore.close() 136 135 137 ExternalCommand(cwd= root,136 ExternalCommand(cwd=self.basedir, 138 137 command=[self.repository.HG_CMD, "addremove"]).execute() -
vcpx/project.py
r522 r527 66 66 67 67 def __str__(self): 68 return "Project %s at %s:\n\t" % (self.name, self.root ) + \68 return "Project %s at %s:\n\t" % (self.name, self.rootdir) + \ 69 69 "\n\t".join(['%s = %s' % (v, getattr(self, v)) 70 70 for v in ('source', 'target', 'state_file')]) … … 79 79 import logging 80 80 81 self.root = self.config.get(self.name, 'root', getcwd())82 if not exists(self.root ):83 makedirs(self.root )81 self.rootdir = self.config.get(self.name, 'root-directory', getcwd()) 82 if not exists(self.rootdir): 83 makedirs(self.rootdir) 84 84 self.subdir = self.config.get(self.name, 'subdir') 85 85 if not self.subdir: … … 112 112 self.logger = logging.getLogger('tailor.%s' % self.name) 113 113 logfile = self.config.get(self.name, 'logfile', 'tailor.log') 114 hdlr = logging.FileHandler(join(self.root , logfile))114 hdlr = logging.FileHandler(join(self.rootdir, logfile)) 115 115 formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s') 116 116 hdlr.setFormatter(formatter) … … 186 186 187 187 dwd = self.workingDir() 188 dwd.prepareWorkingDirectory(self.root, 189 self.target.repository, 190 self.target.module) 188 dwd.prepareWorkingDirectory() 191 189 192 190 def checkoutUpstreamRevision(self): … … 198 196 dwd = self.workingDir() 199 197 revision = self.config.get(self.name, 'start-revision', 'INITIAL') 200 actual = dwd.checkoutUpstreamRevision(self.root, 201 self.source.repository, 202 self.source.module, revision, 203 subdir=self.subdir, 204 logger=self.logger) 205 dwd.initializeNewWorkingDir(self.root, self.source.repository, 206 self.source.module, self.subdir, 207 actual, revision=='INITIAL') 208 209 def _applyable(self, root, changeset): 198 actual = dwd.checkoutUpstreamRevision(revision) 199 dwd.initializeNewWorkingDir(self.source, actual, revision=='INITIAL') 200 201 def _applyable(self, changeset): 210 202 """ 211 203 Print the changeset being applied. … … 221 213 return True 222 214 223 def _applied(self, root,changeset):215 def _applied(self, changeset): 224 216 """ 225 217 Save current status. … … 234 226 """ 235 227 236 from os.path import join237 238 wdir = join(self.root, self.subdir)239 228 dwd = self.workingDir() 240 229 try: 241 pendings = dwd.getPendingChangesets(wdir, 242 self.source.repository, 243 self.source.module) 230 pendings = dwd.getPendingChangesets() 244 231 except KeyboardInterrupt: 245 232 self.log_info("Leaving '%s' unchanged, stopped by user" % self.name) … … 256 243 try: 257 244 last, conflicts = dwd.applyPendingChangesets( 258 wdir, self.source.module, 259 applyable=self._applyable, applied=self._applied, 260 logger=self.logger) 245 applyable=self._applyable, applied=self._applied) 261 246 except: 262 247 self.log_error('Upstream change application failed', True) … … 265 250 if last: 266 251 self.log_info("Update completed, now at revision '%s'" % 267 self.upstream_revision)252 last.revision) 268 253 else: 269 254 self.log_info("Update completed with no upstream changes") -
vcpx/repository.py
r521 r527 35 35 as ``source-repository`` (or ``target-repository``) in its [DEFAULT] 36 36 section. 37 38 If the configuration does not specify a specific ``root-directory`` 39 take the one from the project. 37 40 """ 38 41 … … 45 48 self.module = config.get(self.name, 'module') or \ 46 49 config.get(self.name, '%s-module' % which) 47 if not self.module and self.repository: 48 self.module = split(self.repository)[1] 50 self.rootdir = config.get(self.name, 'root-directory', 51 self.project.rootdir) 52 self.subdir = config.get(self.name, 'subdir', self.project.subdir) 53 54 def _validateConfiguration(self): 55 """ 56 Validate the configuration, possibly altering/completing it. 57 """ 58 59 def log_info(self, what): 60 """ 61 Print some info on the log and, in verbose mode, to stdout as well. 62 """ 63 64 self.project.log_info(what) 65 66 def log_error(self, what, exc=False): 67 """ 68 Print an error message, possibly with an exception traceback, 69 to the log and to stdout as well. 70 """ 71 72 self.project.log_error(what, exc) 49 73 50 74 def workingDir(self): … … 53 77 repository. 54 78 """ 79 80 from source import InvocationError 81 82 self._validateConfiguration() 55 83 56 84 wdname = self.kind.capitalize() + 'WorkingDir' … … 61 89 except (AttributeError, ImportError): 62 90 raise InvocationError("Unhandled source VCS kind: " + self.kind) 63 return workingdir() 91 92 return workingdir(self) 64 93 65 94 … … 73 102 74 103 104 75 105 class BzrRepository(Repository): 76 106 METADIR = '.bzr' … … 99 129 self.CVS_CMD = config.get(self.name, 'cvs-command', self.CVS_CMD) 100 130 131 def _validateConfiguration(self): 132 from os.path import split 133 from config import ConfigurationError 134 135 136 if not self.module and self.repository: 137 self.module = split(self.repository)[1] 138 139 if not self.module: 140 raise ConfigurationError("Must specify a repository and maybe a module also") 101 141 102 142 class CvspsRepository(CvsRepository): … … 148 188 'svnadmin-command', self.SVNADMIN_CMD) 149 189 self.use_propset = config.get(self.name, 'use-propset', False) 190 191 def _validateConfiguration(self): 192 if not self.module: 193 raise ConfigurationError("Must the path within the " 194 "Subversion repository") 195 150 196 if not self.module.startswith('/'): 197 self.project.log_info("Prepending '/' to module") 151 198 self.module = '/' + self.module 152 199 -
vcpx/arx.py
r515 r527 20 20 ## SyncronizableTargetWorkingDir 21 21 22 def _addPathnames(self, root,names):22 def _addPathnames(self, names): 23 23 """ 24 24 Add some new filesystem objects. 25 25 """ 26 26 27 from os.path import join, isdir 27 cmd = [self.repository.ARX_CMD, "add"] 28 ExternalCommand(cwd=self.basedir, command=cmd).execute(names) 28 29 29 cmd = [self.repository.ARX_CMD, "add"] 30 ExternalCommand(cwd=root, command=cmd).execute(names) 31 32 def _commit(self,root, date, author, patchname, changelog=None, entries=None): 30 def _commit(self, date, author, patchname, changelog=None, entries=None): 33 31 """ 34 32 Commit the changeset. … … 52 50 logmessage=" " 53 51 54 cmd = [self.repository.ARX_CMD, "commit", "-s", logmessage, "--author", author, 52 cmd = [self.repository.ARX_CMD, "commit", "-s", logmessage, 53 "--author", author, 55 54 "--date", date.isoformat()] 56 c = ExternalCommand(cwd= root, command=cmd)55 c = ExternalCommand(cwd=self.basedir, command=cmd) 57 56 c.execute() 58 57 59 def _removePathnames(self, root,names):58 def _removePathnames(self, names): 60 59 """ 61 60 Remove some filesystem object. 62 61 """ 62 63 63 cmd = [self.repository.ARX_CMD, "rm"] 64 ExternalCommand(cwd= root, command=cmd).execute(names)64 ExternalCommand(cwd=self.basedir, command=cmd).execute(names) 65 65 66 def _renamePathname(self, root,oldname, newname):66 def _renamePathname(self, oldname, newname): 67 67 """ 68 68 Rename a filesystem object. … … 70 70 71 71 cmd = [self.repository.ARX_CMD, "copy"] 72 rename = ExternalCommand(cwd= root, command=cmd)73 rename.execute(oldname, newname)72 rename = ExternalCommand(cwd=self.basedir, command=cmd) 73 rename.execute(oldname, newname) 74 74 75 def _initializeWorkingDir(self , root, repository, module, subdir):75 def _initializeWorkingDir(self): 76 76 """ 77 77 Setup the ArX working copy … … 88 88 from os import walk 89 89 90 if not exists(join( root, '_arx')):91 raise TargetInitializationFailure("Please setup '%s' as an ArX working directory" % root)90 if not exists(join(self.basedir, '_arx')): 91 raise TargetInitializationFailure("Please setup '%s' as an ArX working directory" % self.basedir) 92 92 93 self._addPathnames(root, [subdir]) 94 95 cmd = [self.repository.ARX_CMD, "add"] 96 add_path = ExternalCommand(cwd=root, command=cmd) 97 98 for root, dirs, files in walk(root): 99 for f in files: 100 if f!="tailor.log" and f!="tailor.info": 101 add_path.execute(join(root,f)) 102 for metadir in IGNORED_METADIRS: 103 if metadir in dirs: 104 dirs.remove(metadir) 105 for d in dirs: 106 add_path.execute(join(root,d)) 93 SyncronizableTargetWorkingDir._initializeWorkingDir(self)
Note: See TracChangeset
for help on using the changeset viewer.
