Changeset - 69420c48a0e6
[Not reviewed]
beta
0 5 0
Marcin Kuzminski - 13 years ago 2012-09-04 22:46:05
marcin@python-works.com
fixes #550 mercurial repositories comparision failed when origin repo had
additional not-common changesets + added regresion test for this
5 files changed with 115 insertions and 6 deletions:
0 comments (0 inline, 0 general)
docs/changelog.rst
Show inline comments
 
@@ -9,49 +9,50 @@ Changelog
 
----------------------
 

	
 
:status: in-progress
 
:branch: beta
 

	
 
news
 
++++
 

	
 
- always put a comment about code-review status change even if user send
 
  empty data 
 
- modified_on column saves repository update and it's going to be used
 
  later for light version of main page ref #500
 
- pull request notifications send much nicer emails with details about pull
 
  request
 

	
 
fixes
 
+++++
 

	
 
- fixed migrations of permissions that can lead to inconsistency.
 
  Some users sent feedback that after upgrading from older versions issues 
 
  with updating default permissions occurred. RhodeCode detects that now and
 
  resets default user permission to initial state if there is a need for that.
 
  Also forces users to set the default value for new forking permission. 
 
- #535 improved apache wsgi example configuration in docs
 

	
 
- fixes #550 mercurial repositories comparision failed when origin repo had
 
  additional not-common changesets
 

	
 
1.4.0 (**2012-09-03**)
 
----------------------
 

	
 
news
 
++++
 
 
 
- new codereview system
 
- email map, allowing users to have multiple email addresses mapped into
 
  their accounts
 
- improved git-hook system. Now all actions for git are logged into journal
 
  including pushed revisions, user and IP address
 
- changed setup-app into setup-rhodecode and added default options to it.
 
- new git repos are created as bare now by default
 
- #464 added links to groups in permission box
 
- #465 mentions autocomplete inside comments boxes
 
- #469 added --update-only option to whoosh to re-index only given list
 
  of repos in index 
 
- rhodecode-api CLI client
 
- new git http protocol replaced buggy dulwich implementation.
 
  Now based on pygrack & gitweb
 
- Improved RSS/ATOM feeds. Discoverable by browsers using proper headers, and 
 
  reformated based on user suggestions. Additional rss/atom feeds for user
 
  journal
rhodecode/lib/diffs.py
Show inline comments
 
@@ -589,48 +589,48 @@ def differ(org_repo, org_ref, other_repo
 
    """
 

	
 
    bundlerepo = None
 
    ignore_whitespace = False
 
    context = 3
 
    org_repo = org_repo.scm_instance._repo
 
    other_repo = other_repo.scm_instance._repo
 
    opts = diffopts(git=True, ignorews=ignore_whitespace, context=context)
 
    org_ref = org_ref[1]
 
    other_ref = other_ref[1]
 

	
 
    if org_repo != other_repo:
 

	
 
        common, incoming, rheads = discovery_data
 
        other_repo_peer = localrepo.locallegacypeer(other_repo.local())
 
        # create a bundle (uncompressed if other repo is not local)
 
        if other_repo_peer.capable('getbundle') and incoming:
 
            # disable repo hooks here since it's just bundle !
 
            # patch and reset hooks section of UI config to not run any
 
            # hooks on fetching archives with subrepos
 
            for k, _ in other_repo.ui.configitems('hooks'):
 
                other_repo.ui.setconfig('hooks', k, None)
 

	
 
            unbundle = other_repo.getbundle('incoming', common=common,
 
                                            heads=rheads)
 
                                            heads=None)
 

	
 
            buf = BytesIO()
 
            while True:
 
                chunk = unbundle._stream.read(1024 * 4)
 
                if not chunk:
 
                    break
 
                buf.write(chunk)
 

	
 
            buf.seek(0)
 
            # replace chunked _stream with data that can do tell() and seek()
 
            unbundle._stream = buf
 

	
 
            ui = make_ui('db')
 
            bundlerepo = InMemoryBundleRepo(ui, path=org_repo.root,
 
                                            bundlestream=unbundle)
 

	
 
        return ''.join(patch.diff(bundlerepo or org_repo,
 
                                  node1=org_repo[org_ref].node(),
 
                                  node2=other_repo[other_ref].node(),
 
                                  opts=opts))
 
    else:
 
        return ''.join(patch.diff(org_repo, node1=org_ref, node2=other_ref,
 
                                  opts=opts))
rhodecode/lib/vcs/utils/hgcompat.py
Show inline comments
 
"""
 
Mercurial libs compatibility
 
"""
 

	
 
from mercurial import archival, merge as hg_merge, patch, ui
 
from mercurial.commands import clone, nullid, pull
 
from mercurial.context import memctx, memfilectx
 
from mercurial.error import RepoError, RepoLookupError, Abort
 
from mercurial.hgweb.common import get_contact
 
from mercurial.localrepo import localrepository
 
from mercurial.match import match
 
from mercurial.mdiff import diffopts
 
from mercurial.node import hex
 
from mercurial.encoding import tolocal
 
from mercurial import discovery
 
from mercurial import localrepo
 
from mercurial import scmutil
 
\ No newline at end of file
 
from mercurial import scmutil
 
from mercurial.discovery import findcommonoutgoing
 
\ No newline at end of file
rhodecode/model/pull_request.py
Show inline comments
 
@@ -15,49 +15,50 @@
 
# the Free Software Foundation, either version 3 of the License, or
 
# (at your option) any later version.
 
#
 
# This program is distributed in the hope that it will be useful,
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import logging
 
import binascii
 
import datetime
 

	
 
from pylons.i18n.translation import _
 

	
 
from rhodecode.model.meta import Session
 
from rhodecode.lib import helpers as h
 
from rhodecode.model import BaseModel
 
from rhodecode.model.db import PullRequest, PullRequestReviewers, Notification
 
from rhodecode.model.notification import NotificationModel
 
from rhodecode.lib.utils2 import safe_unicode
 

	
 
from rhodecode.lib.vcs.utils.hgcompat import discovery, localrepo, scmutil
 
from rhodecode.lib.vcs.utils.hgcompat import discovery, localrepo, scmutil, \
 
    findcommonoutgoing
 

	
 
log = logging.getLogger(__name__)
 

	
 

	
 
class PullRequestModel(BaseModel):
 

	
 
    cls = PullRequest
 

	
 
    def __get_pull_request(self, pull_request):
 
        return self._get_instance(PullRequest, pull_request)
 

	
 
    def get_all(self, repo):
 
        repo = self._get_repo(repo)
 
        return PullRequest.query().filter(PullRequest.other_repo == repo).all()
 

	
 
    def create(self, created_by, org_repo, org_ref, other_repo,
 
               other_ref, revisions, reviewers, title, description=None):
 

	
 
        created_by_user = self._get_user(created_by)
 
        org_repo = self._get_repo(org_repo)
 
        other_repo = self._get_repo(other_repo)
 

	
 
        new = PullRequest()
 
        new.org_repo = org_repo
 
@@ -143,49 +144,51 @@ class PullRequestModel(BaseModel):
 
        pull_request.updated_on = datetime.datetime.now()
 
        self.sa.add(pull_request)
 

	
 
    def _get_changesets(self, org_repo, org_ref, other_repo, other_ref,
 
                        discovery_data):
 
        """
 
        Returns a list of changesets that are incoming from org_repo@org_ref
 
        to other_repo@other_ref
 

	
 
        :param org_repo:
 
        :type org_repo:
 
        :param org_ref:
 
        :type org_ref:
 
        :param other_repo:
 
        :type other_repo:
 
        :param other_ref:
 
        :type other_ref:
 
        :param tmp:
 
        :type tmp:
 
        """
 
        changesets = []
 
        #case two independent repos
 
        common, incoming, rheads = discovery_data
 
        if org_repo != other_repo and incoming:
 
            revs = org_repo._repo.changelog.findmissing(common, rheads)
 
            obj = findcommonoutgoing(org_repo._repo,
 
                                     localrepo.locallegacypeer(other_repo._repo.local()))
 
            revs = obj.missing
 

	
 
            for cs in reversed(map(binascii.hexlify, revs)):
 
                changesets.append(org_repo.get_changeset(cs))
 
        else:
 
            _revset_predicates = {
 
                    'branch': 'branch',
 
                    'book': 'bookmark',
 
                    'tag': 'tag',
 
                    'rev': 'id',
 
                }
 

	
 
            revs = [
 
                "ancestors(%s('%s')) and not ancestors(%s('%s'))" % (
 
                    _revset_predicates[org_ref[0]], org_ref[1],
 
                    _revset_predicates[other_ref[0]], other_ref[1]
 
               )
 
            ]
 

	
 
            out = scmutil.revrange(org_repo._repo, revs)
 
            for cs in reversed(out):
 
                changesets.append(org_repo.get_changeset(cs))
 

	
 
        return changesets
 

	
rhodecode/tests/functional/test_compare.py
Show inline comments
 
@@ -162,28 +162,132 @@ class TestCompareController(TestControll
 
            message='commit2',
 
            content='line1\nline2',
 
            f_path='file1'
 
        )
 

	
 
        rev1 = 'default'
 
        rev2 = 'default'
 
        response = self.app.get(url(controller='compare', action='index',
 
                                    repo_name=r2_name,
 
                                    org_ref_type="branch",
 
                                    org_ref=rev1,
 
                                    other_ref_type="branch",
 
                                    other_ref=rev2,
 
                                    repo=r1_name
 
                                    ))
 

	
 
        try:
 
            response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2))
 

	
 
            response.mustcontain("""<div class="message">commit2</div>""")
 
            response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (r2_name, cs1.raw_id, cs1.short_id))
 
            ## files
 
            response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (r2_name, rev1, rev2))
 

	
 

	
 
        finally:
 
            RepoModel().delete(r1_id)
 
            RepoModel().delete(r2_id)
 

	
 
    def test_org_repo_new_commits_after_forking(self):
 
        self.log_user()
 

	
 
        repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
 
                                        description='diff-test',
 
                                        owner=TEST_USER_ADMIN_LOGIN)
 

	
 
        Session().commit()
 
        r1_id = repo1.repo_id
 
        r1_name = repo1.repo_name
 

	
 
        #commit something initially !
 
        cs0 = ScmModel().create_node(
 
            repo=repo1.scm_instance, repo_name=r1_name,
 
            cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN,
 
            author=TEST_USER_ADMIN_LOGIN,
 
            message='commit1',
 
            content='line1',
 
            f_path='file1'
 
        )
 
        Session().commit()
 
        self.assertEqual(repo1.scm_instance.revisions, [cs0.raw_id])
 
        #fork the repo1
 
        repo2 = RepoModel().create_repo(repo_name='one-fork', repo_type='hg',
 
                                description='compare-test',
 
                                clone_uri=repo1.repo_full_path,
 
                                owner=TEST_USER_ADMIN_LOGIN, fork_of='one')
 
        Session().commit()
 
        self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id])
 
        r2_id = repo2.repo_id
 
        r2_name = repo2.repo_name
 

	
 
        #make 3 new commits in fork
 
        cs1 = ScmModel().create_node(
 
            repo=repo2.scm_instance, repo_name=r2_name,
 
            cs=repo2.scm_instance[-1], user=TEST_USER_ADMIN_LOGIN,
 
            author=TEST_USER_ADMIN_LOGIN,
 
            message='commit1-fork',
 
            content='file1-line1-from-fork',
 
            f_path='file1-fork'
 
        )
 
        cs2 = ScmModel().create_node(
 
            repo=repo2.scm_instance, repo_name=r2_name,
 
            cs=cs1, user=TEST_USER_ADMIN_LOGIN,
 
            author=TEST_USER_ADMIN_LOGIN,
 
            message='commit2-fork',
 
            content='file2-line1-from-fork',
 
            f_path='file2-fork'
 
        )
 
        cs3 = ScmModel().create_node(
 
            repo=repo2.scm_instance, repo_name=r2_name,
 
            cs=cs2, user=TEST_USER_ADMIN_LOGIN,
 
            author=TEST_USER_ADMIN_LOGIN,
 
            message='commit3-fork',
 
            content='file3-line1-from-fork',
 
            f_path='file3-fork'
 
        )
 

	
 
        #compare !
 
        rev1 = 'default'
 
        rev2 = 'default'
 
        response = self.app.get(url(controller='compare', action='index',
 
                                    repo_name=r2_name,
 
                                    org_ref_type="branch",
 
                                    org_ref=rev1,
 
                                    other_ref_type="branch",
 
                                    other_ref=rev2,
 
                                    repo=r1_name
 
                                    ))
 

	
 
        try:
 
            response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2))
 
            response.mustcontain("""file1-line1-from-fork""")
 
            response.mustcontain("""file2-line1-from-fork""")
 
            response.mustcontain("""file3-line1-from-fork""")
 

	
 
            #add new commit into parent !
 
            cs0 = ScmModel().create_node(
 
                repo=repo1.scm_instance, repo_name=r1_name,
 
                cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN,
 
                author=TEST_USER_ADMIN_LOGIN,
 
                message='commit2',
 
                content='line1',
 
                f_path='file2'
 
            )
 
            #compare !
 
            rev1 = 'default'
 
            rev2 = 'default'
 
            response = self.app.get(url(controller='compare', action='index',
 
                                        repo_name=r2_name,
 
                                        org_ref_type="branch",
 
                                        org_ref=rev1,
 
                                        other_ref_type="branch",
 
                                        other_ref=rev2,
 
                                        repo=r1_name
 
                                        ))
 

	
 
            response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2))
 
            response.mustcontain("""file1-line1-from-fork""")
 
            response.mustcontain("""file2-line1-from-fork""")
 
            response.mustcontain("""file3-line1-from-fork""")
 
        finally:
 
            RepoModel().delete(r1_id)
 
            RepoModel().delete(r2_id)
0 comments (0 inline, 0 general)