/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/changeset.py

  • Committer: Martin Pool
  • Date: 2005-08-17 02:06:19 UTC
  • Revision ID: mbp@sourcefrog.net-20050817020618-c7ae430253df8532
- rearrangement of modules, contributed by Gustavo Niemeyer


1) Moved plugins directory to bzrlib/, so that there's a standard
  plugin directory which is not only installed with bzr itself
  but is also available when using bzr from the development tree.
  BZR_PLUGIN_PATH and DEFAULT_PLUGIN_PATH are then added to the
  standard plugins directory.

2) Moved the needed third-party tools to an internal directory under
  bzrlib/util.  This makes sure that needed tools are available in
  the bzr installation, including the correct/expected version, and
  eases the process of packaging and redistribution of bzr
  ('setup.py bdist*' creates a working distribution).

3) Fixed setup.py including the needed package entries.

I hope you find them useful.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import patch
19
19
import stat
20
20
from bzrlib.trace import mutter
21
 
"""
22
 
Represent and apply a changeset
23
 
"""
 
21
 
 
22
# XXX: mbp: I'm not totally convinced that we should handle conflicts
 
23
# as part of changeset application, rather than only in the merge
 
24
# operation.
 
25
 
 
26
"""Represent and apply a changeset
 
27
 
 
28
Conflicts in applying a changeset are represented as exceptions.
 
29
"""
 
30
 
24
31
__docformat__ = "restructuredtext"
25
32
 
26
33
NULL_ID = "!NULL"
1028
1035
 
1029
1036
 
1030
1037
class ExceptionConflictHandler(object):
 
1038
    """Default handler for merge exceptions.
 
1039
 
 
1040
    This throws an error on any kind of conflict.  Conflict handlers can
 
1041
    descend from this class if they have a better way to handle some or
 
1042
    all types of conflict.
 
1043
    """
1031
1044
    def __init__(self, dir):
1032
1045
        self.dir = dir
1033
1046
    
1382
1395
        parent = inventory[dirname]
1383
1396
        return parent.id
1384
1397
 
1385
 
    def get_paths(self, entry, tree):
 
1398
    def get_path(self, entry, tree):
1386
1399
        if entry is None:
1387
1400
            return (None, None)
1388
 
        full_path = tree.readonly_path(entry.id)
1389
1401
        if entry.path == ".":
1390
 
            return ("", full_path)
1391
 
        return (entry.path, full_path)
 
1402
            return ""
 
1403
        return entry.path
1392
1404
 
1393
1405
    def make_basic_entry(self, id, only_interesting):
1394
1406
        entry_a = self.r_inventory_a.get(id)
1395
1407
        entry_b = self.r_inventory_b.get(id)
1396
1408
        if only_interesting and not self.is_interesting(entry_a, entry_b):
1397
 
            return (None, None, None)
 
1409
            return None
1398
1410
        parent = self.get_entry_parent(entry_a, self.inventory_a)
1399
 
        (path, full_path_a) = self.get_paths(entry_a, self.tree_a)
 
1411
        path = self.get_path(entry_a, self.tree_a)
1400
1412
        cs_entry = ChangesetEntry(id, parent, path)
1401
1413
        new_parent = self.get_entry_parent(entry_b, self.inventory_b)
1402
1414
 
1403
1415
 
1404
 
        (new_path, full_path_b) = self.get_paths(entry_b, self.tree_b)
 
1416
        new_path = self.get_path(entry_b, self.tree_b)
1405
1417
 
1406
1418
        cs_entry.new_path = new_path
1407
1419
        cs_entry.new_parent = new_parent
1408
 
        return (cs_entry, full_path_a, full_path_b)
 
1420
        return cs_entry
1409
1421
 
1410
1422
    def is_interesting(self, entry_a, entry_b):
1411
1423
        if entry_a is not None:
1417
1429
        return False
1418
1430
 
1419
1431
    def make_boring_entry(self, id):
1420
 
        (cs_entry, full_path_a, full_path_b) = \
1421
 
            self.make_basic_entry(id, only_interesting=False)
 
1432
        cs_entry = self.make_basic_entry(id, only_interesting=False)
1422
1433
        if cs_entry.is_creation_or_deletion():
1423
1434
            return self.make_entry(id, only_interesting=False)
1424
1435
        else:
1426
1437
        
1427
1438
 
1428
1439
    def make_entry(self, id, only_interesting=True):
1429
 
        (cs_entry, full_path_a, full_path_b) = \
1430
 
            self.make_basic_entry(id, only_interesting)
 
1440
        cs_entry = self.make_basic_entry(id, only_interesting)
1431
1441
 
1432
1442
        if cs_entry is None:
1433
1443
            return None
1434
 
       
 
1444
        if id in self.tree_a and id in self.tree_b:
 
1445
            a_sha1 = self.tree_a.get_file_sha1(id)
 
1446
            b_sha1 = self.tree_b.get_file_sha1(id)
 
1447
            if None not in (a_sha1, b_sha1) and a_sha1 == b_sha1:
 
1448
                return cs_entry
 
1449
 
 
1450
        full_path_a = self.tree_a.readonly_path(id)
 
1451
        full_path_b = self.tree_b.readonly_path(id)
1435
1452
        stat_a = self.lstat(full_path_a)
1436
1453
        stat_b = self.lstat(full_path_b)
1437
1454
        if stat_b is None: