code: def refresh(self, leave_clean=False):
      
      remote, merge = self._get_upstream()
      self._check_call(['fetch', '--tags', remote, merge], raise_type=Scm.RemoteException)
      try:
        self._check_call(['rebase', 'FETCH_HEAD'], raise_type=Scm.LocalException)
      except Scm.LocalException as e:
        if leave_clean:
          logger.debug('Cleaning up after failed rebase')
          try:
            self._check_call(['rebase', '--abort'], raise_type=Scm.LocalException)
          except Scm.LocalException as abort_exc:
            logger.debug('Failed to up after failed rebase')
            logger.debug(traceback.format_exc(abort_exc))
            # But let the original exception propagate, since that's the more interesting one
        raise e
docs: Attempt to pull-with-rebase from upstream.  This is implemented as fetch-plus-rebase
         so that we can distinguish between errors in the fetch stage (likely network errors)
         and errors in the rebase stage (conflicts).  If leave_clean is true, then in the event
         of a rebase failure, the branch will be rolled back.  Otherwise, it will be left in the
         conflicted state.