|
104 | 104 | )
|
105 | 105 |
|
106 | 106 | # Semi-standard module versioning.
|
107 |
| -__version__ = '0.27.2' |
| 107 | +__version__ = '0.28' |
108 | 108 |
|
109 | 109 | USER_CONFIG_FILE = os.path.expanduser('~/.vcs-repo-mgr.ini')
|
110 | 110 | """The absolute pathname of the user-specific configuration file (a string)."""
|
@@ -872,6 +872,39 @@ def merge(self, revision=None):
|
872 | 872 | **self.get_author()
|
873 | 873 | ))
|
874 | 874 |
|
| 875 | + def add_files(self, *pathnames, **kw): |
| 876 | + """ |
| 877 | + Stage new files in the working tree to be included in the next commit. |
| 878 | +
|
| 879 | + :param pathnames: Any positional arguments are expected to be pathnames |
| 880 | + relative to the root of the repository. |
| 881 | + :param all: If the keyword argument `all` is :data:`True` then all |
| 882 | + new files are added to the repository (in this case no |
| 883 | + pathnames should be given). |
| 884 | + :raises: :exc:`~exceptions.ValueError` when pathnames are given and the |
| 885 | + keyword argument `all` is also :data:`True`. |
| 886 | +
|
| 887 | + .. note:: Automatically creates the local repository on the first run. |
| 888 | + """ |
| 889 | + self.create() |
| 890 | + add_all = kw.get('all', False) |
| 891 | + logger.info("Staging working tree changes to be committed in %s ..", self.local) |
| 892 | + if pathnames and add_all: |
| 893 | + raise ValueError("You can't add specific pathnames using all=True!") |
| 894 | + if add_all: |
| 895 | + execute(self.get_command( |
| 896 | + method_name='add_files', |
| 897 | + attribute_name='add_command_all', |
| 898 | + local=self.local, |
| 899 | + )) |
| 900 | + else: |
| 901 | + execute(self.get_command( |
| 902 | + method_name='add_files', |
| 903 | + attribute_name='add_command', |
| 904 | + local=self.local, |
| 905 | + filenames=pathnames, |
| 906 | + )) |
| 907 | + |
875 | 908 | def commit(self, message, author=None):
|
876 | 909 | """
|
877 | 910 | Commit changes to tracked files in the working tree.
|
@@ -1403,6 +1436,8 @@ class HgRepo(Repository):
|
1403 | 1436 | hg -R {local} commit --user={author_combined} --message={message} --close-branch
|
1404 | 1437 | ''')
|
1405 | 1438 | merge_command = 'hg -R {local} merge --rev={revision}'
|
| 1439 | + add_command = 'hg --cwd {local} addremove {filenames}' |
| 1440 | + add_command_all = 'hg --cwd {local} addremove' |
1406 | 1441 | # The `hg remove --after' command is used to match the semantics of `git
|
1407 | 1442 | # commit --all' however `hg remove --after' is _very_ verbose (it comments
|
1408 | 1443 | # on every existing file in the repository) and unfortunately it ignores
|
@@ -1563,6 +1598,8 @@ class GitRepo(Repository):
|
1563 | 1598 | -c user.email={author_email}
|
1564 | 1599 | merge --no-commit --no-ff {revision}
|
1565 | 1600 | ''')
|
| 1601 | + add_command = 'cd {local} && git add -- {filenames}' |
| 1602 | + add_command_all = 'cd {local} && git add --all .' |
1566 | 1603 | commit_command = compact('''
|
1567 | 1604 | cd {local} && git
|
1568 | 1605 | -c user.name={author_name}
|
|
0 commit comments