~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Martin Pool
  • Date: 2005-05-11 10:14:09 UTC
  • Revision ID: mbp@sourcefrog.net-20050511101409-25634506a9caacfd
- move commit code into its own module
- remove some doctest tests in favour of black-box tests
- specific-file parameters for diff and status now cover all
  files inside a directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        return False
78
78
 
79
79
 
 
80
def is_inside(dir, fname):
 
81
    """True if fname is inside dir.
 
82
    """
 
83
    return os.path.commonprefix([dir, fname]) == dir
 
84
 
 
85
 
 
86
def is_inside_any(dir_list, fname):
 
87
    """True if fname is inside any of given dirs."""
 
88
    # quick scan for perfect match
 
89
    if fname in dir_list:
 
90
        return True
 
91
    
 
92
    for dirname in dir_list:
 
93
        if is_inside(dirname, fname):
 
94
            return True
 
95
    else:
 
96
        return False
 
97
 
 
98
 
80
99
def pumpfile(fromfile, tofile):
81
100
    """Copy contents of one file to another."""
82
101
    tofile.write(fromfile.read())