~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-03-12 07:16:39 UTC
  • Revision ID: mbp@sourcefrog.net-20050312071639-0a8f59a34a024ff0
cope when gecos field doesn't have a comma

reported by ysaito, rooneg -- thanks

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,
329
334
        return self.working_tree().unknowns()
330
335
 
331
336
 
332
 
    def commit(self, message, timestamp=None, committer=None,
 
337
    def commit(self, message, timestamp=None, timezone=None,
 
338
               committer=None,
333
339
               verbose=False):
334
340
        """Commit working copy as a new revision.
335
341
        
463
469
        if committer == None:
464
470
            committer = username()
465
471
 
 
472
        if timezone == None:
 
473
            timezone = local_time_offset()
 
474
 
466
475
        mutter("building commit log message")
467
476
        rev = Revision(timestamp=timestamp,
 
477
                       timezone=timezone,
468
478
                       committer=committer,
469
479
                       precursor = self.last_patch(),
470
480
                       message = message,
607
617
 
608
618
 
609
619
 
610
 
    def write_log(self, utc=False):
 
620
    def write_log(self, show_timezone='original'):
611
621
        """Write out human-readable log of commits to this branch
612
622
 
613
623
        :param utc: If true, show dates in universal time, not local time."""
 
624
        ## TODO: Option to choose either original, utc or local timezone
614
625
        revno = 1
615
626
        precursor = None
616
627
        for p in self.revision_history():
620
631
            ##print 'revision-hash:', p
621
632
            rev = self.get_revision(p)
622
633
            print 'committer:', rev.committer
623
 
            print 'timestamp: %s' % (format_date(rev.timestamp, utc))
 
634
            print 'timestamp: %s' % (format_date(rev.timestamp, rev.timezone or 0,
 
635
                                                 show_timezone))
624
636
 
625
637
            ## opportunistic consistency check, same as check_patch_chaining
626
638
            if rev.precursor != precursor:
651
663
        A       foo
652
664
        >>> b.commit("add foo")
653
665
        >>> b.show_status()
 
666
        >>> os.unlink(b._rel('foo'))
 
667
        >>> b.show_status()
 
668
        D       foo
 
669
        
654
670
 
655
671
        :todo: Get state for single files.
656
672