Xqt created this task.
Xqt added projects: Pywikibot, Pywikibot-tests.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION
    ___________________ TestSiteMergeHistory.test_merge_history 
____________________
    
    self = <tests.edit_tests.TestSiteMergeHistory testMethod=test_merge_history>
    
        def test_merge_history(self):
            """Test Site.merge_history functionality."""
            site = self.get_site()
            source = pywikibot.Page(site, 'User:Sn1per/MergeTest1')
            dest = pywikibot.Page(site, 'User:Sn1per/MergeTest2')
        
            # Without timestamp
            self.setup_test_pages()
    >       site.merge_history(source, dest)
    
    tests/edit_tests.py:160: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
    pywikibot/site/_decorators.py:93: in callee
        return fn(self, *args, **kwargs)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
    
    self = APISite("test", "wikipedia"), source = Page('User:Sn1per/MergeTest1')
    dest = Page('User:Sn1per/MergeTest2'), timestamp = None, reason = None
    
        @need_right('mergehistory')
        def merge_history(
            self,
            source: BasePage,
            dest: BasePage,
            timestamp: pywikibot.Timestamp | None = None,
            reason: str | None = None,
        ) -> None:
            """Merge revisions from one page into another.
        
            .. seealso::
        
               - :api:`Mergehistory`
               - :meth:`page.BasePage.merge_history` (should be preferred)
        
            Revisions dating up to the given timestamp in the source will be
            moved into the destination page history. History merge fails if
            the timestamps of source and dest revisions overlap (all source
            revisions must be dated before the earliest dest revision).
        
            :param source: Source page from which revisions will be merged
            :param dest: Destination page to which revisions will be merged
            :param timestamp: Revisions from this page dating up to this 
timestamp
                will be merged into the destination page (if not given or False,
                all revisions will be merged)
            :param reason: Optional reason for the history merge
            :raises APIError: unexpected APIError
            :raises Error: expected APIError or unexpected response
            :raises NoPageError: *source* or *dest* does not exist
            :raises PageSaveRelatedError: *source* is equal to *dest*
            """
            # Data for error messages
            errdata = {
                'site': self,
                'source': source,
                'dest': dest,
                'user': self.user(),
            }
        
            # Check if pages exist before continuing
            if not source.exists():
                raise NoPageError(source,
                                  'Cannot merge revisions from source {source} '
                                  'because it does not exist on {site}'
                                  .format_map(errdata))
            if not dest.exists():
                raise NoPageError(dest,
                                  'Cannot merge revisions to destination {dest} 
'
                                  'because it does not exist on {site}'
                                  .format_map(errdata))
        
            if source == dest:  # Same pages
                raise PageSaveRelatedError(
                    page=source,
                    message='Cannot merge revisions of {page} to itself'
                )
        
            # Send the merge API request
            token = self.tokens['csrf']
            req = self.simple_request(action='mergehistory', token=token)
            req['from'] = source
            req['to'] = dest
            if reason:
                req['reason'] = reason
            if timestamp:
                req['timestamp'] = timestamp
        
            self.lock_page(source)
            self.lock_page(dest)
            try:
                result = req.submit()
                pywikibot.debug(f'mergehistory response: {result}')
            except APIError as err:
                if err.code in self._mh_errors:
                    on_error = self._mh_errors[err.code]
    >               raise Error(on_error.format_map(errdata)) from None
    E               pywikibot.exceptions.Error: Source revisions from 
[[test:User:Sn1per/MergeTest1]] overlap or come after destination revisions of 
[[test:User:Sn1per/MergeTest2]]
    
    pywikibot/site/_apisite.py:2329: Error

TASK DETAIL
  https://phabricator.wikimedia.org/T367300

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Xqt
Cc: Sn1per, Aklapper, Xqt, pywikibot-bugs-list, mevo, PotsdamLamb, Jyoo1011, 
JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Aram, Viztor, Wenyi, Tbscho, 
MayS, Mdupont, JJMC89, Dvorapa, Altostratus, binbot, Avicennasis, mys_721tx, 
jayvdb, Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to