~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-03-13 05:22:51 UTC
  • Revision ID: mbp@sourcefrog.net-20050313052251-2bf004cb96b39933
When removing files, new status should be I or ?, not D

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from inventory import InventoryEntry, Inventory
30
30
from osutils import isdir, quotefn, isfile, uuid, sha_file, username, chomp, \
31
31
     format_date, compact_date, pumpfile, user_email, rand_bytes, splitpath, \
32
 
     joinpath, sha_string, file_kind
 
32
     joinpath, sha_string, file_kind, local_time_offset
33
33
from store import ImmutableStore
34
34
from revision import Revision
35
35
from errors import bailout
159
159
        That is to say, the inventory describing changes underway, that
160
160
        will be committed to the next revision.
161
161
        """
162
 
        inv.write_xml(self.controlfile('inventory', 'w'))
163
 
        mutter('wrote inventory to %s' % quotefn(self.controlfilename('inventory')))
 
162
        ## TODO: factor out to atomicfile?  is rename safe on windows?
 
163
        tmpfname = self.controlfilename('inventory.tmp')
 
164
        tmpf = file(tmpfname, 'w')
 
165
        inv.write_xml(tmpf)
 
166
        tmpf.close()
 
167
        os.rename(tmpfname, self.controlfilename('inventory'))
 
168
        mutter('wrote working inventory')
164
169
 
165
170
 
166
171
    inventory = property(read_working_inventory, _write_inventory, None,
295
300
        if isinstance(files, types.StringTypes):
296
301
            files = [files]
297
302
        
298
 
        inv = self.read_working_inventory()
 
303
        tree = self.working_tree()
 
304
        inv = tree.inventory
299
305
 
300
306
        # do this before any modifications
301
307
        for f in files:
304
310
                bailout("cannot remove unversioned file %s" % quotefn(f))
305
311
            mutter("remove inventory entry %s {%s}" % (quotefn(f), fid))
306
312
            if verbose:
307
 
                show_status('D', inv[fid].kind, quotefn(f))
 
313
                # having remove it, it must be either ignored or unknown
 
314
                if tree.is_ignored(f):
 
315
                    new_status = 'I'
 
316
                else:
 
317
                    new_status = '?'
 
318
                show_status(new_status, inv[fid].kind, quotefn(f))
308
319
            del inv[fid]
309
320
 
310
321
        self._write_inventory(inv)
329
340
        return self.working_tree().unknowns()
330
341
 
331
342
 
332
 
    def commit(self, message, timestamp=None, committer=None,
 
343
    def commit(self, message, timestamp=None, timezone=None,
 
344
               committer=None,
333
345
               verbose=False):
334
346
        """Commit working copy as a new revision.
335
347
        
463
475
        if committer == None:
464
476
            committer = username()
465
477
 
 
478
        if timezone == None:
 
479
            timezone = local_time_offset()
 
480
 
466
481
        mutter("building commit log message")
467
482
        rev = Revision(timestamp=timestamp,
 
483
                       timezone=timezone,
468
484
                       committer=committer,
469
485
                       precursor = self.last_patch(),
470
486
                       message = message,
607
623
 
608
624
 
609
625
 
610
 
    def write_log(self, utc=False):
 
626
    def write_log(self, show_timezone='original'):
611
627
        """Write out human-readable log of commits to this branch
612
628
 
613
629
        :param utc: If true, show dates in universal time, not local time."""
 
630
        ## TODO: Option to choose either original, utc or local timezone
614
631
        revno = 1
615
632
        precursor = None
616
633
        for p in self.revision_history():
620
637
            ##print 'revision-hash:', p
621
638
            rev = self.get_revision(p)
622
639
            print 'committer:', rev.committer
623
 
            print 'timestamp: %s' % (format_date(rev.timestamp, utc))
 
640
            print 'timestamp: %s' % (format_date(rev.timestamp, rev.timezone or 0,
 
641
                                                 show_timezone))
624
642
 
625
643
            ## opportunistic consistency check, same as check_patch_chaining
626
644
            if rev.precursor != precursor:
651
669
        A       foo
652
670
        >>> b.commit("add foo")
653
671
        >>> b.show_status()
 
672
        >>> os.unlink(b._rel('foo'))
 
673
        >>> b.show_status()
 
674
        D       foo
 
675
        
654
676
 
655
677
        :todo: Get state for single files.
656
678