/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/workingtree.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
1627
1627
                                this_tree=self,
1628
1628
                                pb=pb,
1629
1629
                                change_reporter=change_reporter)
1630
 
                    if (basis_tree.inventory.root is None and
1631
 
                        new_basis_tree.inventory.root is not None):
1632
 
                        self.set_root_id(new_basis_tree.get_root_id())
 
1630
                    basis_root_id = basis_tree.get_root_id()
 
1631
                    new_root_id = new_basis_tree.get_root_id()
 
1632
                    if basis_root_id != new_root_id:
 
1633
                        self.set_root_id(new_root_id)
1633
1634
                finally:
1634
1635
                    pb.finished()
1635
1636
                    basis_tree.unlock()
1741
1742
        r"""Check whether the filename matches an ignore pattern.
1742
1743
 
1743
1744
        Patterns containing '/' or '\' need to match the whole path;
1744
 
        others match against only the last component.
 
1745
        others match against only the last component.  Patterns starting
 
1746
        with '!' are ignore exceptions.  Exceptions take precedence
 
1747
        over regular patterns and cause the filename to not be ignored.
1745
1748
 
1746
1749
        If the file is ignored, returns the pattern which caused it to
1747
1750
        be ignored, otherwise None.  So this can simply be used as a
1748
1751
        boolean if desired."""
1749
1752
        if getattr(self, '_ignoreglobster', None) is None:
1750
 
            self._ignoreglobster = globbing.Globster(self.get_ignore_list())
 
1753
            self._ignoreglobster = globbing.ExceptionGlobster(self.get_ignore_list())
1751
1754
        return self._ignoreglobster.match(filename)
1752
1755
 
1753
1756
    def kind(self, file_id):
2191
2194
        """
2192
2195
        raise NotImplementedError(self.unlock)
2193
2196
 
2194
 
    def update(self, change_reporter=None, possible_transports=None):
 
2197
    _marker = object()
 
2198
 
 
2199
    def update(self, change_reporter=None, possible_transports=None,
 
2200
               revision=None, old_tip=_marker):
2195
2201
        """Update a working tree along its branch.
2196
2202
 
2197
2203
        This will update the branch if its bound too, which means we have
2215
2221
        - Merge current state -> basis tree of the master w.r.t. the old tree
2216
2222
          basis.
2217
2223
        - Do a 'normal' merge of the old branch basis if it is relevant.
 
2224
 
 
2225
        :param revision: The target revision to update to. Must be in the
 
2226
            revision history.
 
2227
        :param old_tip: If branch.update() has already been run, the value it
 
2228
            returned (old tip of the branch or None). _marker is used
 
2229
            otherwise.
2218
2230
        """
2219
2231
        if self.branch.get_bound_location() is not None:
2220
2232
            self.lock_write()
2221
 
            update_branch = True
 
2233
            update_branch = (old_tip is self._marker)
2222
2234
        else:
2223
2235
            self.lock_tree_write()
2224
2236
            update_branch = False
2226
2238
            if update_branch:
2227
2239
                old_tip = self.branch.update(possible_transports)
2228
2240
            else:
2229
 
                old_tip = None
2230
 
            return self._update_tree(old_tip, change_reporter)
 
2241
                if old_tip is self._marker:
 
2242
                    old_tip = None
 
2243
            return self._update_tree(old_tip, change_reporter, revision)
2231
2244
        finally:
2232
2245
            self.unlock()
2233
2246
 
2234
2247
    @needs_tree_write_lock
2235
 
    def _update_tree(self, old_tip=None, change_reporter=None):
 
2248
    def _update_tree(self, old_tip=None, change_reporter=None, revision=None):
2236
2249
        """Update a tree to the master branch.
2237
2250
 
2238
2251
        :param old_tip: if supplied, the previous tip revision the branch,
2253
2266
            last_rev = self.get_parent_ids()[0]
2254
2267
        except IndexError:
2255
2268
            last_rev = _mod_revision.NULL_REVISION
2256
 
        if last_rev != _mod_revision.ensure_null(self.branch.last_revision()):
2257
 
            # merge tree state up to new branch tip.
 
2269
        if revision is None:
 
2270
            revision = self.branch.last_revision()
 
2271
        else:
 
2272
            if revision not in self.branch.revision_history():
 
2273
                raise errors.NoSuchRevision(self.branch, revision)
 
2274
        if last_rev != _mod_revision.ensure_null(revision):
 
2275
            # merge tree state up to specified revision.
2258
2276
            basis = self.basis_tree()
2259
2277
            basis.lock_read()
2260
2278
            try:
2261
 
                to_tree = self.branch.basis_tree()
2262
 
                if basis.inventory.root is None:
2263
 
                    self.set_root_id(to_tree.get_root_id())
 
2279
                to_tree = self.branch.repository.revision_tree(revision)
 
2280
                to_root_id = to_tree.get_root_id()
 
2281
                if (basis.inventory.root is None
 
2282
                    or basis.inventory.root.file_id != to_root_id):
 
2283
                    self.set_root_id(to_root_id)
2264
2284
                    self.flush()
2265
2285
                result += merge.merge_inner(
2266
2286
                                      self.branch,
2268
2288
                                      basis,
2269
2289
                                      this_tree=self,
2270
2290
                                      change_reporter=change_reporter)
 
2291
                self.set_last_revision(revision)
2271
2292
            finally:
2272
2293
                basis.unlock()
2273
2294
            # TODO - dedup parents list with things merged by pull ?
2274
2295
            # reuse the tree we've updated to to set the basis:
2275
 
            parent_trees = [(self.branch.last_revision(), to_tree)]
 
2296
            parent_trees = [(revision, to_tree)]
2276
2297
            merges = self.get_parent_ids()[1:]
2277
2298
            # Ideally we ask the tree for the trees here, that way the working
2278
2299
            # tree can decide whether to give us the entire tree or give us a
2308
2329
            #       should be able to remove this extra flush.
2309
2330
            self.flush()
2310
2331
            graph = self.branch.repository.get_graph()
2311
 
            base_rev_id = graph.find_unique_lca(self.branch.last_revision(),
2312
 
                                                old_tip)
 
2332
            base_rev_id = graph.find_unique_lca(revision, old_tip)
2313
2333
            base_tree = self.branch.repository.revision_tree(base_rev_id)
2314
2334
            other_tree = self.branch.repository.revision_tree(old_tip)
2315
2335
            result += merge.merge_inner(