code: public CmsPublishList mergePublishLists(CmsRequestContext context, CmsPublishList pubList1, CmsPublishList pubList2)
      throws CmsException {
  
          CmsPublishList ret = null;
          CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
          try {
              // get all resources from the first list
              Set<CmsResource> publishResources = new HashSet<CmsResource>(pubList1.getAllResources());
              // get all resources from the second list
              publishResources.addAll(pubList2.getAllResources());
  
              // create merged publish list
              ret = new CmsPublishList(
                  pubList1.getDirectPublishResources(),
                  pubList1.isPublishSiblings(),
                  pubList1.isPublishSubResources());
              ret.addAll(publishResources, false); // ignore files that should not be published
              if (pubList1.isUserPublishList()) {
                  ret.setUserPublishList(true);
              }
              ret.initialize(); // ensure sort order
  
              checkPublishPermissions(dbc, ret);
          } catch (Exception e) {
              dbc.report(null, Messages.get().container(Messages.ERR_MERGING_PUBLISH_LISTS_0), e);
          } finally {
              dbc.clear();
          }
          return ret;
      }
docs: Returns a new publish list that contains all resources of both given publish lists.<p>
  
  @param context the current request context
  @param pubList1 the first publish list
  @param pubList2 the second publish list
  
  @return a new publish list that contains all resources of both given publish lists
  
  @throws CmsException if something goes wrong
  
  @see org.opencms.publish.CmsPublishManager#mergePublishLists(CmsObject, CmsPublishList, CmsPublishList)