~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-08-30 05:30:43 UTC
  • Revision ID: mbp@sourcefrog.net-20050830053042-58932432ee958d1e
- make get_parent() be a method of Branch; add simple tests for it

Show diffs side-by-side

added added

removed removed

Lines of Context:
1280
1280
            self.unlock()
1281
1281
 
1282
1282
 
 
1283
    def get_parent(self):
 
1284
        """Return the parent location of the branch.
 
1285
 
 
1286
        This is the default location for push/pull/missing.  The usual
 
1287
        pattern is that the user can override it by specifying a
 
1288
        location.
 
1289
        """
 
1290
        import errno
 
1291
        _locs = ['parent', 'pull', 'x-pull']
 
1292
        for l in _locs:
 
1293
            try:
 
1294
                return self.controlfile(l, 'r').read().strip('\n')
 
1295
            except IOError, e:
 
1296
                if e.errno != errno.ENOENT:
 
1297
                    raise
 
1298
        return None
 
1299
 
 
1300
        
 
1301
 
1283
1302
 
1284
1303
class ScratchBranch(Branch):
1285
1304
    """Special test class: a branch that cleans up after itself.
1327
1346
        os.rmdir(base)
1328
1347
        copytree(self.base, base, symlinks=True)
1329
1348
        return ScratchBranch(base=base)
 
1349
 
 
1350
 
1330
1351
        
1331
1352
    def __del__(self):
1332
1353
        self.destroy()