Esempio n. 1
0
 def apply(self, where):
     name = os.path.join(where, self.name)
     if self.action_kind == self.ADDED:
         if self.isdir:
             os.makedirs(name)
         else:
             dirname = os.path.dirname(name)
             if not os.path.exists(dirname):
                 os.makedirs(dirname)
             f = file(name, 'w')
             if self.contents is not None:
                 f.write(self.contents)
             f.close()
     elif self.action_kind == self.DELETED:
         if os.path.exists(name):
             if self.isdir:
                 rmtree(name)
             else:
                 os.unlink(name)
     elif self.action_kind == self.RENAMED:
         old_name = os.path.join(where, self.old_name)
         if os.path.exists(old_name):
             os.rename(old_name, name)
     elif self.action_kind == self.UPDATED:
         if self.contents is not None:
             f = file(name, 'w')
             f.write(self.contents)
         else:  # update timestamp
             f = file(name, 'w+')
         f.close()
     else:
         raise TailorBug("Unknown ChangesetEntry.action_kind: %s" %
                         str(self.action_kind))
Esempio n. 2
0
 def _checkoutUpstreamRevision(self, revision):
     if revision == 'INITIAL':
         cset = self.changesets[0]
         self.rev_offset = cset.revision - 1
         self._applyChangeset(cset)
         return cset
     else:
         raise TailorBug("Don't know what to do!")
Esempio n. 3
0
    def _applyChangeset(self, changeset):
        """
        Do the actual work of applying the changeset to the working copy.

        Subclasses should reimplement this method performing the
        necessary steps to *merge* given `changeset`, returning a list
        with the conflicts, if any.
        """

        raise TailorBug("%s should override this method!" % self.__class__)
Esempio n. 4
0
    def _getUpstreamChangesets(self, sincerev):
        """
        Query the upstream repository about what happened on the
        sources since last sync, returning a sequence of Changesets
        instances.

        This method must be overridden by subclasses.
        """

        raise TailorBug("%s should override this method!" % self.__class__)
Esempio n. 5
0
    def _commit(self,
                date,
                author,
                patchname,
                changelog=None,
                entries=None,
                tags=[],
                isinitialcommit=False):
        """
        Commit the changeset.
        """

        raise TailorBug("%s should override this method!" % self.__class__)
Esempio n. 6
0
    def _checkoutUpstreamRevision(self, revision):
        """
        Concretely do the checkout of the upstream revision.
        """

        raise TailorBug("%s should override this method!" % self.__class__)
Esempio n. 7
0
    def _renamePathname(self, oldname, newname):
        """
        Rename a filesystem object to some other name/location.
        """

        raise TailorBug("%s should override this method!" % self.__class__)
Esempio n. 8
0
    def _removePathnames(self, names):
        """
        Remove some filesystem object.
        """

        raise TailorBug("%s should override this method!" % self.__class__)
Esempio n. 9
0
    def _addPathnames(self, names):
        """
        Add some new filesystem objects.
        """

        raise TailorBug("%s should override this method!" % self.__class__)
Esempio n. 10
0
 def _set_date(self, date):
     if date and date.tzinfo is None:
         raise TailorBug("Changeset dates must have a timezone!")
     self.__date = date
Esempio n. 11
0
 def _get_changesets(self):
     if not self.__changesets:
         raise TailorBug("Attempted to use empty MockWorkingDir!")
     return self.__changesets