Changeset 471
- Timestamp:
- 05/20/08 10:04:23
(8 months ago)
- Author:
- jmowery
- Message:
incremental check-in for storage: small fix to remove, more updates to cli
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r470 |
r471 |
|
| 227 | 227 | def remove_file(self, name): |
|---|
| 228 | 228 | '''Remove a single file from control by the store.''' |
|---|
| 229 | | raise NotImplementedError |
|---|
| | 229 | for f in os.listdir(self.storage_dir): |
|---|
| | 230 | if f.startswith(name): |
|---|
| | 231 | os.remove(f) |
|---|
| | 232 | self.config.remove_option('entries', name) |
|---|
| 230 | 233 | |
|---|
| 231 | 234 | def add_dir(self, name, local=False): |
|---|
| … | … | |
| 247 | 250 | def remove_dir(self, name): |
|---|
| 248 | 251 | '''Remove a directory from control by the store. Note: this removes its entry not its control files unless the directory is "."''' |
|---|
| 249 | | raise NotImplementedError |
|---|
| | 252 | if name == '.': |
|---|
| | 253 | os.rmdir(self.storage_dir) |
|---|
| | 254 | os.rmdir(self.logs_dir) |
|---|
| | 255 | os.rmdir(self.nodes_dir) |
|---|
| | 256 | os.remove(self.storage_path) |
|---|
| | 257 | self.config = ConfigParser.ConfigParser() #re-initialize to empty |
|---|
| | 258 | self.path = '' |
|---|
| | 259 | self.status_path = '' |
|---|
| | 260 | self.storage_dir = '' |
|---|
| | 261 | self.root = '' |
|---|
| | 262 | self.logs_dir = '' |
|---|
| | 263 | self.nodes_dir = '' |
|---|
| | 264 | self.time = 0 |
|---|
| | 265 | else: |
|---|
| | 266 | self.config.remove_option('entries', name) |
|---|
| 250 | 267 | |
|---|
| 251 | 268 | def write(self): |
|---|
| … | … | |
| 290 | 307 | '''Initialize all available fields of a Layer; note that if the directory layer is not controlled storage will be None''' |
|---|
| 291 | 308 | self.name = os.path.realpath(os.path.expanduser(layer)) |
|---|
| 292 | | if not os.path.isdir(self.Name): |
|---|
| | 309 | if not os.path.isdir(self.name): |
|---|
| 293 | 310 | raise ValueError, '\'' + layer + '\' is not a directory' |
|---|
| 294 | 311 | if is_controlled(self.name): |
|---|
| … | … | |
| 521 | 538 | |
|---|
| 522 | 539 | name = os.path.basename(name) |
|---|
| | 540 | if name in control_files: |
|---|
| | 541 | return #don't remove control files |
|---|
| 523 | 542 | if self.is_locked(): |
|---|
| 524 | 543 | raise RuntimeError, 'Layer \'' + self.Name + '\' is locked; cannot remove \'' + name + '\'' |
|---|
| 525 | 544 | if self.is_locked(name): |
|---|
| 526 | 545 | raise RuntimeError, '\'' + name + '\' is locked; it cannot be removed' |
|---|
| 527 | | if name in control_files: |
|---|
| 528 | | return #don't remove control files |
|---|
| 529 | 546 | if name == '.': |
|---|
| 530 | | if not is_controlled(self.Name): |
|---|
| | 547 | if not is_controlled(self.name): |
|---|
| 531 | 548 | return #nothing to do if not under control |
|---|
| 532 | | if self.recursive_lock_check(): |
|---|
| | 549 | if self.is_locked('.', True): |
|---|
| 533 | 550 | raise RuntimeError, 'One or more files or directories under \'' + self.Name + '\' is locked and cannot be removed' |
|---|
| 534 | 551 | for dir in self.list_controlled_dirs(): |
|---|
| 535 | | l = Layer(os.path.join(self.Name, dir)) |
|---|
| | 552 | l = Layer(os.path.join(self.storage.path, dir)) |
|---|
| 536 | 553 | l.remove('.') |
|---|
| 537 | | os.remove(self.StatusFile) |
|---|
| 538 | | os.remove(self.MetadataFile) |
|---|
| 539 | | os.rmdir(self.StorageDir) |
|---|
| 540 | | os.rmdir(self.NodesDir) |
|---|
| 541 | | self.StatusFile = '' |
|---|
| 542 | | self.StorageDir = '' |
|---|
| 543 | | self.StatusDate = 0 |
|---|
| 544 | | self.Modified = False #changes don't matter everything is gone |
|---|
| 545 | | if is_controlled(os.path.join(self.Name, '..')): |
|---|
| 546 | | l = Layer(os.path.join(self.Name, '..')) |
|---|
| 547 | | l.remove(self.Name) |
|---|
| | 554 | full_path = self.storage.path |
|---|
| | 555 | self.storage.remove_dir('.') |
|---|
| | 556 | self.storage = None |
|---|
| | 557 | self.entries.clear() |
|---|
| | 558 | self.modified = False #changes don't matter everything is gone |
|---|
| | 559 | if is_controlled(os.path.join(self.name, '..')): |
|---|
| | 560 | l = Layer(os.path.join(full_path, '..')) |
|---|
| | 561 | l.remove(os.path.basename(self.name)) |
|---|
| 548 | 562 | l.update() |
|---|
| 549 | | if not self.Entries.has_key(name): |
|---|
| | 563 | self.name = full_path |
|---|
| | 564 | return |
|---|
| | 565 | if not self.entries.has_key(name): |
|---|
| 550 | 566 | return #this is explicitly NOT an error so that remove can ignore duplicate recursive requests for directories quietly |
|---|
| 551 | | if self.Entries[name].Type == 'DIR': |
|---|
| 552 | | self.Entries.remove(name) |
|---|
| 553 | | self.Modified = True |
|---|
| 554 | | l = Layer(os.path.join(self.Name, name)) |
|---|
| | 567 | if self.entries[name].type == 'DIR' or self.enties[name].type == 'LOCAL': |
|---|
| | 568 | self.entries.remove(name) |
|---|
| | 569 | self.storage.remove_dir(name) |
|---|
| | 570 | self.modified = True |
|---|
| | 571 | l = Layer(os.path.join(self.storage.path, name)) |
|---|
| 555 | 572 | l.remove('.') |
|---|
| 556 | 573 | l.update() |
|---|
| 557 | 574 | self.update() |
|---|
| 558 | 575 | else: |
|---|
| 559 | | storage_files = self.get_file_revisions(name) |
|---|
| 560 | | del self.Entries[name] |
|---|
| 561 | | for file_name in storage_files: |
|---|
| 562 | | os.remove(os.path.join(self.StorageDir, file_name)) |
|---|
| 563 | | self.Modified = True |
|---|
| 564 | | |
|---|
| | 576 | self.entries.remove(name) |
|---|
| | 577 | self.stoage.remove_file(name) |
|---|
| | 578 | self.modified = True |
|---|
| 565 | 579 | |
|---|
| 566 | 580 | def control(self): |
|---|
| … | … | |
| 684 | 698 | name_entry = self.get_entry(name) |
|---|
| 685 | 699 | dot_entry = self.get_entry('.') |
|---|
| | 700 | if name_entry is None or dot_entry is None: |
|---|
| | 701 | return '' #not under revision control |
|---|
| 686 | 702 | name_entry.validate() |
|---|
| 687 | 703 | dot_entry.validate() |
|---|
| 688 | | if name_entry is None or dot_entry is None: |
|---|
| 689 | | return '' #not under revision control |
|---|
| 690 | 704 | if name_entry.type == 'DIR': |
|---|
| 691 | 705 | return '' #not stored here |
|---|
| … | … | |
| 1254 | 1268 | l.rollback(int(sys.argv[2]), False) |
|---|
| 1255 | 1269 | l.update() |
|---|
| 1256 | | elif sys.argv[1] == 'status' or sys.argv[1] == 'st': #XXX update me TODO |
|---|
| | 1270 | elif sys.argv[1] == 'status' or sys.argv[1] == 'st': |
|---|
| 1257 | 1271 | if len(sys.argv) < 3: |
|---|
| 1258 | 1272 | l = Layer(os.getcwd()) |
|---|
| 1259 | | l.print_status() |
|---|
| | 1273 | st_dot = l.status() |
|---|
| | 1274 | print st_dot[0] |
|---|
| | 1275 | st_list = l.status(l.list_controlled()) |
|---|
| | 1276 | for st in st_list: |
|---|
| | 1277 | print st |
|---|
| 1260 | 1278 | else: |
|---|
| 1261 | 1279 | for path_name in sys.argv[2:]: |
|---|
| … | … | |
| 1264 | 1282 | if os.path.isdir(path): |
|---|
| 1265 | 1283 | l = Layer(path) |
|---|
| 1266 | | l.print_status('.') |
|---|
| | 1284 | st_dot = l.status() |
|---|
| | 1285 | print st_dot[0] |
|---|
| | 1286 | st_list = l.status(l.list_controlled()) |
|---|
| | 1287 | for st in st_list: |
|---|
| | 1288 | print st |
|---|
| 1267 | 1289 | else: |
|---|
| 1268 | 1290 | layer_name = os.path.dirname(path) |
|---|
| 1269 | 1291 | file_name = os.path.basename(path) |
|---|
| 1270 | 1292 | l = Layer(layer_name) |
|---|
| 1271 | | l.print_status(file_name, prefix=prefix) |
|---|
| 1272 | | elif sys.argv[1] == 'status+' or sys.argv[1] == 'st+': #XXX update me TODO |
|---|
| | 1293 | print l.status(file_name, prefix=prefix)[0] |
|---|
| | 1294 | elif sys.argv[1] == 'status+' or sys.argv[1] == 'st+': |
|---|
| 1273 | 1295 | if len(sys.argv) < 3: |
|---|
| 1274 | 1296 | l = Layer(os.getcwd()) |
|---|
| 1275 | | l.print_status(recursive=True) |
|---|
| | 1297 | st_list = l.status('.', True) |
|---|
| | 1298 | for st in st_list: |
|---|
| | 1299 | print st |
|---|
| 1276 | 1300 | else: |
|---|
| 1277 | 1301 | for path_name in sys.argv[2:]: |
|---|
| … | … | |
| 1280 | 1304 | if os.path.isdir(path): |
|---|
| 1281 | 1305 | l = Layer(path) |
|---|
| 1282 | | l.print_status('.', True) |
|---|
| | 1306 | st_list = l.status('.', True, prefix) |
|---|
| | 1307 | for st in st_list: |
|---|
| | 1308 | print st |
|---|
| 1283 | 1309 | else: |
|---|
| 1284 | 1310 | layer_name = os.path.dirname(path) |
|---|
| 1285 | 1311 | file_name = os.path.basename(path) |
|---|
| 1286 | 1312 | l = Layer(layer_name) |
|---|
| 1287 | | l.print_status(file_name, prefix=prefix) |
|---|
| | 1313 | print l.status(file_name, prefix=prefix)[0] |
|---|
| 1288 | 1314 | elif sys.argv[1] == 'check-in' or sys.argv[1] == 'ci': |
|---|
| 1289 | 1315 | l = Layer(os.getcwd()) |
|---|
Download in other formats:
* Generating other formats may take time.