示例#1
0
    def update_to_latest(obj, rev=False):
        '''
       pull -> update
 
       if rev push is performed
       '''

        url, root, path = obj.get_mercurial_url()

        ### pull
        ocwd = os.getcwd()

        os.chdir(obj.owndir())
        repo = hgapi.Repo(obj.owndir())
        if not rev:
            repo.hg_pull(url)
            obj.hg_set_projtreeviewer_status(repo=repo)
            latest = repo.revisions(slice(-1, -1))[0].rev
        else:
            repo.hg_push(url)
            repo2 = hgapi.Repo(url)
            latest = repo2.revisions(slice(-1, -1))[0].rev
            repo2.hg_update(long(latest))
        os.chdir(ocwd)

        #app = wx.GetApp().TopWindow
        #tv = app.proj_tree_viewer
        #tv.update_widget()

        ### update
        if not rev:
            new_obj = obj.onHGupdate(None, latest)
            return latest, new_obj
        else:
            return latest, url
示例#2
0
        def onHGpush(self, evt):
            app = wx.GetApp().TopWindow
            url, root, path = self.get_mercurial_url()
            if url is not None:
                root = root
                name = path
            else:
                root = None
                name = self._name

            list6 = [
                ["root repository", root, 304,
                 dlg_s()],
                ["name", name, 0, None],
                [None, True, 3, {
                    "text": 'Perform HG update'
                }],
            ]

            value = DialogEditList(list6,
                                   modal=True,
                                   style=wx.DEFAULT_DIALOG_STYLE
                                   | wx.RESIZE_BORDER,
                                   tip=None,
                                   parent=app,
                                   title='HG push')
            if not value[0]:
                return
            if not self.update_hgsub():
                return
            url = rootpath2url(str(value[1][0]), str(value[1][1]))

            ocwd = os.getcwd()
            os.chdir(self.owndir())
            try:
                urlbk, rootbk, pathbk = self.get_mercurial_url()
                repo = hgapi.Repo(self.owndir())
                self.set_mercurial_url(str(value[1][0]), str(value[1][1]))
                repo.hg_push(url)
                if value[1][2] and not url.startswith('ssh'):
                    repo2 = hgapi.Repo(url)
                    latest = repo2.revisions(slice(-1, -1))[0].rev
                    repo2.hg_update(int(latest))
            except:
                dialog.showtraceback(parent=app,
                                     txt='Failed to push',
                                     title='Failed to push',
                                     traceback=traceback.format_exc())
            self.set_mercurial_url(rootbk, pathbk)
            os.chdir(ocwd)
示例#3
0
def _hg_branches(module, path, config_branch=None):
    client = hgapi.Repo(path)
    branches = client.get_branch_names()
    active = client.hg_branch()
    b = []
    branches.sort()
    branches.reverse()
    for branch in branches:
        br = branch

        if branch == active:
            br = "*" + br

        if branch == config_branch:
            br = "[" + br + "]"

        b.append(br)

    msg = str.ljust(module, 40, ' ') + "\t".join(b)

    if "[*" in msg:
        msg = bcolors.OKGREEN + msg + bcolors.ENDC
    elif "\t[" in msg or '\t*' in msg:
        msg = bcolors.FAIL + msg + bcolors.ENDC
    else:
        msg = bcolors.WARN + msg + bcolors.ENDC

    print msg
示例#4
0
 def _do_make_hg(self, value):
     app = wx.GetApp().TopWindow
     try:
         self.setvar('include',
                     [x.strip() for x in str(value[0]).split(',')])
         self.setvar('exclude',
                     [x.strip() for x in str(value[1]).split(',')])
     except:
         dialog.showtraceback(parent=app,
                              txt='Failed to set include/exclude',
                              title='Failure',
                              traceback=traceback.format_exc())
         return
     repo = hgapi.Repo(self.owndir())
     repo.hg_init()
     self.update_hgsub()
     addfile, rmfile, skipfile, txt = hg_add_no_binary(
         repo,
         self.owndir(),
         include=self.getvar('include'),
         exclude=self.getvar('exclude'))
     dlg = wx.MessageDialog(None, txt, "HG add/remove", wx.OK)
     ret = dlg.ShowModal()
     dlg.Destroy()
     self._image_update = False
     _add_include_exclude(self)
     tv = app.proj_tree_viewer
     tv.update_widget()
示例#5
0
 def __init__(self, engine, **kw):
     super(HgStore, self).__init__(engine, **kw)
     self._repo = hgapi.Repo(self._dir)
     try:
         self._repo.hg_status()
     except Exception:
         self._repo.hg_init()
示例#6
0
 def hg_incoming_outgoing_changesets_list(self,
                                          repo=None,
                                          url='default'):
     if repo is None: repo = hgapi.Repo(self.owndir())
     try:
         lines1 = repo.hg_command('incoming', url).split('\n')
         incoming = [
             long(l.split(':')[1]) for l in lines1
             if l.find('changeset') != -1
         ]
     except:
         import traceback
         if 'no changes found' in traceback.format_exc():
             incoming = []
         else:
             traceback.print_exc()
             return [], []
     try:
         lines2 = repo.hg_command('outgoing', url).split('\n')
         outgoing = [
             long(l.split(':')[1]) for l in lines2
             if l.find('changeset') != -1
         ]
     except:
         import traceback
         if 'no changes found' in traceback.format_exc():
             outgoing = []
         else:
             traceback.print_exc()
             return incoming, []
     return incoming, outgoing
示例#7
0
def pull(dir1, dir2, dry_run=False):
    '''
       pull from dir2 to dir1

       example) pull('/Users/shiraiwa/hg_root', 'ssh://cmodws60/hg_root', dry_run = False)
    '''
    for root, dirs, files in os.walk(dir1):
        if '.hg' in dirs:
            dirs.remove('.hg')
            repo = hgapi.Repo(root)
            url = dir2 + root[len(dir1):]
            try:
                out = repo.hg_command('incoming', url)
                lines = out.split('\n')
                numc = len([1 for l in lines if l.startswith('changeset')])
                if numc > 0:
                    print(str(numc) + ' is coming from ' + url)

            except:
                if traceback.format_exc().find('no changes found') != -1:
                    print(url + ' is updated')
                    continue
                if traceback.format_exc().find('There is no Mercurial') != -1:
                    print('no repo found in ' + url)
                    continue
                traceback.print_exc()
                continue
            if dry_run:
                continue
            try:
                repo.hg_pull(url)
            except:
                traceback.print_exc()
示例#8
0
def hg_pull(module, path, update=False, clean=False, branch=None,
        revision=None, ignore_missing=False):
    if not os.path.exists(path):
        if ignore_missing:
            return 0
        print >> sys.stderr, t.red("Missing repositori:") + t.bold(path)
        return -1

    repo = hgapi.Repo(path)
    retries = 2
    while retries:
        retries -= 1
        try:
            repo.hg_pull()
            if update:
                return hg_update_ng(module, path, clean, branch=branch,
                    revision=revision, ignore_missing=ignore_missing)
            return 0
        except hgapi.HgException, e:
            import traceback
            traceback.print_stack()
            if retries:
                print t.bold_yellow('[' + path + '] (%d)' % retries)
            else:
                print t.bold_red('[' + path + ']')
            print "Error running %s : %s" % (e.exit_code, str(e))
            if retries:
                continue
            return -1
        except:
示例#9
0
def upload_review(work, path, branch, review_name, review=None, new=False):
    get_tryton_connection()
    Review = Model.get('project.work.codereview')
    Task = Model.get('project.work')
    Component = Model.get('project.work.component')

    tasks = Task.find([('code', '=', work)])
    if not tasks:
        print >>sys.stderr, t.red('Error: Task %s was not found.' % work)
        sys.exit(1)
    work = tasks[0]

    module = path.split('/')[-1]
    components = Component.find([('name', '=', module)])
    if not components:
        component = Component(name=module)
        component.save()
    else:
        component = components[0]

    review_file = os.path.join(path, '.review.cfg')
    if new and os.path.exists(review_file):
        os.remove(review_file)

    repo = hgapi.Repo(path)
    url = repo.config('paths', 'default')
    url_list = url.split('/')
    owner, repo_name = (url_list[-2], url_list[-1])

    if branch not in repo.get_branch_names():
        print >>sys.stderr, t.red('Error: Branch %s '
            'was not found on repo.' % branch)
        sys.exit(0)

    review = pullrequests.create(owner, repo_name, branch, review_name)

    review_id = review['id']

    review = Review.find([
            ('review_id', '=', str(review_id)),
            ('work', '=', work.id),
            ])
    if not review:
        review = Review()
    else:
        review = review[0]

    review.name = "[{module}]-{task_name}".format(
            module=module, task_name=review_name)
    review.review_id = str(review_id)
    review.url = ('https://bitbucket.org/{owner}/{repo}/'
        'pull-requests/{id}').format(
            owner=owner,
            repo=repo_name,
            id=review_id)

    review.work = work
    review.branch = branch
    review.component = component
    review.save()
示例#10
0
def _module(module,
            dbtype='sqlite',
            fail_fast=False,
            upload=True,
            force=False):

    if upload:
        get_tryton_connection()
        Build = Model.get('project.test.build')
        Config = read_config_file()

        repo = scm.get_repo(module, Config, 'revision')
        repo = hgapi.Repo(repo['path'])
        build = None
        try:
            rev = repo.hg_rev()
            revision = repo.revision(rev)
            build = Build.find([('component.name', '=', module),
                                ('revision', '=', revision.node)],
                               order=[('execution', 'Desc')],
                               limit=1)

        except hgapi.HgException as e:
            print("Error running %s: %s" % (e.exit_code, str(e)))

        if build and not force:
            return

    logger.info("Testing module:" + module)
    test(failfast=fail_fast,
         dbtype=dbtype,
         modules=[module],
         name=module,
         upload=upload)
示例#11
0
 def hg_changesets_list(self, repo=None):
     if repo is None: repo = hgapi.Repo(self.owndir())
     lines = repo.hg_log().split('\n')
     return [
         long(l.split(':')[1]) for l in lines
         if l.find('changeset') != -1
     ]
示例#12
0
def hg_update_ng(module, path, clean, branch=None, revision=None,
        ignore_missing=False):
    if not os.path.exists(path):
        if ignore_missing:
            return 0
        print >> sys.stderr, t.red("Missing repositori:") + t.bold(path)
        return

    repo = hgapi.Repo(path)
    if revision and branch:
        if repo.revision(revision).branch != branch:
            print t.bold_red('[' + module + ']')
            print ("Invalid revision '%s': it isn't in branch '%s'"
                % (revision, branch))
            return -1
    elif branch:
        revision = branch
    elif not revision:
        revision = repo.hg_branch()

    try:
        repo.hg_update(revision, clean)
    except hgapi.HgException, e:
        print t.bold_red('[' + module + ']')
        print "Error running %s: %s" % (e.exit_code, str(e))
        return -1
示例#13
0
def _ver_hgapi():
    """Tries to obtain detailed version information of the running instance via hgapi."""
    import hgapi

    repo = hgapi.Repo(os.path.abspath(os.curdir))
    ver_details = repo.revision(repo.hg_rev()).__dict__
    return ver_details
示例#14
0
 def onHGMakeRepo(self, evt):
     app0 = wx.GetApp().TopWindow
     ret, m = dialog.textentry(app0, "Enter variable name",
                               "Create repo object", 'repo')
     if not ret: return None
     repo = hgapi.Repo(self.owndir())
     self.write2shell(repo, m)
示例#15
0
 def update_source(num):
     repo = hgapi.Repo(os.getcwd())
     repo.hg_command("pull")
     repo.hg_update("default")
     management.call_command("collectstatic", interactive=False)
     if autoreload.code_changed():
         management.call_command("syncdb", interactive=False)
         uwsgi.reload()
示例#16
0
 def hg_has_uncommitedchange(self, repo=None):
     if repo is None:
         repo = hgapi.Repo(self.owndir())
     st = repo.hg_status()
     for key in st:
         if len(st[key]) != 0:
             return True
     return False
示例#17
0
def upload_review(ctx, work, path, branch='default', module=None):
    get_tryton_connection()
    Review = Model.get('project.work.codereview')
    Task = Model.get('project.work')
    Component = Model.get('project.work.component')

    tasks = Task.find([('code', '=', work)])
    if not tasks:
        print(t.red('Error: Task %s was not found.' % work), file=sys.stderr)
        sys.exit(1)
    work = tasks[0]

    if not module:
        module = os.path.realpath(path).split('/')[-1]
    components = Component.find([('name', '=', module)], limit=1)
    if not components:
        component = Component(name=module)
        component.save()
    else:
        component, = components

    repo = hgapi.Repo(path)
    url = repo.config('paths', 'default')
    if url:
        url_list = url.split('/')
        owner, repo_name = (url_list[-2], url_list[-1])
    else:
        owner = 'nantic'
        repo_name, = path.split('/')[-1:]

    review = reviewboard.create(ctx, path, module, work.rec_name,
                                (work.problem or work.rec_name) + '\n' +
                                (work.solution or ''), work.code)

    review_id = review

    review = Review.find([
        ('review_id', '=', str(review_id)),
        ('work', '=', work.id),
    ])
    if not review:
        review = Review()
    else:
        review = review[0]

    review.name = "[{module}]-{task_name}".format(
        module=module, task_name=work.rec_name.encode('utf-8'))
    review.review_id = str(review_id)
    review.url = ('http://reviews.nan-tic.com/r/{id}').format(owner=owner,
                                                              repo=repo_name,
                                                              id=review_id)

    review.work = work
    review.branch = branch
    review.component = component
    review.save()
示例#18
0
def hg_checkout(log, repo, hg_path):
    log.info('checking out hg %s', repo)
    url = 'https://*****:*****@finroc.org/hg/' + repo
    try:
        repo = hgapi.Repo(hg_path)
        repo.hg_command('pull', '--insecure', url)
    except hgapi.HgException as e:
        shutil.rmtree(hg_path, ignore_errors=True)
        hgapi.Repo.command('.', os.environ, 'clone', '--insecure', url,
                           hg_path)
示例#19
0
def hg_summary(module, path, verbose):
    path_repo = os.path.join(path, module)
    if not os.path.exists(path_repo):
        print >> sys.stderr, t.red("Missing repositori:") + t.bold(path_repo)
        return
    repo = hgapi.Repo(path_repo)
    cmd = ['summary', '--remote']
    summary = repo.hg_command(*cmd)
    print t.bold("= " + module + " =")
    print summary
示例#20
0
        def onHGIncoming(self, evt):

            url, root, path = self.get_mercurial_url()
            if url is not None:
                root = root
                name = path
            else:
                root = None
                name = self._name
            app = wx.GetApp().TopWindow
            list6 = [
                ["root repository", root, 304,
                 dlg_s()],
                ["name", name, 0, None],
            ]

            value = DialogEditList(list6,
                                   modal=True,
                                   style=wx.DEFAULT_DIALOG_STYLE
                                   | wx.RESIZE_BORDER,
                                   tip=None,
                                   parent=app,
                                   title='HG incoming')
            if not value[0]:
                return

            url = rootpath2url(str(value[1][0]), str(value[1][1]))
            ocwd = os.getcwd()
            os.chdir(self.owndir())
            try:
                repo = hgapi.Repo(self.owndir())
                l1, l2 = self.hg_incoming_outgoing_changesets_list(repo, url)
                if len(l1) > 0:
                    self._status = '!'
                    out = repo.hg_command('incoming', url)
                    dialog.showtraceback(parent=app,
                                         txt=out,
                                         title='Incoming changeset',
                                         traceback=traceback.format_exc())
                else:
                    self._status = ''
                    dialog.showtraceback(parent=app,
                                         txt='No incoming change',
                                         title='Incoming changeset',
                                         traceback=traceback.format_exc())

            except:
                dialog.showtraceback(parent=app,
                                     txt='Failed to hg_command',
                                     title='Failed to hg_command',
                                     traceback=traceback.format_exc())
            os.chdir(ocwd)
            #           self.set_mercurial_url(str(value[1][0]), str(value[1][1]))
            self.hg_set_projtreeviewer_status(repo=repo)
            evt.Skip()
示例#21
0
        def onHGclone(self, evt):
            app = wx.GetApp().TopWindow
            name = self.getvar('mercurial_path')
            if name is None:
                name = self._name
            l2 = [
                ["commit message", '', 0, None],
            ]
            list6 = [
                ["root repository", None, 304,
                 dlg_s()],
                ["name", name, 0, None],
                #               [None, (False, ['change #1']),  27,
                #                      ({"text": 'commit modification'},
                #                      {"elp": l2},)],
                [
                    None, True, 3, {
                        "text": 'change source tree to the new clone'
                    }
                ]
            ]

            value = DialogEditList(list6,
                                   modal=True,
                                   style=wx.DEFAULT_DIALOG_STYLE
                                   | wx.RESIZE_BORDER,
                                   tip=None,
                                   parent=app,
                                   title='HG clone')
            if not value[0]:
                return
            if not self.update_hgsub():
                return
#           if value[1][2][0]:
#               if not self.do_commit(str(value[1][2][1])): return
            url = rootpath2url(str(value[1][0]), str(value[1][1]))

            ocwd = os.getcwd()
            os.chdir(self.owndir())
            try:
                repo = hgapi.Repo(self.owndir())
                if not url.startswith('ssh://'):
                    # for local repo, check if directory exists
                    dirname = os.path.dirname(url)
                    if not os.path.exists(dirname):
                        os.makedirs(dirname)
                repo.hg_clone('.', url)
            except:
                dialog.showtraceback(parent=app,
                                     txt='Failed to clone subtree to ' + url,
                                     title='Failed to clone',
                                     traceback=traceback.format_exc())
            if value[1][2]:
                self.set_mercurial_url(str(value[1][0]), str(value[1][1]))
            os.chdir(ocwd)
示例#22
0
def hg_check_url(module, path, url, clean=False):

    repo = hgapi.Repo(path)
    actual_url = str(repo.config('paths', 'default')).rstrip('/')
    url = str(url).rstrip('/')
    if actual_url != url:
        print >> sys.stderr, (t.bold('[%s]' % module) +
            t.red(' URL differs ') + "(Disk!=Cfg) " + t.bold(actual_url +
                ' !=' + url))
        if clean:
            print >> sys.stderr, (t.bold('[%s]' % module) + t.red(' Removed '))
            shutil.rmtree(path)
示例#23
0
def hg_is_last_revision(path, revision):
    if not revision:
        return False
    try:
        repo = hgapi.Repo(path)
        rev = repo.revision(revision)
        rev2 = repo.revision(repo.hg_id())
        if rev.date == rev2.date:
            return False
    except:
        return False
    return True
示例#24
0
    def upload_tryton(self, db_type, failfast, name):
        logger.info("Generating report for execution %s" % name)
        report = self._generate_report(self.result)
        logger.info("Report for execution %s" % name)
        get_tryton_connection()
        Test = Model.get('project.test.build')
        # TestGroup = Model.get('project.test.build.group')
        Component = Model.get('project.work.component')
        TestResult = Model.get('project.test.build.result')

        for module in report:
            logger.info("Create Test Report for Module: %s" % module)
            result = report[module]
            component = Component.find([('name', '=', module)])
            component = component and component[0]
            if not component:
                component = Component(name=module)
                component.save()
            path = result['path']
            repo = hgapi.Repo(path)
            rev = repo.hg_rev()
            rev = repo.revisions(slice(rev, rev))[0]
            branch = rev.branch

            test = Test()
            test.coverage = round(self.coverage_result.get(module,
                    (0, 0, 0))[2], 2)
            test.lines = self.coverage_result.get(module, (0, 0, 0))[0]
            test.covered_lines = self.coverage_result.get(module, (0, 0, 0))[1]
            test.component = component
            test.branch = branch
            test.revision = rev.node
            test.execution = datetime.datetime.now()
            test.revision_date = parser.parse(rev.date)
            test.revision_author = rev.author
            test.revision_description = rev.desc

            for test_result in result['test']:
                tr = TestResult()
                tr.name = test_result['desc']
                tr.type = test_result['type']
                tr.description = test_result['output']
                tr.state = test_result['status']
                test.test.append(tr)

            for test_result in list(self.pyflakes_result.get(module, []).values()):
                tr = TestResult()
                tr.name = test_result['name']
                tr.type = test_result['type']
                tr.description = test_result['output']
                tr.state = test_result['status']
                test.test.append(tr)
            test.save()
示例#25
0
    def hg_check_all_incoming_outgoing(obj0, sb=None):
        #app = wx.GetApp().TopWindow

        updated_obj = []
        newer_obj = []
        both_obj = []
        for obj in obj0.get_root_parent().walk_tree(stop_at_ext=True):
            if has_repo(obj):
                url, root, path = obj.get_mercurial_url()
                if url is None:
                    continue
                print('checking incoming to ' + str(url))
                try:
                    repo = hgapi.Repo(obj.owndir())
                    l1, l2 = obj.hg_incoming_outgoing_changesets_list(
                        repo, url)
                    if len(l1) > 0:
                        obj._status = '!'
                        if url.startswith('ssh://'):
                            updated_obj.append(
                                (obj, len(l1), repo.hg_rev(), '?(remote)'))
                        else:
                            repo2 = hgapi.Repo(url)
                            updated_obj.append(
                                (obj, len(l1), repo.hg_rev(), repo2.hg_rev()))
                    else:
                        obj._status = ''
                    if len(l2) > 0:
                        if url.startswith('ssh://'):
                            newer_obj.append(
                                (obj, len(l2), repo.hg_rev(), '?(remote)'))
                        else:
                            repo2 = hgapi.Repo(url)
                            newer_obj.append(
                                (obj, len(l2), repo.hg_rev(), repo2.hg_rev()))
                    if len(l1) > 0 and len(l2) > 0:
                        both_obj.append(obj)
                except:
                    traceback.print_exc()
        return updated_obj, newer_obj, both_obj
示例#26
0
        def onHGrevertall(self, evt):
            dlg = wx.MessageDialog(
                None, 'Do you discard all changes since the last commit?',
                'Revert', wx.OK | wx.CANCEL)
            ret = dlg.ShowModal()
            dlg.Destroy()
            if ret != wx.ID_OK:
                return

            d = self.owndir()
            fpath = os.path.join(d, ".hg_data_hg")
            if not os.path.exists(os.path.join(d, ".hg")):
                return  # not a repo

            ichild = self.get_ichild()

            owndir = self.owndir()
            name = self._name
            parent = self.get_parent()
            repo = hgapi.Repo(owndir)
            # repo.hg_revert(True)
            repo.hg_revert(all)
            self.hg_set_projtreeviewer_status(repo=repo)
            # puting the tree back
            vars = self.getvar().copy()
            self.destroy(clean_owndir=False)
            if not os.path.exists(fpath):
                #
                #  In this case, it makes a containing folder
                #  and gather *.py to make PyScript
                #  I should be handling other files here too?
                #
                print(vars)
                td = handle_pure_file_repo(parent, name, owndir)
                td.setvar(vars)
                load_fpath = False
            else:
                load_fpath = True
            if load_fpath:
                fid = open(fpath, 'rb')
                td, olist, nlist = TreeDict().load(fid, keep_zorder=True)
                fid.close()
                parent.add_child(td._name, td, keep_zorder=True)
            parent.move_child(td.get_ichild(), ichild)
            if load_fpath:
                for obj in td.walk_tree():
                    obj.init_after_load(olist, nlist)

            for item in repo.hg_status()['?']:
                os.remove(os.path.join(d, item))
            ifigure.events.SendFileSystemChangedEvent(parent, reload=True)
            evt.Skip()
示例#27
0
 def do_hg_to_git(self, line=None):
     """
     Move from hg to local git repo
     """
     for hg_module, git_name in REPOS:
         hg_repo = hgapi.Repo(os.path.join(HG_CACHE, hg_module))
         self._make_bookmarks(hg_repo)
         cmd = shlex.split(
             'hg --cwd=%s push -q %s' %
             (os.path.join(HG_CACHE, hg_module),
              os.path.abspath(os.path.join(GIT_CACHE, git_name))))
         retcode = subprocess.call(cmd)
         if retcode not in [0, 1]:
             raise subprocess.CalledProcessError(retcode, cmd)
示例#28
0
def hg_revision(module, path, verbose=False):
    t = Terminal()
    path_repo = path
    if not os.path.exists(path_repo):
        print >> sys.stderr, (t.red("Missing repositori:") + t.bold(path_repo))
        return False

    repo = hgapi.Repo(path_repo)
    branches = repo.get_branches()
    revision = False
    for branch in branches:
        if branch['name'] == repo.hg_branch():
            revision = branch['version'].split(':')[1]

    return revision
示例#29
0
文件: hg.py 项目: tutuca/waliki
def init(app):
    # register plugin
    app.register_blueprint(hgplugin)

    # register signals
    app.signals.signal('page-saved').connect(hg_commit)

    # add cli commands
    app.manager.add_command("hgsync", CmdHgSync())

    # init repository
    app.hg = hgapi.Repo(app.config['CONTENT_DIR'])
    try:
        app.hg.hg_init()
    except hgapi.HgException as err:
        pass
示例#30
0
def close_branch(directory, branch):
    """ Close branch for all modules """

    for module_path in Path(directory).dirs():
        repo = hgapi.Repo(module_path)

        branches = []
        try:
            branches = [x['name'] for x in repo.get_branches() if x]
        except:
            continue

        if branch in branches:
            print module_path
            repo.hg_update(branch, True)
            repo.hg_commit('close branch', close_branch=True)