Changeset 875 in tailor


Ignore:
Timestamp:
10/02/05 08:23:10 (8 years ago)
Author:
R.Ghetta <birrachiara@…>
Hash name:
20051002062310-2c016-23ac114e1206afda4b0cb5f4db6cd669c5e0f770
Message:

bugfix on handling of monotone branches

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/monotone.py

    r850 r875  
    8585        return '\n'.join(s) 
    8686 
    87     def update(self, real_dates, authors, log, real_ancestors): 
     87    def update(self, real_dates, authors, log, real_ancestors, branches): 
    8888        """ 
    8989        Updates the monotone changeset secondary data 
     
    9494        self.real_dates = real_dates 
    9595        self.real_ancestors = real_ancestors 
     96        self.branches = branches 
    9697 
    9798class MonotoneLogParser: 
     
    137138        self.dates=[] 
    138139        self.changelog="" 
     140        self.branches=[] 
    139141 
    140142        cmd = self.repository.command("log", "--db", self.repository.repository, 
     
    174176                    self.dates.append(date) 
    175177                    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"): 
    177183                # unused data, just resetting state 
    178184                state = self.SINGLE 
     
    216222                     authors=self.authors, 
    217223                     log=self.changelog, 
    218                      real_ancestors=self.ancestors) 
     224                     real_ancestors=self.ancestors, 
     225                     branches=self.branches) 
    219226 
    220227        return chset 
     
    431438 
    432439    branch 
    433       ignored (tailor follows only a single branch) 
     440      used to restrict source revs (tailor follows only a single branch) 
    434441 
    435442    testresult 
     
    452459    """ 
    453460 
    454     def __init__(self, repository, working_dir): 
     461    def __init__(self, repository, working_dir, branch): 
    455462        self.working_dir = working_dir 
    456463        self.repository = repository 
     464        self.branch = branch 
    457465        self.logparser = MonotoneLogParser(repository=repository, 
    458466                                           working_dir=working_dir) 
     
    460468                                             working_dir=working_dir) 
    461469 
    462     def _cset_from_rev(self, lin_ancestor, revision): 
    463         # prepare a new changeset and fill it with rev data 
    464         chset = MonotoneChangeset(lin_ancestor, revision) 
    465         self.updateCset(chset) 
    466         return chset 
    467  
    468470    def updateCset(self, chset): 
    469471        # Parsing the log fills the changeset from revision data 
     
    474476            self.diffparser.convertDiff(chset) 
    475477 
    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        """ 
    479485        cslist=[] 
    480486        anc=revlist[0] 
    481487        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 
    484495        return cslist 
    485496 
     
    487498class MonotoneWorkingDir(UpdatableSourceWorkingDir, SyncronizableTargetWorkingDir): 
    488499 
    489     def convert_head_initial(self, repository, module, revision, working_dir): 
     500    def _convert_head_initial(self, dbrepo, module, revision, working_dir): 
    490501        """ 
    491502        This method handles HEAD and INITIAL pseudo-revisions, converting 
     
    496507            # in both cases we need the head(s) of the requested branch 
    497508            cmd = self.repository.command("automate","heads", 
    498                                           "--db", repository, module) 
     509                                          "--db", dbrepo, module) 
    499510            mtl = ExternalCommand(cwd=working_dir, command=cmd) 
    500511            outstr = mtl.execute(stdout=PIPE) 
     
    519530                                  "full history." % module) 
    520531                cmd = [ self.repository.command("automate","ancestors", 
    521                                                 "--db",repository), 
     532                                                "--db",dbrepo), 
    522533                        self.repository.command("automate","toposort", 
    523                                                 "--db",repository, "-@-") 
     534                                                "--db",dbrepo, "-@-") 
    524535                        ] 
    525536                cmd[0].extend(revision) 
     
    529540                    raise InvocationError("Ancestor reading returned " 
    530541                                          "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 
    533551        return effective_rev 
    534552 
     
    553571 
    554572        # now childs is a list of revids, we must transform it in a 
    555         # list of monotone changesets at this time we fill only the 
     573        # list of monotone changesets. We fill only the 
    556574        # linearized ancestor and revision ids, because at this time 
    557575        # 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         chlist = [] 
    561         lin_anc=sincerev 
    562         for r in childs: 
    563             chlist.append(MonotoneChangeset(lin_anc, r)) 
    564             lin_anc = r 
     576        # 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) 
    565583        return chlist 
    566584 
     
    573591                                              "status %s" % mtl.exit_status) 
    574592        mtr = MonotoneRevToCset(repository=self.repository, 
    575                                 working_dir=self.basedir) 
     593                                working_dir=self.basedir, 
     594                                branch=self.repository.module) 
    576595        mtr.updateCset( changeset ) 
    577596 
     
    582601        Concretely do the checkout of the FIRST upstream revision. 
    583602        """ 
    584         effrev = self.convert_head_initial(self.repository.repository, 
     603        effrev = self._convert_head_initial(self.repository.repository, 
    585604                                           self.repository.module, revision, 
    586                                            self.basedir) 
     605                                           self.repository.rootdir) 
    587606        if not exists(join(self.basedir, 'MT')): 
     607 
     608            # actually check out the revision 
    588609            self.log_info("checking out a working copy") 
    589610            cmd = self.repository.command("co", 
     
    591612                                          "--revision", effrev, 
    592613                                          "--branch", self.repository.module, 
    593                                           self.repository.subdir) 
     614                                          self.basedir) 
    594615            mtl = ExternalCommand(cwd=self.repository.rootdir, command=cmd) 
    595616            mtl.execute() 
     
    599620        else: 
    600621            self.log_info("%s already exists, assuming it's a monotone " 
    601                           "working dir" % self.basedir) 
     622                          "working dir already populated" % self.basedir) 
     623 
    602624 
    603625        # Ok, now the workdir contains the checked out revision. We 
     
    610632        # linearized ancestor, changeset entries will NOT be filled 
    611633        mtr = MonotoneRevToCset(repository=self.repository, 
    612                                 working_dir=self.basedir) 
     634                                working_dir=self.basedir, 
     635                                branch=self.repository.module) 
    613636        mtr.updateCset(chset) 
    614637        return chset 
Note: See TracChangeset for help on using the changeset viewer.