author | Nathan Froyd <froydnj@mozilla.com> |
Tue, 14 Feb 2017 16:12:19 -0500 | |
changeset 342903 | 08891e1a5977b6a3eb5d0ec8e659c036395e2e36 |
parent 342902 | f944183330cc3eb499e84edfcd4c4864527635d9 |
child 342904 | 8b9b3653e416f3de771c824c5ee5290d8961ff04 |
push id | 31366 |
push user | cbook@mozilla.com |
push date | Wed, 15 Feb 2017 11:25:19 +0000 |
treeherder | mozilla-central@c0807d6938c1 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | ted.mielczarek |
bugs | 1306078 |
milestone | 54.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
python/mozversioncontrol/mozversioncontrol/__init__.py | file | annotate | diff | comparison | revisions |
--- a/python/mozversioncontrol/mozversioncontrol/__init__.py +++ b/python/mozversioncontrol/mozversioncontrol/__init__.py @@ -56,16 +56,21 @@ class Repository(object): self.version = LooseVersion(match.group(1)) return self.version def get_modified_files(self): '''Return a list of files that are modified in this repository's working copy.''' raise NotImplementedError + def get_added_files(self): + '''Return a list of files that are added in this repository's + working copy.''' + raise NotImplementedError + def add_remove_files(self, path): '''Add and remove files under `path` in this repository's working copy. ''' raise NotImplementedError def forget_add_remove_files(self, path): '''Undo the effects of a previous add_remove_files call for `path`. ''' @@ -73,17 +78,22 @@ class Repository(object): class HgRepository(Repository): '''An implementation of `Repository` for Mercurial repositories.''' def __init__(self, path): super(HgRepository, self).__init__(path, 'hg') self._env[b'HGPLAIN'] = b'1' def get_modified_files(self): - return [line.strip().split()[1] for line in self._run('status', '--modified').splitlines()] + # Use --no-status to print just the filename. + return self._run('status', '--modified', '--no-status').splitlines() + + def get_added_files(self): + # Use --no-status to print just the filename. + return self._run('status', '--added', '--no-status').splitlines() def add_remove_files(self, path): args = ['addremove', path] if self.tool_version >= b'3.9': args = ['--config', 'extensions.automv='] + args self._run(*args) def forget_add_remove_files(self, path): @@ -92,16 +102,19 @@ class HgRepository(Repository): class GitRepository(Repository): '''An implementation of `Repository` for Git repositories.''' def __init__(self, path): super(GitRepository, self).__init__(path, 'git') def get_modified_files(self): return self._run('diff', '--diff-filter=M', '--name-only').splitlines() + def get_added_files(self): + return self._run('diff', '--diff-filter=A', '--name-only').splitlines() + def add_remove_files(self, path): self._run('add', path) def forget_add_remove_files(self, path): self._run('reset', path) def get_repository_object(path): '''Get a repository object for the repository at `path`.