Martin Vejnár avatar Martin Vejnár committed f68b45c

Added new commands: depalias, depaliases, deprmalias.

Comments (0)

Files changed (1)

         alias = config.aliases[d.alias]
         alias.clone(ui, d.rev, d.dest)
 
+def depalias(ui, repo, alias, location, type):
+    '''bind an alias to a source location
+    
+    Add or modify a binding between an alias and a source of
+    a dependency. The binding is immediately recorded in 'aliases' section
+    of .hgdeps file.
+    
+    By default, the dependency is assumed to be a Mercurial repository.
+    You can set a different dependency type using the -t parameter.
+    '''
+    wlock = repo.wlock()
+    try:
+        config = _get_config(ui, repo)
+        config.aliases.add_versioned(alias, type, location, args=[])
+        config.save()
+    finally:
+        wlock.release()
+
+def depaliases(ui, repo):
+    '''list dependency aliases
+    
+    Print the list of all known dependency aliases. The list is formatted
+    as follows:
+    
+        [*]<alias> <type> <source-location>
+    
+    Asterisks mark unversioned bindings (those loaded from hgrc).
+    '''
+    config = _get_config(ui, repo)
+    for alias_name in config.aliases:
+        alias = config.aliases[alias_name]
+        if not alias.is_versioned():
+            ui.write('*')
+        ui.write(alias.versioned_text())
+
+def deprmalias(ui, repo, *aliases):
+    '''remove dependency aliases
+    
+    Remove aliases from from the 'aliases' section in .hgdeps file.
+    If a specified alias does not exist, do nothing.
+    '''
+    wlock = repo.wlock()
+    try:
+        config = _get_config(ui, repo)
+        for alias in aliases:
+            if alias in config.aliases:
+                if config.aliases[alias].is_versioned():
+                    ui.note(_('removing alias: %s\n') % alias)
+                    config.aliases.remove(alias)
+                else:
+                    ui.status(_('skipping non-versioned alias: %s\n') % alias)
+            else:
+                ui.status(_('skipping undefined alias: %s\n') % alias)
+        config.save()
+    finally:
+        wlock.release()
+
 
 # Internal classes
 
              ('', 'remove', None, "remove name's dependencies"),
              ('d', 'dest', '', 'destination directory for the dependency')],
             'hg deps [-a ALIAS -r REV -d DEST] [NAME]'),
-    'depsclone': (deps_clone, [], 'hg depsclone NAME')
+    'depsclone': (deps_clone, [], 'hg depsclone NAME'),
+    
+    'depalias':
+        (depalias, [
+            ('t', 'type', 'hg', 'repository type')],
+        '[-t TYPE] ALIAS LOCATION'),
+    
+    'depaliases':
+        (depaliases, [], ''),
+    
+    'deprmalias':
+        (deprmalias, [], 'ALIAS'),
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.