예제 #1
0
파일: utils.py 프로젝트: armooo/oh-mainline
def find_version_number(show_nick=False):
    path = os.path.join(os.path.dirname(__file__), "..")

    # We're using a package
    if path.startswith('/usr'):
        output = subprocess.Popen(["dpkg-query", "-W", "python-launchpad-bugs"], 
                                   stdout=subprocess.PIPE).communicate()[0]
        try:
            return output.split()[1]
        except:
            # not installed as a package
            return "unknown"
    if HAVE_BZR:
        try:
            trace.be_quiet()
            trace.enable_default_logging()
            version = get_version_from_changelog(path)
            if os.path.islink(os.path.dirname(__file__)):
                path = os.path.realpath(os.path.dirname(__file__))
            branch = Branch.open_containing(path)[0]
            bzr_revno = branch.revno()
            if show_nick:
                nick = branch.nick
                return "%sr%s, branch nick: %s" % (version, bzr_revno, nick)
            else:
                return "%sr%s" % (version, bzr_revno)
        except:
            pass
    return "unknown"
예제 #2
0
def checkin(folder, msg, quiet=False, quiet_stderr=False):
    if quiet:
        be_quiet()
    cmd, out = _prep_cmd(cmd_commit())
    with StderrSuppressor(quiet_stderr) as ss:
        cmd.run(message=msg, selected_list=[folder])
    return out.getvalue()
예제 #3
0
def checkin(folder, msg, quiet=False, quiet_stderr=False):
    if quiet:
        be_quiet()
    cmd, out = _prep_cmd(cmd_commit())
    with StderrSuppressor(quiet_stderr) as ss:
        cmd.run(message=msg, selected_list=[folder])
    return out.getvalue()
예제 #4
0
 def run(self,
         command,
         quiet,
         message=None,
         directory='.',
         branch=None,
         to=None,
         source=None,
         tag=None,
         tree=False,
         revision=None):
     if quiet:
         be_quiet()
     functions = {
         'add': add_sandbox,
         'branch': branch_sandbox,
         'commit': commit_sandbox,
         'info': info_sandbox,
         'merge': merge_sandbox,
         'missing': missing_sandbox,
         'pull': pull_sandbox,
         'push': push_sandbox,
         'revert': revert_sandbox,
         'revno': revno_sandbox,
         'status': status_sandbox,
         'tag': tag_sandbox,
         'tags': tags_sandbox,
         'tag-info': tag_info_sandbox,
         'update': update_sandbox,
     }
     args = {
         'add': dict(directory=directory),
         'branch': dict(to=to, source=source),
         'commit': dict(msg=message, directory=directory),
         'info': dict(directory=directory),
         'merge': dict(directory=directory, source=source),
         'missing': dict(directory=directory),
         'pull': dict(directory=directory, source=source),
         'push': dict(directory=directory, to=to),
         'revert': dict(directory=directory, revision=revision),
         'revno': dict(directory=directory, tree=tree),
         'status': dict(directory=directory, revision=revision),
         'tag': dict(tag=tag, directory=directory),
         'tags': dict(directory=directory),
         'tag-info': dict(directory=directory, tag=tag),
         'update': dict(directory=directory, branch=branch),
     }
     for key in supported_commands.keys():
         if command in supported_commands[key]:
             return functions[key](**args[key])
     # I am repeatedly typing nonsense commands like "bzr sb build". Help
     # users thaw their brain freeze...
     if '|' + command + '|' in '|build|test|cr|coderoot|tr|testroot|root|eval|':
         print('This looks like an "sb" command.')
     elif command != command.lower():
         print('Did you mean "bzr sb %s"?' % command.lower())
     else:
         print('%s is not supported yet. If you need it, log a ticket.' %
               command)
예제 #5
0
 def run(self, command, quiet, message=None, component=None, directory='.', branch='', tag=None, tree=False, revision=None):
     if quiet:
         be_quiet()
     get_implied_comp = not component
     if component:
         parts = re.split('[\\/]', component)
         if len(parts) > 1:
             if not directory or (directory == '.'):
                 directory = component
                 get_implied_comp = True
             else:
                 raise Exception("Directory and component can't both contain path segments.")
     if get_implied_comp:
         component = sandbox.find_component_from_within(directory)
     if component is None:
         print("No valid component.")
         return
     functions = {
         'add':add_component,
         'branch':branch_component,
         'commit':commit_component,
         'info':info_component,
         'merge':merge_component,
         'missing':missing_component,
         'pull':pull_component,
         'push':push_component,
         'revert':revert_component,
         'revno':revno_component,
         'status':status_component,
         'tag':tag_component,
         'tags':tags_component,
         'tag-info':tag_info_component,
         'update':update_component,
     }
     args = {
         'add':dict(comp=component, directory=directory),
         'branch':dict(comp=component, directory=directory, branch=branch),
         'commit':dict(msg=message, comp=component, directory=directory),
         'info':dict(comp=component, directory=directory),
         'merge':dict(comp=component, directory=directory),
         'missing':dict(comp=component, directory=directory),
         'pull':dict(comp=component, directory=directory),
         'push':dict(comp=component, directory=directory),
         'revert':dict(comp=component, directory=directory, revision=revision),
         'revno':dict(comp=component, directory=directory, tree=tree),
         'status':dict(comp=component, directory=directory, revision=revision),
         'tag':dict(comp=component, directory=directory),
         'tags':dict(comp=component, directory=directory),
         'tag-info':dict(comp=component, directory=directory, tag=tag),
         'update':dict(comp=component, directory=directory),
     }
     for key in supported_commands.keys():
         if command in supported_commands[key]:
             return functions[key](**args[key])
     if command != command.lower():
         print('Did you mean "bzr component %s"?' % command.lower())
     else:
         print('%s is not supported yet. If you need it, log a ticket.' % command)
예제 #6
0
 def run(self, command, quiet, message=None, directory='.', branch=None, to=None, source=None, tag=None, tree=False, revision=None):
     if quiet:
         be_quiet()
     functions = {
         'add':add_sandbox,
         'branch':branch_sandbox,
         'commit':commit_sandbox,
         'info':info_sandbox,
         'merge':merge_sandbox,
         'missing':missing_sandbox,
         'pull':pull_sandbox,
         'push':push_sandbox,
         'revert':revert_sandbox,
         'revno':revno_sandbox,
         'status':status_sandbox,
         'tag':tag_sandbox,
         'tags':tags_sandbox,
         'tag-info':tag_info_sandbox,
         'update':update_sandbox,
     }
     args = {
         'add':dict(directory=directory),
         'branch':dict(to=to, source=source),
         'commit':dict(msg=message, directory=directory),
         'info':dict(directory=directory),
         'merge':dict(directory=directory, source=source),
         'missing':dict(directory=directory),
         'pull':dict(directory=directory, source=source),
         'push':dict(directory=directory, to=to),
         'revert':dict(directory=directory, revision=revision),
         'revno':dict(directory=directory, tree=tree),
         'status':dict(directory=directory, revision=revision),
         'tag':dict(tag=tag, directory=directory),
         'tags':dict(directory=directory),
         'tag-info':dict(directory=directory, tag=tag),
         'update':dict(directory=directory, branch=branch),
     }
     for key in supported_commands.keys():
         if command in supported_commands[key]:
             return functions[key](**args[key])
     # I am repeatedly typing nonsense commands like "bzr sb build". Help
     # users thaw their brain freeze...
     if '|' + command + '|' in '|build|test|cr|coderoot|tr|testroot|root|eval|':
         print('This looks like an "sb" command.')
     elif command != command.lower():
         print('Did you mean "bzr sb %s"?' % command.lower())
     else:
         print('%s is not supported yet. If you need it, log a ticket.' % command)
예제 #7
0
 def test_be_quiet(self):
     # Confirm the old API still works
     be_quiet(True)
     self.assertEqual(-1, get_verbosity_level())
     be_quiet(False)
     self.assertEqual(0, get_verbosity_level())
예제 #8
0
def revno(location, tree=False):
    be_quiet()
    cmd, out = _prep_cmd(cmd_revno())
    cmd.run(location=location, tree=tree)
    return out.getvalue().strip()
예제 #9
0
def revno(location, tree=False):
    be_quiet()
    cmd, out = _prep_cmd(cmd_revno())
    cmd.run(location=location, tree=tree)
    return out.getvalue().strip()
예제 #10
0
 def test_be_quiet(self):
     # Confirm the old API still works
     be_quiet(True)
     self.assertEqual(-1, get_verbosity_level())
     be_quiet(False)
     self.assertEqual(0, get_verbosity_level())
예제 #11
0
 def run(self,
         command,
         quiet,
         message=None,
         component=None,
         directory='.',
         branch='',
         tag=None,
         tree=False,
         revision=None):
     if quiet:
         be_quiet()
     get_implied_comp = not component
     if component:
         parts = re.split('[\\/]', component)
         if len(parts) > 1:
             if not directory or (directory == '.'):
                 directory = component
                 get_implied_comp = True
             else:
                 raise Exception(
                     "Directory and component can't both contain path segments."
                 )
     if get_implied_comp:
         component = sandbox.find_component_from_within(directory)
     if component is None:
         print("No valid component.")
         return
     functions = {
         'add': add_component,
         'branch': branch_component,
         'commit': commit_component,
         'info': info_component,
         'merge': merge_component,
         'missing': missing_component,
         'pull': pull_component,
         'push': push_component,
         'revert': revert_component,
         'revno': revno_component,
         'status': status_component,
         'tag': tag_component,
         'tags': tags_component,
         'tag-info': tag_info_component,
         'update': update_component,
     }
     args = {
         'add': dict(comp=component, directory=directory),
         'branch': dict(comp=component, directory=directory, branch=branch),
         'commit': dict(msg=message, comp=component, directory=directory),
         'info': dict(comp=component, directory=directory),
         'merge': dict(comp=component, directory=directory),
         'missing': dict(comp=component, directory=directory),
         'pull': dict(comp=component, directory=directory),
         'push': dict(comp=component, directory=directory),
         'revert': dict(comp=component,
                        directory=directory,
                        revision=revision),
         'revno': dict(comp=component, directory=directory, tree=tree),
         'status': dict(comp=component,
                        directory=directory,
                        revision=revision),
         'tag': dict(comp=component, directory=directory),
         'tags': dict(comp=component, directory=directory),
         'tag-info': dict(comp=component, directory=directory, tag=tag),
         'update': dict(comp=component, directory=directory),
     }
     for key in supported_commands.keys():
         if command in supported_commands[key]:
             return functions[key](**args[key])
     if command != command.lower():
         print('Did you mean "bzr component %s"?' % command.lower())
     else:
         print('%s is not supported yet. If you need it, log a ticket.' %
               command)