~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2005-08-25 12:46:42 UTC
  • mfrom: (1116)
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050825124642-45ed1cd74db10370
merge from mpool

Show diffs side-by-side

added added

removed removed

Lines of Context:
404
404
                         """Inventory for the working copy.""")
405
405
 
406
406
 
407
 
    def add(self, files, ids=None):
 
407
    def add(self, files, verbose=False, ids=None):
408
408
        """Make files versioned.
409
409
 
410
 
        Note that the command line normally calls smart_add instead,
411
 
        which can automatically recurse.
 
410
        Note that the command line normally calls smart_add instead.
412
411
 
413
412
        This puts the files in the Added state, so that they will be
414
413
        recorded by the next commit.
424
423
        TODO: Perhaps have an option to add the ids even if the files do
425
424
              not (yet) exist.
426
425
 
427
 
        TODO: Perhaps yield the ids and paths as they're added.
 
426
        TODO: Perhaps return the ids of the files?  But then again it
 
427
              is easy to retrieve them if they're needed.
 
428
 
 
429
        TODO: Adding a directory should optionally recurse down and
 
430
              add all non-ignored children.  Perhaps do that in a
 
431
              higher-level method.
428
432
        """
429
433
        # TODO: Re-adding a file that is removed in the working copy
430
434
        # should probably put it back with the previous ID.
466
470
                    file_id = gen_file_id(f)
467
471
                inv.add_path(f, kind=kind, file_id=file_id)
468
472
 
 
473
                if verbose:
 
474
                    print 'added', quotefn(f)
 
475
 
469
476
                mutter("add file %s file_id:{%s} kind=%r" % (f, file_id, kind))
470
477
 
471
478
            self._write_inventory(inv)
1110
1117
 
1111
1118
            inv.rename(file_id, to_dir_id, to_tail)
1112
1119
 
 
1120
            print "%s => %s" % (from_rel, to_rel)
 
1121
 
1113
1122
            from_abs = self.abspath(from_rel)
1114
1123
            to_abs = self.abspath(to_rel)
1115
1124
            try:
1134
1143
 
1135
1144
        Note that to_name is only the last component of the new name;
1136
1145
        this doesn't change the directory.
1137
 
 
1138
 
        This returns a list of (from_path, to_path) pairs for each
1139
 
        entry that is moved.
1140
1146
        """
1141
 
        result = []
1142
1147
        self.lock_write()
1143
1148
        try:
1144
1149
            ## TODO: Option to move IDs only
1179
1184
            for f in from_paths:
1180
1185
                name_tail = splitpath(f)[-1]
1181
1186
                dest_path = appendpath(to_name, name_tail)
1182
 
                result.append((f, dest_path))
 
1187
                print "%s => %s" % (f, dest_path)
1183
1188
                inv.rename(inv.path2id(f), to_dir_id, name_tail)
1184
1189
                try:
1185
1190
                    os.rename(self.abspath(f), self.abspath(dest_path))
1191
1196
        finally:
1192
1197
            self.unlock()
1193
1198
 
1194
 
        return result
1195
 
 
1196
1199
 
1197
1200
    def revert(self, filenames, old_tree=None, backups=True):
1198
1201
        """Restore selected files to the versions from a previous tree.