1VCSTOOLS(1)                        vcstools                        VCSTOOLS(1)
2
3
4

NAME

6       vcstools - vcstools Documentation
7
8       The  vcstools module provides a Python API for interacting with differ‐
9       ent version control systems (VCS/SCMs).  The VcsClient  class  provides
10       an  API for seamless interacting with Git, Mercurial (Hg), Bzr and SVN.
11       The focus of the API is manipulating on-disk checkouts  of  source-con‐
12       trolled trees.  Its main use is to support the rosinstall tool.
13

GENERAL VCS/SCM API

15       The VcsClient class provides a generic API for
16
17       • Subversion (svn)
18
19       • Mercurial (hg)
20
21       • Git (git)
22
23       • Bazaar (bzr)
24
25       class vcstools.VcsClient(vcs_type, path)
26              API  for interacting with source-controlled paths independent of
27              actual version-control implementation.
28
29              Parameters
30
31vcs_type – type of VCS to use (e.g. ‘svn’, ‘hg’, ‘bzr’,
32                       ‘git’), str
33
34path  –  filesystem  path where code is/will be checked
35                       out , str
36
37              path_exists() -> bool
38
39                     Returns
40                            True if path exists on disk.
41
42              get_path() -> str
43
44                     Returns
45                            filesystem path this client is initialized with.
46
47              url_matches(self, url, url_or_shortcut) -> bool
48                     client can decide whether the url and the other  url  are
49                     equivalent.  Checks string equality by default
50
51                     Parameters
52                            url_or_shortcut   –  url  or  shortcut  (e.g.  bzr
53                            launchpad url)
54
55                     Returns
56                            bool if params are equivalent
57
58              get_version([spec=None]) -> str
59
60                     Parameters
61                            spec 
62
63                            token for identifying repository revision desired.
64                            Token  might be a tagname, branchname, version-id,
65                            or SHA-ID depending on the VCS implementation.
66
67                            • svn: anything accepted by svn info --help,  e.g.
68                              a  revnumber,  {date}, HEAD, BASE, PREV, or COM‐
69                              MITTED
70
71                            • git: anything accepted by git log, e.g.  a  tag‐
72                              name, branchname, or sha-id.
73
74                            • hg:  anything accepted by hg log -r, e.g. a tag‐
75                              name, sha-ID, revision-number
76
77                            • bzr: revisionspec as returned by bzr help  revi‐
78                              sionspec, e.g. a tagname or revno:<number>
79
80
81                     Returns
82                            current  revision number of the repository.  Or if
83                            spec is provided, the globally  unique  identifier
84                            (e.g.  revision  number,  or SHA-ID) of a revision
85                            specified by some token.
86
87              get_remote_version(self, fatch=False) -> str
88                     Find an identifier for the current  revision  on  remote.
89                     Token  spec might be a tagname, version-id, SHA-ID, … de‐
90                     pending on the VCS implementation.
91
92                     Parameters
93                            fetch – if False, only local  information  may  be
94                            used
95
96                     Returns
97                            current revision number of the remote repository.
98
99              get_current_version_label() -> str
100                     Find an description for the current local version.  Token
101                     spec might be a branchname, version-id, SHA-ID, … depend‐
102                     ing on the VCS implementation.
103
104                        returns
105                               short   description   of  local  version  (e.g.
106                               branchname, tagename).
107
108              checkout(url[, version=''][, verbose=False][, shallow=False])
109                     Checkout the given URL to the path associated  with  this
110                     client.
111
112                     Parameters
113
114url – URL of source control to check out
115
116version – specific version to check out
117
118verbose – flag to run verbosely
119
120shallow  –  flag to create shallow clone without
121                              history
122
123              update(version)
124                     Update the local checkout from upstream source control.
125
126              detect_presence() -> bool
127
128                     Returns
129                            True if path has  a  checkout  with  matching  VCS
130                            type,  e.g.  if  the type of this client is ‘svn’,
131                            the checkout at the path is managed by Subversion.
132
133              get_vcs_type_name() -> str
134
135                     Returns
136                            type of VCS this client is initialized with.
137
138              get_url() -> str
139
140                     Returns
141                            Upstream URL that this code was checked out from.
142
143              get_branch_parent()
144                     (Git Only)
145
146                     Returns
147                            parent branch.
148
149              get_diff([basepath=None])
150
151                     Parameters
152                            basepath – compute diff relative to this path,  if
153                            provided
154
155                     Returns
156                            A string showing local differences
157
158              get_status([basepath=None[, untracked=False]])
159                     Calls scm status command. semantics of untracked are dif‐
160                     ficult to generalize. In SVN, this  would  be  new  files
161                     only.  In  git,  hg, bzr, this would be changes that have
162                     not been added for commit.
163
164                     Parameters
165
166basepath – status path will be relative to this,
167                              if provided.
168
169untracked  –  If  True,  also  show changes that
170                              would not commit
171
172                     Returns
173                            A string summarizing locally modified files
174
175       Example:
176
177          import vcstools
178
179          # interrogate an existing tree
180          client = vcstools.VcsClient('svn', '/path/to/checkout')
181
182          print client.get_url()
183          print client.get_version()
184          print client.get_diff()
185
186          # create a new tree
187          client = vcstools.VcsClient('hg', '/path/to/new/checkout')
188          client.checkout('https://bitbucket.org/foo/bar')
189
190       vcstools is available on pypi and can be installed via pip
191
192          pip install vcstools
193
194       or easy_install:
195
196          easy_install vcstools
197
198       The vcstools module is meant to be used as a normal Python module.  Af‐
199       ter  it  has been installed, you can import it normally and do not need
200       to declare as a ROS package dependency.
201

DEVELOPER'S GUIDE

203   Code API
204   Packages
205   Changelog
206   Changelog
207   0.1
208   0.1.42
209       • remove cosmic and disco until we have hosting for it
210
211   0.1.41
212       • fix git submodule error due to lack of quoting
213
214       • Fix git update failure by refreshing git index before fast-forward
215
216       • Fix python3 incompatibility due to wrong use of urlopen
217
218       • Updating get_affected_files function by removing single quotes cover‐
219         ing format (#129)
220
221       • Fix export_upstream for git submodules with relative urls. (#130)
222
223   0.1.40
224       • Trivial style and testing changes
225
226   0.1.39
227       • Added support for git submodule in export_repository
228
229       • Add Wily Xenial Yakkety
230
231       • Add get_affected_files for all vcss
232
233   0.1.38
234       • Fixed test failures due to SVN 1.9.
235
236       • Added  the  get_default_remote_version_label()  API method to support
237         changes in wstool.
238
239       • Renamed some internal functions to have a leading _ to indicate  that
240         they are private.
241
242   0.1.37
243       • Fix an issue where log were restricted to the named branch (hg).
244
245       • Fixed  svn to use a global revision number rather than a branch-local
246         revision.
247
248       • Added the get_remote_version()  and  get_current_version_label()  API
249         calls.
250
251       • Enhanced use of no_warn in run_shell_command().
252
253       • Fix get_version() to catch stderr.
254
255       • Added get_branches() API call.
256
257       • Fix some errors and warnings to output to stderr.
258
259       • Fix output to avoid extra newlines when show_stdout=True.
260
261   0.1.36
262       • Updates to the release platforms (-lucid +utopic +vivid)
263
264       • Fix an issue with updating branches on git, see vcstools/wstool#25
265
266   0.1.31
267       • Fix submodule support on checkout #71
268
269   0.1.30
270       • use  netrc  to  download  tars from private repos, also will work for
271         private rosinstall files
272
273       • Fix checks for empty repository #62
274
275   0.1.29
276       • fix #57 shallow checkout of non-master breaks with git >= 1.8.0
277
278       • unit test fixes
279
280   0.1.28
281       • test of new upload method
282
283   0.1.27
284       • fix #51 hg status and diff dont work if workspace is inside hg repo
285
286       • fix #47 several performance improvements by removing  unecessary  up‐
287         date actions after checkout
288
289       • fix #46 https tar download fails behind proxy
290
291       • fix #45 sometimes commands run forever
292
293       • fix #44 minor bug when checking out from repo with default branch not
294         master
295
296       • fix #41 improvedAPI, get_vcs_client function part of vcstools module
297
298   0.1.26
299       • fix #38 git commands fail in local  repositories  with  many  (>2000)
300         references
301
302       • fix #31 get_log() svn xml not available on Ubuntu Lucid (hg 1.4.2)
303
304       • fix #37 update() returns True even when fetch failed
305
306   0.1.25
307       • minor bugfixes
308
309       • travis-ci config file
310
311       • fix unit tests for svn diff&status ordering changes
312
313       • deprecated VcsClient Class
314
315       • added get_log function
316
317   0.1.24
318       • fix  git  update return value to False when fast-forward not possible
319         due to diverge
320
321       • fix. svn certificate prompt invisible, svn checkout and update become
322         verbose due to this
323
324   0.1.22
325       • Changed the way that git implements detect_presence to fix a bug with
326         submodules in newer versions of git
327
328       • fix for git single quotes on Windows
329
330       • minor internal api bug where a git function always returned True
331
332       • fix gub in svn export_repository
333
334   0.1.21
335       • bugfix #66: hg http username prompt hidden
336
337       • add export_repository method to vcs_base and all implementations with
338         tests
339
340       • bugfix #64: unicode decoding problems
341
342   0.1.20
343       • rosws update --verbose for git prints small message when rebasing
344
345       • improved python3 compatibility
346
347   0.1.19
348       • more python3 compatibility
349
350       • code style improved
351
352       • match_url to compare bzr shortcuts to real urls
353
354       • more unit tests
355
356       • get_status required to end with newline, to fix #55
357
358   0.1.18
359       • added shallow flag to API, implemented for git
360
361   0.1.17
362       • svn stdout output on get_version removed
363
364   0.1.16
365       • All SCMs show some output when update caused changes
366
367       • All SCMs have verbose option to show all changes done on update
368
369       • bugfix for bazaar getUrl() being a joined abspath
370
371       • bugfix for not all output being shown when requested
372
373   0.1.15
374       • Added pyyaml as a proper dependency, removed detection code.
375
376       • remove use of tar entirely, switch to tarfile module
377
378       • fix #36 allowing for tar being bsdtar on OSX
379
380   0.1.14
381       • Added tarball uncompression.
382
383   0.1.13
384       • added this changelog
385
386       • git get-version fetches only when local lookup fails
387
388       • hg get-version pulls if label not found
389
390       • Popen error message incudes cwd path
391
392   0.1.12
393       • py_checker clean after all refactorings since 0.1.0
394
395   0.1.11
396       • svn and hg update without user interaction
397
398       • bugfix #30
399
400       • minor bugfixes
401
402   0.1.10
403       • minor bugs
404
405   0.1.9
406       • safer sanitization of shell params
407
408       • git diff and stat recurse for submodules
409
410       • base class manages all calls to Popen
411
412   0.1.8
413       • several bugfixes
414
415       • reverted using shell commands instead of bazaar API
416
417   0.1.7
418       • reverted using shell commands instaed of pysvn and mercurial APIs
419
420       • protection against shell incection attempts
421
422   0.1.6
423       • bugfixes to svn and bzr
424
425       • unified all calls through Popen
426
427   0.1.5
428       • missing dependency to dateutil added
429
430   0.1.4
431       switched  shell  calls  to  calls  to  python API of mercurial, bazaar,
432       py-svn
433
434   0.1.3
435       • fix #6
436
437   0.1.2
438       • fix #15
439
440   0.1.1
441       • more unit tests
442
443       • diverse bugfixes
444
445       • major   change   to   git   client   behavior,   based   around   git
446         https://kforge.ros.org/vcstools/trac/ticket/1
447
448   0.1.0
449       • documentation fixes
450
451   0.0.3
452       • import from svn
453
454   Bug reports and feature requests
455Submit a bug report
456
457   Developer Setup
458       vcstools  uses  setuptools, which you will need to download and install
459       in order to run the packaging.  We use setuptools instead of  distutils
460       in order to be able use setup() keys like install_requires.
461          cd vcstools python setup.py develop
462
463   Testing
464       Install test dependencies
465
466          pip install nose
467          pip install mock
468
469       vcstools  uses  Python  nose  for testing, which is a fairly simple and
470       straightfoward test framework.  The vcstools  mainly  use  unittest  to
471       construct  test fixtures, but with nose you can also just write a func‐
472       tion that starts with the name test and use normal assert statements.
473
474       vcstools also uses mock to create mocks for testing.
475
476       You can run the tests, including coverage, as follows:
477
478          cd vcstools
479          make test
480
481   Documentation
482       Sphinx is used to provide API documentation for  vcstools.   The  docu‐
483       ments are stored in the doc subdirectory.
484
485Index
486
487Module Index
488
489Search Page
490

AUTHOR

492       Tully Foote, Thibault Kruse, Ken Conley
493
495       2023, Willow Garage
496
497
498
499
5000.1.42                           Jan 20, 2023                      VCSTOOLS(1)
Impressum