~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

Add a new method ``Tree.revision_tree`` which allows access to cached
trees for arbitrary revisions. This allows the in development dirstate
tree format to provide access to the callers to cached copies of 
inventory data which are cheaper to access than inventories from the
repository. (Robert Collins, Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
867
867
 
868
868
    return width
869
869
 
 
870
 
870
871
def supports_executable():
871
872
    return sys.platform != "win32"
872
873
 
873
874
 
 
875
def set_or_unset_env(env_variable, value):
 
876
    """Modify the environment, setting or removing the env_variable.
 
877
 
 
878
    :param env_variable: The environment variable in question
 
879
    :param value: The value to set the environment to. If None, then
 
880
        the variable will be removed.
 
881
    :return: The original value of the environment variable.
 
882
    """
 
883
    orig_val = os.environ.get(env_variable)
 
884
    if value is None:
 
885
        if orig_val is not None:
 
886
            del os.environ[env_variable]
 
887
    else:
 
888
        if isinstance(value, unicode):
 
889
            value = value.encode(bzrlib.user_encoding)
 
890
        os.environ[env_variable] = value
 
891
    return orig_val
 
892
 
 
893
 
874
894
_validWin32PathRE = re.compile(r'^([A-Za-z]:[/\\])?[^:<>*"?\|]*$')
875
895
 
876
896