001package org.apache.maven.scm.provider;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022/**
023 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
024 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
025 *
026 */
027public abstract class ScmProviderRepository
028{
029    private String user;
030
031    private String password;
032
033    private boolean persistCheckout = false;
034
035    /**
036     * @since 1.4
037     */
038    private boolean pushChanges = true;
039
040    /**
041     * @return The user.
042     */
043    public String getUser()
044    {
045        return user;
046    }
047
048    /**
049     * Set the user.
050     *
051     * @param user The user
052     */
053    public void setUser( String user )
054    {
055        this.user = user;
056    }
057
058    /**
059     * @return The password.
060     */
061    public String getPassword()
062    {
063        return password;
064    }
065
066    /**
067     * Set the password.
068     *
069     * @param password The user password
070     */
071    public void setPassword( String password )
072    {
073        this.password = password;
074    }
075
076    /**
077     * Should distributed changes be pushed to the central repository?
078     * For many distributed SCMs like Git, a change like a commit 
079     * is only stored in your local copy of the repository.  Pushing
080     * the change allows your to more easily share it with other users.
081     * @since 1.4
082     */
083    public boolean isPushChanges() 
084    {
085        return pushChanges;
086    }
087
088    /**
089     * @since 1.4
090     * @param pushChanges
091     */
092    public void setPushChanges(boolean pushChanges) 
093    {
094        this.pushChanges = pushChanges;
095    }
096
097    /**
098     * Will checkouts using this repository be persisted so they can
099     * be refreshed in the future?  This property is of concern to SCMs
100     * like Perforce and Clearcase where the server must track where a
101     * user checks out to.  If false, the server entry (clientspec in Perforce
102     * terminology) will be deleted after the checkout is complete so the
103     * files will not be able to be updated.
104     * <p/>
105     * This setting can be overriden by using the system property
106     * "maven.scm.persistcheckout" to true.
107     * <p/>
108     * The default is false.  See SCM-113 for more detail.
109     */
110    public boolean isPersistCheckout()
111    {
112        String persist = System.getProperty( "maven.scm.persistcheckout" );
113        if ( persist != null )
114        {
115            return Boolean.valueOf( persist ).booleanValue();
116        }
117        return persistCheckout;
118    }
119
120    public void setPersistCheckout( boolean persistCheckout )
121    {
122        this.persistCheckout = persistCheckout;
123    }
124
125    /**
126     * Get a {@link ScmProviderRepository} that represents the parent folder in the repository.
127     * Useful when the repository does not exist yet and we need to create it from the parent.
128     *
129     * @return the parent repository
130     * @throws UnsupportedOperationException unless overridden by subclass
131     */
132    public ScmProviderRepository getParent()
133    {
134        throw new UnsupportedOperationException();
135    }
136
137    /**
138     * Get the relative path between the repository provided as argument and the current repository.
139     *
140     * @param ancestor another repository that should be ancestor of this one
141     * @return the relative path or <code>null</code> if it can't be resolved
142     * @throws UnsupportedOperationException unless overridden by subclass
143     */
144    public String getRelativePath( ScmProviderRepository ancestor )
145    {
146        throw new UnsupportedOperationException();
147    }
148}