~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-07-07 08:02:16 UTC
  • Revision ID: mbp@sourcefrog.net-20050707080216-4e4d884bcf89eb8d
- Merge merge updates from aaron

  aaron.bentley@utoronto.ca-20050706170931-9d2551019af3578d

Show diffs side-by-side

added added

removed removed

Lines of Context:
302
302
            os.mkdir(self.controlfilename(d))
303
303
        for f in ('revision-history', 'merged-patches',
304
304
                  'pending-merged-patches', 'branch-name',
305
 
                  'branch-lock'):
 
305
                  'branch-lock',
 
306
                  'pending-merges'):
306
307
            self.controlfile(f, 'w').write('')
307
308
        mutter('created control directory in ' + self.base)
308
309
 
606
607
 
607
608
    def get_revision_inventory(self, revision_id):
608
609
        """Return inventory of a past revision."""
 
610
        # bzr 0.0.6 imposes the constraint that the inventory_id
 
611
        # must be the same as its revision, so this is trivial.
609
612
        if revision_id == None:
610
613
            from bzrlib.inventory import Inventory
611
614
            return Inventory()
612
615
        else:
613
 
            return self.get_inventory(self.get_revision(revision_id).inventory_id)
 
616
            return self.get_inventory(revision_id)
614
617
 
615
618
 
616
619
    def revision_history(self):
1039
1042
                f.close()
1040
1043
 
1041
1044
 
 
1045
    def pending_merges(self):
 
1046
        """Return a list of pending merges.
 
1047
 
 
1048
        These are revisions that have been merged into the working
 
1049
        directory but not yet committed.
 
1050
        """
 
1051
        cfn = self.controlfilename('pending-merges')
 
1052
        if not os.path.exists(cfn):
 
1053
            return []
 
1054
        p = []
 
1055
        for l in self.controlfile('pending-merges', 'r').readlines():
 
1056
            p.append(l.rstrip('\n'))
 
1057
        return p
 
1058
 
 
1059
 
 
1060
    def add_pending_merge(self, revision_id):
 
1061
        from bzrlib.revision import validate_revision_id
 
1062
 
 
1063
        validate_revision_id(revision_id)
 
1064
 
 
1065
        p = self.pending_merges()
 
1066
        if revision_id in p:
 
1067
            return
 
1068
        p.append(revision_id)
 
1069
        self.set_pending_merges(p)
 
1070
 
 
1071
 
 
1072
    def set_pending_merges(self, rev_list):
 
1073
        from bzrlib.atomicfile import AtomicFile
 
1074
        self.lock_write()
 
1075
        try:
 
1076
            f = AtomicFile(self.controlfilename('pending-merges'))
 
1077
            try:
 
1078
                for l in rev_list:
 
1079
                    print >>f, l
 
1080
                f.commit()
 
1081
            finally:
 
1082
                f.close()
 
1083
        finally:
 
1084
            self.unlock()
 
1085
 
 
1086
 
1042
1087
 
1043
1088
class ScratchBranch(Branch):
1044
1089
    """Special test class: a branch that cleans up after itself.