Changeset 875 in tailor
- Timestamp:
- 10/02/05 08:23:10 (8 years ago)
- Hash name:
- 20051002062310-2c016-23ac114e1206afda4b0cb5f4db6cd669c5e0f770
- File:
-
- 1 edited
-
vcpx/monotone.py (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vcpx/monotone.py
r850 r875 85 85 return '\n'.join(s) 86 86 87 def update(self, real_dates, authors, log, real_ancestors ):87 def update(self, real_dates, authors, log, real_ancestors, branches): 88 88 """ 89 89 Updates the monotone changeset secondary data … … 94 94 self.real_dates = real_dates 95 95 self.real_ancestors = real_ancestors 96 self.branches = branches 96 97 97 98 class MonotoneLogParser: … … 137 138 self.dates=[] 138 139 self.changelog="" 140 self.branches=[] 139 141 140 142 cmd = self.repository.command("log", "--db", self.repository.repository, … … 174 176 self.dates.append(date) 175 177 state = self.SINGLE 176 elif pr("Branch:") or pr("Tag"): 178 elif pr("Branch:"): 179 # branch data 180 self.branches.append(pr.value) 181 state = self.SINGLE 182 elif pr("Tag"): 177 183 # unused data, just resetting state 178 184 state = self.SINGLE … … 216 222 authors=self.authors, 217 223 log=self.changelog, 218 real_ancestors=self.ancestors) 224 real_ancestors=self.ancestors, 225 branches=self.branches) 219 226 220 227 return chset … … 431 438 432 439 branch 433 ignored(tailor follows only a single branch)440 used to restrict source revs (tailor follows only a single branch) 434 441 435 442 testresult … … 452 459 """ 453 460 454 def __init__(self, repository, working_dir ):461 def __init__(self, repository, working_dir, branch): 455 462 self.working_dir = working_dir 456 463 self.repository = repository 464 self.branch = branch 457 465 self.logparser = MonotoneLogParser(repository=repository, 458 466 working_dir=working_dir) … … 460 468 working_dir=working_dir) 461 469 462 def _cset_from_rev(self, lin_ancestor, revision):463 # prepare a new changeset and fill it with rev data464 chset = MonotoneChangeset(lin_ancestor, revision)465 self.updateCset(chset)466 return chset467 468 470 def updateCset(self, chset): 469 471 # Parsing the log fills the changeset from revision data … … 474 476 self.diffparser.convertDiff(chset) 475 477 476 def getCset(self, revlist): 477 # receives a revlist, already toposorted (i.e. ordered by 478 # ancestry) and outputs a list of changesets 478 def getCset(self, revlist, onlyFirst): 479 """ 480 receives a revlist, already toposorted (i.e. ordered by 481 ancestry) and outputs a list of changesets, filtering out revs 482 outside the chosen branch. If onlyFirst is true, only the 483 first valid element is considered 484 """ 479 485 cslist=[] 480 486 anc=revlist[0] 481 487 for r in revlist[1:]: 482 cslist.append(self._cset_from_rev(anc, r)) 483 anc=r 488 chtmp = MonotoneChangeset(anc, r) 489 self.logparser.convertLog(chtmp) 490 if self.branch in chtmp.branches: 491 cslist.append(MonotoneChangeset(anc, r)) # using a new, unfilled changeset 492 anc=r 493 if onlyFirst: 494 break 484 495 return cslist 485 496 … … 487 498 class MonotoneWorkingDir(UpdatableSourceWorkingDir, SyncronizableTargetWorkingDir): 488 499 489 def convert_head_initial(self, repository, module, revision, working_dir):500 def _convert_head_initial(self, dbrepo, module, revision, working_dir): 490 501 """ 491 502 This method handles HEAD and INITIAL pseudo-revisions, converting … … 496 507 # in both cases we need the head(s) of the requested branch 497 508 cmd = self.repository.command("automate","heads", 498 "--db", repository, module)509 "--db", dbrepo, module) 499 510 mtl = ExternalCommand(cwd=working_dir, command=cmd) 500 511 outstr = mtl.execute(stdout=PIPE) … … 519 530 "full history." % module) 520 531 cmd = [ self.repository.command("automate","ancestors", 521 "--db", repository),532 "--db",dbrepo), 522 533 self.repository.command("automate","toposort", 523 "--db", repository, "-@-")534 "--db",dbrepo, "-@-") 524 535 ] 525 536 cmd[0].extend(revision) … … 529 540 raise InvocationError("Ancestor reading returned " 530 541 "status %d" % cld.exit_status) 531 revision = outstr[0].getvalue().split() 532 effective_rev=revision[0] 542 revlist = outstr[0].getvalue().split() 543 mtr = MonotoneRevToCset(repository=self.repository, 544 working_dir=working_dir, 545 branch=module) 546 first_cset = mtr.getCset(revlist, True) 547 if len(first_cset)==0: 548 raise InvocationError("Can't find an INITIAL revision on branch '%s'." 549 % module) 550 effective_rev=first_cset[0].revision 533 551 return effective_rev 534 552 … … 553 571 554 572 # now childs is a list of revids, we must transform it in a 555 # list of monotone changesets at this time we fill only the573 # list of monotone changesets. We fill only the 556 574 # linearized ancestor and revision ids, because at this time 557 575 # we need only to know WICH changesets must be applied to the 558 # target repo, not WHAT are the changesets 559 childs = outstr[0].getvalue().split()560 ch list = []561 lin_anc=sincerev562 for r in childs:563 chlist.append(MonotoneChangeset(lin_anc, r))564 lin_anc = r576 # target repo, not WHAT are the changesets (apart for filtering 577 # the outside-branch revs) 578 childs = [sincerev] +outstr[0].getvalue().split() 579 mtr = MonotoneRevToCset(repository=self.repository, 580 working_dir=self.repository.rootdir, 581 branch=self.repository.module) 582 chlist = mtr.getCset(childs, False) 565 583 return chlist 566 584 … … 573 591 "status %s" % mtl.exit_status) 574 592 mtr = MonotoneRevToCset(repository=self.repository, 575 working_dir=self.basedir) 593 working_dir=self.basedir, 594 branch=self.repository.module) 576 595 mtr.updateCset( changeset ) 577 596 … … 582 601 Concretely do the checkout of the FIRST upstream revision. 583 602 """ 584 effrev = self. convert_head_initial(self.repository.repository,603 effrev = self._convert_head_initial(self.repository.repository, 585 604 self.repository.module, revision, 586 self. basedir)605 self.repository.rootdir) 587 606 if not exists(join(self.basedir, 'MT')): 607 608 # actually check out the revision 588 609 self.log_info("checking out a working copy") 589 610 cmd = self.repository.command("co", … … 591 612 "--revision", effrev, 592 613 "--branch", self.repository.module, 593 self. repository.subdir)614 self.basedir) 594 615 mtl = ExternalCommand(cwd=self.repository.rootdir, command=cmd) 595 616 mtl.execute() … … 599 620 else: 600 621 self.log_info("%s already exists, assuming it's a monotone " 601 "working dir" % self.basedir) 622 "working dir already populated" % self.basedir) 623 602 624 603 625 # Ok, now the workdir contains the checked out revision. We … … 610 632 # linearized ancestor, changeset entries will NOT be filled 611 633 mtr = MonotoneRevToCset(repository=self.repository, 612 working_dir=self.basedir) 634 working_dir=self.basedir, 635 branch=self.repository.module) 613 636 mtr.updateCset(chset) 614 637 return chset
Note: See TracChangeset
for help on using the changeset viewer.
