~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-15 15:57:56 UTC
  • mfrom: (1911.3.5 add-action-55781)
  • Revision ID: pqm@pqm.ubuntu.com-20060815155756-77559a6254704822
(jam) add '--file-ids-from' to 'bzr add' (bug #55781)

Show diffs side-by-side

added added

removed removed

Lines of Context:
274
274
 
275
275
    --dry-run will show which files would be added, but not actually 
276
276
    add them.
 
277
 
 
278
    --file-ids-from will try to use the file ids from the supplied path.
 
279
    It looks up ids trying to find a matching parent directory with the
 
280
    same filename, and then by pure path.
277
281
    """
278
282
    takes_args = ['file*']
279
 
    takes_options = ['no-recurse', 'dry-run', 'verbose']
 
283
    takes_options = ['no-recurse', 'dry-run', 'verbose',
 
284
                     Option('file-ids-from', type=unicode,
 
285
                            help='Lookup file ids from here')]
280
286
    encoding_type = 'replace'
281
287
 
282
 
    def run(self, file_list, no_recurse=False, dry_run=False, verbose=False):
 
288
    def run(self, file_list, no_recurse=False, dry_run=False, verbose=False,
 
289
            file_ids_from=None):
283
290
        import bzrlib.add
284
291
 
285
 
        action = bzrlib.add.AddAction(to_file=self.outf,
286
 
            should_print=(not is_quiet()))
287
 
 
288
 
        added, ignored = bzrlib.add.smart_add(file_list, not no_recurse, 
 
292
        if file_ids_from is not None:
 
293
            try:
 
294
                base_tree, base_path = WorkingTree.open_containing(
 
295
                                            file_ids_from)
 
296
            except errors.NoWorkingTree:
 
297
                base_branch, base_path = branch.Branch.open_containing(
 
298
                                            file_ids_from)
 
299
                base_tree = base_branch.basis_tree()
 
300
 
 
301
            action = bzrlib.add.AddFromBaseAction(base_tree, base_path,
 
302
                          to_file=self.outf, should_print=(not is_quiet()))
 
303
        else:
 
304
            action = bzrlib.add.AddAction(to_file=self.outf,
 
305
                should_print=(not is_quiet()))
 
306
 
 
307
        added, ignored = bzrlib.add.smart_add(file_list, not no_recurse,
289
308
                                              action=action, save=not dry_run)
290
309
        if len(ignored) > 0:
291
310
            if verbose: