def function(tree, srcpath, opts): if not srcpath: srcpath = forest.top().getpath(source) if srcpath: rpath = util.pconvert(relpath(forest.top().root, tree.root)) srcpath = '/'.join((srcpath, rpath)) else: ui.warn(_("skipped: %s\n") % _("repository %s not found") % source[0]) return try: commands.incoming(ui, tree.repo, srcpath, **opts) except Exception, err: ui.warn(_("skipped: %s\n") % err)
def _upgrade(ui, repo): ext_dir = os.path.dirname(os.path.abspath(__file__)) ui.debug(_('kiln: checking for extensions upgrade for %s\n') % ext_dir) try: r = localrepo.localrepository(hgui.ui(), ext_dir) except RepoError: commands.init(hgui.ui(), dest=ext_dir) r = localrepo.localrepository(hgui.ui(), ext_dir) r.ui.setconfig('kiln', 'autoupdate', False) r.ui.pushbuffer() try: source = 'https://developers.kilnhg.com/Repo/Kiln/Group/Kiln-Extensions' if commands.incoming(r.ui, r, bundle=None, force=False, source=source) != 0: # no incoming changesets, or an error. Don't try to upgrade. ui.debug('kiln: no extensions upgrade available\n') return ui.write(_('updating Kiln Extensions at %s... ') % ext_dir) # pull and update return falsy values on success if commands.pull(r.ui, r, source=source) or commands.update(r.ui, r, clean=True): url = urljoin(repo.url()[:repo.url().lower().index('/repo')], 'Tools') ui.write(_('unable to update\nvisit %s to download the newest extensions\n') % url) else: ui.write(_('complete\n')) except Exception, e: ui.debug(_('kiln: error updating extensions: %s\n') % e) ui.debug(_('kiln: traceback: %s\n') % traceback.format_exc())
def _upgrade(ui, repo): ext_dir = os.path.dirname(os.path.abspath(__file__)) ui.debug('kiln: checking for extensions upgrade for %s\n' % ext_dir) try: r = localrepo.localrepository(hgui.ui(), ext_dir) except RepoError: commands.init(hgui.ui(), dest=ext_dir) r = localrepo.localrepository(hgui.ui(), ext_dir) r.ui.setconfig('kiln', 'autoupdate', False) r.ui.pushbuffer() try: source = 'https://developers.kilnhg.com/Repo/Kiln/Group/Kiln-Extensions' if commands.incoming(r.ui, r, bundle=None, force=False, source=source) != 0: # no incoming changesets, or an error. Don't try to upgrade. ui.debug('kiln: no extensions upgrade available\n') return ui.write(_('updating Kiln Extensions at %s... ') % ext_dir) # pull and update return falsy values on success if commands.pull(r.ui, r, source=source) or commands.update(r.ui, r, clean=True): url = urljoin(repo.url()[:repo.url().lower().index('/repo')], 'Tools') ui.write(_('unable to update\nvisit %s to download the newest extensions\n') % url) else: ui.write(_('complete\n')) except Exception, e: ui.debug(_('kiln: error updating Kiln Extensions: %s\n') % e)
def download_patch(source, lastrev, patchbranch): from mercurial import hg, ui, localrepo, commands, bundlerepo UI = ui.ui() bundle = tempfile.mktemp(dir="/var/tmp") cwd = os.getcwd() os.chdir(base) try: repo0 = hg.repository(UI,base) repo0.ui.quiet=True repo0.ui.pushbuffer() commands.pull(repo0.ui, repo0, quiet=True) repo0.ui.popbuffer() # discard all pull output # find out what the head revision of the given branch is repo0.ui.pushbuffer() head = repo0.ui.popbuffer().strip() repo0.ui.pushbuffer() if commands.incoming(repo0.ui, repo0, source=source, branch=[patchbranch], bundle=bundle, force=False) != 0: raise ValueError, "Repository contains no changes" rhead = repo0.ui.popbuffer() if rhead: # output is a list of revisions, one per line. last line should be newest revision rhead = rhead.splitlines()[-1].split(':')[1] if rhead == lastrev: raise NotChanged repo=bundlerepo.bundlerepository(UI, ".", bundle) repo.ui.pushbuffer() old = 'max(ancestors(branch("%s"))-outgoing("%s"))' % (patchbranch, base) commands.diff(repo.ui, repo, rev=[old, patchbranch]) result = repo.ui.popbuffer() finally: os.chdir(cwd) if os.path.exists(bundle): os.unlink(bundle) return result, rhead
def bb_forks(ui, repo, **opts): '''list all forks of this repo at bitbucket An explicit bitbucket reponame (``username/repo``) can be given with the ``-n`` option. With the ``-i`` option, check each fork for incoming changesets. With the ``-i -f`` options, also show the individual incoming changesets like :hg:`incoming` does. ''' reponame = get_bbreponame(ui, repo, opts) ui.status('getting descendants list\n') forks = list_forks(reponame) if not forks: ui.status('this repository has no forks yet\n') return # filter out ignored forks ignore = set(ui.configlist('bb', 'ignore_forks')) forks = [name for name in forks if name not in ignore] if opts.get('incoming'): templateopts = {'template': opts.get('full') and FULL_TMPL or '\xff'} for name in forks: ui.status('looking at %s\n' % name) try: ui.quiet = True ui.pushbuffer() try: commands.incoming(ui, repo, 'bb://' + name, bundle='', force=False, newest_first=True, **templateopts) finally: ui.quiet = False contents = ui.popbuffer(True) except (error.RepoError, util.Abort), msg: ui.warn('Error: %s\n' % msg) else: if not contents: continue number = contents.count('\xff') if number: ui.status('%d incoming changeset%s found in bb://%s\n' % (number, number > 1 and 's' or '', name), label='status.modified') ui.write(contents.replace('\xff', ''), label='log.changeset')
def download_patch(source, lastrev, patchbranch): from mercurial import hg, ui, localrepo, commands, bundlerepo UI = ui.ui() bundle = tempfile.mktemp(dir="/var/tmp") cwd = os.getcwd() os.chdir(base) try: repo0 = hg.repository(UI, base) repo0.ui.quiet = True repo0.ui.pushbuffer() commands.pull(repo0.ui, repo0, quiet=True) repo0.ui.popbuffer() # discard all pull output # find out what the head revision of the given branch is repo0.ui.pushbuffer() head = repo0.ui.popbuffer().strip() repo0.ui.pushbuffer() if commands.incoming(repo0.ui, repo0, source=source, branch=[patchbranch], bundle=bundle, force=False) != 0: raise ValueError, "Repository contains no changes" rhead = repo0.ui.popbuffer() if rhead: # output is a list of revisions, one per line. last line should be newest revision rhead = rhead.splitlines()[-1].split(':')[1] if rhead == lastrev: raise NotChanged repo = bundlerepo.bundlerepository(UI, ".", bundle) repo.ui.pushbuffer() old = 'max(ancestors(branch("%s"))-outgoing("%s"))' % (patchbranch, base) commands.diff(repo.ui, repo, rev=[old, patchbranch]) result = repo.ui.popbuffer() finally: os.chdir(cwd) if os.path.exists(bundle): os.unlink(bundle) return result, rhead
def pullHg(hgRepo, hgUI, sourceURL, sourceBranch): # And update it if commands.incoming(hgUI, hgRepo, source=sourceURL, bundle=None, force=None) == 0: commands.pull(hgUI, hgRepo, source=sourceURL) commands.update(hgUI, hgRepo, rev=sourceBranch)
def pullHg(hgRepo, hgUI): # And update it if commands.incoming(hgUI, hgRepo, source=M_C_SOURCE_URL, bundle=None, force=None) == 0: commands.pull(hgUI, hgRepo, source=M_C_SOURCE_URL)
def check_update(repo, clone_source): if commands.incoming(repo.ui, repo, bundle=None, force=False) == 0: commands.pull(repo.ui, repo, clone_source) commands.update(repo.ui, repo)