コード例 #1
0
 def create_local_branch(self, component, aspect, branch, use_master):
     err = 0
     if not self.source_reporoot:
         return 1
     bi = BranchInfo(branchname=branch,
                     componentname=component,
                     aspectname=aspect)
     aspectdir = bi.get_branchdir(self.local_reporoot)
     if not os.path.isdir(os.path.dirname(aspectdir)):
         os.makedirs(os.path.dirname(aspectdir))
     if not os.path.isdir(aspectdir):
         if use_master:
             print '\nBranching %s into local repository from %s ...' % (
                 bi.branchpath, self.master_reporoot)
         else:
             print '\nBranching %s into local repository from %s ...' % (
                 bi.branchpath, self.source_reporoot)
         mstbr = bi.get_branchdir(self.master_reporoot)
         srcbr = bi.get_branchdir(self.source_reporoot)
         lclbr = bi.get_branchdir(self.local_reporoot)
         if use_master:
             self.branch(mstbr, lclbr, quiet=True, quiet_stderr=True)
         else:
             self.branch(srcbr, lclbr, quiet=True, quiet_stderr=True)
         with open(lclbr + '/.bzr/branch/branch.conf', 'w') as bconf:
             bconf.write('parent_location = %s\n' % mstbr)
             bconf.write('push_location = %s\n' % mstbr)
             bconf.write('submit_location = %s\n' % mstbr)
     return err
コード例 #2
0
ファイル: vcs.py プロジェクト: perfectsearch/sandman
 def create_local_branch(self, component, aspect, branch, use_master):
     err = 0
     if not self.source_reporoot:
         return 1
     bi = BranchInfo(branchname=branch, componentname=component, aspectname=aspect)
     aspectdir = bi.get_branchdir(self.local_reporoot)
     if not os.path.isdir(os.path.dirname(aspectdir)):
         os.makedirs(os.path.dirname(aspectdir))
     if not os.path.isdir(aspectdir):
         if use_master:
             print '\nBranching %s into local repository from %s ...' % (bi.branchpath, self.master_reporoot)
         else:
             print '\nBranching %s into local repository from %s ...' % (bi.branchpath, self.source_reporoot)
         mstbr = bi.get_branchdir(self.master_reporoot)
         srcbr = bi.get_branchdir(self.source_reporoot)
         lclbr = bi.get_branchdir(self.local_reporoot)
         if use_master:
             self.branch(mstbr, lclbr, quiet=True, quiet_stderr=True)
         else:
             self.branch(srcbr, lclbr, quiet=True, quiet_stderr=True)
         with open(lclbr+'/.bzr/branch/branch.conf', 'w') as bconf:
             bconf.write('parent_location = %s\n' %mstbr)
             bconf.write('push_location = %s\n' % mstbr)
             bconf.write('submit_location = %s\n' % mstbr)
     return err
コード例 #3
0
ファイル: vcs.py プロジェクト: perfectsearch/sandman
 def tag(self, tag, component, aspect, branch, revisionid):
     bi = BranchInfo(branchname=branch, componentname=component, aspectname=aspect)
     cmd, out = _prep_cmd(cmd_tag())
     revision = None
     if revisionid:
         revision = bzrlib.option._parse_revision_str("revid:%s" % str(revisionid))
     return cmd.run(revision=revision, tag_name=tag, directory=bi.get_branchdir(self.master_reporoot))
コード例 #4
0
ファイル: aggregate_vcs.py プロジェクト: dhh1128/sandman
def pull_component(comp, sb, source):
    aspects = get_vcs_component_aspects(comp, sb)
    wr = vcs.get_working_repository()
    for a in aspects:
        pattern = '%s/%s/%s(\.[^/]+)' % (sb.get_branch(), comp, a
                                         )  #fix_julie repo structure
        aspect_suffixes = []
        for branchinfo in wr.branches:
            m = re.match(pattern, '/'.join(branchinfo))
            if m:
                aspect_suffixes.append(m.group(1))
        if aspect_suffixes:
            aspects = [a + x for x in aspect_suffixes]
        else:
            aspects = [a]
        for aspect in aspects:
            path = sb.get_component_path(comp, aspect)
            if source:
                if a.startswith(component.BUILT_ASPECT_NAME
                                ) or a == component.REPORT_ASPECT_NAME:
                    continue
                from_location = BranchInfo(branchname=source,
                                           componentname=comp,
                                           aspectname=aspect).get_branchdir(
                                               wr.source_reporoot)
            else:
                from_location = BranchInfo(branchname=sb.get_branch(),
                                           componentname=comp,
                                           aspectname=aspect).get_branchdir(
                                               wr.source_reporoot)
                print('  ' + _get_relative_path(sb, comp, aspect))
            try:
                vcs.pull(path, from_location=from_location)
            except:
                print(sys.exc_info()[1])
コード例 #5
0
ファイル: vcs.py プロジェクト: perfectsearch/sandman
 def tags(self, component, aspect, branch, reporoot=None, lastRevision=True):
     if reporoot == None:
         reporoot = self.master_reporoot
     revision = None
     if lastRevision:
         revision = bzrlib.option._parse_revision_str("last:1")
     bi = BranchInfo(branchname=branch, componentname=component, aspectname=aspect)
     cmd, out = _prep_cmd(cmd_tags())
     cmd.run(revision=revision, directory=bi.get_branchdir(reporoot))
     return out.getvalue().strip()
コード例 #6
0
ファイル: vcs.py プロジェクト: perfectsearch/sandman
def get_file_contents(reporoot, component, aspect, branch, filepath, revision=None):
    """return the contents of a specific file directly from the local repository without a working
    copy.
    """
    bi = BranchInfo(branchname=branch, componentname=component, aspectname=aspect)
    directory = bi.get_branchdir(reporoot)
    output, err= cat(filepath, revision=revision, directory=directory)
    if err:
        print output
    if not err:
        return output
コード例 #7
0
 def tag(self, tag, component, aspect, branch, revisionid):
     bi = BranchInfo(branchname=branch,
                     componentname=component,
                     aspectname=aspect)
     cmd, out = _prep_cmd(cmd_tag())
     revision = None
     if revisionid:
         revision = bzrlib.option._parse_revision_str("revid:%s" %
                                                      str(revisionid))
     return cmd.run(revision=revision,
                    tag_name=tag,
                    directory=bi.get_branchdir(self.master_reporoot))
コード例 #8
0
 def tags(self,
          component,
          aspect,
          branch,
          reporoot=None,
          lastRevision=True):
     if reporoot == None:
         reporoot = self.master_reporoot
     revision = None
     if lastRevision:
         revision = bzrlib.option._parse_revision_str("last:1")
     bi = BranchInfo(branchname=branch,
                     componentname=component,
                     aspectname=aspect)
     cmd, out = _prep_cmd(cmd_tags())
     cmd.run(revision=revision, directory=bi.get_branchdir(reporoot))
     return out.getvalue().strip()
コード例 #9
0
ファイル: vcs.py プロジェクト: perfectsearch/sandman
    def update_local_branch(self, component, aspect, branch):
        ''' update (pull) the local branch from the parent '''
        try:
            if self.source_reporoot:
                source_revid = self.get_source_revid(branch, component, aspect)
                local_revid = self.get_local_revid(branch, component, aspect)
                if source_revid != local_revid:
##                print 'source_revid', source_revid, 'local_revid', local_revid
##                from pprint import pprint
##                pprint(traceback.format_stack())
                    bi = BranchInfo(branchname=branch, componentname=component, aspectname=aspect)
                    branchdir = bi.get_branchdir(self.local_reporoot)
                    print '\nUpdating %s/%s/%s in local repository from %s ...' % (branch, component, aspect, self.source_reporoot)
                    return pull(branchdir, bi.get_branchdir(self.source_reporoot))
        except DivergedBranches, e:
            # Only throw this error in the case that the aspect is not report
            if aspect != 'report':
                raise e
コード例 #10
0
def get_file_contents(reporoot,
                      component,
                      aspect,
                      branch,
                      filepath,
                      revision=None):
    """return the contents of a specific file directly from the local repository without a working
    copy.
    """
    bi = BranchInfo(branchname=branch,
                    componentname=component,
                    aspectname=aspect)
    directory = bi.get_branchdir(reporoot)
    output, err = cat(filepath, revision=revision, directory=directory)
    if err:
        print output
    if not err:
        return output
コード例 #11
0
 def checkout_branch(self,
                     target_dir,
                     component,
                     aspect,
                     branch,
                     revision=None):
     """target_dir is the directory that will contain the new checkout.
     """
     return checkout(
         BranchInfo(branchname=branch,
                    componentname=component,
                    aspectname=aspect).get_branchdir(self.local_reporoot),
         target_dir)
コード例 #12
0
 def update_local_branch(self, component, aspect, branch):
     ''' update (pull) the local branch from the parent '''
     try:
         if self.source_reporoot:
             source_revid = self.get_source_revid(branch, component, aspect)
             local_revid = self.get_local_revid(branch, component, aspect)
             if source_revid != local_revid:
                 ##                print 'source_revid', source_revid, 'local_revid', local_revid
                 ##                from pprint import pprint
                 ##                pprint(traceback.format_stack())
                 bi = BranchInfo(branchname=branch,
                                 componentname=component,
                                 aspectname=aspect)
                 branchdir = bi.get_branchdir(self.local_reporoot)
                 print '\nUpdating %s/%s/%s in local repository from %s ...' % (
                     branch, component, aspect, self.source_reporoot)
                 return pull(branchdir,
                             bi.get_branchdir(self.source_reporoot))
     except DivergedBranches, e:
         # Only throw this error in the case that the aspect is not report
         if aspect != 'report':
             raise e
コード例 #13
0
ファイル: aggregate_vcs.py プロジェクト: dhh1128/sandman
def push_component(comp, sb, to, validate_status=True):
    if validate_status and _complain_component_not_clean(comp, sb, 'push'):
        return
    aspects = get_vcs_component_aspects(comp, sb)
    wr = vcs.get_working_repository()
    for a in aspects:
        if a.startswith(component.BUILT_ASPECT_NAME
                        ) or a == component.REPORT_ASPECT_NAME:
            continue
        path = sb.get_component_path(comp, a)
        if to:
            location = BranchInfo(branchname=to,
                                  componentname=comp,
                                  aspectname=a).get_branchdir(
                                      wr.master_reporoot)
        else:
            location = BranchInfo(branchname=sb.get_branch(),
                                  componentname=comp,
                                  aspectname=a).get_branchdir(
                                      wr.master_reporoot)
        print('  ' + _get_relative_path(sb, comp, a))
        vcs.push(path, location=location)
コード例 #14
0
ファイル: aggregate_vcs.py プロジェクト: dhh1128/sandman
def merge_component(comp, sb, source):
    aspects = get_vcs_component_aspects(comp, sb)
    wr = vcs.get_working_repository()
    for a in aspects:
        if a.startswith(component.BUILT_ASPECT_NAME):
            continue
        path = sb.get_component_path(comp, a)
        if source:
            if a == component.REPORT_ASPECT_NAME:
                continue
            from_location = BranchInfo(branchname=source,
                                       componentname=comp,
                                       aspectname=a).get_branchdir(
                                           wr.master_reporoot)
        else:
            from_location = BranchInfo(branchname=sb.get_branch(),
                                       componentname=comp,
                                       aspectname=a).get_branchdir(
                                           wr.master_reporoot)
        print('  ' + _get_relative_path(sb, comp, a))
        try:
            vcs.merge(path, from_location=from_location)
        except:
            print(sys.exc_info()[1])
コード例 #15
0
 def get_local_revid(self, branch, component, aspect):
     try:
         p = subprocess.Popen('bzr version-info %s' % BranchInfo(
             branch, component, aspect).get_branchdir(self.local_reporoot),
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE,
                              shell=True)
         stdout, stderr = p.communicate()
         err = p.returncode
         if err != 0:
             raise Exception()
         else:
             revid = 'none'
             for l in stdout.split('\n'):
                 if l.startswith('revision-id:'):
                     revid = l.split(':', 1)[1].strip()
             return revid
     except:
         raise Exception()
コード例 #16
0
ファイル: replicatereport.py プロジェクト: dhh1128/sandman
def replicatereport(reporoot, server):
    tmp = reporoot.replace('\\', '/').rstrip('/')
    reportroot = tmp[:tmp.rfind('/')] + '/reportroot'
    lock_file = '%s/lock' % reportroot
    with FileLock(lock_file, 5):
        timeFile = '%s/lastupdate.txt' % reportroot
        if server and os.path.exists(timeFile):
            finished = open(timeFile, 'r')
            finished = finished.read()
            date, t = finished.split()
            year, month, day = date.split('-')
            hour, min, sec = t.split(':')
            sec, micro = sec.split('.')
            finished = datetime.datetime(int(year), int(month), int(day),
                                         int(hour), int(min), int(sec),
                                         int(micro))
            if datetime.datetime.now() - finished < datetime.timedelta(
                    minutes=1):
                return
        while True:
            try:
                p = subprocess.Popen('bzr fast-branches %s' % reporoot,
                                     stdout=subprocess.PIPE,
                                     shell=True)
                reports = []
                output = p.stdout.read()
                for x in output.split('\n'):
                    if x.strip():
                        parts = x.split()
                        if len(parts) == 4:
                            reports.append(parts)
                        elif len(parts) == 3:
                            parts.append('none')
                            reports.append(parts)
                reports = [r for r in reports if r[2] == 'report']
                print 'xxxxxxxxxxxx'
                for report in reports:
                    bi = BranchInfo(branchname=report[0],
                                    componentname=report[1],
                                    aspectname=report[2])
                    branchdir = bi.get_branchdir(reporoot)
                    reportdir = bi.get_branchdir(reportroot)
                    if not os.path.exists(reportdir):
                        print 'Checking out %s.' % reportdir
                        os.makedirs(reportdir)
                        os.system('bzr co --lightweight %s %s' %
                                  (branchdir, reportdir))
                    else:
                        print 'Updating %s.' % reportdir
                        os.system('bzr up -q %s' % reportdir)
                for branch in os.listdir(reportroot):
                    rdir = os.path.join(reportroot, branch).replace('\\', '/')
                    bdir = os.path.join(reporoot, branch).replace('\\', '/')
                    if not os.path.exists(bdir):
                        print 'Removing %s' % rdir
                        shutil.rmtree(rdir, True, handleRmtree)
                    else:
                        for comp in os.listdir(rdir):
                            crdir = os.path.join(rdir, comp).replace('\\', '/')
                            cbdir = os.path.join(bdir, comp).replace('\\', '/')
                            if not os.path.exists(cbdir):
                                print 'Removing %s' % crdir
                                shutil.rmtree(crdir, True, handleRmtree)
            except KeyboardInterrupt:
                sys.exit(0)
            except:
                print(sys.exc_info()[1])
                time.sleep(10)
            if server:
                finished = open(timeFile, 'w')
                finished.write(str(datetime.datetime.now()))
                finished.close()
                break
            time.sleep(60)
コード例 #17
0
def replicatereport(reporoot, server):
    tmp = reporoot.replace('\\','/').rstrip('/')
    reportroot = tmp[:tmp.rfind('/')] + '/reportroot'
    lock_file = '%s/lock' % reportroot
    with FileLock(lock_file, 5):
        timeFile = '%s/lastupdate.txt' % reportroot
        if server and os.path.exists(timeFile):
            finished = open(timeFile, 'r')
            finished = finished.read()
            date, t = finished.split()
            year, month, day = date.split('-')
            hour, min, sec = t.split(':')
            sec, micro = sec.split('.')
            finished = datetime.datetime(int(year), int(month), int(day), int(hour), int(min), int(sec), int(micro))
            if datetime.datetime.now() - finished < datetime.timedelta(minutes = 1):
                return
        while True:
            try:
                p = subprocess.Popen('bzr fast-branches %s' % reporoot, stdout = subprocess.PIPE, shell=True)
                reports = []
                output = p.stdout.read()
                for x in output.split('\n'):
                        if x.strip():
                            parts = x.split()
                            if len(parts) == 4:
                                reports.append(parts)
                            elif len(parts) == 3:
                                parts.append('none')
                                reports.append(parts)
                reports = [r for r in reports if r[2] == 'report']
                print 'xxxxxxxxxxxx'
                for report in reports:
                    bi = BranchInfo(branchname=report[0], componentname=report[1], aspectname=report[2])
                    branchdir = bi.get_branchdir(reporoot)
                    reportdir = bi.get_branchdir(reportroot)
                    if not os.path.exists(reportdir):
                        print 'Checking out %s.' % reportdir
                        os.makedirs(reportdir)
                        os.system('bzr co --lightweight %s %s' % (branchdir, reportdir))
                    else:
                        print 'Updating %s.' % reportdir
                        os.system('bzr up -q %s' % reportdir)
                for branch in os.listdir(reportroot):
                    rdir = os.path.join(reportroot, branch).replace('\\','/')
                    bdir = os.path.join(reporoot, branch).replace('\\','/')
                    if not os.path.exists(bdir):
                        print 'Removing %s' % rdir
                        shutil.rmtree(rdir,True,handleRmtree)
                    else:
                        for comp in os.listdir(rdir):
                            crdir = os.path.join(rdir, comp).replace('\\','/')
                            cbdir = os.path.join(bdir, comp).replace('\\','/')
                            if not os.path.exists(cbdir):
                                print 'Removing %s' % crdir
                                shutil.rmtree(crdir,True,handleRmtree)
            except KeyboardInterrupt:
                sys.exit(0)
            except:
                print(sys.exc_info()[1])
                time.sleep(10)
            if server:
                finished = open(timeFile, 'w')
                finished.write(str(datetime.datetime.now()))
                finished.close()
                break
            time.sleep(60)